stepper.txt
1 [[cha:stepper-config]] 2 3 = Stepper Configuration 4 5 == Introduction 6 7 The preferred way to set up a standard stepper machine is with the 8 Step Configuration Wizard. See the 9 <<cha:stepconf-wizard,Stepper Configuration Wizard>> Chapter. 10 11 This chapter describes some of the more common settings for manually 12 setting up a stepper based system. These systems are using stepper motors 13 with drives that accept step & direction signals. 14 15 It is one of the simpler setups, because the motors run open-loop (no 16 feedback comes back from the motors), yet the system needs to be 17 configured properly so the motors don't stall or lose steps. 18 19 Most of this chapter is based on a sample config released along with 20 LinuxCNC. The config is called stepper_inch, and can be found by running the 21 <<cha:running-emc,Configuration Picker>>. 22 23 == Maximum step rate 24 25 With software step generation, the maximum step rate is one step per 26 two BASE_PERIODs for step-and-direction output. The maximum requested 27 step rate is the product of an axis' MAX_VELOCITY and its INPUT_SCALE. 28 If the requested step rate is not attainable, following errors will 29 occur, particularly during fast jogs and G0 moves. 30 31 If your stepper driver can accept quadrature input, use this mode. 32 With a quadrature signal, one step is possible for each BASE_PERIOD, 33 doubling the maximum step rate. 34 35 The other remedies are to decrease one or more of: the BASE_PERIOD 36 (setting this too low will cause the machine to become unresponsive or 37 even lock up), the INPUT_SCALE (if you can select different step sizes 38 on your stepper driver, change pulley ratios, or leadscrew pitch), or 39 the MAX_VELOCITY and STEPGEN_MAXVEL. 40 41 If no valid combination of BASE_PERIOD, INPUT_SCALE, and MAX_VELOCITY 42 is acceptable, then consider using hardware step generation (such as 43 with the LinuxCNC-supported Universal Stepper Controller, Mesa cards, and 44 others.) 45 46 == Pinout 47 48 One of the major flaws in LinuxCNC was that you couldn't specify the pinout 49 without recompiling the source code. LinuxCNC is far more flexible, and now 50 (thanks to the Hardware Abstraction Layer) you can easily specify which 51 signal goes where. See the <<cha:basic-hal-reference,Basic HAL Tutorial>> 52 for more information on HAL. 53 54 As it is described in the HAL Introduction and tutorial, we have 55 signals, pins and parameters inside the HAL. 56 57 NOTE: We are presenting one axis to keep it short, all others are similar. 58 59 The ones relevant for our pinout are: 60 61 ---- 62 signals: Xstep, Xdir & Xen 63 pins: parport.0.pin-XX-out & parport.0.pin-XX-in 64 ---- 65 66 Depending on what you have chosen in your .ini file you are using 67 either standard_pinout.hal or xylotex_pinout.hal. These are two files 68 that instruct the HAL how to link the various signals & pins. Further 69 on we'll investigate the standard_pinout.hal. 70 71 === Standard Pinout HAL 72 73 This file contains several HAL commands, and usually looks like this: 74 75 ---- 76 # standard pinout config file for 3-axis steppers 77 # using a parport for I/O 78 # 79 # first load the parport driver 80 loadrt hal_parport cfg="0x0378" 81 # 82 # next connect the parport functions to threads 83 # read inputs first 84 addf parport.0.read base-thread 1 85 # write outputs last 86 addf parport.0.write base-thread -1 87 # 88 # finally connect physical pins to the signals 89 net Xstep => parport.0.pin-03-out 90 net Xdir => parport.0.pin-02-out 91 net Ystep => parport.0.pin-05-out 92 net Ydir => parport.0.pin-04-out 93 net Zstep => parport.0.pin-07-out 94 net Zdir => parport.0.pin-06-out 95 96 # create a signal for the estop loopback 97 net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in 98 99 # create signals for tool loading loopback 100 net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared 101 net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed 102 103 # connect "spindle on" motion controller pin to a physical pin 104 net spindle-on spindle.0.on => parport.0.pin-09-out 105 106 ### 107 ### You might use something like this to enable chopper drives when machine ON 108 ### the Xen signal is defined in core_stepper.hal 109 ### 110 111 # net Xen => parport.0.pin-01-out 112 113 ### 114 ### If you want active low for this pin, invert it like this: 115 ### 116 117 # setp parport.0.pin-01-out-invert 1 118 119 ### 120 ### A sample home switch on the X axis (axis 0). make a signal, 121 ### link the incoming parport pin to the signal, then link the signal 122 ### to LinuxCNC's axis 0 home switch input pin 123 ### 124 125 # net Xhome parport.0.pin-10-in => joint.0.home-sw-in 126 127 ### 128 ### Shared home switches all on one parallel port pin? 129 ### that's ok, hook the same signal to all the axes, but be sure to 130 ### set HOME_IS_SHARED and HOME_SEQUENCE in the ini file. 131 ### 132 133 # net homeswitches <= parport.0.pin-10-in 134 # net homeswitches => joint.0.home-sw-in 135 # net homeswitches => joint.1.home-sw-in 136 # net homeswitches => joint.2.home-sw-in 137 138 ### 139 ### Sample separate limit switches on the X axis (axis 0) 140 ### 141 142 # net X-neg-limit parport.0.pin-11-in => joint.0.neg-lim-sw-in 143 # net X-pos-limit parport.0.pin-12-in => joint.0.pos-lim-sw-in 144 145 ### 146 ### Just like the shared home switches example, you can wire together 147 ### limit switches. Beware if you hit one, LinuxCNC will stop but can't tell 148 ### you which switch/axis has faulted. Use caution when recovering from this. 149 ### 150 151 # net Xlimits parport.0.pin-13-in => joint.0.neg-lim-sw-in joint.0.pos-lim-sw-in 152 153 ---- 154 155 The lines starting with '#' are comments, and their only purpose is to 156 guide the reader through the file. 157 158 === Overview 159 160 There are a couple of operations that get executed when the 161 standard_pinout.hal gets executed/interpreted: 162 163 * The Parport driver gets loaded (see the <<cha:parport,Parport Chapter>> 164 for details) 165 * The read & write functions of the parport driver get assigned to the 166 base thread footnote:[the fastest thread in the LinuxCNC setup, usually the 167 code gets executed every few tens of microseconds] 168 * The step & direction signals for axes X,Y,Z get linked to pins on the 169 parport 170 * Further I/O signals get connected (estop loopback, toolchanger loopback) 171 * A spindle-on signal gets defined and linked to a parport pin 172 173 === Changing the standard_pinout.hal 174 175 If you want to change the standard_pinout.hal file, all you need is a 176 text editor. Open the file and locate the parts you want to change. 177 178 If you want for example to change the pin for the X-axis Step & 179 Directions signals, all you need to do is to change the number in the 180 'parport.0.pin-XX-out' name: 181 182 ---- 183 net Xstep parport.0.pin-03-out 184 net Xdir parport.0.pin-02-out 185 ---- 186 187 can be changed to: 188 189 ---- 190 net Xstep parport.0.pin-02-out 191 net Xdir parport.0.pin-03-out 192 ---- 193 194 or basically any other 'out' pin you like. 195 196 Hint: make sure you don't have more than one signal connected to the 197 same pin. 198 199 === Changing polarity of a signal 200 201 If external hardware expects an “active low” signal, set the 202 corresponding '-invert' parameter. For instance, to invert the spindle 203 control signal: 204 205 ---- 206 setp parport.0.pin-09-invert TRUE 207 ---- 208 209 === Adding PWM Spindle Speed Control 210 211 If your spindle can be controlled by a PWM signal, use the 'pwmgen' 212 component to create the signal: 213 214 ---- 215 loadrt pwmgen output_type=0 216 addf pwmgen.update servo-thread 217 addf pwmgen.make-pulses base-thread 218 net spindle-speed-cmd spindle.0.speed-out => pwmgen.0.value 219 net spindle-on spindle.0.on => pwmgen.0.enable 220 net spindle-pwm pwmgen.0.pwm => parport.0.pin-09-out 221 setp pwmgen.0.scale 1800 # Change to your spindle’s top speed in RPM 222 ---- 223 224 This assumes that the spindle controller's response to PWM is simple: 225 0% PWM gives 0 RPM, 10% PWM gives 180 RPM, etc. If there is a minimum 226 PWM required to get the spindle to turn, follow the example in the 227 'nist-lathe' sample configuration to use a 'scale' component. 228 229 === Adding an enable signal 230 231 Some amplifiers (drives) require an enable signal before they accept 232 and command movement of the motors. For this reason there are already 233 defined signals called 'Xen', 'Yen', 'Zen'. 234 235 To connect them use the following example: 236 237 ---- 238 net Xen parport.0.pin-08-out 239 ---- 240 241 You can either have one single pin that enables all drives; or 242 several, depending on the setup you have. Note, however, that usually 243 when one axis faults, all the other drives will be disabled as well, so 244 having only one enable signal / pin for all drives is a common 245 practice. 246 247 === External ESTOP button 248 249 The standard_pinout.hal file assumes no external ESTOP button. For more 250 information on an external E-Stop see the estop_latch man page.