
#LOOP
Simple program loop
JP#LOOP
EN
#TCPERR
Ethernet communication error auto routine
MG {P1}_IA4
Send message to serial port indicating which handle did
not receive proper acknowledgment.
RE
Example – Amplifier Error
The program below will execute upon the detection of an error from an internal Galil Amplifier. The bits in TA1 will
be set for all axes that have an invalid hall state even if BR1 is set for those axes, this is handled with the mask
variable shown in the code below.
#AMPERR
REM mask out axes that are in brushed mode for _TA1
mask=(_BRH*128)+(_BRG*64)+(_BRF*32)+(_BRE*16)+(_BRD*8)+(_BRC*4)+(_BRB*2)+_BRA
mask=@COM[mask]
mask=((_TA1&mask)&$0000FFFF)
LU0;’turn off auto update of LCD
REM amplifier error status on LCD
MG″A-ER TA0″{L1},_TA0{L2};WT2000
MG″A-ER TA1″{L1},mask{L2};WT2000
MG″A-ER TA2″{L1},_TA2{L2};WT2000
MG″A-ER TA3″{L1},_TA3{L2};WT2000
LU1;’turn on Automatic Axis Update of LCD
WT5000
REM the sum of the amperr bits should be 0 with no amplifier error
er=_TA0+mask+_TA2+_TA3
JP#AMPERR,er0
REM Notify user amperr has cleared
LU0
MG″AMPERR″{L1},″RESOLVED″{L2}
WT3000
LU1
RE
JS Subroutine Stack Variables (^a, ^b, ^c, ^d, ^e, ^f, ^g, ^h)
There are 8 variables that may be passed on the subroutine stack when using the JS command. Passing values on
the stack is advanced DMC programming, and is recommended for experienced DMC programmers familiar with
the concept of passing arguments by value and by reference.
Notes:
1. Passing parameters has no type checking, so it is important to exercise good programming style when
passing parameters. See examples below for recommended syntax.
2. Do not use spaces in expressions containing ^.
3. Global variables MUST be assigned prior to any use in subroutines where variables are passed by
reference.
4. Please refer to the JS command in the controller's command reference for further important information.
Example: A Simple Adding Function
#Add
JS
#SUM
(1,2,3,4,5,6,7,8)
;' call subroutine, pass values
MG
_JS
;' print return value
EN
'
#SUM
;NO(^a,^b,^c,^d,^e,^f,^g,^h) syntax note for use
EN
,,(^a+^b+^c+^d+^e+^f+^g+^h)
;' return sum
:Executed program from program1.dmc
36.0000
Chapter 7 Application Programming ▫ 132
DMC-40x0 User Manual