Tachometer for spindle

Okay, this evening I made a small sketch that set the duty cycle to 64, 128, 192, 255, and back down, for a few seconds each point. The power supply has three terminals connected to a potentiometer, and two terminals for PWM. Here are some of the things I observed:

With the pot turned to zero, the PWM signals did nothing.

With the pot turned up anywhere from just barely turning, or almost ready to turn, the PWM settings caused it to start, and run faster at each level. Unless the pot was turned up pretty high, the PWM signals would not get it turning beyond about 8000 rpm, and if turned up high enough, the higher PWM signals actually made it slow down.

If the spindle is turning fast enough, it generates power that feeds back through the LCD, which gets darker (more pixels turning dark) until it’s unreadable, just solid blocks. If the power is off on the arduino, and I run the spindle up with the pot, it will also start to light up the LCD - I have not pushed it to full power like this.

With the pot disconnected, and only the PWM wires connected, nothing happens at 64, it turns at 1100 rpm at 128, 2400 at 192, and 4400 at 255. It won’t go any faster than that.

The voltage output to the motor varies over a range of maybe +/- 10vdc as the PWM cycles, centered around whatever voltage the rheostat is set to. I didn’t measure the output when I had the pot disconnected.

Anyway, that’s just some observations. I’m not sure what to make of them yet. I post them here in case someone can decipher the behavior and give me an idea of how to get it all working.

If the spindle is turning fast enough, it generates power that feeds back through the LCD, which gets darker (more pixels turning dark) until it’s unreadable, just solid blocks. If the power is off on the arduino, and I run the spindle up with the pot, it will also start to light up the LCD – I have not pushed it to full power like this.

Uh… That’s not great. What power supply are you using? Do you have the arduino on a separate power supply? If the only connection between the motor and the arduino is the PWM, and the wall A/C, then I think you probably need to isolate the PWM signal.

With the pot turned up anywhere from just barely turning, or almost ready to turn, the PWM settings caused it to start, and run faster at each level. Unless the pot was turned up pretty high, the PWM signals would not get it turning beyond about 8000 rpm, and if turned up high enough, the higher PWM signals actually made it slow down.

It could be a bad pot. I would measure it with a multimeter. Maybe the resistance is actually going up at that end of the range. If you just connect the red pot wire to the yellow PWM, does it go full speed? When you get your PID in there, if this potentiometer is affecting it, your control loop will be trying to compensate, which, with an integrator, can cause some goofy issues, so hopefully you can just disconnect it, or just jumper it to ground or whatever that red is (5V, 10V?) and then ignore it.

The voltage output to the motor varies over a range of maybe +/- 10vdc as the PWM cycles, centered around whatever voltage the rheostat is set to. I didn’t measure the output when I had the pot disconnected.

So when the output voltage is about 50V, you are seeing ±10V oscillating? But that was only with the PWM connected. About what frequency was it changing? Every few seconds? I like to blame the pot for this too, because it might be varying a little bit… Otherwise, it might not be something to worry about, because the PID loop should be able to clean this up a bit, although the less work it has to do the better… I’m assuming it’s not coincident with the frequency of the PWM, so if your PWM was 500Hz, you aren’t seeing ±10V at 500Hz.

This is cool. I wish I was there with you testing it out.

When I said that the voltage varies, I meant that it varies as the PWM duty cycle changes. However, I just did some more testing, and here’s an example of the voltages. I started at a level that had the spindle already spinning, so there’s a voltage even at 0 PWM.

PWM VDC
0 22
64 59
128 69
192 79
255 94

Interestingly, while I had this running, I unplugged the usb cable from the arduino. I expected the spindle, which was still running, to settle on a single speed, but it continued to cycle, so I realized that the EMF I had observed before must actually be powering the arduino. I then unplugged the motor from the power supply, and the arduino continued to run! Now, there is a huge capacitor in the power supply, so maybe that’s what kept it running, but it seemed weird. Also, as the program continued running, the amount of power feeding into the arduino varied at each PWM point (judging by the brightness of the LCD).

Anyway, I don’t like the EMF feedback (or whatever it is), so I’ve ordered a PWM controller like this: https://www.amazon.com/gp/product/B00HUQY9HC/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1. This is the same type that jmhrvy1947 used in his project, so I’m hoping I’m set up to just use his solution with little modification. That controller should be here tomorrow, so we should know this weekend.

Okay, I got it all hooked up and it works great! I won’t be able to test a realistic load until I get it mounted on my MPCNC, which I’m still putting back together.

Those of you who are experienced coders can probably do all this with any combination of controller and sensor you have at hand, but if you want to put this setup together, here’s what you need:
Spindle and power supply - $135
Arduino Leonardo - $11
LCD Keypad shield - $11
IR Sensor - $7
PWM Controller - $17

You can see a video of the setup here:

Dude! Nice. Can’t wait to see how it handles load changes. That can/should make a very noticeable effect on your future cuts.

Is that noise some sort of alarm or something, is there a peizo on there anywhere?

Thanks, Ryan. I am looking forward to actually trying it out!

I’m not sure where that whine is coming from. There’s no piezo I can find anywhere. It’s hard to isolate, but I’m pretty sure it’s coming from the PWM controller. I will continue trying to eliminate or mitigate it. It is not as loud as it might seem in the video. I certainly expect it to be drowned out by the sound of the bit cutting material, or maybe even just the machine moving.