MDrive/MForce – Move on BCD input

The following application will move the motor to a variety of positions based upon a binary input to I/O 1-4. One of the things this application shows is one of the new Microstep Resolution settings that give the abilty to set motion to occur in 0.001˚ increments. The program does a calculation after each move to show motor position in degrees.

To run program, enter EX 1 into the terminal. You can index the motor by moving the switches to the center (OFF) position to represent a 4-bit binary number where switch 4 is the most significant bit.

The terminal will display the decimal equivalent, as well as the axis position in degrees.

This program illustrates the following functions:

  1. The ability to input BCD to the I/O group and control processes based on the value of the inputs.
  2. The ability to manipulate numeric position data to display it in familiar units of measure.

 

Move on BCD Input chart

'******Global Setup Parameters****
S1=0,0,0  'I1-4 set as GP,LOW Active, sinking
S2=0,0,0
S3=0,0,0
S4=0,0,0
P=0
Ms=180    'Microstep Res to 0.001 deg/ustep

'******Main Program*********
PG 1
LB aa
R1=Il          'Set register 1 = inputs 4-1
BR z1,R1=0     'conditional branches based
BR za,R1=1     'upon the value of IL
BR zb,R1=2
BR zc,R1=3
BR zd,R1=4
BR ze,R1=5
BR zf,R1=6
BR zg,R1=7
BR zh,R1=8
BR zi,R1=9
BR zj,R1=10
BR zk,R1=11
BR zl,R1=12
BR zm,R1=13
BR zn,R1=14
BR zo,R1=15
BR aa

'*******Program Motion Components*******

LB z1
BR aa, P=0     'branch to main prog, position=0
MA 0           'index to abs. pos. 0
H              'Suspend prog. until move completes
CL zz          'call the print position sub.
BR aa          'BR to main prog when complete

LB za          'same as above
BR aa, P=36000
MA 36000
H
CL zz
BR aa

LB zb
BR aa, P=-36000
MA -36000
H
CL zz
BR aa

LB zc
BR aa, P=18000
MA 18000
H
CL zz
BR aa

LB zd
BR aa, P=-27000
MA -27000
H
CL zz
BR aa

LB ze
BR aa, P=9000
MA 9000
H
CL zz
BR aa

LB zf
BR aa, P=-9000
MA -9000
H
CL zz
BR aa

LB zg
BR aa, P=4500
MA 4500
H
CL zz
BR aa

LB zh
BR aa, P=-4500
MA -4500
H
CL zz
BR aa

LB zi
BR aa, P=3000
MA 3000
H
CL zz
BR aa

LB zj
BR aa, P=-3000
MA -3000
H
CL zz
BR aa

LB zk
BR aa, P=6000
MA 6000
H
CL zz
BR aa

LB zl
BR aa, P=-6000
MA -6000
H
CL zz
BR aa

LB zm
BR aa, P=7500
MA 7500
H
CL zz
BR aa

LB zn
BR aa, P=-7500
MA -7500
H
CL zz
BR aa

LB zo
BR aa, P=0
MA 0
H
CL zz
BR aa

'****Print Position Subroutine****
LB zz
R2=P/100     'set register 2 to position/100,
             'this will display degrees as the unit
             'of measure for motor position
PR "Position Selected = ",R1
PR "Absolute Position (Degrees) = ",R2
RT

E
PG

Download Move on BCD Input .mxt file
(color-coded in IMS Terminal)

 

> Motion Control Code Index