LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a chart in the correct time

Solved!
Go to solution

 I have an application which runs non stop and sends collected data to a txt file. I have labview then reading that file and displaying the contents on a chart. I want the X-axis of the chart to be in the correct local time, so that users can see how the data changes throughout the day. Ideally, it would show the data over a 24-hour period with the max being the current time and the min being the time 24hrs ago. I'm guessing this has something to do with time stamps and is probably simple, but I can't figure it out. Any ideas? Thanks

0 Kudos
Message 1 of 8
(3,343 Views)

Do you actually have time data in the file you are reading? If you don't, you cannot programatically set the x-axis. Attach a sample file.

 

p.s. It's also silly to read the same file over and over again in a while loop.

0 Kudos
Message 2 of 8
(3,339 Views)

You probably want to use a graph instead of a chart file. Charts are generally used to display data continuously while the chart displays a view at a time (you will need time stamps for this operation)..

0 Kudos
Message 3 of 8
(3,336 Views)
Solution
Accepted by topic author JamesVAMSC

Hi James,

 

If you know the start time and the sample interval then you can have the chart set the time axis for you.

 

Set the chart X Axis to Relative Time. Be sure to set the Chart History Length to be long enough to display all of the samples you want to display.

 

See the attached example. Here is the block diagram:

 

chart BD.png

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Message 4 of 8
(3,320 Views)

  Thanks, I will try out these ideas. The reason why I have it set to read the file in a while loop is because the data never stops coming in. I'm not sure what the time interval is, but I'm guessing about every second. The data comes in 3 numbers separated by a comma, for example (26.987, 3.005, 32.564). The second number isn't important, but the first number is temperature in Celsius and the third number is salinity. As this data is put into a txt file, I have labview pull the data from the text and display it. Could I use a graph and just update it every X seconds and append the new data to the existing graphed data? or would it overwrite the existing data? Thanks-James

0 Kudos
Message 5 of 8
(3,312 Views)

Since your are reading the entire file, you would have to use a graph and display all of the data you read. That would overwrite everything in the graph. If you change your code to only read new data, then you could use a chart. Currently, since the rate you read is going to be different than the rate that is being written, the x axis is going to be meaningless unless there is actually time data being written to the file. If not, that would almost force you to detect when the file has changed and use that information. An XY Graph might be your best option in that case.

0 Kudos
Message 6 of 8
(3,304 Views)

So, the chart starts at the correct time, but the clock still runs to fast. No, there is no time data in the input file, but is there not some way I can sync the X-axis with the computer clock? The data is being recorded in real time, so I just need the X-axis to display the current time and change as appropriate. I just want the x-axis to show how the data is changing over real time. Thanks -James

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

So, I put the time info in the while loop and the time displayed is correct, but now my chart is acting weird. It's blinking on and off. I'll mess around with it some more, let me know if you got any ideas, Thanks -James

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