Spindle PID troubleshooting -- solved

More
04 May 2020 15:59 #166632 by paulctan
Linuxcnc 2.8pre on mint.

Everything has been working fine for a while now. I started trying to fix my spindle speed (it's been running a little bit slower than programmed). Spindle is controlled from Mesa card via Analog 0-5V output.

I set the P=0.4, FF0=1.0, everything else 0.

See attached photo for halshow.

spindle-vel-fb-rps is 13.94723, and spindle-vel-cmd-rps is 16.66667
but, (see photo circled items), spindle actual rpm is 1293 when I commanded 1000.

What am I missing? Am I looking at the correct hal variables? Is there a hal variable to show the PID error?

Thanks.

Paul Tan.


[SPINDLE_9]
P = 0.4
I = 0.0
D = 0.0
FF0 = 1.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 4700
ENCODER_SCALE = 8192.0
OUTPUT_SCALE = 4700
OUTPUT_MIN_LIMIT = 0
OUTPUT_MAX_LIMIT = 4700
Attachments:

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

More
04 May 2020 16:44 #166637 by tommylight
Can your spindle do 4700 RPM at 5V input ?
Check the scaling so it corresponds to what it actually can do at 5V.

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

More
04 May 2020 17:50 #166647 by paulctan
Yes, the spindle can do 5000 RPM. Scaling is not the issue. The spindle RPM is not linear to the output voltage (or, the output voltage might not be linear). I wanted to use the PID loop to adjust the output voltage accordingly. I.e., at low RPM, e.g. 500 RPM, I get actual RPM of about 420, at 1000 RPM, I get 950, at 2000 RPM I get 1950. At 4500 RPM, I get 4400 RPM. Not perfectly linear. I wanted to close that feedback loop.

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

More
04 May 2020 18:51 #166656 by tommylight
What encoder is on the spindle and how is that scaled in hal ?

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

More
04 May 2020 19:31 #166664 by paulctan
Encoder is built into the DMM DYN4 servo motor. I am scaling it based upon the pulley ratio. But, that's not the issue. My issue is why the PID error is wrong based upon what the system is seeing.

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

More
04 May 2020 20:17 #166672 by paulctan
Hmmm... should I be asking this in the configuring linuxcnc section instead? or maybe in the HAL section? Asking the moderators here if it should be moved or not.

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

More
04 May 2020 20:39 #166676 by tommylight
I can move it there, seems more appropriate .
Thank you.

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

More
05 May 2020 06:28 #166739 by Hakan
Replied by Hakan on topic Spindle PID troubleshooting
First you need to make sure that the pid.s component is actually used. Check the hal file. If you attach it here people can check for you.

If that is all good, I would say to set P=0 and adjust FF0 so the actual spindle speed agrees well with the commanded speed. Judging from your experiments FF0 should be perhaps 1.05.

Then start to increase P until the error is as small as you want. You can go on with I and D. The error is in the pid.s.error pin.

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

More
05 May 2020 14:58 #166777 by PCW
Replied by PCW on topic Spindle PID troubleshooting
Yes, you probably need to increase P, you have

P = 0.4

Which means if you are 100 RPM low the PID output only adds
the equivalent of 40 RPM to the commanded speed...

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

More
05 May 2020 18:03 #166782 by paulctan
That's not the problem. The problem, if you look at the screenshot, is that it's overshooting the compensation, but the hal variables in the screenshot show that it's still below. Screenshot shows the spindle already at 1293 RPM, but the setting is set for 1000 RPM. This is with P=0.4. It should have attempted to decrease the spindle speed, but, if you look at the halshow output, it shows that spindle-vel-fb-rps is 13.94723, and spindle-vel-cmd-rps is 16.6667, so, it's behaving correctly if you look at the rps variables. BUT, the spindle-fb-rpm is 1315.024, and that is CLEARLY above the G code spindle speed of 1000 RPM.

I need someone to tell me what hal variables to look for to further debug this problem.

Thanks.

Paul Tan.

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

Time to create page: 0.180 seconds
Powered by Kunena Forum