I just got a 500W spindle and am working on getting it set up on my MPCNC. I’m also in the middle of upgrading all the parts on the MPCNC, which is an early model, so I still have a way to go before I’m actually cutting with it.
Anyway, I’m thinking about building an arduino-based tachometer for the spindle, but wanted to check and see if anyone has done it already, or is aware if someone else has done it already.
I plan to use some kind of optical sensor mounted to body of the spindle, pointing at the cooling fan at the top of the spindle. I’ll put a piece of reflective tape on the cooling fan, and have the arduino calculate the rpms from that. I’ll use a 2004 lcd to display the rpms. The spindle can turn up to 12000 rpm, so I hope that this setup can handle that.
I’ve done a few projects with arduinos, but I’m still pretty new to them, so if you’re knowledgeable about them and have some ideas about how to approach this, please share your thoughts about this project.
I have also seen handheld optical tachometers on amazon for around $15. If one of those would work with this spindle, it would be easier than building my own. Not nearly as cool, but easier. If anyone has experience using one of these, please let me know.
12000 rpm is 200 Hz, which is 5ms/measurement. That should be fine on a dedicated arduino. You will want to make sure the sensor goes between low and high on the input pin, and either use the pulse in (might not be the right name) or an interrupt handler to measure it. The other thing working for you is that you don’t need to measure every pulse, just measure the time for one pulse, ten times or so, and then average them out. Then you can stop measuring, and go handle your LCD. The big advantage of an arduino (other than it’s cool, and you’ll learn a lot) is that you can then go the next step and control the speed of the spindle with closed loop feedback.
That being said, the tachometers on amazon will probably work fine, just putting some reflective tape on the chuck.
Speed alone doesn’t get you much, anytime the bit makes contact the rpm’s will vary greatly. What you are looking for is a RPM PID controller. That way if you set 1000 rpms, it will do it’s best to vary the power to keep 1000 no matter what.
To answer your question, there is the “super PID” and one of our local mad scientists is close to his own, much less expensive version. Details on that to come.
Good point about not needing to count every pulse, Jeffeb3! That will help. Instead of timing a certain number of pulses, could I just count the number of pulses in a specific amount of time, say 10 seconds, and calculate from that? Or is the way you suggest more accurate? Thanks for your input!
Ryan, that’s also a good point about the RPM being different under load. The PID thing sounds cool! Maybe I should just get the $15 tach and wait for the PID controller to be developed and build that instead. I won’t learn as much, but it seems like a great solution.
You could do it without interrupts, if that’s what you’re asking. Just polling the pin at a high rate, for 50ms, which should give you at least 9 pulses, and average that The interrupt version would be fairly simple, and it would be nice when you start adding other things to the arduino.
So after reading Ryan’s post about someone working on a PID speed control for the spindle, I decided to research it myself. I glued a piece of a gift card to the spindle (the “fan” part at the top of the spindle, actually), and mounted an opto endstop so that the gift card “flag” passed through it. I’m getting an accurate rpm reading, as checked with a handheld optical tachometer. I started with a sketch that incorporates the PID library, and I’m ready to try using the PID part of the sketch to control the spindle speed.
Which brings me to my question: has anyone actually done this? Hooked up an arduino to the PWM input on the power supply (meant for Mach3 control, I think)? Can I hook the arduino directly to the power supply? Do I need another piece, maybe a mosfet or something that can handle a higher current?
Any advice, or even a link to info about this, would be appreciated.
Here are a couple of other pics, one of my breadboard for the project, and another of the spindle with the tach sensor mounted on it. I originally tried using a mini IR sensor (usually used for bed leveling) for the tach, but it didn’t work right. The opto endstop is hot glued to mount I originally designed for the mini IR.
@karl . You’ll need a triac to drive the load. The triac circuit will be high voltage across so it should be optoisolated from the Arduino circuit for safety reasons. A zero Cross detection circuit is also needed to find the exact point in the AC sine waveform where the triac switching should start. The zero Cross detection circuit should also be isolated for safety. Your Arduino will need to read rpm, handle PID loop, and apply phase control to the outgoing AC through the zero cross and triac input/output. Most of this needs to happen at high speed and precise timing so you’ll want to use the Arduino timers and interrupts to manage the zero cross and RPM input.
If your spindle power supply already accepts pwm input then you’re almost there. Post your sketch when you get a chance . There are a few coders on the forum now so I’m sure you’ll get some help.
Do you have a data sheet for your power supply? The details of that pwm in are going to determine what kind of solution you need. It would be smart engineering to read the docs first.
Most likely it’s just going to be a high impedance input, looking for a pwm input at 5V. Otherwise, it might be a pulse input, like an RC controller, but it still wouldn’t hurt it to have it connected, it just wouldn’t work. Still possible, but also unlikely is that it’s a 3.3V input, which you could damage with a 5V Arduino (you could use a voltage divider in that case). If it was something strange like a 12V input, you would need a transistor to get the Arduino output voltage higher. Still not a big MOSFET though. I would be pretty surprised if that needed much current at all, so a higher current circuit shouldn’t be necessary.
The Triac stuff Leo was talking about is more for controlling 120VAC.
Most of these Chinese spindles are made to work with Mach3 control which would be 5v pwm from a PC parallel port or USB motion controller. Karl mentioned something about Mach3. Should be Arduino friendly but it’s a good idea to make sure and avoid the magic smoke:)
There weren’t any docs with the power supply. There is no non-chinese printing on it other than 110VAC and + or -, so there’s no model number to google. I’m guessing that 5v PWM at the Mach3 ports is what it’s looking for, though I have seen references on some CNC forums to jumpers in the power supply that might need to be set to enable PWM (not necessarily talking about this specific power supply, though).
Anyway, that’s why I’m asking if anyone has any experience with this specific spindle and power supply. They are very common and cheap, so I thought someone might. I’ll post my code later if I get it working or need help with it. Currently it’s just a work in progress.
Interesting. Their wiring diagram doesn’t match the pictures. One input is labeled “0-10vdc signal”, and the other is a potentiometer. If you measure the voltage across the red and black wires of the potentiometer, and that’s 5V, and you have a 5V arduino, then you should be able to put the arduino 5V PWM on the yellow connector. If you need to output a 10VDC PWM signal, one transistor would do it. It’s also possible the 10VDC would work with a 5V (even to 100%), and it’s just tolerant to 10V.
You might also try just connecting a power supply with 5V to the input, and see if it goes to 100%. You could also measure the current that way, although I would be very surprised it if was anything significant. This definitely looks like a high impedance input.
Yes, mine matches the hand-drawn picture on the amazon item, with the Mach3 pins labeled 0-10vdc. I can’t remember if my terminals have that marked on them, but they are there. I will see what happens when I put a 5v PWM signal on them.
Good to see you back Karl ? I know you used to run a DeWalt dw660. How would you say your current spindle compares as far as noise, power, speed, and quality of cut?
Hi Leo! I can’t give an opinion yet. I printed the new middle and roller parts for my machine over the holidays. While I had it apart, I decided to get the spindle. I haven’t put the machine back together yet - waiting to get the PID speed control done. The only thing I can say so far is I’m sure it will be quieter! I might keep the 660 handy for things like dressing the waste board, since it will easily turn my 3/4 inch end mill, but I have high hopes for doing more precision stuff with different materials.
I’m also designing a gantry-mounted dust shoe. I saw a video of one on a shapoko or x-carve and it definitely looks like the way to go. No deflection of the cutting head by the shoe or vacuum hose.
Back to the subject of this thread: I hooked up a PWM output to the Mach3 input on the power supply this evening. The arduino PWM output is definitely controlling the speed of the spindle. Nothing is tuned and I don’t know what the range of control is yet, but it was controlling it for sure.
I found this video on youtube: https://www.youtube.com/watch?v=kYFNUQgE26E&t=0s. I’ve ordered the same leonardo board and button lcd shield that he used, as well as the same kind of reflective IR sensor he used. I’ve downloaded his code and hope to use it with maybe only a little modification. This should simplify things for me. I do love figuring out how to do things myself, but it can be tedious and frustrating. If someone’s already figured it out, and I can adapt it, I’m fine with that too.
Did you try looking at the voltage at the motor connector when you had it on before, and when you had it at 100% with the arduino? I would think that it would be at 100V at max. But I haven’t ever owned one of these.
I’m excited to see how this spindle works for you. I like the high-tech feel of it if that makes any sense. Seems neat to have a PID controller, and it also seems neat to have it electronically controlled. Just getting a digital on/off switch for the DW660 was quite a thrill.
I didn’t measure the voltage, I’ll try later. All I was able to ascertain was that the input affected the speed, but I need to play with it a lot more before I understand how to set it up properly so that it actually holds the speed steady. In my brief test, I had a display set up to show me the PWM output, and it was either 0 or 255. The spindle was either slowing down or speeding up at full speed. I think that once it’s properly tuned, there will be some more nuance in the PWM output.
I too like the high-tech feel of it. I originally got the spindle just to have something quieter than the screaming 660. But there are many discussion about bits and speeds here and on every other CNC forum, and it seemed to me that without being able to actually measure and control the speed of the bit, knowing what the speed should be for a given bit and material is a moot point.