Application Note

Converting MDrive MCode to Lexium MCode

Description

There are minor differences between classic MCode and Lexium MCode. This application note discusses those differences and takes you step-by-step through converting a program written for MDrivePlus to Lexium MCode.

Topics

  • Ethernet TCP/IP
  • MCode OS
  • System Upgrade

Applicable Product

  • Lexium MDrive
  • MDrive Linear Actuator
  • MDrive Plus
  • MForce

Requirements

MDrive MCode Device

  • MDrive Plus
  • MDrive Linear
  • MForce

Lexium MCode Device

  • Lexium MDrive
  • Lexium Motion Module

Resource Files

Details

When upgrading a system component from MDrive to Lexium MDrive the key difference in programming is in how the I/O points are configured and used.. In the MDrive the non-isolated I/O points may be programmed as inputs or outputs.

In the Lexium MDrive, the I/O points are fixed as inputs and outputs. In MDrive programs, the sink/source state of the I/O point is set in the user program. In the Lexium MDrive the sink/source state is set by the bias of the Reference input.

The other key difference is the Analog Input. In the MDrive, the input is 10-bit, with a range of 0 to 1024. The Lexium MDrive has a 12-bit analog input with a range of 0 to 4096. Programs not using I/O can generally be loaded onto the device and work without modification. The sample program we will convert uses an input to trigger a routine that will slew the axis a multiple of the analog input and one output set up as a moving output. The program is labeled as SU, so that it will execute on power up or reset.

Program Code (MDrive MCode)

Below is the MDrive MCode program. The bold highlighted lines of code will need to be changed in order to port the program over to a Lexium Motion product.

The first point we will change is I/O #1

Modify the Input

MDrivePlus Lexium MDrive
S1=0,1 Is=1,0

The S1—S4 command has been changed to Is for input setup and Os for output setup In the example, I/O #1 is set as a general purpose input with a sinking interface. To modify the command to function with the Lexium MDrive, The Is (Input setup) command is used by entering Is=[input number],[input function]. Is=1,0 then sets input 1 as a gen- eral purpose input. The available input functions are listed below:

Input Function Table
0 General purpose input
1 Homing function, will function as specified by the homing command (HM).
2 Limit +, will function as specified by the limit command (LM).
3 Limit —, will function as specified by the limit command (LM).
4 G0 input, will run program at address 1 upon activation.
5 Soft stop, stops motion with deceleration and halts program execution. If program is paused (PS), input is ignored.
6 Pause, pause/resume program with motion
7 Jog +, Will Jog motor in the positive direction at Max. Velocity (VM). The Jog Enable (JE) Flag must be set for this to function.
8 Jog —, Will Jog motor in the negative direction at max. velocity (VM). The jog enable (JE) flag must be set for this to function.
11 Reset, When set as RESET input, then the action is equivalent to a ^C entered into a terminal. Note: If setting the input to sourcing, active true, ground the input first or a reset will occur.
12 Capture input will operate with the Trip Capture (TC) trip to run a subroutine when active NOTE: THIS FUNCTION APPLIES TO INPUT 1 ONLY!

Modify the Output

In this program, an output is setup to be active during a move. To change this to function with a Lexium MDrive we will use the Os (output setup) command.

MDrivePlus Lexium MDrive
S2=17,1 Os=1,17

As with the input, the Os command replaces the S2 command in the form of Os=[outut number],[function], in this case Os=1,17 The available output functions are listed on the next page.

Output Function Table
16 USER: General purpose user output.
17 MOVING: output will be active while the axis is in motion.
18 ERROR: will be active when a software error occurs.
19 STALL: Indicates a stall has been detected [Closed loop models only].
20 VCHANGE: velocity changing indicates the axis is accelerating or decelerating.
21 LOCKED ROTOR: indicates the rotor is in a locked state [Closed loop models only].
23 MOVINGPOS: indicates the axis is moving to a specified position.
24 HMT ACTIVE: indicates when HMT is active [Closed loop models only].
25 MAKE UP ACTIVE: indicates when HMT is making up steps [Closed loop models only].
28 TRIP OUT, applies to output 3 only, active low only. Os=3,28,0
29 ATTENTION: indicates a status or statuses as configured by the AO variable.

Modify the Analog Input

To setup the Analog input we will return to the Is (input setup) command.

MDrivePlus Lexium MDrive
S5=9,0 Is=5,9,0

To set the analog input to voltage mode, 0 to +5VDC level the Is command is used as IS=5, [mode],[level] or Is=5,9,0 The parameters for the IS=5 command are listed below.

Analog input mode table
9 Voltage mode
10 Current mode
Analog level table
0 0 to +5V (voltage mode), 0 to 20 mA (current mode)
1 0 to 10V (voltage mode), 4 to 20 mA (current mode)

Modify the Analog Input scaling

The analog input on the Lexium MDrive is 12-bit instead of ten, to set the program to have the same scale factor we need to divide the scale by 4

MDrivePlus Lexium MDrive
SL=I5*100 SL=I5*25

This will give us the same slew rate as with the MDrivePlus.