From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in writing/reading waveform data in a continuous manner

Hello.. I have made a software program to interface a PID controller through Modbus. I implemented this using state machine algorithm where it monitors different parameters (P, I, D, SP, PV etc) in a chained manner. Now I am storing the values of Level% (input Set-Point) and Valve% (output) with real timestamps to a file and then reading & displaying this data on a waveform graph. And this is where I have been stuck. 😞

If I put the Delete function (as shown in the attached pic), it always overwrites the values whenever I rerun the program (not acceptable) and if I enable the Append, it stores the data in a wrong iterative manner (maybe because of the while loop: not acceptable). If I don't use Delete or Append, then it keeps on asking to replace the existing file.

The software program is running fine except the waveform part.

 

What I want is, it should keep storing the timestamped data continuously to a file and by reading that file, we can display the past as well as the current data on to a graph even after rerunning. Can anyone help me out?

 

It would be great if somebody is having a piece of code to do this, for a quick reference.

0 Kudos
Message 1 of 6
(2,145 Views)

Below is some hints:

1.read out all the data (Array1)from file at the beginning of your VI.

2. save test data with append enabled.

3. Insert recent data to Array1. You can use shift register at this step.

4. Let the graph to indicate the data of Array1.

 

0 Kudos
Message 2 of 6
(2,122 Views)

You're building an array and save the complete array each time, as can be clearly seen on your result picture. It's 1 sample the 1st time, 2 the 2nd and so on. Only save the new sample(s) if appending.

Keeping the built array in memory as now is good, though. Also, writing twice and reading it back is wrong, just use the shift register'd array. (I realize you might just be reading it back to check, but still)

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 6
(2,120 Views)

I don't understand how can I get rid of this repetitive samples and how can I save only the new samples. And yes, I am writing the data twice, first to a text (.txt) file (Export Waveform to Spreadsheet file) and then to a binary (.dat) file (Write Waveform to File). I am forced to do this because "Read Waveforms from File.vi" doesn't accept a text file. Text file will be used as a visual reference to display the timestamped data and binary .dat file will be used by Read Waveforms from File.vi. (I don't know if some function is there to read and display the waveform data from a text file).

 

I have attached a separate write/read graph.vi which I am using in my project. Can you plz help me out with the necessary modifications in the vi?

0 Kudos
Message 4 of 6
(2,084 Views)

You are just growing your array and writing the whole thing to the file.  And writing to 2 files is just silly.  My recommendation would be to write to a TDMS file.  You can install a simple plugin (installed with LabVIEW) so you can view the data in Excel and it is just simple to use.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,076 Views)