LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When PID is reinitialized, it stays low

I am using a PID to control a power supply which alters its output in response to a current signal.  I am writing the output of the PID to the power supply via a compact field point, and reading the current produced by the power supply with a current transducer, which becomes the process variable.  It all works fine until I reinitialize the PID, or sometimes when it is first enabled.  Often what happens is that the PID will only put out the lowest possible output even though the set point is clearly higher than the process variable.  If I then alter one of the PID gains, the signal will jump, then begin to behave normally until I reinitialize it again, at which time it will often end up stuck low again.

I wrote a VI that simulates the response of the power supply, and the PID displays the same behavior.  Is this normal?  No matter how I set the gains it behaves the same, it always ends up stuck putting out 4mA no matter what I set the target to.

~Jo-Jo
0 Kudos
Message 1 of 8
(3,893 Views)

My PID is a little rusty and I don't have the PID VIs in front of me, but are you wiring a value into the dt terminal? This might screw this up.

Keep in mind that you can dig into the PID VIs to see exactly why this is happening.

If this doesn't help, you should post an example of your problem so that there is a baseline to play with.


___________________
Try to take over the world!
0 Kudos
Message 2 of 8
(3,881 Views)
Well, it took me way longer than it probably should have, but I discovered the problem.  In the integral portion inside the PID VI, just before the integral portion gets added to the derivative portion, the integral portion gets checked against the high output range using the max & min function.  If it is not greater than the high output range, then the integrated error gets set to zero.  The inegrated error is then added to the rest of the integral portion of the PID on the next iteration.  However, if the integral portion of the PID minus the integral error is less than the minimum output range, and the minimum output is greater than zero, the integral error will always be zero, and the output will keep getting coerced to the minimum output value forever, and ever.  The way I fixed this, is to set the minimum integrated error (on the max & min function) to the minimum output value instead of zero.  This probably isn't very clear, but if you look at the code it will hopfully make sense.  Is this a mistake in the PID VI?  Unless I am missing something, it seems that it is assumed that the PID minimum output will always be less than or equal to zero, but the user has the option of setting it higher, which is what I did.  I guess I should have stuck with using a percentage out, like in the examples, but nowhere does it say that I had to, which also makes me think that this is a mistake in the code.

~Jo-Jo
0 Kudos
Message 3 of 8
(3,878 Views)

On my computer (LV 7.0, don't know which version of the control toolkit) it looks like this:

If I understand you correctly, your version is different, but I don't know if yours is older or newer than mine.

When I do hit an edge, a reinitialize can reset it, if I remember correctly.


___________________
Try to take over the world!
0 Kudos
Message 4 of 8
(3,862 Views)

Jo-Jo,

I tried repeating your setup, and I haven't been able to produce the same problem you have been seeing.  I am using LabVIEW 8.20 with PID 8.2, so this may be something that has already been addressed.  Would it be possible to attach the VI that you used to simulate your system?  This way I will be able to see whether this is an issue with a previous version, and if it is still a problem I can make sure that it is addressed in the future.

Chris M.
Applications Engineer
National Instruments

0 Kudos
Message 5 of 8
(3,843 Views)
Fellas,

Thanks for the responses.

Here are the two VIs I was using to test the PID.  The Payne Sim simulates the response from the power supply we are using which uses an input  which ranges from 4-20mA.  It should work with the current default values for all the controls.  If "reinitialize the PID" is pressed, the signal from the PID goes to 4, and stays there until one of the PID gains is changed, which changes the integrated error in the PID.

~Jo-Jo
Download All
0 Kudos
Message 6 of 8
(3,840 Views)

I can't look at your code, but you might want to check out the Info LabVIEW archives.

These messages, for example, I remember dealing with bugs in older versions of the PID toolkit.


___________________
Try to take over the world!
0 Kudos
Message 7 of 8
(3,833 Views)

Jo-Jo,

I ran your simulated system, and I was able to make it work properly by changing the PID parameters.  Decreasing the Integral Time and the Proportional Gain seems to work much better.  I think what is happening is that the system is getting caught in a cycle where the PID controller tries to output a value below the minimum, and the feedback from the simulated Plant perpetuates this.  Typically, this sort of issue is solved by further tuning of the PID parameters.  Please let me know if this is helpful.

Chris M.
Applications Engineer
National Instruments

0 Kudos
Message 8 of 8
(3,796 Views)