MDrive/MForce – IF THEN sample

This sample configures input 1 as a general purpose input which can then be used as a control bit in the program. If I1 is true, the program continuously loops in label M1 with a relative move of 200000. If I1 goes false, the program falls through M1 and loops in label M2 with a relative move of -100000. A good way to observe the sequence of code execution is to launch the program in trace mode (EX SU,1). Every instruction is mirrored to the terminal window, which is beneficial for program development and debug.

'CODE                  DESCRIPTION

PG 100                'Enter program mode at address 100
LB SU                 'Label using SU to start program
                      'upon power up
S1=0,1                'Sets I/O 1 as a general purpose
                      'input, active high
LB M1                 'Label to begin motion profile 1
MR 200000             'Move relative 200000 steps
H                     'Hold until motion is complete
BR M1, I1=1           'If input is true then branch to
                      'label M1
LB M2                 'Label to begin motion profile 2
MR -100000            'Move relative 100000 steps
H                     'Hold until motion is complete
BR M1, I1=1           'If input is true then brance to
                      'label M1
BR M2                 'Unconditional branch to label M2
E                     'End program
PG                    'Exit program mode

Download IF THEN sample .mxt file
(color-coded in IMS Terminal)

 

> Motion Control Code Index