LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with control and simulation loop

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 7
(4,772 Views)

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.

aputman
0 Kudos
Message 2 of 7
(4,759 Views)

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.

0 Kudos
Message 3 of 7
(4,757 Views)
Solution
Accepted by topic author Loukask

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.  

aputman
0 Kudos
Message 4 of 7
(4,746 Views)

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.

Download All
0 Kudos
Message 5 of 7
(4,707 Views)
Solution
Accepted by topic author Loukask

"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.


GCentral
Message 6 of 7
(4,705 Views)

Thank you. That was actually the problem. I had a big simulation time and it delayed a lot. Now i fixed it. 

0 Kudos
Message 7 of 7
(4,699 Views)