This page contains the comments from the top of an older version of stepgen.c. The current version can be seen [in our CVS repo]. A partial description of some of the behavior of the EMC2 stepgen code can be seen on the StepgenInternals page. <pre> 'stepgen.c', is a HAL component that provides software based step pulse generation. The maximum step rate will depend on the speed of the PC, but is expected to exceed 1KHz for even the slowest computers, and may reach 10KHz on fast ones. It is a realtime component. It supports up to 8 pulse generators. Each generator can produce several types of outputs in addition to step/dir, including quadrature, half- and full-step unipolar and bipolar, three phase, and five phase. A 32 bit feedback value is provided indicating the current position of the motor (assuming no lost steps). The number of step generators and type of outputs is determined by the insmod command line parameter 'step_type'. It accepts a comma separated (no spaces) list of up to 8 stepping types to configure up to 8 channels. So a command line like this: insmod stepgen step_type=0,0,1,2 will install four step generators, two using stepping type 0, one using type 1, and one using type 2. The driver exports three functions. 'stepgen.make-pulses', is responsible for actually generating the step pulses. It must be executed in a fast thread to reduce pulse jitter. The other two functions are normally called from a much slower thread. 'stepgen.update-freq' reads the frequency command and sets internal variables used by 'stepgen.make-pulses'. 'stepgen.capture-position' captures and scales the current values of the position feedback counters. Both 'update-freq' and 'capture-position' use floating point, 'make-pulses' does not. The component can optionally create two threads, one that supports floating point and one that does not. The 'period' parameter (at insmod time) determines the period of the non-FP thread, which is called 'stepgen.thread'. The 'fp_period' parameter sets the period of the floating point thread, which is called 'stepgen.threadFP' Polarity: All signals from this module have fixed polarity (active high in most cases). If the driver needs the opposite polarity, the signals can be inverted using parameters exported by the hardware driver(s) such as ParPort?. Stepping Types: This module supports a number of stepping types, as follows: Type 0: Step and Direction _____ _____ _____ STEP ____________/ \_______/ \____________/ \___ | | | | |--(1)--|-(2)-|--(3)--| |--(4)--| ____|___________________________________|_____________ DIR ____X___________________________________X_____________ There are two output pins, STEP and DIR. Timing is controlled by HAL parameters. The parameters are (1): 'stepgen.n.dirsetup' minimum delay from a change on the DIR line to the beginning of a step pulse, (2): 'stepgen.n.steplen' length of the step pulse, (3): 'stepgen.n.stepspace', space between step pulses, and (4): 'stepgen.n.dirhold', minimum delay after step pulse before DIR may change. The default values for all four parameters are 1, which means 1 period of the thread. A positive frequency command results in DIR low, negative frequency command means DIR high. The minimum time between step pulses is 'steplen' + 'stepspace' periods, and the frequency command is clamped to avoid exceeding these limits. Type 1: Up/Down? (aka Pseudo-PWM) There are two output pins, UP and DOWN. Whenever a step is required, either UP or DOWN is asserted for a single period. The frequency command is not clamped, so a step may be required every period, and the UP or DOWN line may be asserted for several periods in a row. (At the maximum freqency command, UP or DOWN will be constantly asserted.) This type of signal may be usefull with some stepper drives, but is primarily intended as a simple and cheap DAC. A filter and differential amp connected between UP and DOWN can produce a +/-10V signal, with bandwidth and resolution determined by the filter (in general, faster bandwidth gives lower resolution, and vice-versa.) All the remaining stepping types are simply different patterns of output states. For all of these types, a step can occur in every period. When a step occurs, the output state changes to the next (or previous) state in the state listings that follow. There are from two to five output pins, called 'PhaseA?' thru 'PhaseE?'. Type 2: Quadrature (aka Gray/Grey? code) State Phase A Phase B 0 1 0 1 1 1 2 0 1 3 0 0 0 1 0 Type 3: Three Wire State Phase A Phase B Phase C 0 1 0 0 1 0 1 0 2 0 0 1 0 1 0 0 Type 4: Three Wire HalfStep? State Phase A Phase B Phase C 0 1 0 0 1 1 1 0 2 0 1 0 3 0 1 1 4 0 0 1 5 1 0 1 0 1 0 0 Type 5: Unipolar Full Step (one winding on) State Phase A Phase B Phase C Phase D 0 1 0 0 0 1 0 1 0 0 2 0 0 1 0 3 0 0 0 1 0 1 0 0 0 Type 6: Unipolar Full Step (two windings on) State Phase A Phase B Phase C Phase D 0 1 1 0 0 1 0 1 1 0 2 0 0 1 1 3 1 0 0 1 0 1 1 0 0 Type 7: Bipolar Full Step (one winding on) State Phase A Phase B Phase C Phase D 0 1 0 0 0 1 1 1 1 0 2 0 1 1 1 3 0 0 0 1 0 1 0 0 0 Type 8: Bipolar Full Step (two windings on) State Phase A Phase B Phase C Phase D 0 1 0 1 0 1 0 1 1 0 2 0 1 0 1 3 1 0 0 1 0 1 0 1 0 Type 9: Unipolar Half Step State Phase A Phase B Phase C Phase D 0 1 0 0 0 1 1 1 0 0 2 0 1 0 0 3 0 1 1 0 4 0 0 1 0 5 0 0 1 1 6 0 0 0 1 7 1 0 0 1 0 1 0 0 0 Type 10: Bipolar Half Step State Phase A Phase B Phase C Phase D 0 1 0 0 0 1 1 0 1 0 2 1 1 1 0 3 0 1 1 0 4 0 1 1 1 5 0 1 0 1 6 0 0 0 1 7 1 0 0 1 0 1 0 0 0 Type 11: Five Wire Unipolar State Phase A Phase B Phase C Phase D Phase E 0 1 0 0 0 0 1 0 1 0 0 0 2 0 0 1 0 0 3 0 0 0 1 0 4 0 0 0 0 1 0 1 0 0 0 0 Type 12: Five Wire Wave State Phase A Phase B Phase C Phase D Phase E 0 1 1 0 0 0 1 0 1 1 0 0 2 0 0 1 1 0 3 0 0 0 1 1 4 1 0 0 0 1 0 1 1 0 0 0 Type 13: Five Wire Unipolar HalfStep? State Phase A Phase B Phase C Phase D Phase E 0 1 0 0 0 0 1 1 1 0 0 0 2 0 1 0 0 0 3 0 1 1 0 0 4 0 0 1 0 0 5 0 0 1 1 0 6 0 0 0 1 0 7 0 0 0 1 1 8 0 0 0 0 1 9 1 0 0 0 1 0 1 0 0 0 0 Type 14: Five Wire Wave HalfStep? State Phase A Phase B Phase C Phase D Phase E 0 1 1 0 0 0 1 1 1 1 0 0 2 0 1 1 0 0 3 0 1 1 1 0 4 0 0 1 1 0 5 0 0 1 1 1 6 0 0 0 1 1 7 1 0 0 1 1 8 1 0 0 0 1 9 1 1 0 0 1 0 1 1 0 0 0 |
|