Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

PID Structure and Computation Question

Hello,
 
This is a question and perhaps a note for users to be aware of.
 
When using the PID VI's to control multiple systems the PID VI correctly calculates the output when the inputs are given in the form of an array. It seems however that the PID VI has not been design to be used in a For-Loop. Please see the attached example.
 
Has anybody else encountered anything similar?
 
Respectfully,
-Ron
0 Kudos
Message 1 of 7
(4,195 Views)
0 Kudos
Message 2 of 7
(4,203 Views)
Hi Mucam: The reason you are getting wrong values is because you are using the 2 instances of the PID vi incorrectly.

To start: there are 2 instances of the PID VI, a. PID (DBL) b. PID (DBL Array)

Now, if you look inside these VIs you will see a bunch of uninitialized shift registers. The shift registers store values from previous runs of the while loops so that the integral can sum up errors from previous runs and the derivative can do the same. Now however, in the second version of the VI you sent (the incorrect one using the for loop), the first time the for loop runs, some values from process 0 (or machine 0 are stored in the shift register). The next time this for loop runs you actually want to calculate values for process 1 (or machine 1) but the values you are getting from the shift register are from process 0. Hence previous values from process 0 are used to calculate the integral and derivative for process 1. This is whats causing the error. Thus for your application, you would need 3 different PID VIs if you want to use the for loop. A note about this is present in the help file as well:

The DBL Array type of this polymorphic function can be used in multi-loop PID control applications. In this case, the length of the primary input array will determine the length of the output array. Other input arrays do not necessarily need to be the same length as the primary input array.

The term "multi-loop PID control applications" is I think what you are trying to do. In PID each loop is designated to a process hence if you have multiple processes you need multiple loops. If you feed the PID VI an array it automatically knows which instance of the polymorphic VI to use. However, using by using a scalar you are using a single loop for a multi-loop application.

I hope that helps.

Let me know if you have more questions.

Best Regards,
Jaideep Jhangiani
National Instruments
Message 3 of 7
(4,175 Views)
DimensionFinder,
 
Thank you for your reply. It was very helpful. I have attached another VI with profiles added. Is this the correct implementation of multiple profiles? (I left out subVI's so that the upload would be simpler.)
 
Respectfully,
Mucam
0 Kudos
Message 4 of 7
(4,159 Views)
Hi Mucam: It might work, but I think it is still incorrect. You need multiple instances of the PID.vi This is the same VI that you had in your for loop in the earlier incorrect version. The reason for this is that the PID VI is the one doing the integrals and taking the derivatives. You need to make sure that the values going to the integral and derivative VIs are for the same machine. (The values going to these VIs come from the shift register). Hence you need multiple instances of THAT vi and not the set profile vi.
0 Kudos
Message 5 of 7
(4,149 Views)

DimensionFinder,

Why would the PID VI accept an array of inputs unless it was designed to handle multiple systems at once?

-Mucam

0 Kudos
Message 6 of 7
(4,144 Views)
Mucam: Im sorry my last post was incorrect. I was confused. What you did should work.
0 Kudos
Message 7 of 7
(4,128 Views)