DMC-40x0 Command Reference #LIMSWI • 151
#LIMSWI
FUNCTION: Limit switch automatic subroutine
DESCRIPTION:
Without #LIMSWI defined, the controller will effectively issue the STn on the axis when it’s limit
switch is tripped. With #LIMSWI defined, the axis is still stopped, and in addition, code is
executed. #LIMSWI is most commonly used to turn the motor off when a limit switch is
tripped (see example below). For #LIMSWI to run, the switch corresponding to the direction
of motion must be tripped (forward limit switch for positive motion and negative limit switch
for negative motion). #LIMSWI interrupts thread 0 when it runs.
USAGE:
While Moving Yes
In a Program Yes
Command Line No
Controller Usage
ALL
RELATED COMMANDS:
_LFX State of Forward limit switch
_LRX State of Reverse limit switch
EXAMPLES:
#Main ;'print a message every second
MG "Main"
WT1000
JP#Main
EN
#LIMSWI ;'runs when a limit switch is tripped
IF (_LFX = 0) | (_LRX = 0)
MG "X"
DCX=67107840
STX
AMX
MOX
ELSE; IF (_LFY = 0) | (_LRY = 0)
MG "Y"
DCY=67107840
STY
AMY
MOY
ENDIF; ENDIF
RE1
NOTE: The automatic subroutine runs in thread 0.
NOTE: Use RE to end the routine