P
ar
t
2: C
omman
d
s
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 723 of 909
EXAMPLE:
x=0
'Set variable x equal to zero
GOTO0
'Go directly to the C0 label
C10
(#13, "NO PROGRAM CRASH")
RETURN
END
'The following commands intentionally call subroutines without RETURN commands
C0
x=x+1
("x=",x,#13)
GOSUB1
'First GOSUB without return.
C1
x=x+1
("x=",x,#13)
GOSUB2
'Second GOSUB without return.
C2
x=x+1
("x=",x,#13)
GOSUB3
'Third GOSUB without return.
C3
x=x+1
("x=",x,#13)
GOSUB4
'Fourth GOSUB without return.
C4
x=x+1
("x=",x,#13)
GOSUB5
'Fifth GOSUB without return.
C5
x=x+1
("x=",x,#13)
GOSUB6
'Sixth GOSUB without return.
C6
x=x+1
("x=",x,#13)
GOSUB7
'Seventh GOSUB without return.
C7
x=x+1
("x=",x,#13)
GOSUB8
'Eighth GOSUB without return.
C8
x=x+1
("x=",x,#13)
GOSUB9
'Ninth GOSUB without return.
C9
x=x+1
("x=",x,#13)
'GOSUB10 'if this GOSUB is called,
'the program WILL crash!
STACK
'Reset internal stack, which
GOSUB10
'allows this GOSUB to execute without crashing the program.
(#13,"RETURN FROM GOSUB10 OK",#13)
END
Program output is:
x=1
x=2
x=3
x=4
x=5
x=6
x=7
x=8
x=9
x=10
NO PROGRAM CRASH
RETURN FROM GOSUB10 OK
The previous example does not show the preferred way to write code. It is provided to show
where the STACK command would be used to prevent program crashes.
Often, the STACK command is used after an error or motor-protection fault is detected. Then,
immediately after the STACK command, a RUN, END or GOTO command (located near the top
of the program) is issued to recover.
Part 2: Commands: STACK
Содержание SmartMotor
Страница 1: ...Developer s Guide Class 5 Later SmartMotor Technology with TM ...
Страница 909: ...PN SC80100003 002 Rev L ...