Cheap Spindles & Power Fluctuations

While building my CNC mini-mill, I purchased a 500W air-cooled spindle from eBay.  It came with a power supply, which looked great and I (falsely) assumed it would work perfectly on my home-built mill.

Boy was I wrong!  The mill worked great as long as the spindle was turned off.  Whenever the spindle was on, there was a chance that the mill’s microcontroller would reset (bad), lock up (worse), or would suddenly enter an infinite loop (really really bad!) and an axis motor would begin moving in some direction until I noticed and stopped it.

After much work identifying and rectifying the causes, the power supply has finally been tamed.  Here’s a guide for anyone having the same issues.

The Mill Controller

For context, my mill controller is home-designed and built from a pre-drilled perfboard.  It runs on 12 volts, which are supplied from an ATX power supply.  The power supply works well whenever the spindle isn’t on, and temporarily swapping it out with another ATX power supply has never rectified the issue.  The ATX power supply is supplied from the same 110-volt AC circuit as the spindle power supply.

The 12V rail feeds three stepper drivers (A4988’s and DRV8825’s) and an LM7805 voltage regulator.  The regulator delivers 5V to the ATMega328P microcontroller, LCD display, SD reader, and the rest of the peripherals.  A heatsink on the regulator prevents thermal overload from occurring.

The spindle is controlled by an opto-isolated relay.  The wiring is routed so that the spindle’s control wires don’t pass near the controller.

The firmware is my own home-brew.  I know the bugs have been worked out of the firmware as I can ‘dry run’ a CNC job (with the spindle turned off) successfully without issue.

The Symptoms

The three primary symptoms  (briefly described above) are as follows:

  1. Hard Reset.  Occurs frequently.  The microcontroller will behave as though its reset pin has been toggled.  The spindle turns off and the position display shows 0,0,0.
  2. Freezing.  Occurs occasionally.  All motion ceases.  The spindle remains turned on and the position doesn’t change.  The controller doesn’t respond to user input.
  3. Infinite Looping.  Has only happened a couple times.  The controller begins moving an axis in some random direction indefinitely.  the display doesn’t update and the controller doesn’t respond to user input.

These symptoms ONLY occur if the spindle is turned on.  They are also very random: the mill can complete a 1-hour job without any symptoms occurring, but may also reset a few minutes or seconds after turning the spindle on.  Varying the speed of the spindle doesn’t appear to affect the rate of occurrence.

Interestingly, The issues seem to be worst when the spindle tool is in contact with a metallic workpiece.  Also, on one occasion the machine was plugged into the same outlet as my 3D printer.  It was resetting frequently until I plugged it into a separate circuit from the printer, at which point it ran for an hour without issue.

The Causes

The spindle and power supply came pre-loaded with two problems.  First off, metal filings inside the spindle motor were causing intermittent shorts between the commutator / coils and the spindle.  This meant that the tool was being charged and discharged, causing power fluctuations whenever it touched the workpiece. I noticed this after getting a mild zap when I touched the spindle one time.

Second, the power supply was a very crude design which introduced power fluctuations in the supply power.  The supply works by rectifying the AC power and smoothing it with a capacitor.  The spindle motor is connected to the rectified power through a MOSFET, which is turned on and off to control speed.  A flyback diode is also present.  The MOSFET turns on and off very quickly, causing voltage spikes whenever it changes state.  Because there isn’t an isolating transformer, the circuit cannot be grounded to the case in any way as the rectified voltage is constantly moving above and below ground voltage (IE. rectified negative moves between 0 and -110 volts, while rectified positive moves between 110 and 0 volts).

The Solutions

Following are the modifications I’ve made to prevent the symptoms from occurring.  I’ve ordered them from most helpful and easiest to the least helpful and most difficult.

  1. Clean The Spindle (very helpful, moderately easy).  I disassembled the spindle (which isn’t hard) and discovered two problems: There’s an open hole in the top and a chunk of metal filings inside.  I also noticed the brushes look terrible, but there’s not much I can do about that.

    • Remove the C-clip above the fan
    • Remove the Fan (pull hard!)
    • Remove the C-clip below the fan
    • Remove both screws
    • Push the brushes in to slide them past the commutator and bearing
    • Blow out the entire motor very good!
    • Reverse the instructions to re-assemble the motor.  You will need to use vice grips on the main screws to line them up, since there are no guides.
    • Cover up that huge hole with some duct tape. 
  2. Ground The Mill’s Microcontroller (helpful, easy).  Don’t directly connect the controller’s ground to the frame ground, but put a ceramic capacitor in series.  I used a 2.2uF ceramic capacitor which appears to be doing a good job.
  3. Braid And Route All Spindle Wiring (helpful, easy).  Make sure all the wires are in twisted pairs.  Keep some metal between the wires and any microcontroller components or wires.
  4. Ground The Spindle and Mounting Block (helpful, moderately easy).  Connect grounding wires from the spindle power supply (which should be grounded to your frame) to the spindle and its mounting block.  The spindle should have some screws that you can use as a wire ground.  I had to drill and tap a hole in the mounting block for the ground.
  5. Modify the Spindle Power Supply (helpful, difficult).  Remove the two gate resistors (mine were labelled R26 ‘102’ and R25 ‘512’).  Replace R25 with a 10K resistor and R26 with a 3K resistor and (if possible) a 135-ohm@1mHz ferrite bead.
  6. Add Ferrite Beads To The Spindle Power Supply (not very helpful, very easy).  I have 135-ohm @ 100mHz ferrite beads.  Add one in series with the power and ground inputs to the spindle power supply.
  7. Add Ferrite Beads to the Mill Controller (helpful, moderately easy).  I have 135-ohm @ 100mHz ferrite beads.  Add one in series with the +12V and Ground lines from the power supply.
  8. Don’t Run At Full Speed (helpful, maybe inconvenient).  I found that, after these modifications, loading the spindle at high speed can still cause a reset.  Running it slower can prevent a reset.

The Results

I haven’t had much runtime since making all of these modifications, but the issues seem to be resolved (if I don’t overload the spindle).  I will update this post with any more modifications I make.

Last Updated 2019-08-26

Leave a Comment