Controlling a Chinese spindle power supply with PWM

I recently purchased a 500W spindle, which came with a 100V DC power supply. Though adjustable, the voltage could only be controlled using a 4.7kOhm potentiometer, and not using PWM, which is what my CNC setup required.

A potentiometer normally acts as a voltage divider (or as part of one), where it is the resulting voltage (or current, depending on the circuit), which actually controls the speed; so if we can find out exactly how this relationship works, then we can use an electronic circuit to control the voltage instead.

I started by mapping out the various voltages, and noted that the potentiometer was indeed connected via GND and ~4V, with the center leg therefore presenting a voltage between these two.

To achieve the same using PWM, the duty cycle of a 5V signal could be adjusted between 0% and 80%, which would result in the ‘average’ (when smoothed through the internal capacitors) voltage matching the 0-4V range.

Attempt 1:

Seeing that a voltage between 0V and ~4V was needed, my first try was to simply use a PWM output from my arduino to control it, and this did in fact work reasonably well. Or so I thought.

This power supply is a Switch Mode Power Supply, and it is not isolated from mains, meaning that it simply rectifies the 120V mains into a 160V DC before cutting it into the needed voltage. This also means that the output voltage is floating and referenced to mains as opposed to earth, and that by connecting GND of my Arduino to GND of this, and powering the Arduino from my laptop, I was in fact also making both of those referenced to mains. As a result, I saw lots of noise propagating back to my controller and laptop, and also got shocked a few times as I touched components that should have been referenced to earth.

Attempt 2:

Having disassembled the power supply and traced out the main workings of it (and how it was not isolated), I decided to try the same setup but with an optocoupler instead. This would provide me with two very strong advantages:

  1. My Arduino would remain galvanically isolated from the power supply
  2. Instead of sourcing a separate 5V supply with a different output impedance, I’d be sourcing the original supply, meaning that a 25% pot adjustment, and a 25% duty cycle should be practically identical from the system’s point of view.

After testing this on a bread board, I realized that the circuit was still not comparable to using the POT directly, and I identified the cause being that the internal power supply for the ~4V had a fairly high impedance, meaning that as current was drawn, the voltage would drop quite significantly, and that the 4.7kOhm potentiometer to GND was actually pulling it down quite a bit. Since the PWM signal through the optocoupler would not be split between GND and vOut, the PWM remained much higher than it should be. The fix to this was to simply add a 4.7kOhm resistor (actually a trim-pot) between the vOut and GND.

Having traced out the circuit, I had identified two trim-pots, one for minimum and one for maximum voltage. By adjusting the now three trim-pots, I ultimately found a combination that would allow me to control the spindle speed perfectly between 0-100% using a 0-100% PWM duty cycle.

 

Leave a Reply

Your email address will not be published. Required fields are marked *