From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

continuously changing PID gains

Solved!
Go to solution

I am using the PID Advanced VI to effect a pressure controller, and had attempted to vary the proportional gain input to the VI by means of an equation based on other parameters, such that the behaviour was similar to gain scheduling, only contiguous versus stepwise.  Unfortunately, it appears that the PID VI cannot handle PID gains which are continuously variable from iteration to iteration.  The output is zero, and digging into the block diagram of the PID VI, it is barely readable, but appears to do something different upon detection of a change in PID gains.  So, my question is, is there any simple way to do what I'm trying to do with the NI-supplied VIs, or am I limited to fixed PID gains?  Could I get around the problem by allowing the algorithmically calculated proportional gain to persist for some number of iterations before allowing an update?

 

 

 

 

0 Kudos
Message 1 of 10
(4,376 Views)

Hi STS,

 

Unfortunately, it appears that the PID VI cannot handle PID gains which are continuously variable from iteration to iteration.

That function "resets" internal buffers on change of PID parameters…

 

digging into the block diagram of the PID VI, it is barely readable, but appears to do something different upon detection of a change in PID gains.

Yes to both statements: it is "barely readable" and it does reset internal buffers on PID change…

 

So, my question is, is there any simple way to do what I'm trying to do with the NI-supplied VIs, or am I limited to fixed PID gains?

The simple way is as usual: when you have a VI that does not all that you want it to do you can create your own copy of that VI and change the things that annoy you…

 

I did it for the advanced PID for exactly the same reason…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,363 Views)
Is there any particular reason that such a reset is necessary? Why is this the default behaviour?
0 Kudos
Message 3 of 10
(4,355 Views)

Hi STS,

 

the PID has internal buffers, especially for the integral behaviour.

When the PID parameters change those internal buffers can act wired (depending on the parameter change) so it is (more) safe to reset the PID and start with fresh/cleared buffers!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(4,340 Views)
So I trust then that I can simply remove the shift registers involved in the gain change comparison, nullifying that condition as a reset action, and then send my own reset signal (in addition to First Call?) when warranted?
0 Kudos
Message 5 of 10
(4,337 Views)
Solution
Accepted by topic author CFER_STS

Hi,

 

yes, you can.

 

Remember: create your own copy of the VI before you change it! Never change VIs in vi.lib!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(4,335 Views)

Hey,

 

I am having the same problem, but I still don't know how to fix it.

 

My problem is that I want to change the gain parameters of a PID controller based on the output of a fuzzy controller.

 

So the output of the fuzzy has the three gains, and when I connect it to the PID gains, the output will be constant.

 

Can you show me a screenshot on how to fix it. 

 

Thank you,

 

I have my code attached

Download All
0 Kudos
Message 7 of 10
(4,189 Views)

Just for more clarification I think that the way that Gerd is describing is to go into the PID VI and change what happens when the PID gains are changed from one run to the next. One way to do this is force the case structure inside the VI to always be true so it never gets to the false case which states "PID gains have changed since last iteration".

Scott B.
AE NI
0 Kudos
Message 8 of 10
(4,146 Views)

Hi, I am agree with you, as you mention is a easy solution, but however When you modify the PID gains you gonna affect the actual error value (in the case of Integral) because you are multiplying your actual error times the new gain value. This is not desireable because the accumulated error has to be independent of your new gain.

 

Has anyone implemented a PID vi. that enables Gains changes in an easy way?

 

Thanks

0 Kudos
Message 9 of 10
(3,614 Views)

Hi Javimeloc,

 

I just disabled the "reset" feature of the original PID from NI and don't care about the accumulated error. (I change gains only in small steps.)

 

You might also scale the error with your new I-gain…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(3,596 Views)