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