LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timed loop

HI,
  Im very new to Labview and trying to learn by myself, I want to make a loop when the Boolean value is "1" or "true" then the loop runs for 5 seconds and stop. Can you please let me know, how to achieve this . Thanks-suresh.
0 Kudos
Message 1 of 8
(3,810 Views)
 

Use the millisecond timer function to get start time.  Use same function to get present time and subtract the start time.  This gives time elapsed.  See below:

 

You can learn more about Labview here.

Message Edited by tbob on 11-11-2005 01:04 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 8
(3,811 Views)

Hi Thanks a lot, Well it does the job, but during that 5 seconds, it stops every other thing in the VI, What I need is a loop, it turns on and LED for 5 seconds when the input to that loop becomes "TRUE", and during that 5 seconds I also should be able to do other things as well..for example monitor the changes and change things. but the timer that you have sugested, it freezes whole VI during the time it is working 

I have attached the VI file and if you could suggest me something to over come the problem i will be really great full..thanks a lot
suresh

0 Kudos
Message 3 of 8
(3,775 Views)

You just need to put it in a parallel loop so there is no data dependency. The attached simple modification has a parallel loop that only spins whenever the LED is set to true via a signaling property node. It executes a wait case, then resets the LED to false.

See if this makes sense. Modify as needed.

0 Kudos
Message 4 of 8
(3,771 Views)
HI mate; Thanks a lot for your advice..and the modifications to my circuit and i really appreciate your help..now I can go along with my design...
 
however I quite did not get how you passed signal from one loop to another, and i have not read anything about it yet....I will get back to you after reading about it and if I have problems to understand it, because that type of linking will do a major role in my project..
thanks again...
suresh
0 Kudos
Message 5 of 8
(3,746 Views)

You can use a local variable to pass values from one loop to another, but beware of race conditions (where writing to the local might happen before or after the reading of the local, which may cause timing problems).  Another method of passing values between loops is to use the queue functions.

In Altenbach's solution, the event structure will see a value change in the other loop automatically.  No need to pass any signals between the two.

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 8
(3,739 Views)

HI TBOB

well I am having some troubles with the arrays...I want to have an array with 2 elements which takes data continuously each second from a source and store them in those 2 locations,

e.g.. a value been stored as the 0 element and the next value comes from the same source will be stored as the new 0 element and the value already there (in the 0 element) will be passed to 1st When. when the next value comes in, the value in the 1st element will be deleted and the value in the 0 element will be stored in the 1 element and goes on like that..

can you give me a clue how to do that please.

PS I want to have recognize to recognise when the temperature values going up and when the temperature values going down..comparing the 2 elements in the array

0 Kudos
Message 7 of 8
(3,716 Views)

Look at the attached picture.  The loop runs every second.  The Random function generates some data.  The new value generated is used with the value from the shift register on the left to build a new array.  The new array is stored into the array indicator.  On each loop iteration, the new value is passed to the shift register on the right.  This means that the next iteration will have that value on the left, and a new value is generated.  By using build array, the oldest value will always appear as element 1, and the new value will always appear as element 0.

 

Message Edited by tbob on 11-22-2005 01:05 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 8
(3,700 Views)