LinuxCNC · Mesa 7i76E
The 7i76E in depth: step timing, scales, PID and a servo as spindle
Part two of the guide. You already know how to connect the card and move an axis; now it's time to understand every number you enter in PnCconf. With the real configuration of my EMCO F1, its CL57Y hybrid drives and the StepperOnline A6 servo that drives the spindle.
Published on 28 November 2026. Revised on 29 November 2026.
In part one, Mesa 7i76E from scratch, we left an axis moving. It works, sure. But if you ask someone on the forum why they put 5000 in one place and 1000 in another, quite often the answer is "because that's how it came". And the day something fails, you don't know where to start.

Here I go number by number, always with my own machines as examples. No catalogue values: what I show you is what my EMCO F1 and my EMCO Compact 5 lathe actually run, and why.
My machines, so you know what I'm talking about
| X, Y and Z axes of the F1 | 3 StepperOnline CL57Y closed-loop hybrid drives, with NEMA 23 motors of 3 Nm (kit 1-CL57Y-S30-1M5) |
|---|---|
| X and Z axes of the Compact 5 | 2 CL57Y drives from the same kit |
| F1 spindle | StepperOnline A6 AC servo, 1 kW, 3000 rpm and 3.18 Nm, with brake and 17-bit absolute encoder (A6-RS1000H2B1-M17), driven with pulses as if it were just another axis |
| Card | Mesa 7i76E with LinuxCNC; the Mesa's tick every millisecond |
The "closed-loop hybrid" part matters: the CL57Y is a stepper drive with an encoder on the motor that corrects by itself if the motor falls behind. To LinuxCNC it's still an ordinary stepper motor that receives step and direction pulses.
How the Mesa drives a stepper motor

This is the hardest part to understand and the one that helps most when something fails. Every millisecond, this happens:
- LinuxCNC works out where each axis should be at that instant.
- A PID, the same kind of regulator as in a servo, compares that position with the Mesa's and works out the velocity the axis has to move at until the next tick.
- The Mesa receives that velocity and its chip, the FPGA, makes the pulses with nanosecond precision, without the computer stepping in.
- The Mesa counts the steps it has made and sends them back to the PID on the next tick.
Note the detail of the red arrow: the loop is closed with the steps the Mesa has generated, not with an encoder on the motor. If the motor loses steps, LinuxCNC doesn't find out. That's why closed-loop drives like the CL57Y are so interesting: the one watching that the motor gets there is the drive.
In the HAL that PnCconf generates, this mode shows up as one line per axis: control-type 1, which means the Mesa receives velocities, not positions.
Step timing: what your drive asks for

Every drive needs the pulses to have a minimum shape to read them reliably. Those minimums are in its manual, and you pass them to the Mesa with four numbers, all in nanoseconds:
- steplen: how long each pulse lasts.
- stepspace: the minimum gap between one pulse and the next.
- dirsetup: how long the direction signal has to be steady before a pulse.
- dirhold: how long it has to stay steady after the last pulse before it can change.
The CL57Y manual asks for pulses of at least 2.5 microseconds, direction stable 2.5 microseconds before, and a maximum frequency of 200 000 pulses per second. On my F1 I have them like this:
| Time | CL57Y minimum | What I have on the F1 |
|---|---|---|
| steplen | 2500 ns | 5000 ns |
| stepspace | 2500 ns | 5000 ns |
| dirsetup | 2500 ns | 10 000 ns |
| dirhold | – | 10 000 ns |
Why twice, or more? Because long cables and the drives' input optocouplers round the pulses off, and a pulse that's just on time is a pulse that sometimes doesn't get read. With margin, I've never lost a step because of this.
Now the calculation you should always do: a pulse and its gap are 5000 + 5000 = 10 000 ns, so the Mesa can output at most 100 000 pulses per second on that axis. Is that enough? The F1 axes go at 33.3 mm/s (2000 mm/min) at most, and with 533.333 steps per millimetre (I'll tell you where that comes from in a moment) that's about 17 800 pulses per second. Even at the limit I give the step generator, 70 mm/s (4200 mm/min), it would be about 37 300. Plenty. If the numbers don't work on your machine, you have to bring the times down towards the drive's minimum or lower the drive's resolution.
The scale: how many pulses make a millimetre
STEP_SCALE is the number of pulses needed to move the axis one millimetre (or one degree, on a rotary axis). If you get it wrong, the machine moves, but not by what you ask. It comes from three figures:
- Pulses per motor revolution, which you choose with the drive's DIP switches. My F1's CL57Y drives are set to 800.
- The reduction between motor and ballscrew, if there are pulleys: how many revolutions the screw makes for each motor revolution, which is the number of teeth on the motor pulley divided by the number on the screw pulley. On the F1, MXL pulleys with 24 teeth on the motor and 40 on the screw: 24/40 = 0.6 revolutions.
- The ballscrew pitch: how far the axis moves per revolution. On the F1, 8 × 2.5 ballscrews, that is, 2.5 mm per revolution.
Each motor revolution moves the axis 0.6 × 2.5 = 1.5 mm. If 800 pulses are 1.5 mm, one millimetre is 800 / 1.5 = 533.333 pulses, exactly the scale I have on the F1. And watch out, this happened to me: I replaced the motors' original pulleys with some from AliExpress. If you change a pulley, the scale changes, and you have to recalculate it.
Two details that will save you trouble:
- The sign sets the direction. On the F1, X and Z have a negative scale (-533.333) and Y a positive one. If an axis runs the wrong way, don't swap wires: change the sign.
- More pulses per revolution is not more accuracy. Accuracy comes from the mechanics, not from the number of microsteps. Going from 800 to 3200 gives you smoother motion at low speed, but multiplies the pulses you need by four, and that eats the margin from the calculation above.
Velocity and acceleration: the step generator's margin
In the INI each axis has two sets of limits. MAX_VELOCITY and MAX_ACCELERATION are the ones LinuxCNC's planner uses. STEPGEN_MAXVEL and STEPGEN_MAXACCEL are the ones for the Mesa's step generator, and they have to be somewhat higher, because the PID needs a little margin to correct. If the generator sits exactly at the same limit as the planner, as soon as the PID wants to correct a bit the Mesa won't let it, and following errors appear.
PnCconf suggests making the generator's values 25% larger. On the F1 the axes run at 33.3 mm/s (2000 mm/min) with 500 mm/s² of acceleration, and the generator can reach 70 mm/s (4200 mm/min) and 937.5 mm/s², well over that 25%. If you use backlash compensation (BACKLASH), like my X axis, which has 0.036 mm, the generator's acceleration has to be quite a bit higher, because compensation adds sudden jumps at every direction change. PnCconf notes this as a comment in the INI itself: with compensation, double.
PID with stepper motors
A lot of people get nervous when they see a PID on a stepper machine. Relax: with the Mesa you set it once and leave it alone. My values, the same on every axis:
| Parameter | Value | What it does |
|---|---|---|
| FF1 | 1,0 | Does almost all the work: passes the velocity requested by the planner straight to the Mesa. |
| P | 1000 | Corrects whatever error is left. 1000 is the inverse of the 1 ms tick: it corrects any error within one tick. |
| I, D, FF0, FF2 | 0 | Not needed with steppers. |
The idea is this: with FF1 = 1, the Mesa already knows what speed to go at without waiting for an error. P only picks up the crumbs: step rounding and whatever may have slipped through. If you change the Mesa's tick (SERVO_PERIOD), change P too: with a 1 ms tick, 1000.
The DPLL: the detail that links the Mesa with latency
I'll confess: until I was preparing this article I had never paid attention to this. PnCconf puts these two lines in the HAL without asking you anything, and on my F1 they've been there since day one:
setp hm2_7i76e.0.stepgen.timer-number 1
Since I didn't really know what they did, I started reading the documentation and ended up measuring it on the machine. Here are both.
The problem: the computer isn't punctual
Remember the diagram at the start: every millisecond the computer asks the Mesa how many steps it has made. But the computer doesn't always wake up at exactly the same instant; sometimes it's a little early and sometimes a little late. That's latency.
If the Mesa recorded the count right when the request arrives, some samples would be 0.95 ms apart and others 1.05 ms. The PID doesn't know that: it assumes exactly 1 ms has passed between one and the next, and it sees that difference as a position error that doesn't exist. It corrects it, and the axis gets small, pointless jerks in speed.

How it solves it
DPLL stands for digital phase-locked loop. It's a clock inside the Mesa's FPGA that learns the computer's rhythm and locks onto it, like following the beat of a song even when the drummer isn't perfect. With that clock the Mesa knows when the next read should arrive, and it always records the position a fixed time before. That time is timer-us: -50 means 50 microseconds before. So the samples end up exactly 1 ms apart, whenever the read arrives.
The second line, stepgen.timer-number 1, hooks the step generators to that clock. It applies to all of them at once, the spindle's included. If you remove it, or set it to -1, the DPLL keeps running but nothing listens to it.
When it fails
There's only one case: a read arriving so early that it slips in before the Mesa has recorded the position. Then it gets the previous cycle's data. Arriving a few microseconds late doesn't spoil the sample, because the position is already recorded and waiting for it. A huge delay, a good part of the millisecond, is another matter: that's no longer the DPLL's business but a communication problem, and LinuxCNC reports it with its own Mesa read errors.
That's why the documentation asks for this margin to be larger than your computer's variation, and suggests -100 for most systems and -50 only for those with good latency. With -100 you lose nothing noticeable: the position is recorded a little earlier, but always by the same amount, and the PID absorbs a fixed delay without any trouble.
I measured it on my F1
My first idea was to just recommend -100, because in my latency tests this computer reached 74 microseconds. But that test measures how long the computer takes to wake up, not when the read reaches the Mesa. And the Mesa tells you that directly: it has a signal, dpll.phase-error-us, that gives you on every cycle how far the read landed from where the DPLL expected it.
I logged it every millisecond, with LinuxCNC running and the machine in emergency stop, and with the computer exactly as I use it every day: the 6.12 real-time kernel with the parameters I left after the latency tests, isolcpus=4.5 idle=poll irqaffinity=0.3. First 2 minutes idle and then 11 minutes with the same punishment as in the latency tests, stress-ng and glxgears at the same time.

| Idle, 2 min | Under load, 11 min | |
|---|---|---|
| Cycles measured | 120 000 | 660 000 |
| 99.9% of the reads | between -3 and +5.5 µs | between -3.8 and +17.5 µs |
| Earliest read | -5.1 µs | -7.4 µs |
| Latest read | +19.9 µs | +51.6 µs |
Look at the shape: to the left the curve drops off right away, and to the right it has a long tail. That makes sense: the DPLL locks onto the time the computer usually arrives, and the computer can be very late, but it can't wake up much earlier than its time. That tail is reads that arrived late, at most 51.6 microseconds, and for the sample that's no problem. On the dangerous side, the earliest read in 780,000 cycles was 7.4 microseconds early. With the sample at -50, I have 42 to spare.
If you apply the documentation's rule to the letter, counting the variation in both directions, the worst read out of the 660,000 with the computer under brutal load reached 51.6, just above 50. A single time in eleven minutes, and late.
Conclusion for my F1: -50 works with margin and I'm leaving it as it is. For you: if you haven't measured it, use -100, which is the safe value and costs you nothing. If you want to fine-tune it, measure it like this, with LinuxCNC running (replace hm2_7i76e.0 with the name of your card):
halcmd addf sampler.0 servo-thread
halcmd net dpll-pe hm2_7i76e.0.dpll.phase-error-us sampler.0.pin.0
halsampler -n 600000 > dpll.txt
grep -v overrun dpll.txt | sort -g | sed -n '1p;$p'
That's ten minutes of samples; the last command gives you the earliest and the latest read. The one that matters is the earliest, the negative number: it has to stay well away from your timer-us. If a line with the word overrun shows up, that's the program saving the samples not keeping up; it isn't a machine fault. The measuring component disappears when you close LinuxCNC.
An AC servo as spindle, driven by pulses
The F1 spindle is driven by the StepperOnline A6 servo. The usual way to drive a spindle is with the 7i76E's 0 to 10 V analogue output to a VFD. I drive it with pulses, using one of the card's five step generators, as if it were just another axis. Why? Because that way the speed command is exact, with no analogue drift, and the servo follows it with its own encoder.
One thing to watch, and it's the same as with stepper motors: LinuxCNC knows the revolutions it has asked the spindle for, not the ones it has really made. The A6's encoder closes the loop inside the servo itself, but its measurement doesn't reach LinuxCNC. If the spindle couldn't follow the command, the one who finds out is the servo, and that's why its fault output goes to a Mesa input. For LinuxCNC to measure the real rotation, for example for synchronised threading, you'd need to take the servo's encoder output to an encoder input on the Mesa.
The calculation is the same as for an axis, with two differences: the units are spindle revolutions and the number of pulses is much higher.
- The A6 is set to 10 000 pulses per motor revolution (that's its electronic gear: the encoder has 131 072 positions per revolution, and the drive spreads the incoming pulses across them).
- Pulleys with 30 teeth on the motor and 36 on the spindle: the motor turns 1.2 times for every spindle revolution.
- Scale: 10 000 × 36/30 = 12 000 pulses per spindle revolution.
And here's the calculation that rules. At 5000 spindle rpm (6000 motor rpm), that's 83.3 revolutions per second × 12 000 = a million pulses per second. That's five times the CL57Y's limit. That's why the A6 isn't connected to its normal inputs but to its fast differential input, which according to its manual accepts up to 4 million pulses per second with pulses of at least 0.125 microseconds. The 7i76E's step outputs are 5 V differential, RS-422 compatible, so they connect directly.
My timing for the spindle:
| Time | Value on the F1 |
|---|---|
| steplen and stepspace | 250 ns each: up to 2 million pulses per second, twice what I need |
| dirsetup and dirhold | 10 000 ns |
| STEP_SCALE | -12 000 (the sign, once again, sets the direction of rotation) |
| STEPGEN_MAXVEL | 83.333 revolutions per second, which is 5000 rpm |
| STEPGEN_MAXACCEL | 25 revolutions per second squared: from 0 to 5000 rpm in about 3.3 seconds |
What you don't see in the table and is just as important:
- The servo's status signals go to Mesa inputs. The A6's "ready" and "fault" signals go into the 7i76E, and if the servo isn't ready, LinuxCNC won't start the spindle. I learned this the hard way on the BF20L: in a crash its spindle servo stopped and LinuxCNC didn't stop the machine, because nobody had told it.
- The spindle is «at speed» when the speed the Mesa generates is within half a revolution per second (30 rpm) of the commanded speed, and the servo is also ready. That way programs don't start cutting while the acceleration ramp is still going. Note that this is the speed of the pulses, not a measurement at the motor: making sure the real rotation follows it is the servo's job, and if it can't, its fault output trips.
- The motor brake is controlled by the A6 itself, not by LinuxCNC. The servo knows better than anyone when to release it.
What I learned about closed-loop drives
A CL57Y warns you if the motor falls behind more than it should: it has an alarm output (ALM) for that. Wire it to a Mesa input and link it to the axis fault in the HAL. Otherwise, the drive goes into alarm and stops, and LinuxCNC stays convinced the axis is where it sent it, because, as you saw in the diagram, the position it watches is that of the steps it generated. It's the same lesson as with the spindle servo: anything that can stop on its own has to be able to tell LinuxCNC.
Frequently asked questions
Can I set steplen and stepspace to the minimum the drive's manual gives?
You can, but I don't recommend it. Cables and optocouplers distort the pulses, and a pulse that's just on time gets lost every now and then. Leave twice the minimum and do the pulses-per-second calculation: if it's enough, there's no reason to cut it fine.
My axis travels more or less than I ask. What do I change?
The scale. Move the axis a long known distance, for example 100 mm, measure with a dial indicator how far it actually moved and correct: new scale = current scale × requested distance / actual distance. If the difference is large, first check the drive's pulses-per-revolution switches.
I get following errors with steppers. Is it the PID?
Almost never. Usually STEPGEN_MAXVEL or STEPGEN_MAXACCEL are too close to the axis limits, or the pulses-per-second calculation doesn't reach the speed you're asking for. Check that before touching the PID.
What value do I put in the DPLL?
If you haven't measured it, -100 microseconds, which is what the documentation suggests for most computers. To keep -50, measure dpll.phase-error-us as I show you above: the earliest read has to stay clearly below 50. On my F1, with the computer fully loaded, the earliest was 7.4 microseconds.
Why drive a spindle with pulses instead of the analogue output?
Because the speed command is exact, with no drift, and the servo follows it with its own encoder. Bear in mind that LinuxCNC knows the commanded revolutions, not the measured ones: take the servo's fault output to the Mesa and, if you need the real measurement, its encoder output to an encoder input. You need a servo with a fast enough pulse input: mine needs a million pulses per second at 5000 rpm at the spindle. If your spindle is a motor with a regular VFD, the 7i76E's analogue output is the right choice.
Do closed-loop drives need a different configuration in LinuxCNC?
No. To LinuxCNC they are ordinary stepper drives. The only difference is that they have an alarm output you'll want to wire to the Mesa.
What now?
Now you know the why behind every PnCconf number. If you haven't checked your computer yet, start with LinuxCNC latency in depth; if you're about to fit the card, part one, Mesa 7i76E from scratch; and on the page for my EMCO F1 CNC you'll see the machine with all of this working. In the LinuxCNC from scratch series we'll go through it on video, step by step.
Sources
- Mesa Electronics: 7i76E manual (PDF)
- LinuxCNC 2.9: the hostmot2 driver (step generators, timing and DPLL)
- StepperOnline: CL57Y drive manual (PDF)
- StepperOnline: 1 kW A6 servo kit, with its manual under downloads
- My configuration: the INI and HAL files of my EMCO F1 CNC, generated with PnCconf and adapted by hand.
- My measurements: 780,000 cycles of
dpll.phase-error-uson the F1, with the 7i76E, LinuxCNC 2.9.10 and the 6.12 real-time kernel.