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.
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 rt-stepper software is used to drive the dongle over the USB bus. This software is open source similar to the EMC2 open source project at www.linuxcnc.org. Both projects are separate PC applications that interpret gcode and drive CNC controllers. Instead of re-inventing another gcode interpreter the rt-stepper software is based on the EMC2 software from www.linuxcnc.org. By re-purposing the EMC2 software the rt-stepper software provides - 4-axis support, complete gcode interpreter, trajectory planner, GUI front-end and Backploting.
Note through out the rest of this document the term "EMC2" and "EMC2 software" refers to software from the EMC2 project at www.linuxcnc.org. Both projects have separate code bases and create separate executables or binaries.
Since the rt-stepper dongle 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 (rtstepperemc) 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 and expect guaranteed speed. This means a different approach must be used for USB. Step buffers must be created with known distances and trajectories before being sent over-the-wire. EMC2 code for continuous jogging, homing or probing must be re-factored or dropped. As a result only incremental jogging is supported and homing is now done via python scripts.
HAL has been removed. All configuration options are done via a *.ini file. The rcslib library dependency has been removed.
The rt-stepper software is an open source project available at www.ecklersoft.com.
rt-stepper software will be based on software from the EMC2 project at www.linuxcnc.org.
The GUI will be similar to the existing EMC2 mini.tcl GUI.
Since the rt-stepper software is a single process multi-threaded design, the NML messaging protocol is not longer used.
Any EMC2 dependency on the rcslib from www.isd.mel.nist.gov/projects/rcslib has been removed.
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.
Device permissions and user policies should be settable independently by administrators and distributions.
The dongle will have IO support for 8-bit output and 3-bit input. Both output and input are supported by the rt-stepper software.
The dongle 8-bit output will be configurable for axis support or general digital output.
Spindle and coolant mcodes will be implemented via python scripts.
All user-defined mcodes will be implemented via python scripts.
Homing will be performed with a user-defined mcode.
Simply stated the GNU GPL license does allow the following.
The rt-stepper software is based on the EMC2 open source project at www.linuxcnc.org. Note both projects are seperate software applications and the dongle will only run on the rt-stepper software. With the rt-stepper software there is only one process that runs on the PC - TkMini. TkMini is a GUI front-end program that communicates directly to the dongle. This single process performs the gcode translation, trajectory planning and rt-stepper IO. TkMini generates the step pulses, but 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.
Mcodes are handled differently the rt-stepper software. Most mcodes are now implemented with python scripts. This means spindle, coolant and homing are now executed via python scripts. Tool Change codes 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!
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.
Different digital output configurations can be defined in the ini file. DB25 pins 2-9 can be assigned to different output signals. The following examples show how 8 digital outputs can be configured for different CNC applications.
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.
[EMC] MACHINE = TkMini (rtstepper.ini)Sets the title in the UI application. Useful for identifying what ini file is loaded.
[DISPLAY] PROGRAM_PREFIX = /etc/rtstepperemcSets the default path to gcode and mcode files.
[TRAJ] DEFAULT_VELOCITY = 0.2 MAX_VELOCITY = 400 DEFAULT_ACCELERATION = 200 MAX_ACCELERATION = 400Sets the trajectory planner default velocity and acceleration in engineering units. In the above example this would be 0.2 inches/second or 12 inches/minute (12 = 0.2 * 60). This sets the trajectory planner overall acceleration and velocity then each axis can be fine tuned individually in the AXIS section.
[AXIX_n] MAX_VELOCITY = 0.15 BACKLASH = 0.0 INPUT_SCALE = 32000 STEP_PIN = 2 DIRECTION_PIN = 3 STEP_ACTIVE_HIGH = 0 DIRECTION_ACTIVE_HIGH = 0There 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.
STEP_ACTIVE_HIGH specifies the polarity of the step signal (0 = active_low, 1 = active_high).
DIRECTION_ACTIVE_HIGH specifies the polarity of the direction signal (0 = active_low, 1 = active_high).
The default values for step/direction pins will work for many commercial CNC controller boards. Note, the dongle supports 8 digital output signals on DB25 connector pins 2, 3, 4, 5, 6, 7, 8 and 9. Your CNC controller MUST be built to use these pins, most commercial boards are.
[TASK] INPUT0_ABORT = 0 INPUT1_ABORT = 0 INPUT2_ABORT = 0Use the "INPUTx_ABORT" option to automatically trigger a un-synchronized estop. Any "INPUTx_ABORT" option can be used to enable a estop. Generally the input signals are used for limit switches. See the Limit Switches section for wiring details.
When "INPUTx_ABORT=0" the INPUTx signal is ignored. This is the default.
When "INPUTx_ABORT=1" an "active high" transition on the INPUTx pin will cause a un-synchronized estop.
OUTPUT0_PIN = 0 OUTPUT1_PIN = 0 OUTPUT2_PIN = 0 OUTPUT3_PIN = 0 OUTPUT4_PIN = 0 OUTPUT5_PIN = 0 OUTPUT6_PIN = 0 OUTPUT7_PIN = 0Use the "OUTPUTx_PIN" option to enable a general digital output signal. The signal can be used for turning spindle or coolant on/off. Each "OUTPUTx_PIN" specifies a DB25 pin number. IMPORT!! The pin number MUST be an unused axis step/direction pin. This means the same pin number can NOT be used in [AXIS_n] section.
When "OUTPUTx_PIN" = 0 the OUTPUTx signal is unused. This is the default.
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 a 3D view of the CNC path used to create the dongle PCB.
The above screen an example of TkMini running on Mac OSX 10.6. The Backplot example shows a 2D XY view of the CNC path used to create the dongle PCB.
The log file is automatically created in the user home directory. For example the log file for Linux and OSX would be "~/.rtstepperemc/milltask.log". For Windows it would be "c:\Documents and setting\usr_name\.rtstepperemc\milltask.log". Error logging is always enabled and should be referenced before asking for help.
for Fedora: rpm -ivh rtstepperemc-1.7.1-0-x86_32.rpm for Ubuntu: dpkg -i rtstepperemc-1.7.1-0-x86_32.deb
For Linux use the following steps to build and install rt-stepper.
./configure make make install
sudo port install libusb-compat
./configure --prefix=/opt/local LDFLAGS=-L/opt/local/lib CFLAGS=-I/opt/local/include CXXFLAGS=-I/opt/local/include make make dmg
yum install mingw32-*
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/
./configure --host i686-pc-mingw32 make make zip
The LED should be on solid (no blinking).
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.
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.
When tuning is complete you are ready to start cutting parts.
The rt-stepper dongle supports three "active high" input signals called INPUT0, INPUT1 and INPUT2. Although any of the three input signals can be used for limit switches, the following example uses INPUT0. INPUT0 signal is hard wired to the DB25 connector pin 10. Multiple switches are wired in-series as normally closed switches connected to CNC ground.
This configuration frees up INPUT1-2 for other uses and provides simple in-series cable wiring. Note, "active high" digital input signals means broken wires will be detected immediately.
INPUT0-2 have a internal pull up resistors so no external power or pull up resistor is required. INPUT0-2 use 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-2 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 "INPUTx_ABORT" option in the Configuration File section.
Note the "input0-2_abort" option has a small amount of software overhead so the abort sequence in not immediate. Depending on how fast your PC is, 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.
What can you do with python a script? Scripts can perform the same functions as the GUI (tkmini) provides in Manual mode. This includes jogging, spindle on/off and coolant on/off. A good python script example that exercises most functionality is the homing script m190.py.
Python scripts that execute spindle and coolant mcodes are included with the rtstepperemc software. Users can specify in the python script which digital output signal will be used. Here is the python script file for turning the spindle on.
# # m3.py - m3 mcode script turns spindle on clockwise. # # inputs: # path = ARGV[0] # this python file name # rpm = ARGV[1] # S parameter (spindle speed) # # returns: # emc.h result code # # example: # m3 s250.0 # import rtstepper def main(): return rtstepper.dout(rtstepper.OUTPUT6, True) return main()
This script will set the digital output bit OUTPUT6 true. The DB25 pin assignment for OUTPUT6 would be defined in the ini file. See the "OUTPUTx_PIN" option in the [TASK] section. A similar python script file (m5.py) would turn the spindle off.
The rtstepperemc software supports homing with user-defined mcodes. User-defined mcodes are M100-199 and all user-defined mcodes are implemented via python scripts. Included with the rtstepperemc software is an example python script file that implements the user-defined mcode M190 (m190.py). This is simple script file will home a specified axis. The user will need to customize the script for their CNC application. M190 can be executed as a MDI command or from a gcode file.
M190 P0 Q0 (use INPUT0 for estop, home x-axis) M190 P0 Q1 (use INPUT0 for estop, home y-axis) M190 P0 Q2 (use INPUT0 for estop, home z-axis)The script was tested on a Sherline CNC system and proved to be very accurate using an optical switch. Note, when running the script from a gcode file the M190 mcode cannot be executed inline because the estop will cancel the interp_list.
CAD/CAM support