Os – Output setup

The output setup (Os) command is used to set the functionality of the outputs. The parameters define the output point to be configured, the desired functionality, and the active control state high or low. When applied to outputs 1 – 2 the output setup command is utilized thus:

Os=<output #>, <function>, <active>

Example:

Output functions

All digital input parameters are listed in the table below.

Outputs
Output Notes
1 May be programmed to any function except trip and Encoder Channel B. Not available in NEMA 17 Sizes
2 May be programmed to any function except trip and Encoder Channel A. Not available in NEMA 17 Sizes
3 May be programmed to any function except as an Encoder output. External circuitry may be required if using to drive inductive loads.
Functions
Function Description
16 USER: General purpose user output. (Default)
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].
26 ENC A: Encoder channel A output applies to output 1 only. Os=1,26,<0/1> [Closed loop models only].
27 ENC B: Encoder channel B output applies to output 2 only. Os=2,27,<0/1> [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.
Active
State Description
0 Active when LOW (default)
1 Active when HIGH

General output usage commands

An I/O instruction results in the change of parameters or the state of an input or output. The syntax for these commands are as follows: type the command then an equal sign, then the data. Example:

Mnemonic Function Usage example Description
Individual I/O point control commands
O<output> Set the logic state of an individual output O3=1 Set output 3 HIGH (1)
Binary coded decimal (BCD) commands
OT=<0-7> Set the logic state of all outputs OT=7 Set outputs 1 – 3 HIGH
Note On NEMA17 models this command in not applicable

Is – Input setup command

The input setup (Is) command is used to set the functionality of all inputs, digital and analog. The parameters define the input point to be configured, the desired functionality, and the active response state high or low.

Digital inputs

Usage

When applied to the digital inputs 1 – 4 the input setup command is utilized thus:

Is=<input #>, <function>, <active>

Example:

Digital input functions

All digital input parameters are listed in the table below.

Inputs
Input Notes
1 May be programmed to any function, not available in NEMA 17 sizes
2 Maybe programmed to any function except capture
3 Maybe programmed to any function except capture
4 Maybe programmed to any function except capture
Functions
Function Description
0 General purpose input (default)
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 thenegative 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 witll operate with the Trip Capture (TC) trip to run a subroutine when active NOTE: THIS FUNCTION APPLIES TO INPUT 1 ONLY!
Active
State Description
0 Active when LOW
1 Active when HIGH (default)

Analog Input

Usage

When used to setup the analog input, the Is command is used in this manner:

Is=5, <mode>, <level>

Example:

Analog input details

Modes
Description
9 Voltage mode (default)
10 Current mode
Levels
Description
0 0 to +5V (voltage mode), 0 to 20 mA (current mode) (default)
1 0 to 10V (voltage mode), 4 to 20 mA (current mode)

Encoder inputs

Usage and details

The encoder index mark only has one settable parameter, which is the active response state.

Is=6,0,<active>

This can be active when LOW (0, default) or active when HIGH (1).

General input usage commands

Mnemonic Function Usage example Description
Individual input point control commands
I<input> Read an individual input state as 1 or 0 PR I4 Read the state of input 4
CL k3, I4=1 Call subroutine k3 when I/O 4 is ACTIVE (1)
Binary coded decimal (BCD) commands
IN Read all logic inputs as a group. PR IN Read inputs1 – 4 as a group (response will be 0 – 15 based on I1 being LSb and I4 being MSb)
Note on NEMA 17 models the response range will be 0-7.
Input filtering commands
D<input>=<0-255> Set the input filtering to time in milliseconds D1=150 Set the filter for input 1 to 150 milliseconds. Input must be stable for 150 msec before the change will be detected.
Input trip
TI=<input>, <subroutine> Sets the operation of an input trip TI=2, K3 Execute subroutine labeled K3 when input 2 is active.

Global or Local variables

Like All MDrive variables, the I/O point configuration can be declared two ways:

  1. Globally
  2. Locally

Global:  Global I/O configurations, are declared outside the main body of the program. These are more typical and are used when you want the I/O point to have the same function at all times.

Local:  Local configurations are declared inside the body of the program and are stored in RAM, thus may be changed on the fly. An example would be where you may want an input to output to perform one function in part of the program and another in a different part of the program.

Event triggering

The most common use of the I/O is to trigger events within a system:

  • Inputs:  to trigger events internal to the MDrive program.
  • Outputs:  to trigger events within a machine or system.

Input example:

The following program example shows an input used to trigger an internal event:

The following program will move the axis to an absolute position based upon the state of I/O 1 and will hold that position until the state changes.

In this example, the program will use a conditional branch (BR) to activate the event. Input-driven events may also use the Call Subroutine (CL) command in a similar fashion.

Output event

The following program example shows an output used to trigger an external event. A real-world example may be that the MDrive performs and completes a task, when complete the program will activate an output to trigger an external process, such as executing a program in a second system MDrive.

Using a Bank of I/O

The MDrive I/O can read inputs and write outputs as a group in Binary Coded Decimal (BCD).

The I/O may be connected as shown below. For purposes of example, we have used switches for inputs and LED’s for outputs. All are configured as general purpose, active when low, sinking.

For this example we will use two basic programs:

  • Inputs: A program that will perform a specific move based on the input decimal value.
  • Outputs: A program that will cause the outputs to operate as a binary up counter.

Move on BCD Input Example

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 ability to set motion to occur in 0.001˚ increments. The program does a calculation after each move to show motor position in degrees. To make the web view shorter, the example below omits many repetitive branch routines for the various moves. See the full program to view.

Binary up counter – BCD output example

The following program example shows the use of the lower output bank as a binary up-counter. IO1 – IO4 are setup as general purpose outputs, active when HIGH, sinking. The main program will set the outputs, store the decimal equivalent of the outputs, and index the motor a multiple of the output state. Once complete it will increment the register and repeat until the value of the register =15 (binary 1111). It will then clear the register, set the outputs to 0, and restart the process.

 

PNP Input

In this example case we will assume that we need a PNP Sensor connected to an input to trigger events within an MDrive program. Thus we will configure I/O point 1 as a General Input which will activate when HIGH.

The command:

will set I/O1 to function as we desire:

  • S1=: setup I/O 1
  • 0: General purpose input function
  • 1: Active when HIGH
  • 1: Sourcing input type

Switch Input

In this example case we need a Start switch to execute an MDrive program.

The commands:

will set I/O 1 to function as we desire:

  • S1=: setup I/O 1
  • 4: G0 input function
  • 1: Active when HIGH
  • 1: Sourcing input type

Inductive Load Output

In this example case we will configure a sourcing output. When active, the output will energize a solenoid which in turn will activate another system process based upon an event inside an MDrive program.

The command:

will set I/O 12 to function as we desire:

  • S12=: setup I/O 12
  • 16: FGeneral purpose output function
  • 1: Active when HIGH
  • 0: Sourcing output type

NPN input

This setup example uses the hardware configuration shown in the illustration labeled A on the right. In this example case, we will assume that we need a PLC output to stop the motion of an axis due to an event elsewhere in the system. Thus we will configure I/O point 1 as a Soft Stop Input which will activate when LOW.

The command:

will set I/O1 to function as we desire:

  • S1=: setup I/O 1
  • 5: Soft Stop input function
  • 0: Active when LOW
  • 0: Sinking input type

Switch input

In this example case we will assume a linear actuator is needing positive and negative limit switches. We will use I/O3 as the positive limit and I/O4 as the negative limit.

The commands:

will set I/O 3 and 4 to function as we desire:

  • S3=: setup I/O 3
  • 2: Positive Limit input function
  • 0: Active when LOW
  • 0: Sinking input type
  • S4=: setup I/O 4
  • 3: Negative Limit input function
  • 0: Active when LOW
  • 0: Sinking input type

Inductive load output

In this example case we will configure a sinking output. When active, the output will open a relay which will de-energize another part of the system on an error or fault.

The command:

will set I/O 2 to function as we desire:

  • S2=: setup I/O 2
  • 18: Fault/Error output function
  • 1: Active when HIGH
  • 0: Sinking output type

LED output

In this example case we will configure an output to illuminate a LED indicator when the axis is in motion.

The command:

will set I/O 1 to function as we desire:

  • S1=Moving output function
  • 0: Active when LOW
  • 0: Sinking output type

S command (I/O setup)

The I/O setup command establishes how the I/O point will function in the system, note that each I/O point MUST be setup individually if changed from the factory default:

  • Will it be an input or an output?
  • Will it be general purpose, or set to a dedicated function?
  • Will it be a sinking or sourcing type?
  • Will it be ACTIVE when logic HIGH or LOW?

Setup parameters

The I/O setup command has three parameters that define its operational characteristics, these are:

  1. Function: Assigns the point to an input or output function.
  2. The active state defines the point as being ACTIVE when HIGH or LOW.
  3. Sink/Source: Sets the point as a sinking or sourcing type. NOTE: sourcing outputs only available on Plus2 models.

I/O Functions

The following table lists the function codes relevant to the first parameter: Input or Output functions.

Input Functions Output Functions
Param # Function Param # Function
0 General purpose 16 General purpose
1 Homing 17 Moving
2 Positive limit 18 Fault/Error
3 Negative limit 19 Stall
4 G0 20 Velocity changing
5 Soft stop
6 Pause running program
7 Jog positive
8 Jog negative
11 Reset

Active state

The Active State parameter defines the level at which the I/O point will be active and may be set to:

0 – I/O is Active when logic LOW (0 volts, ground)
1 – I/O is Active when logic HIGH (+5 to +24 VDC)

With outputs, the Active setting becomes of particular importance. The impact of the Active state setting will impact functionality based upon the hardware configuration of the output point and whether it will be sinking or sourcing. The following table details the output circuit conditions for each state and sink/source configuration.

Sink/Source Active State Output State Circuit Condition
Sinking Active HIGH Output = 1 Sink OFF, High impedance
Output = 0 Sink ON
Active LOW Output = 1 Sink ON
Output = 0 Sink OFF, High impedance
Sourcing
(Plus2 Only)
Active HIGH Output = 1 Source ON
Output = 0 Source OFF, High impedance
Active LOW Output = 1 Source OFF, High impedance
Output = 0 Source ON

 

Sink/Source

The Sink/Source parameter identifies the I/O point as sinking or sourcing. If the hardware is connected using any of the configurations shown in the Connecting Power and I/O tutorial, this should be set to match the hardware connection.

0 – Sinking – Point will change states when pulled to ground.
1 – Sourcing – Point will change states when sourced (+5 to +24 VDC).

General I/O usage commands

An I/O instruction results in the change of parameters or the state of an input or output. The syntax for these commands are as follows: type the command then an equal sign, then the data. Example: O2=0 will set output 2 to 0.

This tutorial only covers the General purpose I/O points with the following set of commands to be exampled in the programming part of this tutorial. The Clock I/O and Capture/Trip I/O are only slightly different in their configuration. Please refer to the MCode manual for this instructions.

Mnemonic Function Usage example Description
Individual I/O point control commands
I<io point> Read an individual input state as 1 or 0 PR I4 Read the state of input 4
CL k3,I4=1 Call subroutine k3 when I/O 4 is ACTIVE (1)
O<io point> Set the logic state of an individual output O3=1 Set output 3 HIGH (1)
Binary coded decimal (BCD) commands
OL=<0-15> Set the logic state of the lower output bank OL=15 Set outputs 1 – 4 HIGH (All MDrives) See Details
OH=<0-15> Set the logic state of the upper output bank OH=15 Set outputs 9 – 12 HIGH (Plus2 MDrives) See Details
OT=<0-255> Set the logic state of both output banks OH=255 Set outputs 1 – 4 and 9 – 12 HIGH (if standard I/O this will only set the available points, 1 – 4) See Details
IL Read lower input bank as BCD PR IL Read inputs 1 – 4 as group (response will be 0 – 15 based on I1 being LSb and I4 being MSb) See Details
IH Read upper input bank as BCD PR IH Read inputs 9 – 12 as group (response will be 0 – 15 based on I9 being LSb and I12 being MSb – Plus2MDrives only) See Details
IN Read both input banks as BCD PR IN Read inputs1 – 4 and 9 – 12 as group (response will be 0 – 255 based on I1 being LSb and I12 being MSb) See Details
Input filtering commands
D<input>=<0-255> Set the input filtering to time in milliseconds D1=150 Set the filter for input 1 to 150 milliseconds. Input must be stable for 150 msec before a change will be detected.
Input trip
TI=<input>, <subroutine> Sets the operation of an input trip TI=2, K3 Execute subroutine labeled K3 when input 2 is active. See Details
Lexium MDriveMDrive / MForce

Introduction: Sinking or Sourcing

The terms sinking and sourcing are used in the Lexium MDrive I.O description to describe the configuration of the I/O point with regards to the current flow through the device when active.

  • Sinking: Voltage “sinks” the current to ground.
  • Sourcing: Voltage “sources” the current from a voltage “source.”

Sinking Inputs

Sinking Output

Connection Examples

Sinking input

The sink/source operation of the inputs is determined by the reference potential seen at the input reference input. For sinking input operation, the input reference should be connected to the +VDC side of a +5 to +24 VDC supply.

Sinking input – Switch

Open-Collector (NPN) Sinking Interface

Sourcing input

For sourcing input operation, the input reference should be connected to the return (GND) side of a +5 to +24 VDC supply.

Sourcing Input – Switch

Open-Collector (PNP) Sourcing Interface

Analog input

The Analog input may be interfaced to devices outputting the following signal types and used to control applications such as Speed control, torque control, program interactions.:

  • 0 to +5 VDC
  • 0 to +20 VDC
  • 0 to 30 mA
  • 4 to 20 mA

Dry-contact type power outputs

The outputs of the Lexium MDrive are isolated, dry contact outputs with a voltage range of -24 to +24 VDC and current rating of -100 to +100 mA.

 

Signal (trip) output

The trip output is a high speed, low current output which can be connected as either open-collector or open-emitter. As this output current range max is 5.5 mA, it should not be used with inductive loads, but only as a signal indicator.

Sinking I/O

A sinking device provides a path for the current to ground. Terms used to describe sinking devices include NPN, Open Collector, Normally High, and IEC Negative Logic.

The Motion Control device’s I/O points are programmable as sinking or sourcing, general purpose or dedicated functions with the active state programmable as HIGH or LOW.

Sourcing I/O

A sourcing device provides the power or a positive potential to an I/O point. Sourcing devices ‘push’ the current through the load. Other terms used to describe sourcing devices include PNP, Open Emitter, Normally Low, and IEC Positive Logic.

Note that sourcing outputs are only available on Motion Control devices equipped with Plus2 expanded features.

 

Lexium MCodeMDrive MCode