P
ar
t
1: P
rog
ra
m
ming
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)
("Switch Released",#13)
ENDIF
WHILE
1
IF
GoSelSwitch>=Sel
("Sel",#13)
WHILE
GoSelSwitch>=Sel LOOP
("Switch Released",#13)
ENDIF
IF
GoSelSwitch<=Go
("Go",#13)
WHILE
GoSelSwitch<=Go LOOP
("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
("Current is above ",i,"mAmps",#13)
C200
("Current twice as high as it should be!",#13)
RETURN
Part 1: Programming: GOTO(), GOSUB() Examples
Содержание SmartMotor
Страница 1: ...Developer s Guide Class 5 Later SmartMotor Technology with TM ...
Страница 909: ...PN SC80100003 002 Rev L ...