The final part of the project is to hook up the controller to my CNC control software, Linux CNC. Linux CNC has some good examples of how to do this over here.
I'd already done a bit of research on this so I knew the way it would work would be PWM. To make it easier to interface, I'd included space on the PCB for a simple RC low pass filter. I couldn't find any info on how fast the PWM signal is from Linux CNC (and I didn't remember to measure it). I just used a 10uF cap and a 10k resistor and that worked fine. The output from the parallel port is 5v, and I got from 0 to 1000 (out of 1024) on the Arduino analogRead() function.
If you build this and you're not using the filter, you'll need to put a wire link over the resistor or you'll get no signal.
I felt a bit unsafe about just using a speed signal to control the spindle, so I have a run pin and a speed pin. The code I used in the Linux CNC .hal file is here on lines 11 to 19.
I found out also that someone has used Linux CNC to do the PID itself! Which I didn't know was possible. I don't feel the effort was wasted though, as I'd still need to do the loop tuning, and the phase control TRIAC stuff.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.