Application Notes

Configuring MDrive I/O: MCode Basics

Home > Resources > Application Notes > Configuring MDrive I/O: MCode Basics


Setting up the hardware interface for the MDrive I/O only represents half of the battle. Before it can function it must be configured in software using the “S” command.


  • MDrive Linear Actuator
  • MDrive Plus
  • MForce


  1. MDrive r MForce Motion Control or Ethernet product
  2. DC power supply
  3. Optional: +5 to +34 VDC Auxiliary supply
  4. +5 to +24 VDC I/O supply (if using sourcing outputs).
  5. Input and/or output devices
  6. Cabling: 22 AWG shielded twisted pairs for I/O, Shielded twisted pair for power, AWG determined by length and current


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 FunctionsOutput Functions
Param #FunctionParam #Function
0General purpose16General purpose
2Positive limit18Fault/Error
3Negative limit19Stall
4G020Velocity changing
5Soft stop
6Pause running program
7Jog positive
8Jog negative

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/SourceActive StateOutput StateCircuit Condition
SinkingActive HIGHOutput = 1Sink OFF, High impedance
Output = 0Sink ON
Active LOWOutput = 1Sink ON
Output = 0Sink OFF, High impedance
(Plus2 Only)
Active HIGHOutput = 1Source ON
Output = 0Source OFF, High impedance
Active LOWOutput = 1Source OFF, High impedance
Output = 0Source ON



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.

MnemonicFunctionUsage exampleDescription
Individual I/O point control commands
I<io point>Read an individual input state as 1 or 0PR I4Read the state of input 4
CL k3,I4=1Call subroutine k3 when I/O 4 is ACTIVE (1)
O<io point>Set the logic state of an individual outputO3=1Set output 3 HIGH (1)
Binary coded decimal (BCD) commands
OL=<0-15>Set the logic state of the lower output bankOL=15Set outputs 1 – 4 HIGH (All MDrives) See Details
OH=<0-15>Set the logic state of the upper output bankOH=15Set outputs 9 – 12 HIGH (Plus2 MDrives) See Details
OT=<0-255>Set the logic state of both output banksOH=255Set outputs 1 – 4 and 9 – 12 HIGH (if standard I/O this will only set the available points, 1 – 4) See Details
ILRead lower input bank as BCDPR ILRead inputs 1 – 4 as group (response will be 0 – 15 based on I1 being LSb and I4 being MSb) See Details
IHRead upper input bank as BCDPR IHRead inputs 9 – 12 as group (response will be 0 – 15 based on I9 being LSb and I12 being MSb – Plus2MDrives only) See Details
INRead both input banks as BCDPR INRead 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 millisecondsD1=150Set 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 tripTI=2, K3Execute subroutine labeled K3 when input 2 is active. See Details

When it comes to your form, fit and function requirements, don’t settle. Get precisely what you need working with us. We know motion.

Contact us with any questions about how we can help you with your motion application or for assistance with your IMS products.

Browse our resource section and find the most useful tools and documents for all our products.