PID Windup on the way down

More
10 months 1 day ago #340682 by ContinenteCNC
Hi folks!

The current PID hal module has a maxoutput pin to avoid integrator windup, but wasn't it supposed to have also a minoutput pin?

I am currently setting up a basic spindle control for a lathe and I am experiencing windup when I have to go from a higher spindle speed to a lower speed. On the way up it works just fine (well tuned)

Then I noticed that the PID output goes negative for a while during the ramp down, so the integrator is winding up to the negative side. This doesn't make sense from the DAC/VFD point of view, once the lower voltage they can handle is 0V. (I am using 0-10v analog control)

What I've just wrote make sense? Or am I just shaming myself publicly again? 

Please Log in to join the conversation.

More
10 months 1 day ago #340697 by NWE
Replied by NWE on topic PID Windup question/suggestions
Pid maxoutput limits in the positive and negative direction. So, you can set maxoutput to 1.0 and it will limit the output in the range of 1.0 to -1.0

I'm not sure what it would take to prevent windup below 0.

For what its worth, one thing that has bit me in the past in trying to tune PID and lots of troubles with windup: slow vfd accel/decel. If the PID is tuned to respond faster than the ramp time of the VFD, that'll wind it up.

Also, a hal limit1 component might be in order to prevent sending a negative voltage to the vfd analog input, some kinds smoke when they get negative signals.

Please Log in to join the conversation.

More
10 months 16 hours ago #340736 by ContinenteCNC
In my case, there is no need to limit the output at zero. I am using pwmgen to generate the 0–10 V signal in type=0, so any negative PID output is clamped to zero.

The PID behaves correctly during ramp-up, since the output is limited to the maximum possible pwmgen value. The derivative gain provides enough damping to prevent overshoot in that direction. However, during ramp-down, there is a small amount of overshoot. It is minimal and perfectly acceptable for my application.

I was just wondering whether it would be useful to have a minoutput pin, allowing the lower limit to be set to zero instead of -maxoutput.

Please Log in to join the conversation.

More
9 months 4 weeks ago #340854 by ContinenteCNC
I have edited the original pid.c to include a minoutput pin, and now it works like a charm. There is no windup and zero overshoot on the way down, just like on the way up.

To install it, open a terminal in the folder containing the modified pid.c and run:
Code:
sudo halcompile --install pid.c

Then set the minoutput pin to the minimum ADC value your setup can handle. In my case, this value is zero, since I am using a software pwmgen to generate a 0–10 V signal:
Code:
setp pid.0.minoutput 0.0

This is the piece of code I have customized:
Code:
/* apply output limits */ if (*(pid->maxoutput) != 0.0) {     if (tmp1 > *(pid->maxoutput)) {         tmp1 = *(pid->maxoutput);         pid->limit_state = 1.0;     } else if (tmp1 < *(pid->minoutput)) {         tmp1 = *(pid->minoutput);         pid->limit_state = -1.0;     } else { pid->limit_state = 0.0; }   

Please Log in to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum