Position Mode Control Example
Moog Animatics Class 5 SmartMotor™ DMX Guide, Rev. C
Page 33 of 46
OCHN
(DMX,1,N,250000,2,8,D)
'Open DMX channel: COM1, no parity,
'250 kBd, 2 stop, 8 data, datamode
GOSUB
(100)
'Always run a homing routine before DMX.
'==================================================================
'
Set Initial Values
UR
(2)
'Clear flag so we know when the end of the next
'data packet arrives.
MP
'Set to Position mode.
ADT
=800
'Accel/decel value (adjust as needed).
VT
=1500000
'Velocity (adjust as needed).
'===================================================================
'
Set up interrupts to linger at higher values:
ITR
(0,0,0,0,0)
'Interrupt to catch all motor drive faults.
EITR
(0)
'Enable fault interrupt.
ITRE
'Enable global interrupts.
'===================================================================
'
Main Program Loop
WHILE
1
'NOTE: This loop constantly polls DMX data and scales.
'it directly to target position.
IF
B
(12,2)==1
'Check for next data packet.
UR
(2)
'Clear flag so we will know when next packet arrives.
nn=n-1
p=0
'Zero data value.
WHILE
nn>=0
p=p*256+aw[nn+s]
'Set p variable for next data value.
nn=nn-1
LOOP
'Loop takes 4 milliseconds when using three
'channels (24 bit).
PT
=p*m
'Calculate target position.
G
'Start moving to latest trajectory.
ENDIF
LOOP
END
'End of the main program.
'===================================================================
'
Fault Routine Code (place here)
C0
END
RETURNI
'===================================================================
'
Home Motor
C100
'Set up parameters (edit as required)
rr=-1
'Home direction
vv=10000
'Home speed
aa=1000
'Home accel
ee=100
'Home error limit
tt=3000
'Home torque limit
hh=4000
'Home offset