rt-stepper
with EMC2
External Reference Specification (ERS)
Table of contents
1 Purpose
The purpose of this document is to present a description of what the rt-stepper product is and how it is used. This description is intended to define what the product controls, human interface, machine interface and how to use the product.
This document is provided "AS IS" without warranties of any kind including warranties of merchantability, fitness for a particular purpose, or non-infringement of intellectual property.
2 Introduction
The rt-stepper USB-to-Parallel dongle is a special dongle designed specifically for CNC controllers. This dongle provides CNC parallel port support and real time stepper motor control. You can use this dongle to convert a parallel port CNC controller into a USB CNC controller.
Most CNC controllers are designed to be driven with a PC parallel port. Unfortunately parallel ports are a thing of the past and many new PCs have no parallel port. Commercial USB-to-Parallel dongles do exist, but these dongles are designed for printers not CNC controllers. CNC controllers require XYZ step/direction signals. With the rt-stepper dongle you can now drive XYZ step/direction signals over the USB bus.
The original rt-stepper software was a small terminal program that ran a small subset of CNC gcodes.
This software was open source similar to the EMC2 open source project at www.linuxcnc.org. In stead of re-inventing another gcode interpreter the rt-stepper software is now based on EMC2. EMC2 provides a number of improvements - 4-axis support, complete gcode interpreter, trajectory planner, GUI front-end and Backploting.
Since rt-stepper provides the real time step pulse generator this version of EMC2 has been re-factored. The EMC2 real time component has been removed. There are no kernel modules or real time kernel patch dependencies. This allows EMC2 (rtstepper_emc) to run on Linux, Mac or Windows.
For those familiar with EMC2 some functionality was dropped. USB devices are different from parallel port devices. Basically the rt-stepper dongle must be treated as a buffered device in order take advantage of USB bus speed. You cannot control the device one-byte-at-time like a parallel port. This means no continuous joging, homing or probing are supported because it would be too slow. Only incremental joging is supported.
For the time being HAL has been removed. All configuration options are done via a *.ini file.
The rt-stepper software is an open source project available at www.ecklersoft.com.
2.1 Requirements
rt-stepper was created to satisfy the following requirements.
- Support USB only PCs
- Support existing parallel port only CNC controllers
- Work with standard OSs, no real-time kernel required
- Support Linux, Mac, Windows and other OSs
- Fast, reliable, minimalist system
- Event driven, multithreaded
- Support third-party applications
2.2 Design Goals
rt-stepper software will be based on the EMC2 project at www.linuxcnc.org.
The GUI will be based on NML messaging protocol provided by the rcslib at www.isd.mel.nist.gov/projects/rcslib.
Only USB IO will be supported. Parallel port support will be provided via the rt-stepper USB-to-parallel dongle.
All USB IO will be based on libusb. rt-stepper is designed to be used by Linux, but other OSs that support libusb will also work.
The rt-stepper software will be open source, but the dongle will be sold as a product.
GNU software tools will be used to build the source code. This includes an ANSI C compiler and POSIX compliant environment.
The tar ball will have built-in binary package support when used with EPM.
Device permissions and user policies should be settable independently by administrators and distributions.
The dongle will have IO support for 8-bit output and 1-bit input. Both output and input are supported by the rt-stepper software.
The dongle 8-bit output will be reserved for 4 axis support. Initially no other spindle/tool control will be supported.
2.3 License
The rt-stepper software that runs on the PC is covered by the GNU GPL 2.0 license.
Simply stated the GNU GPL license does allow the following.
- Use the rt-stepper software at no charge.
- Distribute verbatim copies of the software in source or binary form.
- Sell verbatim copies of the software for a media fee or sell support for the software.
What this license does NOT allow you to do is make changes or add features to rt-stepper software and then sell a binary distribution without source code. You must provide source code for any changes, or additions to the software and all code must be provided under the GPL or LGPL as appropriate.
3 Solution
4 Overview
rt-stepper consists of PC software and USB-to-parallel dongle. The dongle's USB connector connects to the PC. The dongle's DB25 connector connects to the parallel port of the CNC controller.
The rt-stepper software is based on the EMC2 open source project at www.linuxcnc.org. There are two processes that run on the PC - TkMini and milltask. TkMini is a GUI front-end program that communicates through the milltask to the dongle. The milltask process performs the gcode translation, trajectory planning and rt-stepper IO. Together they act as a real time stepper motor gcode virtual machine. Step timing is maintained by dongle thus eliminating the need for a real time kernel.
The software will interpret the gcode file, covert the gcode instructions into a series of step buffers. Each step buffer is sent over the USB 1.1 bus to the dongle. The dongle then clocks each step byte out over the parallel port at precise step intervals. Each step byte drives the step/direction pins on the CNC controller parallel port.
Both manual and auto CNC operations are supported by the software.
5 CNC Program Codes
The rt-stepper software supports the same gcode interpreter as EMC2.
See the "Gcode Overview" section at www.linuxcnc.org for
program syntax, parameters, expressions, binary operators, functions and looping constructs.
Keep in mind that program codes that deal with Tool Change, Spindle, Coolant and Homing are currently ignored.
Notes on some codes:
Perfect circles can be made with the circular interpolation codes G02 or G03 using the R radius word. Generally this is done with two commands, one command for each half of the circle. Here is an gcode example that cuts a one inch circle at the origin.
G0 X0.5 (rapid to 0 degree point on circle)
G1 Z-0.035 F6 (plunge)
G3 X-0.5 Y0 R0.5 F6 (cut arc to 180 degree point on circle)
G3 X0.5 Y0 R0.5 F6 (cut arc to 0 degree point on circle)
Of coarse in this example a perfect circle will require accurate XY backlash values in the ini file. I repeat perfect circles require accurate backlash values!
6 Configuration File
A configuration file will be used to set rt-stepper runtime options. By default the rtstepper.ini file is used as the configuration file. You can also
specify a custom ini file on the TkMini command line.
tkmini -ini rtstepper.ini
The ini file is a simple ASCII text file that must be customized for each unique CNC controller. Use any text editor to customize the ini file. Multiple ini files can be used for different CNC controllers.
The ini file is divided into different sections and key/value pairs. Sections are defined by brackets "[ ]" and key/value pairs are defined by the "=" character. Comment lines start with the "#" character.
The rest of this section define some common configuration options and their default values. Generally only these options need to be modified by the user.
6.1 EMC section
[EMC]
MACHINE = TkMini (rtstepper.ini)
Sets the title in the UI application. Useful for identifying what ini file is loaded.
6.2 TRAJ section
[TRAJ]
DEFAULT_VELOCITY = 0.2
DEFAULT_ANGULAR_VELOCITY = 0.2
Sets the trajectory default max velocity in engineering units. In the above example this would be 0.2 inches/second or 12 inches/minute (12 = 0.2 * 60).
6.3 AXIS section
[AXIX_n]
MAX_VELOCITY = 0.15
BACKLASH = 0.0
INPUT_SCALE = 32000
STEP_PIN = 2
DIRECTION_PIN = 3
There is a AXIS section for each axis (AXIS_0 - AXIS_3).
MAX_VELOCITY specifies the max velocity for this axis. In the example this would be 0.15 inches/second.
BACKLASH is the amount of backlash or "play" in your XYZ lead screw. Start with zero then after tuning your CNC system, measure your backlash and enter the values here. Note, backlash compensation is a poor substitute for good lead screws. Excessive backlash can "throw" the table, causing inaccurate cuts and or broken tool.
INPUT_SCALE define the stepper motor steps/inch for this axis. This is a function of your motor, lead screw and CNC controller. Metric values can be used here instead of inch.
Here are some notes on how to calculate the INPUT_SCALE for a Sherline mill using the using a Xylotex 3-axis CNC controller and 269 oz.in steppers.
1.8 = degrees/step
360 / 1.8 = 200 steps/revolution
.050 = one revolution of the lead screw
200 / .050 = 4000 steps/inch full steps
Since the Xylotex CNC controller board is set to 1/8 stepping.
4000 * 8 = 32000 steps/inch = INPUT_SCALE
STEP_PIN specifies the step pin on the DB25 connector for this axis.
DIRECTION_PIN specifies the direction pin on the DB25 connector for this axis.
The default values for step/direction pins will work for many commercial boards.
Note, all step/direction signals are "active low". Your CNC controller MUST be built this way, most commercial boards are.
6.6 TASK section
[TASK]
INPUT0_ABORT = 0
The "INPUT0_ABORT" sets the INPUT0 abort option. INPUT0 signal is hard wired to the DB25 connector pin 10. This signal can be used for limit switches.
See the Limit Switches section for wiring details.
When "INPUT0_ABORT=0" the INPUT0 signal is ignored. This is the default.
When "INPUT0_ABORT=1" an "active high" transition on the INPUT0 pin will cause a un-synchronized estop.
7 Screens
The above screen is an example of TkMini running on Linux. The Backplot example shows the CNC path used to create the dongle case.
The above screen an example of TkMini running on Windows XP. The Backplot example shows the CNC path used to create the dongle PCB.
8 Error logging
Any errors during rt-stepper program execution are written to a local milltask.log file.
The log file will always have more specific error information than the TkMini display.
Use a text editor to view the log file.
The log file is automatically created in the user home directory.
For example the log file for Linux would be "~/.rtstepper_emc/milltask.log".
For Windows it would be "c:\Documents and setting\usr_name\.rtstepper_emc\milltask.log".
Error logging is always enabled and should be referenced before asking for help.
9 Dependencies
- Software build requirements
- GNU software tools, this includes the ANSI C compiler and POSIX compliant environment
- libusb-devel 0.1.10a or higher
- Runtime requirements
- libusb 0.1.10a or higher
- ncurses
- pthread
- tcl/tk
- rcslib
10 OS Support
rt-stepper is designed to be used by Linux, Mac and Windows.
All though not a complete list the following OSs have be tested.
- Fedora 13
- Ubuntu 10.04
- MacBook Intel OS X 10.6.4
- Windows XP
11 Software Installation
The best way to install the rt-stepper software is with a pre-build binary package. Pre-build binary packages are available at www.ecklersoft.com/download. Installing from source code is an option, but should only be attempted by an experienced programmer or administrator.
11.1 Binary Install
All binary packages include the rcslib library.
For Windows use the following steps to install rt-stepper. The instructions have been tested on Windows XP and Windows 7.
- Download and install the latest 32-bit ActiveTcl for Windows (ie: ActiveTcl 8.5.9.2 or higher) at www.activestate.com.
- Download the latest rtstepper_emc_win32 zip file from www.ecklersoft.com/download.
- Unzip rtstepper_emc_win32 into a directory of your choice.
- At this point you should be able to run "tkmini.tcl" by double clicking on it. This should start two processes - the TkMini application and milltask. Only the TkMini application should be visible.
- With no dongle plugged in, TkMini should have displayed the message "unable to connect to the rt-stepper dongle". You can go ahead and exit out of TkMini for now. This should close both windows.
- Now it is time to install the rt-stepper USB driver.
- Plug-in a USB cable from the PC to the rt-stepper dongle.
- When Windows asks for a new hardware driver, manually choose the "rt-stepper.inf" file. Ignore any not "digitally signed" messages and continue with the installation.
- Disable any power save options that will cause the PC to shutdown during CNC operation.
- Now you can run "tkmini.tcl" and there should be no "unable to connect to the rt-stepper dongle" message.
- You are now ready to proceed with the Power Up section.
For Linux use the following instructions to install rt-stepper. The instructions have been tested on Fedora and Ubuntu.
- Download the latest rt-stepper rpm or deb package from www.ecklersoft.com/download.
- Install the binary package. Note the software version number will be the same or higher.
for Fedora:
rpm -ivh rtstepperemc-1.7.1-0-x86_32.rpm
for Ubuntu:
dpkg -i rtstepperemc-1.7.1-0-x86_32.deb
- At this point you should be able to run "tkmini" from the command line. This should start two processes - the TkMini application and milltask. Only the TkMini application should be visible.
- With no dongle plugged in, TkMini should have displayed the message "unable to connect to the rt-stepper dongle". You can go ahead and exit out of TkMini for now. This should close both processes.
- Plug-in a USB cable from the PC to the rt-stepper dongle.
- Disable any power save options that will cause the PC to shutdown during CNC operation.
- Now you can run "tkmini" and there should be no "unable to connect to the rt-stepper dongle" message.
- You are now ready to proceed with the Power Up section.
11.2 Source Code Install
Use this section as a reference for building and installing rt-stepper from source code. WARNING the instructions are not complete and vary by OS and release.
There are many build time dependencies. Even an experienced programmer will find building from source code very frustrating.
For Linux use the following steps to build and install rt-stepper.
- Download and untar the latest rt-stepper tar ball.
- In the rt-stepper directory build and install rt-stepper.
./configure
make
make install
- Disable any power save options that will cause the PC to shutdown during CNC operation.
- rt-stepper is now ready to run.
For Mac OS X 1.6 use the following steps to build and install rt-stepper.
- Download install xcode to get the GNU tools.
- Download install darwinports at darwinports.org/getdp.
- Install libusb.
sudo port install libusb
- Download and untar the latest rt-stepper tar ball.
- In the rt-stepper directory build and install rt-stepper.
./configure --prefix=/opt/local LDFLAGS=-L/opt/local/lib CFLAGS=-I/opt/local/include
make
sudo make install
- Disable any power save options that will cause the PC to shutdown during CNC operation.
- rt-stepper is now ready to run.
Building and installing for Windows XP is a two step process. First build a win32 rt-stepper zip package on Fedora 13 then install the package on Windows.
After installing rt-stepper can be run totally from the zip directory.
The following steps outline this procedure.
- On Fedora 13 install mingw. Mingw is a win32 cross-compiler tool chain. More information about mingw is available at www.mingw.org.
yum install mingw32-*
- Copy the following libusb-winusb files to the mingw32 directories. Libusb-winusb is based on Microsoft's winusb user mode driver. The libusb-winusb files are available in the binary download.
cp libusb-winusb.a /usr/i686-pc-mingw32/sys-root/mingw/lib/
cp usb.h /usr/i686-pc-mingw32/sys-root/mingw/include/
cp libusb-winusb.dll /usr/i686-pc-mingw32/sys-root/mingw/bin/
- Download and untar the latest rt-stepper tar ball.
- In the rt-stepper directory build the rt-stepper zip package.
./configure --host i686-pc-mingw32
make
make zip
- Now transfer the rt-stepper zip package to the Windows XP PC.
- Choose a directory location to run the rt-stepper program(s) from. Unzip the rt-stepper package into this directory.
- For TkMini download and install the latest 32-bit ActiveTcl for Windows (ie: ActiveTcl 8.5.9.2 or higher) at www.activestate.com.
- Plug-in a USB cable from the PC to the rt-stepper dongle.
- When Windows asks for a new hardware driver, manually choose the rt-stepper.inf file. Ignore any not "digitally signed" messages and continue with the installation.
- Windows should now recognize the dongle's USB device vid, pid and serial number at plug-and-play time.
- Disable any power save options that will cause the PC to shutdown during CNC operation.
- rt-stepper is now ready to run. Run "tkmini.tcl" from the zip directory.
12 Power Up
The rt-stepper dongle is powered from the USB bus on the PC, no external power supply is required. Since the CNC controller has a separate power supply the following power up sequence must be used.
- Power up the PC.
- If not already connected, plug the dongle into the PC via the USB cable.
- After the kernel enumerates the USB device check the dongle's green LED.
The LED should be on solid (no blinking).
- Power up the CNC controller.
Use the reverse order for the power down sequence.
13 Testing
Before we can start CNC stepping the motors we must verify the USB subsystem with the rt-test program. rt-test is part of the rt-stepper package.
IMPORT!! The rt-test program must be performed with no CNC controller connected to the dongle.
rt-test will verify that your USB subsystem on your PC can drive the rt-stepper dongle. Run "rt-test" from the command line and
the following checks will be made.
- USB device enumeration.
- Device permissions.
- Start a 65K byte bulk write transfer.
- Wait for transfer complete.
- Print pass or fail.
Run rt-test several times, if rt-test passes every time proceed to the Tuning section.
14 Tuning
Before we can cut any real parts we must tune rt-stepper with the CNC system.
At this point the INPUT_SCALE values, see the Configuration File section, should be correct for your CNC controller.
Since rt-stepper has it's own real-time clock, tuning is very simple.
All we have to determine is the MAX_VELOCITY for each axis on the CNC system. Then update the ini file with the new values.
The MAX_VELOCITY is the max speed the stepper motors can operate at. Stepper motors will go out of sync if they are accelerated or decelerated too suddenly.
This is because the magnetic fields are advancing faster than the rotor can keep up.
Once a motor is out of synchronization further CNC stepping is useless as the position of that axis has been lost.
For tuning purposes the measured MAX_VELOCITY should be less than the current MAX_VELOCITY values in the ini file. The initial values in the default
ini file should be a good starting point for tuning.
The MAX_VELOCITY is a very important control variable and can be used for the following functions.
- Set rapid limit in TkMini.
- Set the max feed rate in the gcode file.
MAX_VELOCITY must be measured for each axis.
Here is the procedure for measuring each axis.
- Run TkMini.
- Set the default max velocity by clicking the Rapid button.
- Jog the axis 1 inch.
- If the motor chatters or does not move at all reduce Speed with the slider and repeat step 1.
- Measure the distance moved, if not 1 inch reduce Speed and repeat step 1.
- Done, the resulting Speed is your measured MAX_VELOCITY, set MAX_VELOCITY = (Speed / 60) in the ini file.
Generally the measured MAX_VELOCITY is a function of your CNC controller board and stepper motors not rt-stepper. If your measured MAX_VELOCITY is not acceptable try reducing your steps/inch on your controller board. If you change your steps/inch remember to change the INPUT_SCALE in the ini file.
When tuning is complete you are ready to start cutting parts.
15 Limit Switches
Depending on the CNC system limit switches are optional. If exceeding the XYZ physical limits can cause physical damage to your CNC system then limit switches are NOT optional.
The current rt-stepper dongle supports one "active high" input signal called INPUT0.
INPUT0 signal is hard wired to the DB25 connector pin 10. This signal can be used for limit switches.
Multiple switches must be wired in series as normally closed switches connected to CNC ground.
INPUT0 has a internal pull up resistor so no external power or pull up resistor is required.
INPUT0 uses a Schmitt Trigger input buffer for noise immunity, but care should still be taken with the switch wiring. Do NOT route switch wires near power wires.
INPUT0 can be used to signal an un-synchronized estop of the current CNC controller move. This functionality can be enabled via the ini file.
See the "input0_abort" option in the Configuration File section.
Note the "input0_abort" option has a small amount of software overhead so the abort sequence in not immediate.
Some extra steps may be executed after a switch has been tripped.
The number of extra steps will be feed rate dependent. Switches should be chosen that can handle any extra steps without being damaged.
16 CNC/CAD/CAM Support
All though not a complete list the following publicly available CAD/CAM packages and CNC controllers have be tested.
CAD/CAM support
CNC controller support
- Xylotex 3-Axis Controller, www.xylotex.com. Used with Sherline 2000 Mill to build rt-stepper dongle cases.
- Camtronics 3-Axis 2A Controller (no longer sold), Camtronics Inc.
Used with Sherline 5000 Mill plus 10,000RPM pulley to build dongle PCBs.
18 Specifications
Step resolution: 46,875 hz
Standards: USB V1.1, USB V2.0 Compliant
USB Speed: Full Speed (12 Mb/s)
VID: 0x04d8
PID: 0xff45
Power: Bus Power Only (~5v)
Indicators: Power
Overall Dimensions: 2.5 in.(L) x 2.35 in.(W) x 0.95 in.(H)
Weight: 2.3 oz.
© 2009-2011 Eckler Software

Last updated December 9, 2011