LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you initilize the time for accurate time stamping

"I am reading temperature and frequency from a couple of RS232 devices - I am needing to plot these readings over time... how do i initialize a timer to 0 for accurate time stamping for my graphs, which will reset say back to zero whenever i rerun the VI?"
0 Kudos
Message 1 of 6
(3,189 Views)
Since your application involves temperature and RS232, I'm guessing that you only need timestamp precision out to the second or tenth of a second at best. For that, you can simply place the "Get Date/Time in Seconds" function outside your main VI's while loop. Pass that number in to your loop and subtract it from another "Get Date/Time in Seconds" for each measurement. You can encapsulate the second function in a subVI with error clusters for data-dependant sequence.

Remember, Alliance Members like us do this stuff every day.

Daniel L. Press
PrimeTest Corp.
www.primetest.com
Message 2 of 6
(3,189 Views)
Use the millisecond timer, and an X/Y graph.

I assume you're in a WHILE loop.

Add a shift register (SR). Initialize it with a (U32) zero value (from outside the loop).

Initialize another shift reg with an empty array of {X|Y} clusters.

Repeat
Y = Receive a value.
Tnow = MilliSecond timer.
if SR = 0
SR = Tnow (Initialize the start time)
else
SR = SR (leave it alone)
X = Tnow - SR
Append {X,Y} to your plot array.
Limit the array to the latest N points (or it will grow indefinitely).
Replot the array on the graph.
until Stopped.

The idea is that you initialize the SR with the current time WHEN YOU RECEIVE YOUR FIRST READING.

After that, you take the time difference between now and the start time, and p
lot that as the X (time) value.

The 0th point plotted will always be at time zero, every point after that will be some number of mSec later. Every time you restart the program, you start at zero again.

Note that this doesn't account for serial transmission time, nor the fact that the instrument may have stored the value for some time before transmitting it.

If you're using real slow update rates, you may want to use DATE/TIME in SECONDS instead of the mSec timer, but the principle is the same.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 6
(3,189 Views)
thank-you
0 Kudos
Message 4 of 6
(3,189 Views)
thank-you
0 Kudos
Message 5 of 6
(3,189 Views)
Brilliant! didn't work at first, but with some clever ordering... nice one!
0 Kudos
Message 6 of 6
(3,189 Views)