Intro to MCode 1: Basic Motion Commands

Tutorial overview

This tutorial covers the basic variables and instructions impacting motion.

What you need:

  1. PC with the Motion Control Programmer application installed
  2. A Lexium MDrive Motion Control connected to power and RS-422/485 communication.
Motion variables and commands covered

Variables

  • A – Acceleration
  • D – Deceleration
  • MS – Set microstep resolution
  • VI – Intitial velocity
  • VM – Maximum velocity

Commands

  • MA – Move to absolute position
  • MR – Move to relative position
  • SL – Slew at constant velocity

 

Motion variables

MCode motion variables
  1. A – Acceleration
  2. D – Deceleration
  3. MS – Set microstep resolution
  4. VI – Intitial velocity
  5. VM – Maximum velocity

The relationship between VI, VM, A and D is shown in the motion profile diagram on the right. The following details the sequence of events when a motion command is given.

  1. The motor will accelerate from VI to VM based upon the setting of A in steps per second^2.
  2. Upon reaching VM, the motor will index at the velocity specified by VM in steps per second.
  3. Before reacing the commanded position the axis will decelerate at the rate in steps per second^2.

    Note: Setting VI to a high value could cause a motor stall.

The relationship of MS (Microstep resolution select) and the motion variables

The motion variables are all based on microsteps as the unit of measure. The ratio between the microstep resolution setting and the variables is an important factor in how the motor will perform. Using the factory default settings as a baseline for example we can see that when we change the step resolution of the device, the motion variable may also need to be changed.

For example, the default settings of the Lexium MDrive Motion Control:

  MS (steps/rev) VI VM A D
Default 51200 1000 768000 1000000 1000000
New 200 4 3000 3906 3906
Ratio MS:<var>   1:0.20 1:15 1:19.5 1:19.5

As shown in the table, the settings for a particular velocity profile can change dramaticall based on the microstep resolution setting

 

Move to Relative Position (MR)

Move to a relative position (MR)

A move relative (MR) moves an offset distance (motor steps) from the current position. In the case of the profile shown above the end position of the first move will be 1 + 2, or 0 + 51200. Position will be 51200 steps from 0.

The second move of +51200 steps will end at position 3 or 51200 steps from position 2. The third MR will index the axis 153600 steps in the negative direction from position 3.

Note that if the position counter is read using PR P, the counter will read in steps from 0 or -51200.

 

Move to Absolute Position (MA)

Move to an Absolute Position (MA)

A move absolute (MA) moves a distance (motor steps) from the 0. In the case of the profile shown above the end position of the first move will be 1 + 2, or 0 + 51200. Position will be 51200 steps from 0.

The second move of +51200 steps will end at position 3 or 102400 steps from position 2. The third MA will index the axis 153600 steps in the negative direction from position 3, with a final position of -51200 absolute from 0.

 

Slew at velocity (SL)

Slew at velocity (SL)

Slew (SL) is used to index the axis at a constant velocity. The motor will continue to slew at commanded velocity until an SL 0, or escape is commanded.

Note that SL will function independant of the VM setting. If a velocity greater than VM is commanded the motor will accelerate to the commanded velocity, ignoring the setting of VM.

 

Using an encoder

Using an encoder

If the encoder is enabled the move commands use different values. The encoder has 1000 lines and yields 4000 counts or counts per revolution, as shown in the diagram at right.

Therefore, the MR and MA command values are programmed in encoder counts. One full revolution would be programmed as MR or MA 4000.

When the encoder is enabled, the MS value is defaulted to 256.

Knowing these factors you can program a multitude of different movements, speeds, and time intervals.

The default values for the motion variables is now used in encoder counts with the following values:

MS VI VM A D
51200 78 60000 78125 78125

 

Encoder related variables and commands

C2 - Encoder counter I6 - Read encoder index mark
DB - Encoder deadband PM - Position maintenance enable flag
EE - Encoder enable flag SF - Stall factor
EL - Encoder line count SM - Stall detect mode
HI - Home to index mark ST - Stall flag

Note that when the Lexium MDrive is in an hMTechnology mode (AS=1, 2 or 3) the encoder functions become irrelevant.

 

 

 

Home   |   Product Disclaimer & Warranty © Schneider Electric Motion USA   |   Privacy Policy