Automatic spindle gear detection

More
05 Oct 2013 23:45 - 05 Oct 2013 23:45 #39583 by andypugh
My Mill has an 8 speed gearboxe to give speeds from a slow 1000rpm to a _really_ slow 45rpm.
The VFD lets me up those speeds by 50%, luckily.

I was thinking of fitting switches to the levers so that the system knows which gear is selected, but then I had an idea.

Cars typically detect which gear is engaged simply by comparing the engine rpm to the wheel speed (using two sensors that need to exist anyway). Then the ratio of the two speeds is passed into a 1D lookup table, and the output is the selected gear.

It would be easy to do the same with a machine tool, with the output of the lookup table being the required ratio between spindle speed request and pwm request.

In the case of my milling machine I don't have a sensor on the gearbox input shaft (though it would be pretty easy to add one, and the result would be better). Instead I am using the duty cycle sent to the VFD as a proxy for the motor speed. Yes, this does mean that the pwm duty cycle request is a function of the pwm duty cycle request…

I recently added a 2D lookup table to Master, so that part is easy enough. It can be seen as a curve a bit like a flight of stairs, and anywhere on one step is considered to be a single gear.

I found that I needed to limit both the rate at which gears were seen to change, and the value of the ratio measured (or occasionally I would see 10E+14 type numbers, and the system would take a while to sort itself out. I also needed to cap the motor speed request, or the calculations go wrong (above max motor speed the calculation is wrong, and it hangs-up in the top gear).

Here is the code that is working for me. It might need some way to "lock in" to gear for tasks like rigid tapping.
# Spindle handler
loadrt abs names=abs.0,abs.1,gear_abs
loadrt limit2 count=2
# Gear detection
loadrt lincurve count=1 personality=16
loadrt invert count=1
loadrt mult2 count=2

addf spindle-interlock.0       servo-thread
addf abs.0 servo-thread
addf limit2.0                   servo-thread
addf limit2.1                   servo-thread
addf  abs.1 servo-thread
addf lincurve.0 servo-thread
addf invert.0 servo-thread
addf mult2.0 servo-thread
addf mult2.1 servo-thread

# Resolver and PWM are both scaled in RPM.
# Maxmotor speed is 2250rpm

net spindle-speed-abs abs.1.out invert.0.in
net ratio-denom invert.0.out mult2.0.in0
net spindle-speed-cmd-abs mult2.1.in1
net speed-ratio mult2.0.out limit2.0.in
net speed-ratio-filt limit2.0.out lincurve.0.in
net spindle-command-gain lincurve.0.out mult2.1.in0
net spindle-command-raw mult2.1.out limit2.1.in
net final-spindle-duty limit2.1.out mult2.0.in1 hm2_5i23.0.pwmgen.00.value

# 0 speed
setp lincurve.0.x-val-00 0
# Gear 1000rpm
setp lincurve.0.x-val-01 .5
setp lincurve.0.x-val-02 1.9
# Gear 639rpm
setp lincurve.0.x-val-03 2
setp lincurve.0.x-val-04 2.75
# Gear 409rpm
setp lincurve.0.x-val-05 3
setp lincurve.0.x-val-06 4
# Gear 288rpm
setp lincurve.0.x-val-07 4.25
setp lincurve.0.x-val-08 6.75
# Gear 156rpm
setp lincurve.0.x-val-09 7
setp lincurve.0.x-val-10 9
# Gear 100rpm
setp lincurve.0.x-val-11 10
setp lincurve.0.x-val-12 17
# Gear 64rpm
setp lincurve.0.x-val-13 18
setp lincurve.0.x-val-14 25
# Gear 45rpm
setp lincurve.0.x-val-15 26

# 0 speed
setp lincurve.0.y-val-00 10
# Gear 1000rpm
setp lincurve.0.y-val-01 1.5
setp lincurve.0.y-val-02 1.5
# Gear 639rpm
setp lincurve.0.y-val-03 2.347
setp lincurve.0.y-val-04 2.347
# Gear 409rpm
setp lincurve.0.y-val-05 3.667
setp lincurve.0.y-val-06 3.667
# Gear 288rpm
setp lincurve.0.y-val-07 5.208
setp lincurve.0.y-val-08 5.208
# Gear 156rpm
setp lincurve.0.y-val-09 9.615
setp lincurve.0.y-val-10 9.615
# Gear 100rpm
setp lincurve.0.y-val-11 15.0
setp lincurve.0.y-val-12 15.0
# Gear 64rpm
setp lincurve.0.y-val-13 23.44
setp lincurve.0.y-val-14 23.44
# Gear 45rpm
setp lincurve.0.y-val-15 33.333

#VFD set up a bit funny...
setp hm2_5i23.0.pwmgen.00.scale 5000 
setp hm2_5i23.0.pwmgen.00.output-type 2
setp hm2_5i23.0.resolver.03.scale -1
setp hm2_5i23.0.resolver.03.velocity-scale -60
setp limit2.0.min 0
setp limit2.0.max 40
setp limit2.0.maxv 2
setp limit2.1.min 0
setp limit2.1.max 2240
setp limit2.1.maxv 2
Last edit: 05 Oct 2013 23:45 by andypugh.
The following user(s) said Thank You: ArcEye, jo_key, endian

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

More
07 Oct 2013 01:47 #39603 by ArcEye

Cars typically detect which gear is engaged simply by comparing the engine rpm to the wheel speed (using two sensors that need to exist anyway). Then the ratio of the two speeds is passed into a 1D lookup table, and the output is the selected gear.


I never actually thought of that, just assuming that there was a sensor on the appropriate linkage.

Having said that, we now have 3 cars without a physical throttle cable, or any other kind of physical linkage in many cases, so it makes sense.
My Merc has so many CPU's etc it makes it impossible to service beyond any basic level oneself.

Looks like a good way forward, save a lot of hard wiring and replace with computated data

regards

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

More
18 Aug 2014 02:57 - 18 Aug 2014 03:00 #49977 by mariusl
Andy
Could you give a high level explanation of how you put things together. I think I understand but would like to know how it works in practise before I change my hal file to match. And also to make sure I do it right. I understand why you did it but I would like to know the functioning better please.

P.S. Maybe the mathematical formula if any :)

Regards
Marius


www.bluearccnc.com

Last edit: 18 Aug 2014 03:00 by mariusl.

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

More
18 Aug 2014 05:39 - 04 Jun 2018 10:09 #49979 by andypugh

Could you give a high level explanation of how you put things together.

It is simpler than it looks, the majority of the HAL code is just putting the numbers in the Lincurve.

The spindle speed and motor (commanded) speed are divided one into the other to give a speed ratio (there is no divide, so I use invert and mult)

That value then goes in to the lincurve component, which is set up so that the output corresponds to the rpm-to-pwm ratio that corresponds to the required VFD request for that gear when multiplied by the commanded speed.

If you have a VFD with actual motor speed output then it would work even better. My implementation relies on motor commanded speed so take a little time to settle, which is why I have the limit2 component to smooth things out.
Last edit: 04 Jun 2018 10:09 by andypugh.

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

More
18 Aug 2014 13:51 #49988 by mariusl
Ah thanks, clear as mud :). My VFD is a 0-10v analog (pot) input from the 7i76 so it should work similarly to yours.
I will give it a bash.

Regards
Marius


www.bluearccnc.com

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

More
18 Aug 2014 15:13 #49992 by andypugh

Ah thanks, clear as mud :).


What isn't clear? The ratio of motor speed to spindle speed tells the system which gear it is in. The "graph" inside the lincurve is set up with fairly wide level spots in the line at each shaft ratio number corresponding to each gear.

I _could_ have set the lincurve up to give an integer gear number from 1 to 8 as the Y-values. But knowing that I would have to do further numerical manipulations on them I pushed those manipulations back into the returned Y-values.

For more complicated systems you probably would have integer gear numbers coming out, and would use them to drive a set of mux-blocks to (for example) return a set of PID values for each gear.

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

More
18 Aug 2014 15:40 #49994 by mariusl
It was actually said with tongue in cheek, but although I get what you implemented, I dont fully understand how it works in practise.

My machine has six pulley speeds and my motor can go up to 2250 rpm as it is set now. That is achieved by setting the 0-10v signal. For that I have a scaled gain of say 0.004 to give 10v at 2250 rpm. The spindle-fb is a 2048 ppr quadrant encoder that is mounted directly to the spindle. So no gearing there.
If I am in the middle gear for instance, with the motor running at 2250 rpm I get a 650 rpm reading from the encoder.
So clearly the requested speed is not the same as the actual speed.
So how do I tell the system that I can only get 650 rpm at full span of the output for that specific gear?
Now I understand how you get a value from the lincurve but I dont know how that influences the requested value.

Excuse me for being stupid and a pain here but I have never dealt with spindle speed control in this manner as it is my first lathe conversion. I am somehow not bringing the ends together.

Regards
Marius


www.bluearccnc.com

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

More
19 Aug 2014 01:01 #50016 by andypugh

So how do I tell the system that I can only get 650 rpm at full span of the output for that specific gear?


The short answer is that this system doesn't do that. All it does is choose the correct multiplier to set the required voltage demand to provide the requested spindle speed in whatever gear is detected.

You could use wcomp in addition to this to illuminate "higher gear needed" and "lower gear needed" LEDS based on the voltage requested being >9.5 or <5 volts (as examples)

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

More
19 Aug 2014 01:40 #50017 by mariusl
Ok I understand. That makes sense. In my case the highest spindle speed is also the highest motor speed on the last gear. So I have six speed ranges which are all achieved with full voltage.
I have found very strange behaviour with CSS when it cannot reach the required speed. If I just change some settings it will go supper fast or supper slow. It puts out a request for 1500 RPM and the gear allows only 850.
I think I need to set things up in such a way that I am told what gear to select. Or at least what range the CSS will work in correctly.
Am I right in thinking that the system uses the spindle feedback to control the CSS when using a G96?

Regards
Marius


www.bluearccnc.com

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

More
19 Aug 2014 01:58 #50019 by andypugh

Am I right in thinking that the system uses the spindle feedback to control the CSS when using a G96?


No.

All that CSS does is output a speed request (motion.spindle-speed-cmd (or whatever it is actually called)) to match the current S-number and the current X position.

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

Time to create page: 0.088 seconds
Powered by Kunena Forum