Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrator in saturation #19

Open
pterodaktil02 opened this issue Sep 13, 2022 · 11 comments
Open

Integrator in saturation #19

pterodaktil02 opened this issue Sep 13, 2022 · 11 comments

Comments

@pterodaktil02
Copy link

pterodaktil02 commented Sep 13, 2022

In steady state PID = Kp * error + Ki(previous integral + error) + Kd(error - last)
= 0 + Ki (previous integral + error) + 0
= Ki (previous integral + error)
So output of PID controller at the steady state is equal to integral term.

A problem arises if the regulator is in the saturation zone for a very long time.
Therefore, if the regulator is in the saturation zone, it is necessary to reduce the integral component.
I tried this but my knowledge of python is very low.
Instead of self._i_term += self._ki * error * delta_time I set this code

        if self._last_output == 0 :
           self._i_term += 0
        elif self._last_output == 100 :
           self._i_term += 0 
        else:           
           self._i_term += self._ki * error * delta_time 

Maybe add this fix to the main plugin?

@soloam
Copy link
Owner

soloam commented Oct 17, 2022

Basicly what you mean is that the pid should not do anything if reaches 0 or 100? Doesn't he already do that? The min and max values are constrained, it should not raise above the maximum, or lower bellow the minimum!

@lukepighetti
Copy link

I'm also having extreme saturation problems with the integral component, I believe

@pterodaktil02
Copy link
Author

pterodaktil02 commented Oct 18, 2022

Basicly what you mean is that the pid should not do anything if reaches 0 or 100? Doesn't he already do that? The min and max values are constrained, it should not raise above the maximum, or lower bellow the minimum!

When the control action on the object reaches saturation, the feedback is broken (the control action does not depend on the state of the system).
Even with windup, the integrator continues to integrate, the signal at its output grows, but this signal does not participate in the regulation process.
I suggest turning off the integration when the regulator is in saturation.
This will have a good effect on the transient process, reduce oscillations after exiting saturation.

@soloam
Copy link
Owner

soloam commented Oct 18, 2022

I have seen that behavior, turn off the integrator, when the system is saturated!

You could do this if you use templating in the 'I' variable, but I agree that should be automatic!

I'll look into it!

Tks

@pterodaktil02
Copy link
Author

I added the solution in the start thread.
I just don't know how to add commits.

@soloam
Copy link
Owner

soloam commented Oct 18, 2022

I'll try to take a look at this tomorrow, let me see what I can do!

@hauard
Copy link

hauard commented Oct 29, 2022

I'll try to take a look at this tomorrow, let me see what I can do!

Any luck with this? Having the same issue

@pterodaktil02
Copy link
Author

I'll try to take a look at this tomorrow, let me see what I can do!

Any luck with this? Having the same issue
You can make it yourself - just open pidcontroller.py and change after code after

# Calculate terms

from
self._i_term += self._ki * error * delta_time
to

        if self._last_output == 0 :
           self._i_term += 0
        elif self._last_output == 100 :
           self._i_term += 0 
        else:           
           self._i_term += self._ki * error * delta_time 

@soloam
Copy link
Owner

soloam commented Nov 9, 2022

Merged into 1.1.5

@soloam soloam closed this as completed Nov 9, 2022
@hauard
Copy link

hauard commented Nov 10, 2022

I'm no expert in coding, but after the last update, it seems that the readout of the integral-attribute is in saturation, but maybe not the regulator itself? I get the attribute
i: 2.3816e-16

I have the min/max to 0-100, windup to 100, and earlier the readout of the integral was the max-vaule, 100

@soloam
Copy link
Owner

soloam commented Nov 10, 2022

The expected behavior is to the PID to increment the "I" until the output reaches the maximum. When on maximum the "I" will stop incrementing and remain constant. That is the expected. But should resume incrementing the "I" if the output falls bellow the maximum.

@soloam soloam reopened this Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants