Starting from scratch (again) - Lathe gears

More
15 Dec 2019 03:11 #152673 by mooser
I'm preparing to change a lathe from mach over to linuxcnc and I'm building a new PC/controller while leaving the machine running under it's current system as long as possible while I try to work out as many issues (lack of knowledge with linux and linuxcnc and the mesa cards) before disconnecting the running controller.

The lathe is a smaller standard-modern series 2000 and has a 6 speed spindle gearbox running from about 45 to 2000 rpm currently using a VFD
Mach has a spot to plug in gear ratios and set speed ranges and then I can just plug in what gear I'm in and it limits the speed to those ranges and feeds the VFD the correct values.

I haven't found the actual spot in linuxcnc yet but I understand it really only has 2 gear ranges available (with someone posting link to someone else who added more but the link was broken and I didn't really dig any father as I was still working on getting the VFD control worked out.)

Anyway, I can't help but think I can't be the only one with a gearbox greater than 2 gears?
Do I under and overdrive the VFD a ton and just pick the middle gears of the high and low range?
What's the best approach?

I'm just looking at getting the spindle encoder working right now but this is next on the list

Thanks and more questions to come
M

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

More
15 Dec 2019 03:18 #152675 by tommylight
Have a search for maho retrofit, i think i read there about gearboxes and stuff.

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

More
17 Dec 2019 02:02 #152772 by mooser
Holey Moley, just finished wading through there, I'm not sure I learned what I needed but did pick up some other ideas. The bulk of the gearing seemed to be in the control side whereas mine are manual shift (but of course while reading through there I started wondering if I could change it to computer control LOL)

Anyway, one of the links brought me to a series of posts by andypugh and although I didn't get very deep in those I think between the two somewhere is the info I'll need

Thanks
M
The following user(s) said Thank You: tommylight

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

More
More
07 Jan 2020 20:16 #154249 by andypugh
Here is a multi-gear version of "gearchange". It should compile and install with halcompile and then "man gearchange" will show the documentation. This will over-write the existing gearchange component.
component gearchange """Adjust motor speed command for geared spindles.
Scales the input value to the output depending on selected gear.""";

pin in float speed-in "Speed command input.";
pin out float speed-out "Speed command to DAC/PWM";
pin in bit sel-# [32 : personality] """Gear selection by bit. Higher
numbers take priority if more than one is set""";
pin in bit dir-in "Direction input for absolute speed + dir modes";
pin out bit dir-out "Direction output (will be reversed for negative ratios)";
pin out bit min-lim "Indicates that the minimum limitation is active";
pin out bit max-lim "Indicates that the maximum limitation is active";
pin in signed gear-number =-1 "Numeric (rather than bit) Gear selection";
pin out float speed-filtered "Speed command to display, limited and absolute";
pin out float accel-limit "Acceleration limit for the selected gear";
pin out unsigned gear "The actual detected gear";
param rw float min-#[32: personality] = 0
"Minimum allowed speed in gear range N";
param rw float max-#[32 : personality] = 100000
"Maximum allowed speed in gear range N";
param rw float acc-#[32 : personality] = 0
"Maximum Acceleration in output units/s. 0 = no limit";
param rw float scale-#[32 : personality] = 1.0 """Ratio between speed input and
the required output value""";
modparam dummy num_gears """The number of gear ratios to create in
each instance.
To create mutiple instances use multiple, comma separated values.""";

description """The output will be a  value scaled for the selected gear, and
clamped to the min/max values for that gear.

This version should work for up to 32 gears.
To load two instances, one with 5 gears and one with 6 use:

loadrt gearchange num_gears=5,6

Gears are numbered from zero, ie the count includes neutral, so typically the
modparam should be one more than the actual gear ratio count.

The Component accepts negative speeds, negative outputs and negative scales to
allow for gear ranges that reverse the motion.

The scale pin is the ratio between output value and input speed, so
the same VFD
scale parameter (typically set by the PWM scale parameter) will work for any
gear. It might be sensible to set the PWM scale to 1, in which case the
individual gear scales will be in rpm/volt.
The output value is that motor speed which would be required to give the
requested output speed with a gear ratio of 1 at the set PWM scale. For example
if gear 1 has a max speed of 1000rpm and requires 10V to the VFD to achieve
that, and gear 2 has a max speed of 4000rpm then gearchange.N.ratio2 should be
set to 4. Then a spindle speed of 1000rpm would give 10V output in gear 1 and
2.5V in gear 2.


The gear can be input either as a numeric value (possibly assembled from
\\fBweighted_sum\\fR components to convert the positions of several levers into
a gear) or as an individual select bit for each gear.""";

option count_function yes;
option extra_setup yes;

variable float old_speed = 0;

function _;
license "GPL";
;;
#include <rtapi_math.h>
#define MAX_INSTS 8
static int num_gears[MAX_INSTS];

RTAPI_MP_ARRAY_INT(num_gears, MAX_INSTS, "Gear count for each gearbox");

FUNCTION(_) {
    double speed_target;
    double delta;

    if (gear_number != -1) gear = gear_number;
    else for (gear = personality-1 ; gear > 0 && !sel(gear) ; gear--) {}

    speed_filtered = fabs(speed_in);
    if (speed_filtered > max(gear)) {
        max_lim = 1; min_lim = 0;
        speed_filtered = max(gear);}
    else if (speed_filtered != 0 && speed_filtered < min(gear)) { // zero is 0
        min_lim = 1; max_lim = 0;
        speed_filtered = min(gear);}
    else { min_lim = 0; max_lim = 0; }

    if (scale(gear) == 0) {
        speed_target = 0;}
    else {
        speed_target = speed_filtered / scale(gear) * ((speed_in < 0)? -1 : 1);}

    delta = acc(gear) * fperiod * ((speed_target > old_speed)? 1 : -1);

    if (acc(gear) != 0 && fabs(speed_target - old_speed) > fabs(delta)){
        speed_out = (old_speed += delta);}
    else{
        speed_out = (old_speed = speed_target);}

    dir_out = ((scale(gear) < 0)? !dir_in : dir_in);

    accel_limit = acc(gear);
}

EXTRA_SETUP( ) {
    if (num_gears[extra_arg] < 2) personality = 2;
    else personality = num_gears[extra_arg];
    return 0;
}

int get_count(void){
    int i;
    for (i = 0; num_gears[i] != 0 && i < MAX_INSTS; i++){}
    if (i == 0) return 1;
    return i;
}

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

More
07 Jan 2020 22:48 - 07 Jan 2020 22:54 #154273 by mooser

This one?
forum.linuxcnc.org/47-hal-examples/27071...indle-gear-detection


Yup. That's the one I was looking at (after the other one)

Haven't jumped into it yet (getting close I think)

Since it's yours I'll ask if it's where I think I'm going.

My lathe has 6 gears, 3 across, high and low range
The motor is a 220vac 3ph 1720RPM running off a VFD (220v single phase)
Anyway. I had set (mach3) the system up something like this
gear low and high rpm in that gear
1 40 - 100
2 100-180
3 180-325
4 325-600
5 600-1050
6 600-2000

I have no recollection of how I came up with those numbers but that's where they were.

On the mach setup I would enter the gear and then set the desired rpm and if it was within the range it would bring the spindle up to that RPM otherwise it would use the minimum or maximum speed available on the range for the gear I told it I was on.

Somehow I was thinking yours was sort of the other way and you specified the speed you wanted and it told you what gear to put it in?
Again I haven't gotten that for so I didn't try to read too deep
M
Last edit: 07 Jan 2020 22:54 by mooser.

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

More
08 Jan 2020 18:35 - 08 Jan 2020 18:35 #154334 by andypugh

Somehow I was thinking yours was sort of the other way and you specified the speed you wanted and it told you what gear to put it in?


Not exactly. With my milling machine I set a spindle speed in LinuxCNC and the system attempts to achieve that by detecting the ratio of actual spindle speed to motor speed to work out the gear ratio, then sets the motor speed accordingly to achieve the required spindle speed, within the frequency limits of the VFD.

On my mill the gearbox is electrically controlled and 2-speed. With that the system chooses the gear to engage depending on the spindle speed requested.
Last edit: 08 Jan 2020 18:35 by andypugh.

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

More
04 Feb 2020 20:46 #156539 by mooser
OK I'm back to here again.
Lathe has the encoder mounted on the spindle and working correctly. VFD is functioning correctly, etc, etc, etc.
Next up is dealing with the gearbox

It's a manual gearbox, three speeds with a high and low shift so 6 all together
without VFD they are 75,135,250 in low and 450,810,1500 in high
ALL MANUAL SELECTIONS

Since it's a manual box, your method above would need to tell me what gear to select rather than trying to shift it by itself ?
O should I go with the "stock" gearchange component that came with the linuxcnc install?

I partially understand the "sudo halcompile --install gearchange.comp" instruction but where do I go from there?
Thanks
M

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

More
04 Feb 2020 22:27 #156548 by andypugh
The component above assumes that there are switches on the levers so that the system can work out which gear you are in.

My mill setup is different; LinuxCNC works out which gear I have put it in by comparing motor speed and spindle speed, and scales accordingly.
forum.linuxcnc.org/47-hal-examples/27071...indle-gear-detection

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

More
04 Feb 2020 23:22 #156549 by mooser
OK, backwards to the way I thought it was.

So lets say in the middle of a program I switch from a turning to a partoff or something and the RPM change (in the program) drops from 1500 to 600 or something, will I, the user, see anything on the screen reminding me to switch gears or which gear to change into?
I guess I was imagining more what I was used to in Mach3, which is similiar to what mariusl was describing, something on the screen where I told it what gear I was in and it would let me know if the commanded RPM was ok or suggest a higher/lower gear.

Anyway, I know I'll have to try to tweak your component to match my settings so I'll have to get the HAL off the machine and look at comparing.

More questions to follow I'm sure
Thanks again Andy
M

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

Moderators: piasdom
Time to create page: 0.235 seconds
Powered by Kunena Forum