Programming a Huanyang VFD for CNC Spindle Control: Parameters, Modbus RTU, and 0-10V Wiring
Converting a trim router to a VFD spindle — covered elsewhere on this site as a full mount-and-wire build — gets you variable speed control and a quieter, more consistent cut. But the VFD itself, most commonly one of the ubiquitous Chinese Huanyang-brand units (and the many rebadged clones sold under other names), ships with a parameter menu that's dense, poorly translated, and genuinely confusing if you've never programmed one before. Get the parameters wrong and you'll get anything from a spindle that won't reach full RPM to one that free-spins uncontrollably on power-up. This is a reference guide to the parameters that actually matter, and to setting up Modbus RTU so GRBL or grblHAL can control spindle speed directly instead of you standing at the VFD's front panel turning a dial.
Before You Touch a Parameter: Know Your Motor
Every parameter you set flows from three numbers printed on your spindle motor's nameplate: rated voltage, rated current, and rated frequency (usually 50 Hz or 60 Hz for a standard induction spindle motor, though many Chinese spindles are built for 400 Hz operation at higher RPM — check yours carefully, this is the single most common source of a badly-tuned VFD). Write these down before opening the parameter menu. Setting the VFD's motor parameters incorrectly doesn't just hurt performance — it can let the motor draw more current than it's rated for, overheating windings over repeated use even if nothing fails on the first few cuts.
Core Parameters
Parameter numbering varies between Huanyang firmware revisions and the many rebadged clones (some use PD-prefixed codes like PD004, others use a P0.xx / P1.xx grouped format) — treat the table below as "what to look for," and confirm exact codes against your specific unit's printed manual before changing anything.
FunctionTypical Huanyang codeWhat to set it to Max output frequencyPD004 / P0.04Match your spindle's rated frequency — commonly 400Hz for high-speed spindles, don't exceed the motor's actual rating Base (rated) frequencyPD005 / P0.05From the motor nameplate — this is the frequency at which rated voltage is applied Rated motor voltagePD141 / P0.11From the nameplate — typically 220V for most hobby spindles Rated motor currentPD142 / P0.12From the nameplate — set too high and the VFD won't protect the motor from overcurrent; too low and it'll nuisance-trip under normal load Motor pole pairsPD144 / P0.142 for a standard 2-pole (1-pair) spindle motor — check your motor's actual pole count, this directly affects the RPM-to-frequency relationship Acceleration timePD101 / P0.08Start conservative (10-15 sec) and shorten once you confirm the spindle isn't tripping on overcurrent during spin-up Deceleration timePD102 / P0.09Similarly conservative to start; too short can trigger overvoltage trips from regenerative braking Control sourcePD001 / P0.01Set to external terminal/communication control once you're wiring in GRBL control — leaving this on keypad control means your G-code speed commands get ignored Frequency sourcePD002 / P0.02Set to match how you're commanding speed — analog 0-10V, or Modbus RTU communication if going that routeTwo Ways to Command Spindle Speed from GRBL
Option 1: 0-10V Analog
The simplest approach: GRBL's PWM spindle output drives a small RC filter circuit (a resistor and capacitor) to convert the PWM signal into a smoothed 0-10V analog voltage, which feeds the VFD's analog speed reference input (often labeled VI or AI1). This requires almost no software configuration beyond GRBL's standard $30/$31/$32 spindle speed settings, but it's an open-loop, somewhat noise-susceptible signal — long wire runs between controller and VFD can pick up electrical noise from the VFD's own switching, causing speed jitter. Keep this wiring short and, ideally, shielded, and route it away from the VFD's motor power leads.
Option 2: Modbus RTU (grblHAL)
grblHAL (unlike vanilla GRBL) supports direct Modbus RTU spindle control over RS-485, letting the controller command exact RPM values digitally rather than an approximated analog voltage, and read back real spindle status. This needs an RS-485 transceiver on the controller side, wiring to the VFD's RS-485 terminals (commonly labeled 485+ and 485-), and setting the VFD's communication parameters to match:
FunctionTypical codeSetting Communication addressPD163 / P0.13Match the address configured in your grblHAL Modbus spindle settings (commonly 1) Baud ratePD164 / P0.14 (varies)9600 is a safe, widely-supported default — match exactly on both ends Data formatPD165Typically 8N1 (8 data bits, no parity, 1 stop bit) — again, must match both sides exactlyModbus control gives you closed-loop-feeling behavior (actual RPM feedback rather than an assumed analog relationship) and eliminates the analog signal's noise susceptibility, at the cost of more setup complexity and grblHAL-specific firmware — vanilla GRBL doesn't support Modbus spindle control at all.
Troubleshooting Common Symptoms
SymptomLikely cause Spindle won't reach full commanded speedMax frequency (PD004) set too low, or base frequency mismatched to actual motor rating VFD trips on "overcurrent" during spin-upAcceleration time too short for the motor's inertia, or rated current parameter set below the motor's actual draw Spindle speed doesn't respond to GRBL commands at allControl source / frequency source parameters still set to keypad or analog when you're expecting Modbus, or vice versa Speed reading is noisy/jittery on analog controlUnshielded or overly long 0-10V signal wire running parallel to VFD power cabling Spindle spins the wrong directionSwap any two of the three motor phase wires at the VFD output terminals — never at the VFD inputSafety Notes
- VFDs retain lethal capacitor voltage after being unplugged — wait the time specified in your unit's manual (often several minutes) before opening the enclosure, and verify with a multimeter before touching internal terminals.
- Never swap wires at the VFD's input (mains) side to reverse spindle direction — only swap two of the three phases at the motor output side. Swapping input phases does nothing for rotation direction and risks miswiring line voltage.
- Undersized or incorrect motor current settings can mask a genuine overcurrent fault, letting a motor overheat without the VFD's protection tripping — don't guess at nameplate values, read them directly off the motor.
- If your spindle setup shares mains wiring with other shop equipment, review this site's 240V shop wiring guide before finalizing your circuit — VFDs are sensitive to voltage sag under shared heavy loads.
A correctly parameterized VFD is one of those jobs that's genuinely tedious once and invisible forever after — get the motor nameplate values right, pick analog or Modbus control based on what your firmware supports, and confirm the control/frequency source parameters actually point at the interface you're using. Get it wrong and you'll spend a confusing afternoon chasing a "GRBL isn't controlling my spindle" problem that's actually a VFD parameter still pointed at the front-panel keypad.
Related Guides
- WolfPawn 4040 Pro CNC Router: Setup, First Project, and Feeds & Speeds
- RS-485 and Modbus RTU for Makers: Wiring, Termination, and Reading Industrial Sensors
- Converting a Mini Metal Lathe to CNC: Ballscrews, Steppers, and GRBL/LinuxCNC Control
- CNC Controller Firmware Compared: GRBL, grblHAL, Smoothieware, and Duet/RepRapFirmware
- Mounting a Diode Laser Module on a CNC Router Gantry: A Combo Setup
- Adding a 4th-Axis Rotary to the Wolfpawn 4040 Pro: Wiring and Your First Cut
- How to Use LaserGRBL: Free Laser Control Software for GRBL Engravers
- How to Use EstlCAM for CNC Routing: Toolpaths, G-Code, and GRBL Control