MD2xp Motor Control System Program

Edit: 22

This help file provides information about the MD2xp program and key aspects of the MD2 Dual Stepper Motor Control System and C4 Controller hardware. For additional information about hardware and software, see the MD2 User's Guide, or visit us online at

The MD2xp software is an interactive motion control environment for Microsoft Windows XP and other versions. MD2xp allows you to control motors on up to three MD2 drivers (6 motors), experiment with motor parameters, control I/O ports, and build motion sequences in a simple, in an intuitive way without any prior knowledge of motion control.

Version V2.0 and up of MD2xp will also control MD2 drivers connected through the C4 controller via the serial or USB port. C4 is the preferred and supported way to connect MD2 drivers to a PC. Parallel port control is still possible but troublesome due to operating system issues.

Table of Contents

Getting Started
    Quick Start
    System Requirements

The MD2 Hardware
    The Driver Box
    AC Power Input
    Front Panel
    Computer Port
    Motor Ports
    Input/Output Port
    DC Power Connector
    Home Switches
    C4 Controller
    C4 Firware Update

The MD2xp Program
    MD2xp Program Usage
    Hot Keys
    Parallel Printer (LPT) Ports
    Enabling MD2 Systems
    Holding Motors
    Standby Mode
    Absolute and Relative Moves
    Speeds and Ramping
    Backlash Compensation
    Step Types
    Units Conversion
    Soft Limits
    Input/Output Port Details

Moving Motors
    Moving with Buttons
    Home Moves
    Line Moves
    Circle and Arc Moves
    Grid Moves

Motor Parameters
    Motor Parameters Overview
    Parameter Files
    Setting up an XY Positioning Table

Motion Sequences (Programs)
    Overview with Examples
    Quick Run Buttons
    Teach Mode

Visual Basic Programs
    Visual Basic .net Programming

More Information and Help
    Online Help





Quick Start

1   Review system requirements.
2   Review the warnings.
4   Insert the MD2 CD and run setup.exe to install the MD2xp program.
5   To use the serial port on your computer, connect the supplied serial cable between your PC and the C4 controller.
6   To use the USB port on your computer, install the software for the USB-Serial Converter first, then connect the converter to a USB port and use the supplied serial cable between the converter and the C4 controller.
7   Connect the C4 controller to the MD2 driver(s) using the supplied flat cables.
8   Connect motors to the MD2 driver(s), then apply power.
9   Run the MD2xp program.
10   Click on the parameters tab, then one of the connection buttons near the bottom. In the connections form, select the type of port.
11   Check the MD2 Enable box on the Control screen.
12   Click the arrow buttons to move motors.
13   Adjust motor parameters on the parameter screen.
14   Refer to help to learn about parameters, motion sequences, and troubleshooting.

Return to Table of Contents


Do NOT use the MD2 system where a malfunction, programming error, or unexpected behavior could result in harm, loss of life, or damage to property.

Only use the correct input voltage to power the MD2 system. The AC voltage requirement can be found on the label on the bottom of the driver.

Do NOT attach or remove cables with power applied to the MD2 driver.

Place the MD2 driver and motors in a well-ventilated area to minimize heat build-up.

Do NOT replace the fuse with a different value or style.

Do NOT remove the MD2 cover or disassemble motors.

See the MD2 User's Guide for additional warnings and details.

Return to Table of Contents

System Requirements

The MD2xp program will run on most PC's running Windows XP, 98, ME, 2000, NT. Not all configurations have been tested so if you run into a problem, please contact us.

A serial port (COM) or USB port.

A mouse makes operation easier but most actions can be accomplished using the keyboard.

A CD drive.

Internet Explorer V5.01 or greater is required by Microsoft to install some components on some machines.

Return to Table of Contents


Install from a CD
Insert the CD
If the setup program does not auto-run, click the Windows Start button and select Run.
Navigate to the CD and click on the SETUP program.
Follow the online instructions.
MD2xp requires the Microsoft .Net Framework version 2.0 which will be installed if needed.

Install from a Zip File
Download or copy the file into a folder of your choice.
Using Windows Explorer, double-click the file.
A window will appear - select Extract All, and select a folder of your choice.
Navigate to the location where the files were extracted and locate the Setup file.
Run the Setup file and follow the installation instructions.

The zip file may not include the .Net Framework V2.0 which is required by MD2xp.

Microsoft .Net Framework 2.0
MD2xp is written in Visual Basic .net 2005 Express and requires the .Net Framework version 2.0. The Framework is provided and will be installed if needed. The Framework can also be downloaded free from Search for .net framework to find the exact location. The Framework is approximately 20Mb in size. To install the Framework, Microsoft also requires Internet Explorer V5.01 or newer.

WMI is an operating system component that MD2xp uses for an optional function to Find parallel printer ports. For Windows 98, you may need to install WMI manually by running wmi9x.exe from the CD. Or download it from the Microsoft website.

Return to Table of Contents


Most control buttons and labels will show Help information when the mouse hovers over them.

A help file provided and is accessable using the Help buttons found on various screens of the program.

Additional help can be found Online. See the Troubleshooting section to solve problems.

Return to Table of Contents

The MD2 Driver Box

The MD2 driver box contains a power supply, 2 stepper motor driver circuits, and control logic.

Return to Table of Contents

AC Power Input

A standard IEC style AC power connector is mounted on the back of the MD2 driver box. First, verify the voltage (110VAC or 220VAC) that the MD2 system operates at by looking at the label on the bottom of the MD2 driver box. Only supply the correct voltage to the MD2 driver box. Incorrect voltage may cause damage to the system.

Return to Table of Contents

Front Panel

The front panel of the MD2 driver box provides a power switch and LEDs indicating the status of the motors and home switches.

Power ON LED and Switch
The ON LED in the POWER section indicates that the MD2 driver box has power applied and that the power switch is on. If this LED does not turn ON, the AC or DC power going to the MD2 driver may be incorrect or the fuse may be blown.

Motor ON LEDs
These LEDs indicate that the motor has power being applied to it, but not necessarly moving. The MD2 system must be enabled and motors moved at least once. If the Hold parameter is set to Off, power will not be left on a motor after a move is complete and the LED will turn off. When the motor is energized as indicated by the LED but not moving, it will retain holding torque.

The Switch LEDs indicate the status of the home switch. Normally you will only see these LEDs flash briefly at the end of a Home move.

Return to Table of Contents

Computer Port

The computer port on the back of the MD2 driver box provides the connection to the PC using a standard parallel (LPT) printer cable. The connector is a 36-pin Centronics female - the same as found on a standard parallel printer.

Return to Table of Contents

Motor Ports

Two motor ports are provided on the back of the MD2 driver box. The type of connector used depends on the motor size. Different motor sizes require different wire sizes.

Cables can be extended as much as 25 feet or more if needed.

Warning Do NOT attach or remove cables with power applied to the MD2 driver

Return to Table of Contents

Input/Output (I/O) Port

A general purpose Input/Output port provides 2 digital outputs, 3 digital inputs, +5 volts, and access to the home switch signals via a 20-pin dual row header connector.

Output signals can be used to control solid state relays which in turn can control user-supplied devices such as tools, lights, etc.

Input signals can be used to read switch closures and digital signals.

See the Input/Output Port Details section for more information.

Return to Table of Contents

DC Power Connector

A DC power connector allows the MD2 system to be powered from an external 24 volt DC source such as two 12-volt car batteries in series.

Warning The jumper between IN and OUT must be removed before external power can be applied.

Return to Table of Contents


Two identical stepper motors are provided with each MD2 system.

The motors are matched to the power supply and drive circuitry of the MD2 driver box so changing motors should not be done.

The size of the motor depends on the MD2 system model.

Most MD2 system motors are NEMA size #23 with a .25 shaft diameter, and a full step angle of 1.8 degrees, and a half step angle of .9 degrees.

Return to Table of Contents

Home Switches

Each motor has an associated Home switch which is used by the software to determine the home (or zero) position.

When a home switch is pressed, the SWITCH light on the front of the MD2 driver will light. The status of the home switches can also be viewed on the I/O tab.

When a Home move is performed, the motor will move reverse at the minimum speed until the home switch is activated, then forward until it is not-activated, the forward the distance set by the Home Offset parameter.

The direction to home is normally set to reverse, but can be changed with the Home Direction parameter.

Return to Table of Contents

C4 Controller

The C4 controller can control 2 MD2 driver boxes (4 motors) through the PC's serial port - or USB port using the included converter cable.

To setup connections to C4, click the connection button at the bottom of the parameter tab. Select C4 and the COM port (Serial port) it is connected to. The USB converter emulates a COM port and appears as one to the software.

Unless you are daisy-chaining several C4 controllers, you can leave the ID set to '1'.

A test button is provided to check the connection to the C4.

A Utilities button opens a window which allows you to send commands to C4 manually, or to update C4's internal firmware.

Return to Table of Contents

C4 Firmware Update

C4's current firmware version can be determined by manually entering !1fv followed by Enter into the manual entry box on the C4 utilities form.

First you will need to download the latest firmware file from our website at Save this file to your desktop.

Click the Select File button on the C4 Utilities form in the MD2xp program and find the firmware file.

Click the Update button. The update will take about 1 minute.

Return to Table of Contents

MD2xp Program Usage

MD2xp provides an easy way to move MD2 motors, change motor parameters, and create sequences of motor movements.

Program operation is simple and intutive using a main window having several tabs - or screens. Simply click on the tab near the top of the window to view the various screens including the main control screen, the motor parameter screen, and the motion sequence screen.

Help buttons are located on many screens. Hover your mouse over labels and buttons to get usage tips.

Before moving motors, you must first Calibrate, and set valid parallel printer port addresses which are used to interface with the MD2 system.

A teach mode is provided to record motor movements initiated from the keyboard. This makes building motion sequences easy.

Return to Table of Contents

Hot Keys

Press the CTRL key to stop a motor.

Switching between Tabs
Use Alt-T to cycle quickly through the tabs.

Function Keys Move Motors
Function keys act just like clicking the forward and reverse buttons on the Control screen.
Function keys operate no matter which Tab is active

F1 - Move Motor 1 Reverse
F2 - Move Motor 1 Forward
F3 - Move Motor 2 Reverse
F4 - Move Motor 2 Forward
F5 - Move Motor 3 Reverse
F6 - Move Motor 3 Forward
F7 - Move Motor 4 Reverse
F8 - Move Motor 4 Forward
F9 - Move Motor 5 Reverse
F10 - Move Motor 5 Forward
F11 - Move Motor 6 Reverse
F12 - Move Motor 6 Forward

Shifted Function Keys Move Motors 1 Step
Hold down the Shift key while pressing a Function key to move the motor only 1 step.
This works great for moving to a precise position.

Home Moves
Alt-1 - Home Motor 1
Alt-2 - Home Motor 2
Alt-3 - Home Motor 3
Alt-4 - Home Motor 4
Alt-5 - Home Motor 5
Alt-6 - Home Motor 6
Alt-7 - Home Motor 1 & 2
Alt-8 - Home Motor 3 & 4
Alt-9 - Home Motor 5 & 6

QuickRun Sequence Hot Keys
Alt-Function keys load and run a sequence named MD2xp?.bas
This is the same as pressing the QuickRun buttons on the sequence tab.
Alt-F1 - Load and Run md2xp1.bas
Alt-F2 - Load and Run md2xp2.bas
and so on...

Control Screen Hot Keys
Press the Alt key and you will see underlined hot key characters for most buttons.

Alt-L - Line Move
Alt-C - Circle Move
Alt-G - Grid Move
Alt-R - Run Program
Alt-E - Edit Program
Alt-M - Teach Mode On/Off
Alt-X - Exit

Parameter Screen Hot Keys
Ctrl-S - Save Parameter File
Ctrl-L - Load Parameter File

Program Screen Hot Keys
Ctrl-S - Save Program File
Ctrl-L - Load Program File

Return to Table of Contents

Printer Ports

Parallel printer ports, also called LPT ports, are used to connect the MD2 Dual Stepper Motor Driver to a PC.

Each printer port can control one MD2 system which controls 2 motors. Printer ports can be part of the PC's motherboard or on a ISA-bus card or PCI-bus expansion board. The MD2xp software can address up to 3 ports (3 MD2 systems) for a total of 6 motors.

Before moving motors you must first find the parallel port address(es) and enter them into the port field of the parameter screen.

Incorrect Addresses
Setting the port address incorrectly may cause your computer to lock-up.

Finding Port Addresses Manually in Windows XP
Click the Windows START button,
Click the SYSTEM icon,
Click on the HARDWARE tab,
Click on the DEVICE MANAGER button,
Click on PORTS (COM & LPT),
Select the desired parallel port (not a COM port),
Click on the RESOURCES tab,
Make a note of the the very first address in the I/O Range box,
This 3 or 4-character word is the Base address of the port.
A typical address might be 0378 or DD98
The leading zero is not required. Letters in the address are not case-sensitive.

Using the Find button
A Find button is located near the Port Address label on the parameter screen. This feature will attempt to locate port addresses through the operating system. This feature many not find any or all ports in all instances. The port will not be found if the driver for the operating system is not installed. If multiple ports are found, selecting which port connects to the MD2 system is up to you.

If an error occurs using the Find button in Windows 95 or 98, this might be due to a missing operating system component called WMI. You can add the WMI component to your Windows 95, 98 system by running wmi9x.exe from the CD. Or download it from the Microsoft website. WMI is only used for the Find button function, so it is not mandatory.

Enter the Port Addresses
Enter the 3 or 4-character port address in the port field on the parameter screen.
Using the wrong address can cause your computer to lock up so double-check it.

Selecting the right port
On computers with multiple ports, you can discover which port the MD2 system is connected to by pressing the home switches and watching the I/O tab of the MD2xp program.

Find and enter all port addresses into the MD2xp program's parameter screen. Connect the MD2 system with motors to a printer port, click on the I/O tab, and press the motor's home switch. The SWITCH light should turn ON on the front of the MD2 system, and the screen will indicate which MD2 system is responding. This tells you which port address is connected to your MD2 system.

Connectors and Cables
Printer ports have a 25-pin female D-Sub connector on the computer side, and printers (and the MD2 system) have a 36-pin female centronics connector. A standard PC parallel printer cable can be used.

Converters Don't Work
You can not use a serial-to-parallel or USB-to-parallel converter to control the MD2 system, it must be a normal parallel port. The MD2 software uses the parallel port as general-purpose digital I/O and must have direct access to the hardware.

Return to Table of Contents


Calibration must be done before moving motors on your newly installed MD2 system. Calabration allows motor speeds to be calculated accurately for your particular computer hardware. Motors will not move during calibration and it doesn't matter if the MD2 system is connected or powered. A calibration file named is saved to disk so you only need to do it once.

Calibration may be performed automatically the first time you start the MD2xp program. The process usually takes 15-30 seconds. Do not use the computer while calibration is being performed..

You can also start calibration manually by pressing the Calibrate button on the Control screen. Do this if motor speeds seem to be inaccurate.

Return to Table of Contents

Enabling MD2 Systems

Before motors can be moved, or outputs controlled, the MD2 system must be enabled. A check-box is provided to enable or disable the MD2. Motor lights on the MD2 driver will not turn on unless motors are moved first, and they will not stay on unless the "Hold" parameter is ON.

Return to Table of Contents

Holding Motors

When the coils of a stepper motor are energized but not changing, the motor shaft will not rotate, but provides holding torque to resist movement. The Motor On LEDs on the front panel indicate that a motor is energized. In this condition, the motor generates heat. Some applications require the motor to maintain holding torque at standstill, and some do not. If holding torque is not needed after a movement is complete, turn off the "Hold" parameter on the parameter screen. This will de-energize motors after movements are complete, reduce heat, yet produce no holding torque at standstill. The Hold parameter applies to all motors.

If lost steps occur while performing a series of movements, turn the Hold parameter ON, then before the last movement, turn Hold Off.

In a motion sequence program, control the Hold parameter like this:

md2hold = -1  'Keep motors energized after next move.

md2hold = 0   'Deenergize motors after next move.
Disabling the MD2 system also de-energizes motors and turns off holding torque. Also see Standby mode.

Return to Table of Contents

Standby Mode

Standby mode reduces current to the motors by half. This reduces motor heating but also reduces torque. Use Standby mode after movements to maintain some holding torque while reducing heat. Trying to move motors while in standby mode might result in lossed steps due to reduced motor torque. Standby mode affects both motors on an MD2 system.

In a motion sequence program, control Standby mode like this:

md2motor=12     'Specify a motor or motor pair.
md2standbyON    'Turn On Standby Mode.

md2standbyOFF   'Turn Off Standby Mode.

Return to Table of Contents

Absolute and Relative Moves

Motors can be moved to an Absolute position, or to a position that is Relative to the current position. This is called the Move Type.

In absolute moves, the target position is an absolute position value. Targets can be negative or positive. The software will calculate which direction and how far it must move the motor to land at the target position.

In relative moves, the the target position indicates a distance and direction from the current position. Target values can be negative (reverse from current position) or positive (forward from current position).

In a motion sequence program, use move type like this:

md2movetype = "A"     'Absolute move.
md2motor = 1          'Motor 1.
md2target(1) = 2260   'Target position +2260
md2move               'Move the motor.

md2movetype = "R"     'Relative move.
md2motor = 3          'Motor 3.
md2target(3) = -100   'Target position reverse 100
md2move               'Move the motor.

Return to Table of Contents

Speeds and Ramping

Motor speed is determined by how fast the software switches the motor's coils On and Off.

Three parameters control the speed of motors: Minimum Speed, Maximum Speed, and Slope. When a motor begins to move, its speed is set by the Minimum Speed value. The speed then accelerates (ramps up) until it reaches the Maximum Speed value, then decelerates (ramps down) until it finally reaches the Minimum Speed value. The distance that acceleration and deceleration occurs is called the slope.

Minimum Speed and Maximum Speed are given in Units per second. If the Unit Value is set to 1, then this is motor steps per second. Slope is given in Units.

Hints on Setting Motor Speeds
Moving the motor too fast for a given load will result in lost steps which causes inaccurate positioning. The number of lost steps can be unnoticable then accumulate to create a large positioning error. Experimentation is required to find the best performance without lost steps.

Set Minimum Speed to 400, Maximum Speed to 400, and Slope to 800. (Unit Value = 1) Since the speeds are the same, no ramping will be done. Move the motor back and forth to assure no lost steps. Increase both speeds until lost steps are detected. Use this speed, minus 30% as the Minimum Speed. A typical Minimum Speed might be 800, and is never greater than 1500.

Now increase the Maximum Speed in increments of 200 until lost steps are detected. Use this speed, minus 30% as the Maximum speed.

Then decrease the slope until lost steps are detected. Use this value, plus 30% as the slope.

Calibration must be performed for the computer being used in order to generate accurate speeds.

In a motion sequence program, set speed values like this:

md2minspeed(1) = "400"    'Motor 1 min speed.
md2maxspeed(1) = "2000"   'Motor 1 max speed.
md2slope(1) = "200"       'Motor 1 slope.

Return to Table of Contents

Backlash Compensation

Backlash is the looseness in the gears, pullies, and couplings of the mechanical system. When the motor changes direction, this backlash usually causes a positioning error until the looseness is taken up.

Backlash compensation adds additional movement to the motor to take up the looseness.

Backlash compensation values are given in Units.

In a motion sequence program, set Backlash compensation like this:

md2backlash(1) = "3"     'Motor 1 backlash.
md2backlash(2) = "3"     'Motor 2 backlash.

Return to Table of Contents

Step Types

The Step Type describes the pattern that is used to energize the coils inside the motor. Three Step Types are available: Half Step, Full-Double, Full-Single. In Half-step mode, the steps are 1/2 the normal size. This is the perferred mode. This results in finer positioning resolution and smoother movement.

In Full-Double mode, 2 motor coils are On at at time - more torque, more heat. In Full-Single mode, 1 motor coil is On at a time - less torque, less heat.

In a motion sequence program, Set the step type like this:

md2steptype = "H"     'Half Step Mode.

Return to Table of Contents

Units Conversion

The smallest movement that a stepper motor can move is called a step, and is usually .9 degrees. The exact step angle is determined by the type of motor, driver, and step type.

A stepper motor is usually connected to a mechanical system to provide linear or rotary motion. For example, a stepper motor that controls a linear positioning table may require 200 motor steps to move 1 linear inch.

Units conversion allows you to use a unit other than steps to refer to positions, speeds, and other motor parameters. For example, setting the unit value to 200 for the above example, would allow you to program positions in inches instead of steps. When you request that a motor move 2 inches forward, the sofware will multiply 2 by 200 to produce 400 motor steps.

It's important to remember that units conversion affects most motor parameters including speeds, slope, backlash, positions, soft limits, and home offset. Changing the unit value will requiring changing all of the other parameters to account for the new unit.

A parameter called Unit Name is also available so you can provide a description of the unit which is then displayed on the control screen. Typical names would be Inches, mm, Degrees, Steps.

In a motion sequence program, set units conversion like this:

md2units(1) = "200"         'Motor 1, 200 steps per inch.
md2unitname(1) = "Inches"   'Motor 1, inches.

Return to Table of Contents

Soft Limits

Soft limits prevent motors from moving beyond a certain point, forward or reverse. An error message will be given if you attempt to move the motor to a position beyond the soft limit.

Soft limit values are given in Units.

In a motion sequence program, Set the soft limits like this:

md2limitf(1) = "10000"     'Motor 1 forward limit.
md2limitr(1) = "-10000"    'Motor 1 reverse limit.
md2limitf(2) = "10000"     'Motor 2 forward limit.
md2limitr(2) = "-10000"    'Motor 2 reverse limit.

Return to Table of Contents

Input/Output Port Details

The MD2 system provides a general purpose I/O port that offers 3 digital inputs and 2 digital outputs. Both motor home switch signals are available also. a 14-pin dual-row header connector provides access to the signals along with +5 and +12 volt power sources.

1 - +5 Volts DC @ 25ma max
2 - Output #1, active low
4 - Output #2, active low
6 - Input #1, active low
7 - Input #2, active low
8 - Input #3, active low
11 - Motor 1 switch, active low
12 - Motor 2 switch, active low
13 - Ground
14 - +12 Volts DC @ 25ma max

Outputs can be controlled by clicking the check-boxes on the Control and I/O tabs of the MD2xp program, or in a program.

Output signals are active low.
When OFF, the outputs are high (+5 volts).
When ON, the outputs are low (0 volts, ground).
Outputs will not turn on unless the MD2 is Enabled.

Connecting a Solid-State Relay
Use a solid state relay to control large devices from the output signals. Many solid state relays require very low voltage and current to operate and can control very large voltages and currents. A CRYDOM D2400 series is an example. Mouser and Digi-Key, among others are vendors of solid-state relays. Since the outputs are active low, connect the control inputs of the relay to the MD2 output signal and +5 volts. When the output is ON, the signal will be driven to ground and create a 5 volt potential across the solid-state relay to activate it.

The status if Input signals can be found on the I/O tab of the MD2xp program.

Input signals are active low and internally pulled high to +5 volts. To activate an input signal, simply connect it to 0 volts - ground.

Return to Table of Contents

Button Moves

The Control screen provides buttons to move each motor reverse (Left Arrow) or forward (Right Arrow). The Distance box determines how far the motor will move with each click of the button. Distances are in Units which may be steps or a user-defined value such as inches, mm, or degrees. Motor speed and other parameters can be set on the parameter screen.

The Home buttons will cause the motor to move reverse to the home switch.

Pressing the CTRL key will stop the motion instantly. When a move is stopped before completing, the position will be incorrect.

Joysticks and Gamepads
Joysticks and Gamepads usually come packed with drivers that emulate keypresses. Buttons can be assigned to move motors, home motors, and run sequences. See Hotkeys for more information.

Return to Table of Contents

Line Moves

Line moves are when 2 motors move together in a straight line when attached to an XY positioning system. Also known as linear interpolation.

During multi-motor line moves, motors start and stop at the same time even though they are moving a different distance. The speed parameters of the motor moving the longest distance determines the speed. Motors going the shorter distance will have their speed slaved to the other motor.

Click the Line button on the Control screen to perform a line move. One or two motors can be selected, their target position(s) and move type - absolute or relative.

Pressing the CTRL key will stop the motion instantly. When a move is stopped before completing, the position will be incorrect.

Return to Table of Contents

Circle Moves

Circle moves cause 2 motors to move in a circular pattern when attached to an XY positioning system. Also known as circular interpolation.

Each circular motion profile is created my moving in straight lines between points on the circle. The resolution of these points is set using the chord angle parameter. Setting the chord angle to 1 will result in a line every one degree for example.

The Arc angle parameter determines how complete the circle is in increments of 1 degree. Set it to 360 for a complete circle or 90 to a quarter of a circle. A positive value will produce counter-clockwise motion, a negative will produce clockwise. If the arch angle can not be evenly divided by the selected chord angle, the last line segment will be shortened so that the desired arc angle results.

Parameters of a circle move allow you to select the radius of each axis thereby creating an ellipse shape.

Acceleration is not done on circle moves. The speed of the motors is determined by their minimum speed parameters. Best performances is achieved by setting the minimum speed for both motors to the same value.

Pressing the CTRL key will stop the motion instantly. When a move is stopped before completing, the position will be incorrect.

Return to Table of Contents

Grid Moves

A grid move moves a 2-axis XY linear positioning table to a specific column and row on a user-defined grid. Grids consist of a series of equally-spaced positions on the X axis (columns) and a series of equally-spaced positions on the Y axis (rows). The grid must be setup before moving by specifying the beginning of grid on the the X and Y axis, and the spacing between columns and rows. All grid setup values are given in user-defined Units which may be motor steps, inches, mm, etc.

Movement to a specific grid location only requires the target X and target Y positions which are given in column number and row number.

Pressing the CTRL key will stop the motion instantly. When a move is stopped before completing, the position will be incorrect.

Return to Table of Contents

Motor Parameters

Motor parameters are set on the Parameter screen of the MD2xp program - select the Parameter Tab.

A column of parameters for each of the 6 possible motors (3 MD2 systems) is provided.

Motor Name
User-defined motor name. Used for display purposes Only.

The current position of the motor in Units. If Unit Value is set to 1, then position is in motor steps.

Unit Name
Name of the positioning units set in Unit Value. Ysed for display purposes. Only

Unit Value
Number of motor steps for each user-defined Unit. Normally set to 1 for individual motor steps. Can be set to any number of integer steps to equate to inches, mm, degrees, etc. of the mechanical system. Motor speeds, slope, backlash, limits, offset, positions, and distance are given in Units.

Home Direction
The direction that the motor must move to approach the home position. Normally this is Reverse but the mechanical system may require Forward. All motion directions are affected by this parameter.

Home Offset
When the motor moves Home, it is followed by a motion in the opposite direction with a distance set by the Home Offset value. The value is in Units. Home Offest allows you move the starting location of a motion program to various locations without changes to the relative movements inside the program. It is also useful for setting tool and material offsets.

Limit Forward
This is a software limit imposed on every move command. The value is in Units. Useful for preventing mechanics from hitting their stop due to incorrect movements..

Limit Reverse
This is a software limit imposed on every move command. The value is in Units. Useful for preventing mechanics from hitting their stop due to incorrect movements..

Minimum Speed
Motor movements start at the Minimum Speed, accelerate according to the Slope parameter, then move at the Maximum Speed for a time, then decelerate according to the Slope parameter, and finish at the Minimum Speed. Minimum Speed is given in Units per second. A typical value would be 400 steps per second.

Maximum Speed
Maximum Speed is the fastest speed the motor will reach after acceleration. Given in Units per second. A typical value would be 2000 steps per second.

Slope is the distance in Units that it takes for the motor to move between the Minimum Speed and the Maximum Speed during acceleration and deceleration. Smaller numbers produce faster acceleration and deceleration. A typical value would be 200 steps.

The distance that is added to motor moves when direction is changed to compensate for looseness in the mechanical system.

Port Address
The 3 or 4-character LPT parallel printer port base address. Locate port addresses in Windows Hardware Device Manager. Example addresses are 03BC, 0378, or DD88. Inaccurate values can cause computer lock-up. See the section on Printer Ports for more detailed information.

Hold Motors When Done
Set to hold power on motor after a motion is done. This will retain holding torque but cause heat buildup in the motor and driver. Hold will also reduce lost steps between moves if the mechanical system has excessive friction. Leave Hold on during a series of moves, then turn it off before the last move, or use Standby mode to reduce heat. See Standby Mode for additional information.

Move Type - (Absolute/Relative)
Determines if target postion is relative to the current position or an absolute position.

Step Type (Half,Single,Double)
Motor phase energization pattern. Use Half for normal operation. Full step modes will result in larger step angles and rougher motion.

Return to Table of Contents

Parameter Files

Motor parameters are stored on disk in a text file - normally with a .par extension. The MD2xp program loads the MD2xp.par file when it first starts. You can save and load parameter files manually or in a motion program.

Parameter files can hold the default values so you don't have to set them in your program. Load a parameter file at the beginning of your program, then change parameters only as needed throughout the program. Here is an example:

md2parfile = "dispense.par"    'Parameter file name
md2parload                     'Load parameters

md2motor=12     'Turn on MD2 #1 (Motors 1,2)

md2target(1) = 420    'Move motor 1 420 steps forward.
md2motor=1            'Relative mode was set in par file.

md2maxspeed(1) = 2000  'Increase max speed for 1 move.
md2target(1) = 20  

md2motor=12     'Turn off MD2 #1 (Motors 1,2)

Return to Table of Contents

Setting Up an XY Positioning Table

Arrick Robotics XY Positioning Tables
Our X and XY series belt-driven positioning tables coupled with an MD2a or MD2b motor control system will result in 200 motor half steps per inch of linear travel.

To operate in Inches, use units conversion. Set Unit Value to 200, and Unit Name to Inches. This will change all parameters such as speeds, backlash, target positions, limits, etc.

The following parameters are typical:
Home Direction: Reverse.
Speeds: MinSpeed=400, MaxSpeed=1500, Slope=200
Limits: Reverse Limit=0, Forward limit for 9"=1800, for 18"=3600, for 30"=6000.
Backlash: 6 steps, or .03 inches.
Step Type: Half

Pulley Reducers
Using a PR23-2.5 pulley reducer improves the accuracy, smoothness, and speed of our belt-driven XY positioning tables. The 2.5:1 ratio will result in 500 motor half steps per inch of travel. The following parameters are typical:
Home Direction: Reverse.
Speeds: MinSpeed=800, MaxSpeed=2500, Slope=200
Limits: Reverse Limit=0, Forward limit for 9"=4500, for 18"=9000, for 30"=15000.
Backlash: 15 steps, or .03 inches.
Step Type: Half

Return to Table of Contents

Motion Sequences (Programs)

Simple motion control programs called sequences are similar to BASIC and can be created and run inside of the MD2xp program. If you require a complex motion program, see the section on Visual Basic Programming.

Sequences can load parameter files, set motor parameters, call motion functions, control outputs, and perform loops. Here is a short example program which shows most of the commands you will need:

Sequence text is not case-sensitive.

'Turn ON MD2 #1
md2motor=12           '12 indicates motors 1 and 2

'Load a parameter file

'Move motor #1 to home

'Move motor #2 to absolute position 300
md2movetype="A"     'Absolute. Was set to R=Relative in parameter file.

'Move motor #2 to relative position 4400
'MD2motor still = 2

'Turn output #1 of MD2#1 high.

SLEEP 2    'Wait for 2 seconds

'Wait for input #3 of MD2#1 to go low

'Move motors #1 and #2 together

'Turn off MD2, md2motor still equals 12



Any motor parameter can be changed in a sequence and it has that value unless it is changed by setting it again or loading a parameter file. This means that if you need to do many different motions using MD2MOTOR=1 then you only need to set it once. Example:


Parameters for each motor have the motor number in (). This number can be 1-6. Below is a listing of motor parameters that can be set. These examples are for motor 1 and show example values along with a short comment:

md2backlash(1)=0          'Backlash compensation distance
md2homeoffset(1)=100      'Distance to move off Home
mdhomedir(1)=-1           'Home direction 0=reverse, -1=forward
md2limitf(1)=999999       'Forward limit position
md2limitr(1)=-999999      'Reverse limit position
md2motorname(1)="X Axis"  'Description of motor use
md2maxspeed(1)=2000       'Maximum speed after acceleration
md2minspeed(1)=400        'Starting and stopping speed
md2slope(1)=100           'Distance of accel/decel
md2target(1)=2044         'Desired target position for next move
md2units(1)=1             'Units conversion.  1=motor steps
md2unitname(1)="steps"    'Description of unit

A few parameters apply to all motors:

md2hold=-1        'Hold motors when done, 0=off, -1=on
md2steptype="H"   'H=Half step, D=Double, S=Single
md2movetype="R"   'R=Relative, A=Absolute move

The following commands are available for use in a sequence:

md2on            'Enables MD2 according to md2motor
md2off           'Disables MD2 according to md2motor
md2parload       'Loads parameter file set in md2parfile
md2home          'Moves motor home according to parameters
md2move          'Moves motor anywhere according to parameters
md2circle        'Moves motor in a circle according to parameters
md2grid          'Moves motors to a grid location according to parameters
md2outputs       'Turns ON/OFF output signals
md2standbyon     'Turns standby mode on according to md2motor
md2standbyoff    'Turns standby mode off according to md2motor
beep             'Make a beep 
sleep            'Wait for a number of seconds
end              'End of program

Output Programming
To control on output signal, first set the MD2OUTPUTCODE, then call the MD2OUTPUTS command like this:

MD2OUTPUTCODE=120 : MD2OUTPUTS   'Turn OFF output #2 of MD2 #1.
MD2OUTPUTCODE=311 : MD2OUTPUTS   'Turn ON  output #1 of MD2 #3.

The first digit of the outputcode indicates which MD2 system (1,2, or 3).
The second digit indicates which output (1 or 2).
The third digit indicates On or Off (1 or 0).

Input Programming
There are 5 inputs per MD2 system. 2 motor home switch inputs, and 3 general purpose inputs that are available on the I/O port. In a sequence, you can make the program wait until an input becomes low before continuing.

MD2WAIT4INPUT(13)	'Wait for input #3 of MD2#1 to go low

The first digit is the MD2 #, 1,2,3
The second digit is the input # 1,2,3,4,5
Input #1 is motor 1 home switch, #2 is motor 2 home switch
Input #3,4,5 are the general purpose inputs on the I/O port

Use SLEEP to cause the program to wait for a number of seconds. If the number given is 0, the program will wait for the CTRL key to be pressed.

Sleep 2		'Wait for 2 seconds.
Sleep 0		'Wait for the CTRL key to be pressed.

Circle Moves
To do a 2-axis circle move, simply set the parameters, and do the MD2CIRCLE command. The 2 motors must be a pair 12, 34, or 56. See the Circle Moves section for more information.

Circles are multi-sided polygons and the parameters of the polygon must be defined first.

Parameters are in Units

'Define the circle.
MD2circleRadiusX=2	'X Axis Radius in units.
MD2circleRadiusY=2	'Y Axis Radius in units.
MD2circleCenterX=10.5	'X Axis center position in units.
MD2circleCenterY=4.1	'Y Axis center position in units.
MD2circleStart=0	'Starting angle in degrees.
MD2circleArc=360	'Arc in degrees. 360=complete circle.
MD2circleChord=1	'Chord in degrees.  1=360 sided polygon.
MD2MoveType="A"		'All of these are absolute numbers.
MD2Motor=12		'Motor pair 1 & 2.
MD2Circle		'Do the circle move.

Grid Moves
Grid moves are a way to move motors to a predefined Row and Column location instead of positions in inches or steps. The 2 motors must be a pair 12, 34, or 56. See the Grid Moves section for details.

Parameters are in Units

'First, define the grid.
MD2GridBeginX=0		'Define Row beginning position in units.
MD2GridBeginY=0		'Define Column beginning position in units.
MD2GridSpaceX=2.5	'Define the Row spacing in units.
MD2GridSpaceY=2.5	'Define the Column spacing in units.

'Now, do the move.
MD2Motor=12		'Motor pair 1 & 2.
MD2GridTargetX=3	'Row 3
MD2GridTargetY=4	'Column 4
MD2Grid			'Move to the target

Use GOTO to jump to any location within a sequence program - forward or backward. The location is identifed with a $ followed by 2 digits 01-99, and must be on a line by itself. Leave out the $ when specifying the location in the GOTO statement.

Goto Example:

'Enable MD2


'Home the motor.

'Move motor 1.

'Loop Back.

Use GOSUB to jump to any location within a sequence program - forward or backward, and return back to the the calling location using RETURN. Instead of duplicating sections of code, use a Gosub/Return. The location is identifed with a $ followed by 2 digits 01-99, and must be on a line by itself. Leave out the $ when specifying the location in the GOSUB statement.

Gosub/Return Example:

'Enable MD2

'Home both motors.

'Move motor 1.

'Home both motors.

'Disable MD2


'Home both motors.
MD2HOME 'Home motor 1.
MD2HOME 'Home motor 2.

There are 9 loop counters - 1 through 9. Loop counts are initialized with MD2LOOPCOUNT# variable assignments. Loops are finished with the MD2LOOP#. # = 1-9. Loops can be nested and can contain Gosubs - up to a total of 9 levels.

'Start loop.

    'Move X axis.

    SLEEP .5


Here is a nested loop example:

'Start outside loop.

    'Move X axis.

    'Inside Loop.

        'Move Y axis.
        MD2TARGET(2)=100 : MD2MOTOR=2: MD2MOVE

        SLEEP .5



If-Then, Variables, Do-Loops, Print, Input, etc.
If your program needs to interact with the operator, use variables, IF-THEN statements, etc, then use our Visual Basic .net subroutine library to get the full features of a programming language.

Running Sequences

Run the sequence currently in the editor by clicking the Run button on either the Sequence Tab or on the Control screen. Execution starts at the beginning of the sequence - location 1.

Run starting from any location by clicking the cursor at the desired location, then clicking the Run From button.

You can also run a section of the sequence by highlighting text, then clicking the Run Selection Button.

Press the CTRL key to stop a sequence from running. When you do this, the motor positions may be inaccurate due to motion being stopped in progress. The cursor will be left at the stop location.

Return to Table of Contents

Quick Run Buttons

Quick Run buttons load and run a sequence with a single click. This is very convenient and powerful. Buttons can run short programs that do simple moves, assign motor speeds, control outputs; or large programs that carry out an elaborate task.

Button 1 loads and runs the sequence file named 'md2xp1.bas'.
This is the default sequence that is loaded at startup.

Button 2 loads and runs 'md2xp2.bas', and so on....

The sequence loaded will be highlighted.

Hotkeys Alt-F1 through Alt-F11 is the same as clicking the respecitve Quick Run buttons. These hotkeys work no matter which tab is being shown.

Return to Table of Contents

Writing Sequences

Sequences are written using the text editor found on the Sequence screen. The MD2xp1.seq sequence file is loaded each time the MD2xp program is started. You can use this file name, or save to another, and build a whole library of programs. Sequence files can also be edited in any plain text editor such as Windows Notepad.

Return to Table of Contents

Teach Mode

Teach mode is controlled by a check box on the Control screen. When Teach mode is On, each motion performed by button moves, line moves, circle moves, grid moves, home moves, and output control, will record instructions into the sequence editor. New instructions are added to the bottom of the sequence. Exiting without saving the sequence will result in lost data.

Return to Table of Contents

Visual Basic Programming

The MD2xp program is written using Microsoft Visual Basic .Net 2005 Express. VB Express is free from the Microsoft website. The source code for the MD2xp program is provided along with the MD2 system so you can modify it and create your own custom application.

The MD2VN2S.VB is the subroutine library which controls the MD2 system. It requires the inpout32.dll for I/O.

Return to Table of Contents


Power light never turns on
The MD2 driver is probably not getting power. Check the power cord and the fuse. If the fuse is blown, replace it with one of the exact type and value. If the fuse blows a second time, the electronics are likely failed and repairs will have to be made. If a battery is being used instead of AC power, make sure the voltage is correct at the terminal strip.

The jumper between the battery input terminal and the power supply output terminal must be in place for normal AC operation, and removed for external battery operation.

Motor lights never turn on
The MD2 system is not receiving the proper signals from the computer. Check the cable connecting the MD2 to the computer. Check for proper parallel port addresses.

Motor lights turn on but motors do not move
If using custom software, try using the supplied software. Check all cables. Verify that motor speed parameters are not set incorrectly causing very fast undetectible attempts at motor movement. Re-calibrate.

MD2 randomly disables, requiring re-enable
This can be caused by a Windows printer driver talking to the printer. To witness this, Enable the MD2, Set Hold to ON, and move a motor. The motor light will stay ON. Then wait a few minuites to see if the motor light goes off automatically. Removing the printer driver should solve this.

Also, power saving features of the host computer can turn off ports when they are not in use. Disable power-saving features should solve this.

Home switches do not activate the SWITCH Lights
Check the motor cable for problems. Swap cables and motors and home switches to attempt to identify a broken component. If using a custom sensor, try the supplied micro-switch.

Too much motor heat
Motor and driver heathing is normal and occurs mostly during standstill. Mount the motors on metal brackets to help dissapate the heat, or use a fan. Configure the software to deenergize motors after moves are complete, or use Standby Mode to reduce heat.

Missing motor steps causing inaccurate positioning
This could be caused by exceeding the torque capacity of the motor. The available torque of a stepper motor decreases as the speed increases. Reducing speed below 500 steps per second will result in the maximum torque available. Use gearing or a pulley reducer to increase torque. Turn on the "Hold motors when done" parameter to keep motors energized between movements. Then turn on Standby Mode to reduce heat at standstill. Attempting to move motors while in standby mode will result in half of the torque and possibly lost steps.

Motion is not smooth
The Windows operating system is not designed to allow real-time software such as the MD2 software to run completely smoothly. You can greatly improve smoothness by disabling software that steals processor time such as: internet software, virus checkers, screen savers, modem watchers, battery monitors, software update managers, power saving features, themes, screensavers, etc. In Windows XP, pressing Ctrl-Alt-Del will display the task manager and show all processes. You can look up the processes on the internet and determine which is really needed.

Return to Table of Contents

Online Help

This document should answer most questions you may have about the MD2 system, but if you still need help, visit our website at This and other websites might not display correctly in the small help browser supplied with MD2xp so use a full-featured browser instead.

Return to Table of Contents


The MD2 Dual Stepper Motor System, and the MD2xp program were created by Roger Arrick.

Return to Table of Contents

















































The Very End