LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it important to reinitialize the PID alorithm each time I use it ?

Hi,

With Labiview 7.0 RT and the PID toolSet if you use the PID.vi, you can reinitialized it (boolean). This is in order to "clear" Integrate and Derivate error values when you use the vi for a new control sequence. But, what is the problem if I don't reinitialize it? What appends on the control loop?

Thanks,

Benj.
0 Kudos
Message 1 of 15
(7,997 Views)
It's been a while since I used the PID VIs, but the very definition of PID states that it needs to remember the previous data. Also, looking at the code of the PID VIs, you can see that they use a data structure known as a functional global. That's a loop with an uninitialized shift register that runs only once each time. Since the shift register is uninitialized it keeps the data from the last run. If the Initialize input is T, the shift register is reset. So, to answer your question, if you don't wire T into initialize, the PID VI will remember the values from your previous sequence and they will probably affect at least the beginning of your current sequence.

___________________
Try to take over the world!
0 Kudos
Message 2 of 15
(7,984 Views)
I understand that it will affect the first time the loop runs because the shift register contain a value related to the first control sequence. But, will it affect the loop's behaviour for several iterations or not? Is the alogrithm sensitive to old values (memory effect)?
0 Kudos
Message 3 of 15
(7,979 Views)
To be honest, I don't remember, but I think that under certain conditions the PID function will use averages and similar things that probably do have an effect for several readings. I just use the initialize input.

___________________
Try to take over the world!
0 Kudos
Message 4 of 15
(7,976 Views)
Hello,

Integral action eliminates offset proportionally to the amount of time the error is present. If you enable reinitialization of the PID VI (which set integral and derivative action to 0), you will have an offset that you cannot avoid between the process variable and your setpoint.
You can see this behavior with the "General PID Simulator.vi" example provided with LabVIEW.
0 Kudos
Message 5 of 15
(7,961 Views)
I agree with you : Integral action eliminates static error (offset) so it's important to keep integral action active.
But I would like to know what happens if I start a new control sequence without clearing the I and D shift register (reinitialize PID.vi at the first iteration). Is it dangerous for system stability? PID algorith will be slower or less efficient? Or nothing else?
0 Kudos
Message 6 of 15
(7,958 Views)
Odds are you'll want to reinitialize for each run, especially the integral term. I can imagine cases where you might not, but I think they'd be pretty unusual.

Remember the basic definition. The integral term stores the cumulative sum of the error signal from your previous run. If your last term ended before driving this integral back to 0, it could be the dominant term in your PID when you start your next run. It could also be of the wrong sign, causing your next response to start in the wrong direction. The old stored value ("wind-up") may affect your next response for a substantial amount of time as the old cumulative error must first be "dissipated" before the system responds normally to the present input.

The derivative term is probably a smaller issue -- it's usually a smaller term in most control loops anyway, and it's unlikely to have a very long memory effect. It doesn't accumulate error, it just remembers old error values long enough to calculate a derivative. Its effect will probably return to normal within a couple control loop cycles or so.

Still, since you probably will need to reset your integrator, you might as well also reset your derivative.

-Kevin P
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 7 of 15
(7,953 Views)
The PID vi is initialized the first time it is run. It will set the initial value of the integral to zero, and will calculate the derivitive term only after the 2nd call (when at least a true previous measurement is available).
Normally you leave the reset unwired, and things will work fine. If you are controlling to a set point, and , you can change the set point , the PID will control smoothy, will go from one set point to the other without any hickup.
If you stop the control, may be by forcing the output voltage to zero (and bypassing the PID, like putting it in a case structure), the next time you call the PID (the other case of the case structure), the control voltage will be initialzed from the previous settings of derivitive and integral. This will create a hickup for he first iterations since the measurement does not match the coressponding control voltage. After some iterations it will recover. In a case like that, you will have to reset the PID once.
Note also if you stop the vi from running (stop LabView), next time it runs it will automatically reset.
0 Kudos
Message 8 of 15
(7,948 Views)
So, I have to reinitialise pid.vi each time I run a new control loop because between 2 of them, it's possible the user of the program forces the output, and anyway I have to clear cumulative error from integral parameter.

Otherwise, I would like to control several quantities during a run (for instance 1 presure, 1 flow and 1 temperature...) with each there own P I D parameters.
I know that I can't use PID.vi (Double) because it will use the same algorithm with the same shift registers for all the different quatities.
Perhaps, I can use the PID.vi(Array) - polymorphic form. But the problem is during a first run of 60 seconds, I have to control presure from 0s to 60s, flow from 30s to 60s and temperature from 10s to 50s. Thus, I have to reinitialise each PID algorithm the fist time : 0s for presure, 30s for flow and 10s for temperature. Then, next run will last 100s and times and parameters will change.

How can I carry out this?
0 Kudos
Message 9 of 15
(7,917 Views)
You do not have to use the array_version of the PID vi. The PID vi is reentrant. so if you use the pid vi in several places, each will have its own data space. So you can control pressure, temperature, and flow with the same "reentrant PID.vi" independly, without worrying about interaction of integral values etc...
Message 10 of 15
(7,910 Views)