Spindle Speed Control

Finally got the spindle working with a square wave produced by the computer.

I am using the StepGen component of the Hal. I am using a type = 2 which produces a quadrature signal. One phase of this is fed to pin 1 on the parallel port which connects to pin 11 on the machine. This component is tied, in the Hal to the spindle control, the same as it was with the pwm signal that was giving me so much trouble.

Now I can finally change the spindle speed with M3 commands and get a variable square wave out of the parallel port pin. The spindle works much better with this type of signal and I am now able to control the speed.

I had a few problems trying to set this up and could not have done it at all without the help of Jepler on IRC freenode #EMC.  Thanks so much to him for his help and pointing me in the right direction.

First I had to learn something more about the Hal file and how Hal actually works. Up till this point I had been using the Wizard StepConf to configure EMC. There is only so far the Wizards can take you and this maneuver crossed the boundary.

Also, I migrated to a different machine, and installed Hardy, the newest LTS Ubuntu at the same time I was mucking around in my Hal file. I ended up with lots of screwy errors, never change everything all at once, its a bad idea.

Turns out I had commented something out in the Hal file that I shouldn’t have, days ago, and it was screwing everything else up after the computer migration. Once I braced up, went back to the original config and basically started over, I realized what was going wrong.

Trying to use the distro images I downloaded from the EMC web site did not work out well for me either, I tried a few times to install, with lots of disk errors after the restart and general flakiness. Finally, I downloaded an official Alternate CD from Ubuntu and installed that, breeze, then installed EMC, now everything seems to be working pretty well again. I did try two separate downloads and burns of the EMC image with no luck, it installed fine, just wouldn’t run afterwards worth a flip.

After I managed to get controllable square waves coming out of the proper pin I gathered some data on the speed of the spindle.  Hooking a scope to pin 15 on the  Spindle Motor Control Board I found that if you turn the spindle by hand you get two high outputs per revolution.  There is feedback from the spindle that comes to this pin (S1 & S2).  So, by sending the machine different M3 speed commands I was able to keep adjusting the Position-Scale variable in the Hal file until the speed commands almost matched the actual speed of the spindle.

Here is what I ended up with that worked out to be the best:

Position-Scale = .045

Set Speed Measured Speed
1000 2400
5000 6000
10000 11190
20000 21600
30000 27900
35000 28800

Helpful Documents for figuring this out:

StepGen overview that explains various step types.

Wiki page that covers types in some more detail.

Notes from jepler that I got on IRC (Thanks again!)

Ozo.hal file that I eventually ended up with.

Finally, I can cut some material…

Tags:

Leave a Reply