LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Loop vs. While Loop?

Hello all,

 

I am attemping to understand some timing issues.

I have two while loops running in paralle.  One while loop is not timed, the other while loop is set at 0.5second (just for the fun of it).  Both loops seems to be running conccurrently (both graphs update normally).

 

Then, I changed the while loops into timed loops (and did nothing else).  Now, only one loop updates once every 5 sec?  The other one is completely dead (graphs not updating).   I have a stop button for each of the loops, so I stopped the loop that was updating, and the other loop remains dead.  I was expecting them to behave the same as they did with just while loops.  What is happening?

0 Kudos
Message 1 of 9
(4,384 Views)
When you say the one While Loop is "not timed", do you mean it doesn't have a timer in it? When you just create a timed loop from the non-timed version, the default time is one second. You have to wire the time to it. Also, I don't see how 0.5 seconds bacame 5 seconds, unless your clock source is different. Are you on a real time system? If not, you're probably using 1khz clock. Post the Vi and we can help further.
Richard






0 Kudos
Message 2 of 9
(4,372 Views)

Most likey you are making a simple mistake and it would be trivial to troubleshood of you would attach your two code versions (before and after).

 

0 Kudos
Message 3 of 9
(4,345 Views)

It is an RT system, it is the R 7833.  I don't know how realistic it is to post all the files needed to run this thing.  But here are the pictures.

Basicly, I just right click on the loop and select "Replace with timed loop".  The front panel have graphs.

Before

 

 

And after:

 

0 Kudos
Message 4 of 9
(4,306 Views)

Oh... I have figured out why now.

 This is completely stupid.  I linked the stops together.  I didn't do this before, and did it after, forgetting that the loop depends on it.

 

Now, how do I link the stops together so i only have to press stop once?

0 Kudos
Message 5 of 9
(4,305 Views)

In this use case i think it would be appropriate to use a local variable of the stop button in the other loop.

hope this helps

 

Now Using LabVIEW 2019SP1 and TestStand 2019
Message 6 of 9
(4,296 Views)

Yes, you created a data dependency between the two loops. 😄

 

You could place a local variable of the stop button inside the other loop. (you nee to change the button to switch action to do that. Don't forget to set it back to false outside the loop.)

Message 7 of 9
(4,295 Views)

One of the few perfect uses for a local.

Also remember if you're on RT, there's more than one choice of internal clocks. That can be a "gotcha" with timed loops on RT.

Richard






Message 8 of 9
(4,260 Views)
Or you could use a notifier so that your other loop would also stop if there were an error in the first loop (and if you want, vice-versa).
Message 9 of 9
(4,235 Views)