#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 ▫ 117
DMC-42x0 User Manual
Summary of Contents for DMC-42 0 Series
Page 195: ...ICM 2900 PCB Layout Appendices 191 DMC 42x0 User Manual...
Page 205: ...CB 50 100 Drawings Appendices 201 DMC 42x0 User Manual...
Page 206: ...Appendices 202 DMC 42x0 User Manual...
Page 207: ...Appendices 203 DMC 42x0 User Manual...
Page 208: ...Appendices 204 DMC 42x0 User Manual...
Page 209: ...Appendices 205 DMC 42x0 User Manual...
Page 210: ...Appendices 206 DMC 42x0 User Manual...
Page 211: ...Appendices 207 DMC 42x0 User Manual...
Page 214: ...CB 50 80 Drawing Appendices 210 DMC 42x0 User Manual...