1. Introduction
The preferred way to set up a standard stepper machine is with the Step Configuration Wizard. See the Stepper Configuration Wizard Chapter.
This chapter describes some of the more common settings for manually setting up a stepper based system. 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 a sample config released along with LinuxCNC. The config is called stepper_inch, and can be found by running the Configuration Picker.
2. Maximum 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 LinuxCNC-supported Universal Stepper Controller, Mesa cards, and others).
3. Pinout
One of the major flaws in EMC was that you couldn’t specify the pinout without recompiling the source code. EMC2 was far more flexible, and thus now in LinuxCNC (thanks to the Hardware Abstraction Layer) you can easily specify which signal goes where. See the HAL Basics for more information on HAL.
As it is described in the HAL Introduction and tutorial, we have signals, pins and parameters inside the HAL.
Note
|
We are presenting one axis to keep it short, all others are similar. |
The ones relevant for our pinout are:
signals: Xstep, Xdir & Xen
pins: parport.0.pin-XX-out & parport.0.pin-XX-in
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.
3.1. Standard Pinout HAL
This file contains several HAL commands, and usually looks like this:
# standard pinout config file for 3-axis steppers # using a parport for I/O # # first load the parport driver loadrt hal_parport cfg="0x0378" # # next connect the parport functions to threads # read inputs first addf parport.0.read base-thread 1 # write outputs last addf parport.0.write base-thread -1 # # finally connect physical pins to the signals net Xstep => parport.0.pin-03-out net Xdir => parport.0.pin-02-out net Ystep => parport.0.pin-05-out net Ydir => parport.0.pin-04-out net Zstep => parport.0.pin-07-out net Zdir => parport.0.pin-06-out # create a signal for the estop loopback net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in # create signals for tool loading loopback net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed # connect "spindle on" motion controller pin to a physical pin net spindle-on spindle.0.on => parport.0.pin-09-out ### ### You might use something like this to enable chopper drives when machine ON ### the Xen signal is defined in core_stepper.hal ### # net Xen => parport.0.pin-01-out ### ### If you want active low for this pin, invert it like this: ### # setp parport.0.pin-01-out-invert 1 ### ### A sample home switch on the X axis (axis 0). make a signal, ### link the incoming parport pin to the signal, then link the signal ### to LinuxCNC's axis 0 home switch input pin. ### # net Xhome parport.0.pin-10-in => joint.0.home-sw-in ### ### Shared home switches all on one parallel port pin? ### that's ok, hook the same signal to all the axes, but be sure to ### set HOME_IS_SHARED and HOME_SEQUENCE in the INI file. ### # net homeswitches <= parport.0.pin-10-in # net homeswitches => joint.0.home-sw-in # net homeswitches => joint.1.home-sw-in # net homeswitches => joint.2.home-sw-in ### ### Echantillon d'interrupteurs de fin de course séparés sur l'axe X (axe 0) ### # net X-neg-limit parport.0.pin-11-in => joint.0.neg-lim-sw-in # net X-pos-limit parport.0.pin-12-in => joint.0.pos-lim-sw-in ### ### Just like the shared home switches example, you can wire together ### limit switches. Beware if you hit one, LinuxCNC will stop but can't tell ### you which switch/axis has faulted. Use caution when recovering from this ### extreme position to avoid a hard stop. ### # net Xlimits parport.0.pin-13-in => joint.0.neg-lim-sw-in joint.0.pos-lim-sw-in
Les lignes commençant par # sont des commentaires, aident à la lecture du fichier.
3.2. Overview
Voici les opérations qui sont exécutées quand le fichier standard_pinout.hal est lu par l’interpréteur :
-
Le pilote Parport est chargé (voir Chapitre Parport pour plus de détails).
-
The read & write functions of the parport driver get assigned to the base thread
[The fastest thread in the LinuxCNC setup, usually the code gets executed every few tens of microseconds.]
. -
Les signaux du générateur de pas et de direction des axes X,Y,Z sont raccordés aux broches du port parallèle.
-
D’autres signaux d’entrées/sorties sont connectés (boucle d’arrêt d’urgence, boucle du changeur d’outil).
-
Un signal de marche broche est défini et raccordé à une broche du port parallèle.
3.3. Modifier le fichier 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.
Si vous voulez par exemple, modifier les broches de pas et de direction de l’axe X, il vous suffit de modifier le numéro de la variable nommée parport.0.pin-XX-out
:
net Xstep parport.0.pin-03-out net Xdir parport.0.pin-02-out
peut être modifiée pour devenir:
net Xstep parport.0.pin-02-out net Xdir parport.0.pin-03-out
ou de manière générale n’importe quel numéro que vous souhaiteriez.
Attention : il faut être certain de n’avoir qu’un seul signal connecté à une broche.
3.4. Modifier la polarité d’un signal
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-out-invert TRUE
3.5. Ajouter le contrôle de vitesse broche en PWM
Si votre vitesse de broche peut être contrôlée par un signal de PWM, utilisez le composant pwmgen pour créer ce signal :
loadrt pwmgen output_type=0 addf pwmgen.update servo-thread addf pwmgen.make-pulses base-thread net spindle-speed-cmd spindle.0.speed-out => pwmgen.0.value net spindle-on spindle.0.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.
3.6. Ajouter un signal de validation enable
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.
Pour les connecter vous pouvez utilisez l’exemple suivant :
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.
3.7. Ajouter un bouton d’Arrêt d’Urgence externe
The standard_pinout.hal file assumes no external ESTOP button. For more information on an external E-Stop see the estop_latch man page.