MDrive/MForce – Limit switch test program

This program demonstrates the limit switch function when defined as inputs. When a limit switch is activated, motion will stop in that direction and an error code will be generated. A positive limit generates error code 83 while a negative limit generates 84. The limit mode (LM) can be configured in six different modes as explained in the MDrivePlus Software Reference.

 

'Limit Switch Test Program

'CODE         DESCRIPTION

S1=2,0      'set input 1 as positive limit, low true
S2=3,0      'set input 2 as negative limit, low true
PG 1        'enter program mode at address 1
LB aa       'label aa
Vm=51200    'set max velocity to 51200 steps/sec
MR 102400   'move positive 102400 steps
            'close switch at input 1 to
            'stop motion in the positive direction
            'and cause an error 83
            'NOTE: PROGRAM CONTINUES TO EXECUTE
            'leave switch open and program runs normal
H           'hold program execution until motion complete
H 250       'hold program execution for 250 millisecond
PR Er       'print error number to terminal window
MR-102400
            'close switch at input 2 to
            'stop motion in the negative direction
            'and cause an error 84
            'NOTE: PROGRAM CONTINUES TO EXECUTE
H           'hold program execution until motion complete
H 250       'hold program execution for 250 millisecond
PR Er       'print error number to terminal window
BR aa       'branch to label aa
E           'end program
PG          'exit program mode
	    'hit "Esc" key to stop program

Download Limit Switch Test .mxt file
(color-coded in IMS Terminal)

 

> Motion Control Code Index