This documentation is no longer maintained. For documentation of the current version of emc2, please see http://www.linuxcnc.org/docview/html

STEPGEN/FREQGEN

NAME
SYNOPSIS
DESCRIPTION
FUNCTIONS
PINS
PARAMETERS
BUGS
SEE ALSO

NAME

freqgen, stepgen − software step pulse generation

SYNOPSIS

loadrt freqgen step_type=type0[,type1...]
loadrt stepgen step_type=
type0[,type1...]

DESCRIPTION

freqgen and stepgen are used to control stepper motors. The maximum step rate depends on the CPU and other factors, and is usually in the range of 10KHz to 50KHz. If higher rates are needed, a hardware step generator is a better choice.

freqgen runs the motor at a commanded velocity, subject to acceleration and velocity limits. stepgen drives the motor to a commanded position, again subject to accel and velocity limits. Usually, stepgen is used for machine axes. freqgen is reserved for unusual applications where continuous movement at some speed is desired, instead of movement to a specific position.

Either component can control a maximum of eight motors. The number of motors/channels actually loaded depends on the number of type values given. The value of each type determines the outputs for that channel. Both components support the same 15 possible step types.

By far the most common step type is ’0’, standard step and direction. Others include up/down, quadrature, and a wide variety of three, four, and five phase patterns that can be used to directly control some types of motor windings. (When used with appropriate buffers of course.)

Some of the stepping types are described below, but for more details (including timing diagrams) see the stepgen section of the HAL reference manual.

type 0: step/dir

Two pins, one for step and one for direction. make-pulses must run at least twice for each step (once to set the step pin true, once to clear it). This limits the maximum step rate to half (or less) of the rate that can be reached by types 2-14. The parameters steplen and stepspace can further lower the maximum step rate. Parameters dirsetup and dirhold also apply to this step type.

type 1: up/down

Two pins, one for ’step up’ and one for ’step down’. Like type 0, make-pulses must run twice per step, which limits the maximum speed.

type 2: quadrature

Two pins, phase-A and phase-B. For forward motion, A leads B. Can advance by one step every time make-pulses runs.

type 3: three phase, full step

Three pins, phase-A, phase-B, and phase-C. Three steps per full cycle, then repeats. Only one phase is high at a time - for forward motion the pattern is A, then B, then C, then A again.

type 4: three phase, half step

Three pins, phases A through C. Six steps per full cycle. First A is high alone, then A and B together, then B alone, then B and C together, etc.

types 5 through 8: four phase, full step

Four pins, phases A through D. Four steps per full cycle. Types 5 and 6 are suitable for use with unipolar steppers, where power is applied to the center tap of each winding, and four open-collector transistors drive the ends. Types 7 and 8 are suitable for bipolar steppers, driven by two H-bridges.

types 9 and 10: four phase, half step

Four pins, phases A through D. Eight steps per full cycle. Type 9 is suitable for unipolar drive, and type 10 for bipolar drive.

types 11 and 12: five phase, full step

Five pins, phases A through E. Five steps per full cycle. See HAL reference manual for the patterns.

types 13 and 14: five phase, half step

Five pins, phases A through E. Ten steps per full cycle. See HAL reference manual for the patterns.

FUNCTIONS

Note: module can be either freqgen or stepgen in the following function names.

module.make-pulses (no floating-point)

Generates the step pulses, using information computed by update-freq. Must be called as frequently as possible, to maximize the attainable step rate and minimize jitter. Operates on all channels at once.

module.capture-position (uses floating point)

Captures position feedback value from the high speed code and makes it available on a pin for use elsewhere in the system. Operates on all channels at once.

module.update-freq (uses floating point)

Accepts a velocity (freqgen) or position (stepgen) command and converts it into a form usable by make-pulses for step generation. Operates on all channels at once.

PINS

Note: module can be either freqgen or stepgen in the following pin names.

module.N.counts s32 out

The current position, in counts, for channel N. Updated by capture-position.

module.N.position-fb float out

The current position, in length units (see parameter position-scale). Updated by capture-position.

stepgen.N.enable bit in (stepgen only)

Enables output steps - when false, no steps are generated.

freqgen.N.velocity float in (freqgen only)

Commanded velocity, in length units per second (see parameter velocity-scale).

stepgen.N.position-cmd float in (stepgen only)

Commanded position, in length units (see parameter position-scale).

module.N.step bit out (step type 0 only)

Step pulse output.

module.N.dir bit out (step type 0 only)

Direction output: low for forward, high for reverse.

module.N.up bit out (step type 1 only)

Count up output, pulses for forward steps.

module.N.down bit out (step type 1 only)

Count down output, pulses for reverse steps.

module.N.phase-A thru phase-E bit out (step types 2-14 only)

Output bits. phase-A and phase-B are present for step types 2-14, phase-C for types 3-14, phase-D for types 5-14, and phase-E for types 11-14. Behavior depends on selected stepping type.

PARAMETERS

Note: module can be either freqgen or stepgen in the following parameter names.

module.N.frequency float ro

The current step rate, in steps per second, for channel N.

module.N.maxaccel float rw

The acceleration/deceleration limit. For freqgen it is in steps per second squared, for stepgen it is in length units per second squared.

freqgen.N.maxfreq float rw (freqgen only)

The maximum allowable velocity, in steps per second. If the requested maximum velocity cannot be reached with the current make-pulses thread period, it will be reset to the highest attainable value.

stepgen.N.maxvel float rw (stepgen only)

The maximum allowable velocity, in length units per second. If the requested maximum velocity cannot be reached with the current combination of scaling and make-pulses thread period, it will be reset to the highest attainable value.

module.N.position-scale float rw

The scaling for position feedback (and stepgen position command), in steps per length unit.

freqgen.N.velocity-scale float rw (freqgen only)

The scaling for the velocity command, in steps per length unit.

module.N.rawcounts s32 ro

The position in counts, as updated by make-pulses. (Note: this is updated more frequently than the counts pin.)

module.N.steplen u32 rw (step type 0 only)

The length of the step pulses, in make-pulses periods. Measured from rising edge to falling edge.

module.N.stepspace u32 rw (step type 0 only)

The minimum space between step pulses, in make-pulses periods. Measured from falling edge to rising edge. The actual time depends on the step rate and can be much longer.

module.N.dirsetup u32 rw (step type 0 only)

The minimum setup time from direction to step, in make-pulses periods. Measured from change of direction to rising edge of step.

module.N.dirhold u32 rw (step type 0 only)

The minimum hold time of direction after step, in make-pulses periods. Measured from falling edge of step to change of direction.

BUGS

freqgen should have an enable pin.

freqgen’s command pin should be called velocity-cmd, not velocity, for clarity and consistency with stepgen.

freqgen should use maxvel, not maxfreq. (In other words, the velocity limit should be scaled in length units per second, not steps per second. The scale parameter can be set to 1.0 if it is desired to work in steps instead of length units.)

freqgen’s maxaccel parameter should be in length units per second squared, not steps per second squared, for consistency with stepgen.

freqgen should use position-scale for scaling both command and feedback, velocity-scale is redundant and should be eliminated.

Step type 1 (up/down) should respect the steplen and stepspace limits.

Timing parameters steplen, stepspace, dirsetup, and dirhold should be in nano-seconds, not make-pulses periods. That would allow the period to be changed without requiring the parameters to be recalculated.

Most of these will be fixed in version 2.2, rather than 2.1.x, because they represent changes in the public interface (different pin names or behaviors).

SEE ALSO

stepgen(9) freqgen(9)