LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying time value read from .csv in graphics and simulating the data

I'm reading the data from a .csv file and trying to display it in a chart. I can show the data by adding a 2D array with a wave chart, but I want the timestamp on the wave chart to be the timestamp read in .csv. I also want to simulate the data according to the refresh interval of the VI in Excel. For example, the time elapsed between each row in the first column (time). If it is 1 ms, data must continue to be added to the graph every 1 ms in labview.

I tried a few ways but I couldn't get exactly what I wanted.

constructionworker_0-1711623616676.png

I've included sample data I read below.
Anyone have an idea about this?
__________________________________
Every opinion given is worthy of respect.


0 Kudos
Message 1 of 12
(629 Views)

Hi 

since you're running windows, you won't have the resolution to plot precisely the data at 1ms rate for example. (Windows is not real time).

what you could do is use the time stamp and wire that information to a wait function that will run on a loop where you plot your chart. At every new data to be plotted it will wait for the time (within windows interference). 

 

You must create a loop and pass the data into the loop with auto index to plot one data at a time not the whole array (otherwise the plot will show all the data at once. 

 

If the time stamp data is equally spaced you can use that information to write the chart property note prior to the beginning of plot to adjust to the time stamp ( you may need to dig the manual how to properly setup that). 

 

 

0 Kudos
Message 2 of 12
(594 Views)

@LVNinja wrote:

If the time stamp data is equally spaced you can use that information to write the chart property note prior to the beginning of plot to adjust to the time stamp ( you may need to dig the manual how to properly setup that). 

 

 


I definitely cannot run LabView at the same refresh intervals. What I am thinking of is adding data at every refresh.

constructionworker_1-1711777582468.png

The data I am trying to read is as follows. It is the time data in the first column. How can I use this time data instead of the timeline here?

0 Kudos
Message 3 of 12
(549 Views)

Hi worker,

 

seems quite easy:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(529 Views)

 thanks for answer.

Well, only the time column and the column next to it are shown here. So, at the same time, the other 3 data branches need to be drawn on the screen according to the time in the 0 column in a graphic. How can this be done?

In other words, I want to plot the data one by one based on time in this .csv file. In a way, the data is simulated in real time. We can think of it like a video, with play and pause buttons.

0 Kudos
Message 5 of 12
(515 Views)

Hi worker,

 

then you need to implement more code:

  • Use a loop with a small delay
  • calculate the elapsed time in the loop
  • add more points to your plots as the time elapses
  • before entering the loop you should clean up the data to get rid of all unneeded rows: there is garbage at the end of your file...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(506 Views)

I have created a small example here but here it only takes the value of one column and it does not plot the whole chart in the chart.

Download All
0 Kudos
Message 7 of 12
(488 Views)

your code is plotting column 13 fromn the csv file. 

 

If you want to plot all three columns, then you need to  read all the 3 columns (accelX,accelY,accelZ)

and create a cluster xy for each plot then build and array of clusters to plot on the XY graph. 

NOTE> The while loop inside the for loop is not necessary. 

 

LVNinja_0-1711981526667.png

If you enable indexing on the for loop you can eliminate the index array , it will automatically pass one value at a time. 

Using a control on Wait time let's you change the speed of plot as it plays back.

LVNinja_0-1711982383916.png

 

 

0 Kudos
Message 8 of 12
(477 Views)

try using the 3D Cornet plot you will be able to see 3d image 

LVNinja_0-1711981895585.png

 

0 Kudos
Message 9 of 12
(475 Views)

Hi worker,

 


@constructionworker wrote:
  1. it only takes the value of one column
  2. it does not plot the whole chart in the chart.

  1. Because you only read one column (and your time column). When you want to plot more/all columns then you need to handle them all!)
  2. Because you create exactly ONE plot with exactly ONE sample. When you want to plot all samples then you need to build your plots from all samples!
  • Why don't you use autoindexing at loop borders?
  • What's the point of your inner while loop that you placed around the XYgraph terminal?
  • What's the point of your sequence structure? It's just rube-Goldberg!
  • Why did you try to index the 14th column of your CSV file when it only has 4 columns???
  • Why do you need to index the first column twice? Why do you need to convert the values of the 1st column twice to integer data? Why do you need to divide twice by 1M? (Why is there so many unneeded code???)

Your VI, just cleaned up slighty…

 

Suggestion:

Cleaned up a little bit more, now with a XYgraph showing the "whole" plot…

 

I don't recommend to update graphs so fast. And I don't recommend to plot so many samples into such small graphs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
0 Kudos
Message 10 of 12
(466 Views)