Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 194 of 909
TMR(timer,time)
Timers
The TMR() function controls four timers. Their states are found in the first four bits of Status
Word 4. The TMR() function can be used to execute an interrupt routine after a certain period
of time.
The TMR() function has two parameters where:
timer Specifies the timer #. There are four timers: 0 to 3.
time Specifies the time (in milliseconds) to count down to zero.
While the timer is counting down, the corresponding status bit in Status Word 4 will be one.
When it reaches zero, the status bit reverts to zero. This bit change can be made to trigger a
subroutine using the ITR() function.
EIGN(2) 'Disable left limit
EIGN(3) 'Disable right limit
ZS 'Clear faults
MP 'Set Position mode
VT=500000 'Set target velocity.
AT=300 'Set target acceleration.
DT=100 'Set target deceleration.
TMR(0,1000) 'Set Timer 0 to 1s
ITR(0,4,0,0,20) 'Set interrupt
EITR(0) 'Enable interrupt
ITRE 'Enable all interrupts
p=0 'Initialize variable p
O=0 'Set commanded and actual pos. to zero
C10 'Place a label
IF PA>47000 'Just before 12 moves
DITR(0) 'Disable interrupt
TWAIT 'Wait till reaches 48000
p=0 'Reset variable p
PT=p 'Set target position
G 'Start motion
TWAIT 'Wait for move to complete
EITR(0) 'Re-enable interrupt
TMR(0,1000) 'Re-start timer
ENDIF
GOTO10 'Go back to label
END 'End (never reached)
C20 'Interrupt subroutine label
TMR(0,1000) 'Re-start timer
p=p+4000 'Increment variable p
PT=p 'Set target position
G 'Start motion
RETURNI 'Return to main loop
Part 1: Programming: TMR(timer,time)