Two speed spindle gear changer for VMC

More
09 Jan 2019 07:07 #123815 by eriksalo
Two speed spindle gear changer for VMC was created 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...

Attachments:
The following user(s) said Thank You: akb1212

Please Log in or Create an account to join the conversation.

More
09 Jan 2019 16:31 #123835 by andypugh
Replied by andypugh on topic Two speed spindle gear changer for VMC
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 or Create an account to join the conversation.

More
09 Jan 2019 16:51 #123842 by eriksalo
Replied by eriksalo on topic Two speed spindle gear changer for VMC
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 or Create an account to join the conversation.

More
09 Jan 2019 19:41 #123858 by andypugh
Replied by andypugh on topic Two speed spindle gear changer for VMC
I have a 2-position physical switch for brake enable and a 3-position manual switch for spindle high, low, auto.
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 or Create an account to join the conversation.

More
10 Jan 2019 18:48 #123918 by eriksalo
Replied by eriksalo on topic Two speed spindle gear changer for VMC
This is interesting. So would this be a file like "gearchange.comp" that then gets compiled and called like carousel.comp?

Please Log in or Create an account to join the conversation.

More
10 Jan 2019 19:09 #123919 by andypugh
Replied by andypugh on topic Two speed spindle gear changer for VMC
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.
The following user(s) said Thank You: tommylight, rodw

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum