DMX Packet Test Example
Moog Animatics Class 5 SmartMotor™ DMX Guide, Rev. C
Page 38 of 46
DMX Packet Test Example
The following example will test up to two channels summed together as a single 24-bit data
block. It will provide the time between data packets and the data itself. It is recommended to
use three DMX channels for maximum position resolution.
Also, note that there is a home to hard stop subroutine embedded in this program. It is
important to always home the motor before executing the main DMX code. For more homing
details, see Home Against a Hard Stop Example on page 30.
'==================================================================
'DMX Packet Test Code
'==================================================================
ADDR
=1
'Set Motor serial address as needed.
'This does not affect DMX address.
ECHO
'Set ECHO on, not required for DMX.
EIGN
(
W
,0)
'Disable hardware limit switch checking
'(for demo purposes).
ZS
'Clear any startup errors.
'Variables for DMX control
b=1
'Set DMX base address
Valid Address: 1 thru 512
n=3
'Set number of DMX channels to use
'NOTE: max that may be summed is 3 or 24 bit position unsigned int.
s=0
'First motor array variable index to use starting with aw[s].
'NOTE: aw[0 thru 101] are available
.
'The main WHILE loop calculates binary total value of incoming data.
'NOTE: Data ranges for value of "n" for number of channels are:
'n=1 0 to 255
'n=2 0 to 65535
'n=3 0 to 16777215
'Configure DMX data usage and motor variable storage:
IF
n>3
("n too large.",#13)
END ENDIF
'Limit "n" based on a max of 3 bytes.
IF
b>(513-n)
("b too large.",#13)
END ENDIF
'Limit "b" based on max data slot.
IF
s>(102-n)
("s too large.",#13)
END ENDIF
'Limit "s" to max array value.
q=b+n-1
'Last data channel used (will be trigger when data received).
COMCTL
(1,b)
'Set base DMX channel to value from CADDR.
COMCTL
(2,n)
'Accept 1 DMX channel of data.
COMCTL
(3,q)
'Status word 12 bit 2 will be set to 1 when
'channel "q" arrives
.
COMCTL
(4,s)
'Set start of array index storage (good for
'bypassing cam mode dynamic array).
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
'(see other examples)