Spindle encoder

A spindle encoder tells the FluidBoard where the spindle is in its rotation and how fast it's turning. Without one, the controller is completely blind — and that means no threading, no electronic leadscrew, and no spindle speed verification.

The encoder is mandatory for:

  • Threading (G33, G76) — the controller synchronizes axis movement to spindle rotation. It needs to know the exact spindle angle to start each pass in the same place.
  • Electronic leadscrew / feed per revolution (G95) — the axis advances a fixed distance per spindle turn. The encoder drives the stepping directly.
  • Speed monitoring — the controller continuously checks if the spindle is running at roughly the commanded RPM. If the belt slips, the motor stalls, or something grabs the chuck, it raises an alarm before you break a tool or worse.

This is what makes a CNC lathe a CNC lathe. Without an encoder, you have a stepper-driven carriage with no spindle awareness — which is fine for a router, but not for a lathe.

FluidBoard

What encoder to buy

The FluidBoard supports AB quadrature encoders only. No SPI encoders, no absolute encoders, no serial protocols — just A and B channels with an optional index (Z) pulse.

Why PPR matters more than you think

Optical encoders have a maximum output frequency — typically around 50 kHz. The electrical frequency depends on both the PPR and the spindle speed:

\text{Frequency} = \frac{\text{PPR} \times \text{RPM}}{60}

A 500 PPR encoder at 4,000 RPM produces 33.3 kHz — well within spec. A 5,000 PPR encoder at the same speed produces 333 kHz — far beyond what the encoder (or anything in the signal chain) can handle.

More PPR is not better. A 500 PPR encoder gives you 2,000 counts per revolution after quadrature decoding (4x). That's more than enough resolution for threading. A 5,000 PPR encoder will either not work at all at your operating RPM, or produce garbage data.

Encoder PPR Counts per rev (4x) Max RPM at 50 kHz Practical use
200 800 ~15,000 Very high speed, lower resolution
500 2,000 ~6,000 Best all-round choice
600 2,400 ~5,000 Good alternative
1,000 4,000 ~3,000 Fine for slower lathes
2,500 10,000 ~1,200 Only for very slow spindles
5,000 20,000 ~600 Too high — avoid

For most lathes running up to 3,000–4,000 RPM, a 500 PPR optical quadrature encoder is the sweet spot.

How it works on the FluidBoard

The encoder signals are decoded by the ESP32's hardware pulse counter (PCNT) peripheral — not in software. This means counting is accurate at full speed with zero CPU overhead.

The encoder inputs go through high-speed optocouplers on the board, which provide isolation and clean signal conditioning.

Two small RC filter components near the encoder inputs need to be desoldered for the high-frequency signals to pass cleanly. This is a quick one-time modification. Tell us you want to run a lathe, and we'll do it for you.

Wiring

Wiring diagram not available. View SVG

Connect the encoder to the FluidBoard's encoder inputs:

  • A channel → encoder input A
  • B channel → encoder input B
  • Index / Z pulse → optional, used for thread start synchronization
  • Use 390 Ω series resistors on each signal line
  • Do not add capacitors — they filter out the high-frequency edges you need
  • Route the cable away from VFD power cables and spindle wiring

Configuration

spindle_encoder:
  pin_a: gpio.40
  pin_b: gpio.41
  cpr: 2000              # Counts per revolution (PPR × 4)
  gear_ratio: -1          # Negative = reverse direction
  tolerance: 15           # RPM deviation tolerance (%) before alarm
  allowed_errors: 5       # Consecutive violations before triggering alarm

Set cpr to your encoder's PPR × 4. For a 500 PPR encoder, that's 2000.

If your spindle has a belt or gear reduction between the motor and the encoder, set gear_ratio accordingly.

Next steps

With your encoder wired, you're ready for threading, CSS, and the other lathe G-codes.

If you're converting a manual lathe to CNC, see our lathe conversion checklist for everything you need.

Copyright (c) 2024 by NubiloSoft, all rights reserved.