Introduction
The preferred way to set up a standard stepper machine is with the Step Configuration Wizard. See the Getting Started Guide.
This chapter describes some of the more common settings for manually setting up a stepper based system. Because of the various possibilities of configuring EMC2, it is very hard to document them all, and keep this document relatively short.
The most common EMC2 usage is for stepper based systems. These systems are using stepper motors with drives that accept step & direction signals.
It is one of the simpler setups, because the motors run open-loop (no feedback comes back from the motors), yet the system needs to be configured properly so the motors don’t stall or lose steps.
Most of this chapter is based on the sample config released along found in `/etc/emc2/sample-configs/stepper`.
Maximum step rate{step rate}
With software step generation, the maximum step rate is one step per two BASE\_PERIODs for step-and-direction output. The maximum requested step rate is the product of an axis' MAX\_VELOCITY and its INPUT\_SCALE. If the requested step rate is not attainable, following errors will occur, particularly during fast jogs and G0 moves.
If your stepper driver can accept quadrature input, use this mode. With a quadrature signal, one step is possible for each BASE\_PERIOD, doubling the maximum step rate.
The other remedies are to decrease one or more of: the BASE\_PERIOD (setting this too low will cause the machine to become unresponsive or even lock up), the INPUT\_SCALE (if you can select different step sizes on your stepper driver, change pulley ratios, or leadscrew pitch), or the MAX\_VELOCITY and STEPGEN\_MAXVEL.
If no valid combination of BASE\_PERIOD, INPUT\_SCALE, and MAX\_VELOCITY is acceptable, then consider using hardware step generation (such as with the emc2-supported Universal Stepper Controller, Mesa cards, and others.)
One of the major flaws in EMC was that you couldn’t specify the pinout without recompiling the source code. EMC2 is far more flexible, and now (thanks to the Hardware Abstraction Layer) you can easily specify which signal goes where. See the HAL manual for more detailed information on HAL.
As it is described in the HAL Introduction and tutorial, we have signals, pins and parameters inside the HAL.
The ones relevant for our pinout are
[Note: we are only presenting one axis to keep it short,
all others are similar.
]
:
signals: Xstep, Xdir & Xen pins: parport.0.pin-XX-out & parport.0.pin-XX-in
footnote:[Refer to section <<sec:Parport>> for additional information ]
Depending on what you have chosen in your .ini file you are using either standard\_pinout.hal or xylotex\_pinout.hal. These are two files that instruct the HAL how to link the various signals & pins. Further on we’ll investigate the standard\_pinout.hal.
standard\_pinout.hal{standard pinout}
This file contains several HAL commands, and usually looks like this:
``timinput{../../../configs/stepper/st``ndard\_pinout.hal}
The files starting with # are comments, and their only purpose is to guide the reader through the file.
Overview of the standard\_pinout.hal
There are a couple of operations that get executed when the standard\_pinout.hal gets executed / interpreted:
-
The Parport driver gets loaded (see [sec:Parport] for details)
-
The read & write functions of the parport driver get assigned to the base thread
footnote:[the fastest thread in the EMC2 setup, usually the code gets executed every few microseconds ]
-
The step & direction signals for axes X,Y,Z get linked to pins on the parport
-
Further IO signals get connected (estop loopback, toolchanger loopback)
-
A spindle-on signal gets defined and linked to a parport pin
Changing the standard\_pinout.hal
If you want to change the standard\_pinout.hal file, all you need is a text editor. Open the file and locate the parts you want to change.
If you want for example to change the pin for the X-axis Step & Directions signals, all you need to do is to change the number in the parport.0.pin-XX-out name:
net Xstep parport.0.pin-03-out net Xdir parport.0.pin-02-out
can be changed to:
net Xstep parport.0.pin-02-out net Xdir parport.0.pin-03-out
or basically any other numbers you like.
Hint: make sure you don’t have more than one signal connected to the same pin.
Changing the polarity of a signal{signal polarity}
If external hardware expects an "active low" signal, set the corresponding `-invert` parameter. For instance, to invert the spindle control signal:
setp parport.0.pin-09-invert TRUE
Adding PWM Spindle Speed Control{spindle speed control}
If your spindle can be controlled by a PWM signal, use the `pwmgen` component to create the signal:
loadrt pwmgen output\_type=0 addf pwmgen.update servo-thread addf pwmgen.make-pulses base-thread net spindle-speed-cmd motion.spindle-speed-out => pwmgen.0.value net spindle-on motion.spindle-on => pwmgen.0.enable net spindle-pwm pwmgen.0.pwm => parport.0.pin-09-out setp pwmgen.0.scale 1800 # Change to your spindle's top speed in RPM
This assumes that the spindle controller’s response to PWM is simple: 0% PWM gives 0 RPM, 10% PWM gives 180 RPM, etc. If there is a minimum PWM required to get the spindle to turn, follow the example in the nist-lathe sample configuration to use a `scale` component.
Adding an enable signal{enable signal}
Some amplifiers (drives) require an enable signal before they accept and command movement of the motors. For this reason there are already defined signals called Xen, Yen, Zen.
To connect them use the following example:
net Xen parport.0.pin-08-out
You can either have one single pin that enables all drives; or several, depending on the setup you have. Note, however, that usually when one axis faults, all the other drives will be disabled as well, so having only one enable signal / pin for all drives is a common practice.
As you can see in [sub:standard_pinout.hal] by default the stepper configuration assumes no external ESTOP button.
[An extensive explanation of hooking up ESTOP circuitry is
explained in the wiki.linuxcnc.org and in the Integrator Manual
]
To add a simple external button you need to replace the line:
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
with
net estop-loop parport.0.pin-01-in iocontrol.0.emc-enable-in
This assumes an ESTOP switch connected to pin 01 on the parport. As long as the switch will stay pushed
[make sure you use a maintained switch for ESTOP.
]
, EMC2
will be in the ESTOP state. When the external button gets released
EMC2 will imediately switch to the ESTOP-RESET state, and all you
need to do is switch to Machine On{machine on}and you’ll be able to
continue your work with EMC2.