LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert data from serial port to real time plot

I have a serial terminal that reads my data in the following format.

X=-0.020 Y= 0.026 Z= 1.160
X=-0.007 Y= 0.015 Z= 1.144
X=-0.007 Y= 0.020 Z= 1.160
X=-0.010 Y= 0.015 Z= 1.160
X=-0.012 Y= 0.015 Z= 1.170

How do I get this data to be graphed on X, Y or  versus time plots? Please help I usually work with excel macros and I am not familar with labview
0 Kudos
Message 1 of 34
(7,372 Views)
Try this in 7.0 format.
0 Kudos
Message 2 of 34
(7,365 Views)

Thanks a lot as this is getting me closer to where I want to be.

My serial terminal labview vi continiously reads the sensor output at 25 readsings/second. I see your array vi converts this output to a useful format and now I want to graph the the three arrays (x ,y and z) of data using this type of xy plot that I am including as an attachment. A large amount of data could build up in short time so saving the data as a csv file would be great as well.

I using the this vi to plot in real time data from an accellerometer and plot each axis versus time to help a volunteer based rowing club. My experience is limited in labview but would love to learn more after I get this little project out of the way. I hope you or other forum member can help me again.

Frank

 

0 Kudos
Message 3 of 34
(7,355 Views)
Thanks for the info and I shall try working on what you gave me later. I just thought I let people know that NI have already developed VI for this type of sensor at the following link. I been searching long and hard trying to up my knowledge of labview

http://zone.ni.com/devzone/conceptd.nsf/we...625706d0061889e

So my goal of getting the real time output from the sensor and plotting it in realtime has already been achieved by other capable NI users! So hopefully with the forums continued assistance I can sort this out soon.

Thanks again.

Frank
0 Kudos
Message 4 of 34
(7,334 Views)
Hi,
 
Getting there slowly but surely. Serial terminal takes data from a sensor. Places it a scrolling screen at 25 point per second. I am still having problems trying to parse the three pieces of data continiously from the scrolling screen using the scan from strin.vi. Thank you for posting it. I have a partial vi (generously given to me by another labview programmer) and it graphs the 1 line of the data in the correct format.
 
I am including it in the post as all I need now is help integrating the serial terminal vi with the real time graphing of the data.
 
Hopefully some more generous forum readers can point me in the right direction.
 
Frank
0 Kudos
Message 5 of 34
(7,326 Views)
Hello,
 
I think you have a string parsing question, where you have some ascii data returned and you need to parse it, convert values to numeric type where necessary, and then graph it.  This is very easy to do in LabVIEW, and I would like to help you, but I am going to need precise information to show you exactly how to do this in your case.  Since we don't have your hardware, pasting your entire program makes it difficult to view because many subVIs and custom controls cannot be found.  However, since you don't seem to have problems with the serial part of the code, how about copying and pasting a sample return string into a labview string constant, put that on a block diagram, and then very carefully explain exactly what your desired plot should look like.  In particular, you show data for X, Y, and Z... would you like those to each be independent plots, where those represent y-coordinates in a cartesian plane?  In that case, what are the corresponding x-coordinates for that data?  It would be enough to specify and initial start time, say t0, and then an acquisition rate or a "time per sample" for each of your apparent sets of data - the X data, Y data and Z data.
 
If you can provide this information, I think it'll be easy to guide you to a solution.  Basically, you'll be working with string parsing and string-numeric conversion functions, and then building arrays to plot your data in either a Waveform Chart or Graph, or an XY Graph.
 
I look forward to your repost!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 6 of 34
(7,311 Views)

Hi,

I am going to summarise exactly what I want to do with my project and see if you can put me on the right track.

I own a SerAccel v5 Enclosed 3 axis accelerometer. Its uses a rs232 communication protocol and I would like to graph the real time output of this sensor using labview. My project involves using the accelerometer to help rowing training on a rowing erogmeter.

http://www.sparkfun.com/datasheets/Acceler...SerAccel-v5.pdf

I can communicate with the device by hyperterminal but now I need to use labview to save the data and also graph the output of the sensor as a function of time. Here is an example of the typical output of the accelerometer usiong either hyperterminal or the serial terminal in labview

X= 0.676 Y=-0.313 Z= 0.754
X= 0.679 Y=-0.326 Z= 0.744
X= 0.676 Y=-0.331 Z= 0.722
X= 0.686 Y=-0.336 Z= 0.725
X= 0.676 Y=-0.339 Z= 0.744
X= 0.691 Y=-0.328 Z= 0.744
X= 0.686 Y=-0.326 Z= 0.706
X= 0.686 Y=-0.339 Z= 0.744
X= 0.686 Y=-0.339 Z= 0.752
X= 0.684 Y=-0.336 Z= 0.744
X= 0.691 Y=-0.326 Z= 0.754
X= 0.691 Y=-0.342 Z= 0.752
X= 0.686 Y=-0.321 Z= 0.744

I have been using a serial terminal vi I which I obtained from http://sthmac.magnet.fsu.edu/labview/vi_library.html and this succesfully gets the data from the sensor.

Next I want to data to be plotted in realtime so I need to parse the data from the serial terminal vi response box and convert it to a useful format.

I want to plot X, Y, and Z axis data versus time in the same graph. The time would start at zero and each point would represent a fixed time interval. I currently believe the data is being sent to the serial terminal at 25 data points/second. 

I have a serial terminal vi, I have now found a Extract Numbers.vi in the labview help which converts the data to a useful form and I have a graphing vi which puts the data in format I require. The type of graph I need would be something like an oscilloscope reading over a 0-20 second range. The events I am measuring are transient in nature and I just want to plot the single event and watch it on the screen and repeat the process numerous times. I do not need to keep the same data plotted on the same graph for minutes. I am trying to give biofeedback to rowers as they watch there acceleration curve during the rowing stroke. The rowing stroke only last a minimum of 2 seconds and a maximum of 4seconds. Keeping 5-10 strokes on the graph would allow the rower to visible compare each stroke taken on the rowing machine.

What I need to figure out is how to connect the sensor data output of the serial terminal to the parsing vi and then finally to the graphing vi. I am including some attachments of what I have at the moment.

I hope this give you more information about what I am trying to do.

Frank

 

Download All
0 Kudos
Message 7 of 34
(7,296 Views)
Hello again,
 
I have attached a text file which contains the data you posted, as well as an example of how to parse the file and plot it.  Now, as your data comes in from the serial port, I don't know how much you read each time, and how frequently you want to plot the data.  True real-time is not gonig to be possible because it takes time for the data to travel across the serial port, but I am guessing that you receive a line like:
 
X= 0.676 Y=-0.313 Z= 0.754
 
and want to parse and plot that data each time.  You can do this by reading exactly that many characters (plus probably an invisible carriage return and/or linefeed character) from the serial port and parsing just the line.  In that case, you will have to modify the code, and you can use a chart instead of a graph because a chart keeps a history of data and allows you to plot point by point.  In any event, I was able to modify a program only slightly to provide you this example of parsing and plotting your data, so I hope it serves as a good example to help you along!
 
Repost if you continue to have trouble!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 8 of 34
(7,271 Views)
Here's the attachment 🙂
 
- JLS
Best,
JLS
Sixclear
0 Kudos
Message 9 of 34
(7,270 Views)
Just another quick note - just specify the file path on the front panel of VI I attached with the data you have in the format you posted above, and it should work... I copied and pasted what you had there to a text file and used that as the test data.
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 10 of 34
(7,270 Views)