06-06-2017 01:54 PM
Hello everyone,
i am trying to create a control loop with a PID controller. I am attaching the VI i have created. I want to take as setpoint inputs values from a file and when the process variable is equal to setpoint go to next value. But for some reason i dont think it is working correctly. Please help.
P.S i attach a file with values for setpoint
Solved! Go to Solution.
06-06-2017 02:26 PM
What does it do that makes you think it isn't working correctly? Unfortunately, I can't open your file but based on your description, I deduce that it either never makes it to the next step (are you checking for equality on a floating point value?) or it makes it to the end of the file much quicker than you expect.
06-06-2017 02:32 PM
Yes actually from what i see when running it, it doesn't go to the next value. I attach a png also to check it.
06-06-2017 02:39 PM
I do see an equality check on two doubles. That is going to be your problem. If you expand the precision of those two numbers far enough, you'll see that they are not equal. The better solution might be to keep a running sum of the latest N readings and calculate the standard deviation. If that value is below some threshold, then change to the next setpoint.
06-07-2017 04:24 AM
I changed the condition for going to next value. It works as i would like, the matter is that for some reason the true/false value doesn't pass out of the control and simulation loop. Inside the simulation loop the condition works fine ( check "x and y" indicator whichs shows TRUE, when the "boolean" indicator should also show TRUE but is FALSE. I can't understand why. I attach too photos in order to check it.
06-07-2017 04:27 AM - edited 06-07-2017 04:31 AM
"boolean" will take the last value of the "x and y" value when the inner loop finishes.
The values inside a loop aren't passed to the outside of the loop until the loop finishes running. This is a core concept in LabVIEW (and key to many clean-up routines for data acquisition).
In your case, it's unclear how many iterations the inner loop is carrying out, but I think the default is t=0->10, dt=0.1, so 100 steps. With a 5ms wait, that should take at least 500ms, but might take much longer depending on how long the code in the loop requires to execute.
06-07-2017 05:04 AM
Thank you. That was actually the problem. I had a big simulation time and it delayed a lot. Now i fixed it.