Spindle PID control
28 Mar 2017 15:15 #90447
by vilts
Spindle PID control was created by vilts
Hi,
I have a retrofit lathe with Mesa 5i25+7i76 and Omron 1000ppr ABZ spindle encoder. Spindle speed is controlled with 0-10v to VFD, but the speeds are wrong. Voltages coming from 7i76 are correct, so I think there's some non-linearity in the VFD control. At lower speeds the actual speed is too high and on high rpm range actual speeds are lower.
For few days I've read about the PID control and different threads about it, but so far I haven't really understood how it should work.
The configs are attached. I read somewhere that for a start I should change the FF0 until the speed is sort-of-correct and then follow with I and P. But changing these values doesn't change anything for me. Currently the configs are as they came from config wizard, no my changes present.
How should I proceed with debugging and fixing it? It looks to me like the PID "process" should be attached and processing "stuff", but I'm not getting the results...
I have a retrofit lathe with Mesa 5i25+7i76 and Omron 1000ppr ABZ spindle encoder. Spindle speed is controlled with 0-10v to VFD, but the speeds are wrong. Voltages coming from 7i76 are correct, so I think there's some non-linearity in the VFD control. At lower speeds the actual speed is too high and on high rpm range actual speeds are lower.
For few days I've read about the PID control and different threads about it, but so far I haven't really understood how it should work.
The configs are attached. I read somewhere that for a start I should change the FF0 until the speed is sort-of-correct and then follow with I and P. But changing these values doesn't change anything for me. Currently the configs are as they came from config wizard, no my changes present.
How should I proceed with debugging and fixing it? It looks to me like the PID "process" should be attached and processing "stuff", but I'm not getting the results...
Please Log in or Create an account to join the conversation.
28 Mar 2017 20:06 #90457
by PCW
Replied by PCW on topic Spindle PID control
Note these three lines in your hal file: (reorganized for clarity)
net spindle-output <= pid.s.output
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-vel-cmd-rpm-abs => hm2_5i25.0.7i76.0.0.spinout
These mean that the analog output is set by the spindle speed from motion
(motion.spindle-speed-out-abs), not from the PID output
To have the PID output set the analog voltage, you would need to change
net spindle-vel-cmd-rpm-abs => hm2_5i25.0.7i76.0.0.spinout
to
net pid.s.output => hm2_5i25.0.7i76.0.0.spinout
net spindle-output <= pid.s.output
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-vel-cmd-rpm-abs => hm2_5i25.0.7i76.0.0.spinout
These mean that the analog output is set by the spindle speed from motion
(motion.spindle-speed-out-abs), not from the PID output
To have the PID output set the analog voltage, you would need to change
net spindle-vel-cmd-rpm-abs => hm2_5i25.0.7i76.0.0.spinout
to
net pid.s.output => hm2_5i25.0.7i76.0.0.spinout
The following user(s) said Thank You: vilts
Please Log in or Create an account to join the conversation.
28 Mar 2017 20:33 #90462
by vilts
Replied by vilts on topic Spindle PID control
Allright, I think the logic is dawning now.
There's also defined:
net spindle-output <= pid.s.output
So I could just as well do this, right?
net spindle-output => hm2_5i25.0.7i76.0.0.spinout
Just setting variables as the arrow is pointing...
There's also defined:
net spindle-output <= pid.s.output
So I could just as well do this, right?
net spindle-output => hm2_5i25.0.7i76.0.0.spinout
Just setting variables as the arrow is pointing...
Please Log in or Create an account to join the conversation.
28 Mar 2017 21:01 #90465
by PCW
Replied by PCW on topic Spindle PID control
Yes, you are correct, my example would not work as you
cannot have a pin (like pid.s.output) used as a net
net syntax is:
net net-name pin pin pin pin ...
Note that the arrows are just for looks (they dont do anything)
cannot have a pin (like pid.s.output) used as a net
net syntax is:
net net-name pin pin pin pin ...
Note that the arrows are just for looks (they dont do anything)
Please Log in or Create an account to join the conversation.
29 Mar 2017 11:43 #90497
by andypugh
An alternative to PID would be to use a linearisation curve and to correct the command open-loop.
linuxcnc.org/docs/2.7/html/man/man9/lincurve.9.html
PID is probably more adaptable and accurate.
Replied by andypugh on topic Spindle PID control
I think there's some non-linearity in the VFD control. At lower speeds the actual speed is too high and on high rpm range actual speeds are lower.
For few days I've read about the PID control and different threads about it,
An alternative to PID would be to use a linearisation curve and to correct the command open-loop.
linuxcnc.org/docs/2.7/html/man/man9/lincurve.9.html
PID is probably more adaptable and accurate.
Please Log in or Create an account to join the conversation.
29 Mar 2017 14:10 #90503
by vilts
Replied by vilts on topic Spindle PID control
Well, I tried the config changes out, but something is still wrong and I have no idea how to approach this. Currently config states:
net spindle-output => hm2_5i25.0.7i76.0.0.spinout
But the feedback loop behaves strangely. Whenever I set only P value, the spindle speed is changed to static value, either higher or lower from the commanded one. I think that is expected.
However, if I set something for the I value, the speed is ramped up to the max (in case of positive I) or min (negative I), it doesn't settle to the commanded value. Speed of change depends on the I value. I tried very small I value to see if the rate of change somehow messes with the "settlement", but nope. I will go to max or min, no matter the I value.
D value didn't seem to do anything. Or I didn't know which combination of the PID to try.
I poked around a little with halmeter and got these values for different pid.s values
That was for S200. pid.s.feedback seems to be always 0, is that correct?
lincurve could be an option indeed, but PID would be much awesomer
net spindle-output => hm2_5i25.0.7i76.0.0.spinout
But the feedback loop behaves strangely. Whenever I set only P value, the spindle speed is changed to static value, either higher or lower from the commanded one. I think that is expected.
However, if I set something for the I value, the speed is ramped up to the max (in case of positive I) or min (negative I), it doesn't settle to the commanded value. Speed of change depends on the I value. I tried very small I value to see if the rate of change somehow messes with the "settlement", but nope. I will go to max or min, no matter the I value.
D value didn't seem to do anything. Or I didn't know which combination of the PID to try.
I poked around a little with halmeter and got these values for different pid.s values
net spindle-index-enable <=> pid.s.index-enable # FALSE
net spindle-enable => pid.s.enable # TRUE
net spindle-vel-cmd-rpm-abs => pid.s.command # 200
net spindle-vel-fb-rpm-abs => pid.s.feedback # 0
net spindle-output <= pid.s.output # 200
That was for S200. pid.s.feedback seems to be always 0, is that correct?
lincurve could be an option indeed, but PID would be much awesomer
Please Log in or Create an account to join the conversation.
29 Mar 2017 14:19 #90504
by andypugh
Replied by andypugh on topic Spindle PID control
It looks like you do not have any feedback, so the PID will, as you have noticed, ramp up indefinitely.
You probably have spindle speed into HAL from the encoder? You will need to pass this through an ABS component and into the spindle-vel-fb-rpm-abs signal.
You probably have spindle speed into HAL from the encoder? You will need to pass this through an ABS component and into the spindle-vel-fb-rpm-abs signal.
Please Log in or Create an account to join the conversation.
29 Mar 2017 14:37 - 29 Mar 2017 14:41 #90506
by vilts
Replied by vilts on topic Spindle PID control
Thanks, that makes sense.
To see if that really made sense, here's the spindle speed part from my current config
So, to connect the abs spindle speed to the pid feedback I'd need to do this:
Or should I use the non-lowpassed abs value for feedback?
To see if that really made sense, here's the spindle speed part from my current config
setp scale.spindle.gain 60
setp lowpass.spindle.gain 0.005000
net spindle-vel-fb-rps => scale.spindle.in
net spindle-fb-rpm scale.spindle.out => abs.spindle.in
net spindle-fb-rpm-abs abs.spindle.out => lowpass.spindle.in
net spindle-fb-rpm-abs-filtered lowpass.spindle.out
So, to connect the abs spindle speed to the pid feedback I'd need to do this:
net spindle-vel-fb-rpm-abs <= lowpass.spindle.out
Or should I use the non-lowpassed abs value for feedback?
Last edit: 29 Mar 2017 14:41 by vilts.
Please Log in or Create an account to join the conversation.
29 Mar 2017 15:09 #90511
by andypugh
Replied by andypugh on topic Spindle PID control
This is starting to look like just a confusion about signal names.
Try changing:
net spindle-vel-fb-rpm-abs => pid.s.feedback
to
net spindle-fb-rpm-abs => pid.s.feedback
Try changing:
net spindle-vel-fb-rpm-abs => pid.s.feedback
to
net spindle-fb-rpm-abs => pid.s.feedback
Please Log in or Create an account to join the conversation.
04 Apr 2017 20:21 #90883
by vilts
Replied by vilts on topic Spindle PID control
I got this working with lincurve, that is nice.
I tried many-many combinations to get the PID control loop working, but to no avail. Just couldn't get it stable. Method I tried was to increase the P until output started oscillating (happened at around P=4) and the started increasing I to get rid of the oscillation. But increasing I never got rid of the oscillation, and at some higher levels it started to increase it.
Was this method wrong somehow? How should it actually be done and what are the approx numbers the P, I and D? 0.1, 1, 10, 100, 1000? I have no idea.
I tried many-many combinations to get the PID control loop working, but to no avail. Just couldn't get it stable. Method I tried was to increase the P until output started oscillating (happened at around P=4) and the started increasing I to get rid of the oscillation. But increasing I never got rid of the oscillation, and at some higher levels it started to increase it.
Was this method wrong somehow? How should it actually be done and what are the approx numbers the P, I and D? 0.1, 1, 10, 100, 1000? I have no idea.
Please Log in or Create an account to join the conversation.
Time to create page: 0.112 seconds