Two speed spindle gear changer for VMC

More
7 years 9 months ago #123815 by eriksalo
I have an Okada VM500 with a two speed gearbox for the spindle.

I re-mapped the "S" command with a G-Code O-Word sub-routine.

It was much more complex than I expected. I needed to check at each stage if the appropriate sensors were True/False and also handle zero speed commands, etc. The biggest mistake I made was to forget to handle a speed command when the spindle is already spinning on the opposite gear. For example, If I'm spinning in the high gear and send an "S0" command, my first program tried to shift to the low gear and then send the S0. This resulted in a bad crash of the gears.

I needed to make the spindle come to a stop before changing gears in any case.

Since it was harder than I expected, here are my .ngc, .hal and .ini files to serve as reference to others trying to do something similar.

Also a video...

Please Log in to join the conversation.

More
7 years 9 months ago #123835 by andypugh
On my lathe I handle this with a custom HAL component.
My gearbox uses electromagnetic clutches (and a brake) though, so probably isn't directly applicable.
My point is that, sometimes, a custom HAL component can be a lot simpler than HAL logic.

Please Log in to join the conversation.

More
7 years 9 months ago #123842 by eriksalo
That's really interesting. Is your custom HAL component in any of the samples or can you point me to it so I could have a look at it? Would be interested to see how you did it. Erik

Please Log in to join the conversation.

More
7 years 9 months ago #123858 by andypugh
I have a 2-position physical switch for brake enable and a 3-position manual switch for spindle high, low, auto.
Code:
component gearchange "A component to choose spindle gears according to spindle speed"; pin in float speed-command; pin in bit spindle-on; pin in bit manual-low; pin in bit manual-high; pin in bit brake-enable; pin out float motor-speed; pin out bit low-gear; pin out bit high-gear; pin out bit brake; param rw float low-ratio=3; param rw float high-ratio=1; param rw float max-low = 500; author "andy pugh"; license "GPL"; function _; ;; FUNCTION(_){ static int old_M3; if (spindle_on) { if (!old_M3){ // spindle off to on transition if (manual_high) { high_gear = 1; low_gear = 0; brake = 0; } else if (manual_low){ high_gear = 0; low_gear = 1; brake = 0; } else if (speed_command <= max_low){ high_gear = 0; low_gear = 1; brake = 0; } else { high_gear = 1; low_gear = 0; brake = 0; } } } else { //spindle off high_gear = 0; low_gear = 0; brake = brake_enable; } old_M3 = spindle_on; if (high_gear){ motor_speed = speed_command * high_ratio; } else if (low_gear){ motor_speed = speed_command * low_ratio; } }

Please Log in to join the conversation.

More
7 years 9 months ago #123918 by eriksalo
This is interesting. So would this be a file like "gearchange.comp" that then gets compiled and called like carousel.comp?

Please Log in to join the conversation.

More
7 years 9 months ago #123919 by andypugh
Yes, exactly. Sometimes a few lines of C can be a lot simpler than a maze of HAL components.

linuxcnc.org/docs/2.7/html/hal/comp.html

For the details of the syntax.

Please Log in to join the conversation.

Time to create page: 0.113 seconds
Powered by Kunena Forum