From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Serial data gauge, charting, and logging

Solved!
Go to solution

 

Is anyone able to point me at a sample project to read 3 data values from a serial stream and display them on a gauge and a chart. 

Logging would be nice as well, but gauge and chart are more important.

 

My data comes through in the format below, but I have complete control over this. 

 

R: 0,P:-210.15,F:173.191
R: 0,P:-210.65,F:173.191
R: 0,P:-210.78,F:173.191
R: 0,P:-210.67,F:173.191

 

Have basically left myself way short no time for this one, and trying to understand the sample files has put me in a spin.

 

May be interested in paying for expert assistance if this is non-trivial.

 

Any help gratefully received!

 

Duncan

0 Kudos
Message 1 of 7
(3,485 Views)
Solution
Accepted by topic author duncannz

Read the data one line at a time and use Scan from String to break it up into the 3 values.

 

Message 2 of 7
(3,481 Views)

Wow, thanks for the rapid reply. That looks super simple!

The other thing that's thrown me is the sample projects. They seem to have about a dozen different files in them. For a simple project, can I just have a single vi file?

 

For a project that just reads those values from a serial port and displays in a gauge, can I just have a single VI, read in from a VISA element, wire to a scan block, and then wire the 3 output values to 3 separate gauges?

 

Do these need to go in a while loop?

And does it need a stop button attached to exit, or can I just use the stop button in the Labview program?

 

Sorry to be 'that guy' but my time all got eaten up on the hardware side of things, and I need to get a front end together asap.

 

Cheers

Duncan

0 Kudos
Message 3 of 7
(3,444 Views)

I think you can safely put all of your code in one VI.

 

Open files and serial ports before the while loop.

The while loop contains your serial read.  If you don't have to read too fast, then you can also write to the file in that same loop.  (If you have timing issues and start missing data because your logging can't keep up with your serial data, then look at "producer/consumer" patterns where the logging is put in a separate loop.)

After the loop, close your serial port and your log file.

 

Do not use the LabVIEW abort button.  Use as a Stop button wire to the conditional terminal of the while loop.  (Aborting is like "crashing your car" to stop the program.  It stops it dead right there and gives it no chance to clean up like closing the serial port and log file.)

Message 4 of 7
(3,439 Views)

@duncannz wrote:

For a project that just reads those values from a serial port and displays in a gauge, can I just have a single VI, read in from a VISA element, wire to a scan block, and then wire the 3 output values to 3 separate gauges?

Yes, you can just have 1 VI.  But subVIs help to break up the program into simpler problems.

 

Do these need to go in a while loop?

And does it need a stop button attached to exit, or can I just use the stop button in the Labview program?

Yes, you should use a While loop.  And No, do NOT use the Abort VI.  You need to use a stop button to exit the loop properly and close your ports/files/etc.


 


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
Message 5 of 7
(3,437 Views)

Works as advertised, thanks RavensFan!

 

I get some errors on startup, presumably because it gets a partial packet on the first read.

Is there an easy way to filter this out?

0 Kudos
Message 6 of 7
(3,391 Views)

Just read once after you configure the port and before the loop starts.  Just discard it.  That should synchronize future reads with the termination character.

 

 

Message 7 of 7
(3,383 Views)