Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: chriscain on January 13, 2008, 05:05:26 PM

Title: Lathe speed control
Post by: chriscain on January 13, 2008, 05:05:26 PM
I have a viceroy lathe that I have converted for Mach and it works very well but spindle speed is still manual.

The speed control is by a variable speed pully that is driven by a motor with an up and down button that changes the ivariable pully drive.

The question is if I put 2 relays driven by 2 output port bits across the up/down button is there a way to get mach to adjust the speed
to the speed given in the S command and monitor the spindle feed back to make it match the required speed ?

Title: Re: Lathe speed control
Post by: TonyP on January 14, 2008, 10:52:29 AM

The first thing that you need is a spindle sensor so that Mach knows what is going on. Maybe you have one already? If you can get a readout of speed then maybe a bit of code could be written to do what you want, but I'm not sure how easy that would be.
One way to do it would be using the brains system in Mach. It would be possible to compare the requested speed with the actual speed and turn on an output accordingly.
There is also a hardware solution, with Mach using the normal PWM or pulse output to produce a voltage proportional to the speed. The rest of the hardware would require a couple of comparators and another pulse/ voltage converter. Basically the output from the spindle sensor would be converted to a local voltage which would be compared to the voltage produced by Mach. If the local volts are lower one comparator actuates the speed increase relay - if  higher the other actuates the speed reduce relay. There would be a small dead band in the two levels so that relay chatter could be avoided.
I'm not saying that it is simple, but if you are into electronics it would be both possible & interesting.

Title: Re: Lathe speed control
Post by: chriscain on January 14, 2008, 11:02:06 AM

I have the speed sensor, (needed it for threading to work).
I hadn't though of using a hardware comparitor with the PWM, that might work out simpler to deal with than trying to program Mach to do it
Simpler to debug since I know a lot more about electronics than programing Mach!.

Thanks Chris
Title: Re: Lathe speed control
Post by: TonyP on January 14, 2008, 12:21:23 PM
Saves an output too!
Does your breakout board have a pulse/voltage converter? If not, I can recommend the LM2917 for the job. You would also need something similar for the local (motor) converter.

Title: Re: Lathe speed control
Post by: TonyP on January 14, 2008, 03:08:40 PM
Having said all that, I've had a quick play amongst the brains and I think I can do it with a brain. The brain editor is a bit frustrating with its editing limitations, so I'll go off to the pub now & think about it on paper over a pint. I'll have another go tomorrow and try it on a real machine so I have some true spindle revs as an input.
I assume you have a couple of outputs free as well as spindle start etc?

Title: Re: Lathe speed control
Post by: Peter Homann on January 14, 2008, 10:14:16 PM
Hi Chris,

For hooking up a sensor, have a look at the Engineering notes I've written;

Also for speed control, consider the DigiSpeed-XL. It helps with the wiring of the sensor as well as allows the spindle to be controlled via the PWM signal from Mach3.


Title: Re: Lathe speed control
Post by: TonyP on January 15, 2008, 05:03:18 AM

I've tried the brain on my lathe & it seems to work. There needs to be a bit of polishing but the idea works. See the attached file.
I've allocated outputs 5 & 6 for the relays. To try it, load the brain file into you brains folder. You should then see it in Mach under Operator/ Brain control. Enable it and go to diagnostics. If you set a speed & start your spindle, Output 6 will start to flash (speed up relay), as the speed passes the requested number, 6 will go out & 5 will come on. ( speed reduce)
I need to include a delay in operation so that the spindle reaches a stable speed before any corrections start & also a bit of dead space to stop chatter.
As I say, it's not exactly right yet but it shows that it's possible.

Hmm it won't let me post brains, I'll try a .dxf ending. If it works you'll have to rename it.