LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To read & save data from serial port (write to .csv file), and plot data as waveform

 

 

Hi,

I've been stuck with this problem for weeks and really need some help. I've been searching a lot but I can't find a proper solution.

I am trying to use Labview to plot and display some parameters of a data acquisition system for a project.

 

The data acquisition system is connected to a computer via serial connection through COM 1 port.

The data acquisition system sends a serial stream of data (ASCII string with baud rate 19200), as shown below (from HyperTerminal),

 

01:00:26,933.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,

01:00:27,931.54,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,

 

The serial data stream consists of a time stamp (as 1st data), followed by 16 individual channel data, separated by comma "," and each stream ending in return "\n". Each value of the data ranges from 1 to 6 digits (value of -5000 to 15000).

 

 I have no problem reading this values correctly using HyperTerminal, but I have problem to plot and display individual parameters of this serial string in Labview. I want to save the entire data in  a “.csv” file corresponding to all the 16 channels with time stamp and plot each individual channel parameter in a graph with time on X-axis.

 

I am relatively new to Labview hope I can learn a lot from your help.

 

 Thank you

Message 1 of 6
(10,184 Views)

You can use the spreadsheet string to array with the delimiter as comma ",". It works fine check this. Use 1 D array if your data is a single coloumn/row. Further you can convert this array string to DBL value and plot the data in the chart/graph.

 

Spreadsheet string.png

 

Good luck

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 6
(10,174 Views)

Thank you For the help Anand!!  

 

Sorry for the delay in reply. I was engaged in modifying a "read write file to RS232.vi", which I downloaded from the internet, the program was meant for writing data obtained from the serial port into a file and to send out data to serial port from a file inside the computer.

 

I have attached the VI application (Suitcase.vi), which I modified by using the Spreadsheet string to array block, as you had instructed earlier. Also I have attached Suitcase.txt file which I obtained while executing the same.

 

I had modified the program for plotting three channels of serial stream on a single waveform graph, the program is running well but as there is a Read characters from a file and VISA write function in the VI, it doesn’t run properly in “Run continuously” mode.  Can u help me in editing the program so as to eliminate the Read characters from a file and VISA write function?

 

Also I have an additional functionality to be incorporated in the application, i.e., to selectively indicate the real time value of a particular channel from the serial string data, on a gauge.

 

Can you further guide me in implementing the same?

 

Thanks!!

Rahul

Download All
0 Kudos
Message 3 of 6
(10,134 Views)

Simply delete the read from file and VISA Write.

 

Why are you converting to a 2D array. As mentioned, use a 1D array constant for the Spreadsheet String to Array.

 

Connect an Index Array function to the 1D array output (that you will have by doing the conversion correctly. Connect the index input to a control and the output element to your gauge.

0 Kudos
Message 4 of 6
(10,130 Views)

Thank you Dennis.........

 

Now I had modified the program incorporating1D array for gauge display.....but currently I have a new problem. The program is running updating the file, waveform graph and Gauge very slowly. Approximately once in every 15 seconds 16 data streams are getting updated in a bunch with gauge sticking to the last value rather than indicating real time value.

 

eg.

12:33:41,-3728.78,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:42,-3730.47,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:43,-3729.81,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:44,-3733.80,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:45,-3733.57,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:46,-3729.27,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:47,-3725.97,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:48,-3730.14,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:49,-3733.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:50,-3733.60,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:51,-3732.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:52,-3734.51,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:53,-3728.07,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:54,-3732.54,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:55,-3732.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,
12:33:56,-3731.58,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,

 

gets updated in a bunch after 15 seconds, rather than in every second. I thought the problem is with while loop but, i realised there is no delay associated with it..... Can u kindly help me in modifing the program so as it can update the waveform, file data and gauge in real time? (I have attached the modified VI file "suitcase new.vi" and the data gathered after executing the same as in "Trail.txt".)

 

Thank You,

Rahul

Download All
0 Kudos
Message 5 of 6
(10,084 Views)

I m new to Labeled, do I have to use buffer and registers to enhance speed of this program ?

Whether using matrices reduces the speed of execution in labview?

Pls help

0 Kudos
Message 6 of 6
(10,038 Views)