Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 190 of 909
#define GoSelSwitch INA(V1,6)
#define Go 200
#define Sel 4000
C345 'Detecting switch on SmartBox
IF (GoSelSwitch<Sel) & (GoSelSwitch>Go)
PRINT("Switch Released",#13)
ENDIF
WHILE 1
IF GoSelSwitch>=Sel
PRINT("Sel",#13)
WHILE GoSelSwitch>=Sel LOOP
PRINT("Switch Released",#13)
ENDIF
IF GoSelSwitch<=Go
PRINT("Go",#13)
WHILE GoSelSwitch<=Go LOOP
PRINT("Switch Released",#13)
ENDIF
LOOP
RETURN
GOTO(), GOSUB() Examples
The Class 5 software allows passing of values into GOTO and GOSUB commands. For details,
see GOTO#, GOTO(label), C# on page 183 and GOSUB#, GOSUB(label), RETURN on page 184.
There are two theories on writing code: One says uses all GOTO commands; the other says
use all GOSUB commands. There are pros and cons to both methods.
l
GOTO is good for conditional code bypassing
l
GOSUB ensures a return to where you came from
Pay attention to either command when you run into a RETURN that gets ignored by a GOTO or
when you never reach a RETURN for a previous GOSUB due to a GOTO.
i=400 'Motor Current to check for
WHILE 1 'While forever
IF UIA>i 'If motor current in mAmps is > "i"
GOSUB(100)
WHILE UIA>i LOOP 'prevent double trigger
ENDIF
LOOP
C100
IF UIA>(i*2) 'If current is twice as much
GOTO200 'bypass PRINT line below
ENDIF
PRINT("Current is above ",i,"mAmps",#13)
C200
PRINT("Current twice as high as it should be!",#13)
RETURN
Part 1: Programming: GOTO(), GOSUB() Examples