MDrive/MForce – Position teach

Teach.mxt is a program that prompts for manual positioning of the MDrive and when input 1 toggles it remembers the position based on the value of C2. It sets two positions and will run point to point with input 2.

This program requires that the MDrivePlus be eqipped with an internal (-EQ) or remote (-EE) encoder option.

'[Parameters}

Ee=1       'enable encoder
VA p1      'declare variables
VA p2
S1=0,0,0   'define i/o 1 as user input
S2=0,0,0   'define i/o 2 as user input


'[Program]
PG 1       'enter program mode
LB su      'startup label
Er=0       'clear any errors
C2=0       'init C2 (encoder counter)
p1=0       'init user variables
p2=0
PR "Move driver to first position"
PR "Press PB1 when ready
LB k1
BR k1,I1=0 'loop while waiting for first value from input 1
p1=C2      'save value of C2 to p1 variable
PR p1      'print it
LB k2
BR k2,I1=1 'hold here till pushbutton is released
PR "Move driver to second position"
PR "Press PB1 when ready
LB k3
BR k3,I1=0 'loop while waiting for 2nd value from input 1
p2=C2      'save value of C2 in p2
PR p2      'print it
LB k4
BR k4,I1=1 'hold till pushbutton is released
PR "Toggle Sw 2 to start cycle"
Sf=0       'clear stall flag
Sm=1       'do not stop on a stall
LB m1      'run a little program to move driver from
BR m1,I2=0 'first point to second point
LB m2
MA p1      'move to absolute value of point 1
H          'hold until move is complete
PR P       'print position
H 250      'delay 250mS
MA p2      'move to absolute value of point 2
H          'hold until move is done
PR P       'print position
H 250      'delay 250mS
BR m1     'branch to m2 to repeat cycle
E          'end of program
PG         'leave program mode

Download Teach .mxt file
(color-coded in IMS Terminal)

 

> Motion Control Code Index