From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait (ms) delaying my clock indicator

I need to simulate the opening of 3 valves in a large system. For ease of use, my attached VI has gotten rid of a bunch of the cases as this problematic section is very deep within a nested case statement.

 

I'm using LEDs to indicate an open/close in the valve.  On = open, off = closed.  I need the first valve to open, then wait 1 second, then the second to open, another 1 sec, then the 3rd open. I got the valves to open in this manner, but for some reason unknown to me it is affecting the way my clock is outputing. With the way the attached VI is running, the clock updates every 3 seconds. I want it to update continuously. 

 

My thoughts are that the clock being in the same loop as this case statement is tying the two together.  If I could make the clock indepenent from the rest of the system, would that solve the problem? If yes, how would I go about doing that?

 

Thanks in advance!

Download All
0 Kudos
Message 1 of 5
(2,287 Views)

That is normal dataflow.

 

The while loop is only going to iterate again once all the code is inside of it is finished.  The clock update isn't going to execute more than once per iteration because that is the way you coded it.  The while loop is only going to iterate at a rate based on the slowest code inside of it, and that is the sequence structure because of the wait statements.

 

If you want to update the clock more rapidly, put it in its own while loop.

0 Kudos
Message 2 of 5
(2,280 Views)

I put the clock in its own while loop and it worked! Thanks for your help. I'm still trying to understand dataflow as I'm relatively new to LabVIEW.  

 

I have a follow up question though. I need to use the clock to tell the user what time these valves turn on.  Connecting the while loops with a terminal messes everything up in a way that I don't understand. How can I get the clock data from one loop to the other? 

0 Kudos
Message 3 of 5
(2,272 Views)

Right now you don't have the clock information used anywhere else but the indicator.

 

If you pass a wire from one loop to the other, the data won't pass out of the loop until the loop is complete.  That means stopped and not iterating again.

 

You can use queues and notifiers to pass data between loops.  You could use a local variable, which is quick and easy, but if used improperly, new programmers don't know why their code isn't working the way they expect it to.  Search the forums for "race condition".

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 4 of 5
(2,268 Views)

I have programming experience so I know about race conditions. I just didn't know how they work in here. I also didn't know LabVIEW had queues and such. Thanks, you've been very helpful! 🙂

0 Kudos
Message 5 of 5
(2,251 Views)