DMX Five Channel Example
Moog Animatics Class 5 SmartMotor™ DMX Guide, Rev. C
Page 35 of 46
DMX Five Channel Example
The following example allows you to use up to five channels. The function of each is shown in
the following table.
Channel
Purpose
1st
Velocity
2nd
Accel/Decel
3rd
8-bit position control
4th
+ 8 for 16-bit optional position control
5th
+ 8 more for 24-bit optional position control
In the example code (see below):
"b" sets base DMX channel
"n" sets number of position channels to use (0 through 3)
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 Five Channel Example
'==================================================================
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 check (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 for Position control
'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 will calculate the binary total value of incoming data.
'NOTE: Data ranges for the value of "n" for number of channels are:
'n=1 0 to 255
'n=2 0 to 65535
'n=3 0 to 16777215
m=1
'Scale Factor multiplied by data to give target position.
'NOTE: For 2 or 3 channels (16 or 24-bit position), this should be 1.
'For a single channel with 8-bit positioning, you may need to
'increase "m". Jerky motion may result by using just a single
'channel with only 8-bit resolution.
vvv=2000
'Scale factor for velocity target times max of 255
aaa=10
'Scale factor for Accel/Decel
times max of 255