LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while/time loop from pc clock

Solved!
Go to solution

Hi Guys

 

I have some code that (currently) uses a while loop to periodically open a file and read from it (in its simplest form....and...the details are not germaine to this post)

 

The requirements have now tightened and the loop (While or Timed??) must read the file once every two minutes based on the computer clock (accuracy is not too important, certainly not milliseconds)

 

e.g. time is 11:35.... read file

      time is 11:36.. ..do nothing

      time is 11:37.....read file

      time is 11:38.....do nothing

     etc.   etc.

 

In simpler terms (if thats possible)....have the loop perform the code inside it every two minutes with the time sequence coming from the pc clock.

 

I've looked at timed loops (but never used them) and they seem a possibility

 

So, could somebody show me an example of the best way to do this.

 

Thanks for your assistance and best regards

 

Ray

 

 

0 Kudos
Message 1 of 6
(3,485 Views)

I would use a normal while loop.  Put the target time in a shift register.  Every iteration compare the target time to the current time.  If the current time is >= target time, do the file read and put a new target time into the shift register.    Set the time delay in the loop to something like 1 second.

0 Kudos
Message 2 of 6
(3,480 Views)

 

Hello Ravens Fan

 

I have had an attempt (unsuccessfully) at your suggestion, but not much luck I'm afraid.

 

I'm kicking myself because I should know how to do this.

 

I have attached my attempt. Would you please take a look at it and see where I'm missing the next ingredient.

 

Kind regards

Ray

0 Kudos
Message 3 of 6
(3,442 Views)
Solution
Accepted by topic author rayclout

You forgot to update the time going into the shift register.

 

 

Message 4 of 6
(3,429 Views)

You could simply use the Elapsed Time function.

Message 5 of 6
(3,426 Views)

Guys

 

Ravens Fan......once again thank you.I knew I was close.......Smiley Happy

 

Dennis....you know...my first effort was to try the express vi......but I didn't put a wait in the loop, so the express vi didn't work. I'm going to give the solution to Ravens Fan simply because I'm trying to learn from the best....and the best on the forum.....including your goodself....always suggest that the express vi's be limited or not used in our coding. But....kudos

 

Thanks guys

 

Regards

Ray

0 Kudos
Message 6 of 6
(3,414 Views)