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: 

Real Time Graphing from Com Port Data

Do you have control over what the other device is sending?  Or is it a 3rd party device that you don't have control over?

 

If you don't have control, then you need to figure out how it is sending data and the best way to gather it.  If it doesn't send a carriage return or a a line feed character, then using a termination character won't help you.  If it sends binary data where a x10 or x13 character is just as likely to be data as it could be a termination character, then using a termination character won't help you.

 

If the other end is a device that you can program and control the code, then you can pretty much do whatever you want.  Figure out what is the best way to format the data you want to send.  Sending it has human readable ASCII characters and terminating it with a line feed is generally a pretty easy way to be able to read and parse the data when it arrives into LabVIEW.

0 Kudos
Message 11 of 39
(1,221 Views)

Thanks! Seems to be graphing well now.  If I am going to be plotting continuously 24 hours a day, Is there a way to set the graph to show a 24 hour period time?  And is there a way to save the data for the day?

0 Kudos
Message 12 of 39
(1,216 Views)

Set the X-axis min and max to represent a day.

 

Use Write to Text File function to save the data.

0 Kudos
Message 13 of 39
(1,212 Views)

You can edit the chart sample size.  There are probably good tutorials on graphs, charts, etc.  You'll learn the most by digging in and going through them on your own.

 

The project you are working on right now though, it's not cut and dry that the VI you have right now will work for 24 hours.

 

When you are doing data acquisition, such as blind streaming of data from the MSP to LabView, it's important to know that LabView is keeping up with the MSP.  Just because the VI can run for 1 minute, doesn't mean that the MSP isn't gradually filling up some write buffer because you're not flushing it fast enough.  For example, if you are spitting out data at 5ms from the MSP, and the timeout on the event structure is 5ms, your loop will not keep up with the MSP.  There's latency in the VISA read function.  So, just for example, let's say that the VISA read function takes 3ms to complete, that's an 8ms loop time.

 

Also, keep in mind that amount of data you are wanting to buffer in LabView.  At 5ms per sample, 24 hours of data would be 17,280,000 samples.

 

Additonally, you may want to consider looking into producer/consumer state machines.  It would be smart and beneficial to write your data at intervals during the day, so that if an error occurred, or a hiccup, a power surge, etc, you wouldn't be out your entire data set.  It's much simpler to just write the file at the end of your dataset, but you risk losing it all if something goes amuck.  It also means you have to buffer your entire data set until the end.

 

So, try to structure your code to do exactly what you need it to, as well as be robust and effcient.



Bruce K

Not as smart as many other peepz on here....
0 Kudos
Message 14 of 39
(1,207 Views)

So I have been playing around and am able to save the data to a text file and also pull up multiple text files and plot them.  I am now working on trying to continuously sum the numbers coming in (which sounds simple), but I have not been able to make it work. So if 1 2 3 4 5... comes in i want the sum to show 3 then 6  then 10 then 15 and so on. Any suggestions on the best way to accomplish this?  attached is the vi and a screenshot of a portion of the vi.

Download All
0 Kudos
Message 15 of 39
(1,162 Views)

Here's a very simple example of how to sum data in a loop.  Basically just use a shift register and add the value of the shift register to the current data and pass that result back around via the shift register.  Make sure you initialize the shift register with default data (in my example, 0).

 

I would strongly suggest trying to reduce your block diagram size and eliminating as much white space as possible and get your wires a little cleaned up.  It's just easier to manage and sustain your code.

 

Good luck!



Bruce K

Not as smart as many other peepz on here....
Message 16 of 39
(1,125 Views)

Thanks Bruce.  I have the summer working well now.  I am now having some issues with reading in data.  I am now using a microcontroller running at 16MHz that sends the data.  I am telling it to send temperature which usually ranges between 70 and 85 in decimal, but the data that it receives/is graphing, is constantly 255 (0xFF).  (This is when i set read count to 1 and event structure timeout to 500). If i set the read count higher I time out.  I think there is some sort of timing issue, but i am not entirely sure.  Any ideas?

 

0 Kudos
Message 17 of 39
(1,064 Views)

Even when I tell it to transmit 0x00 continuously, it still graphs 255

0 Kudos
Message 18 of 39
(1,058 Views)

Realized it was something in my code with the baud rate when switching to 16MHZ.  Sorry, I thought this was an issue in labview

0 Kudos
Message 19 of 39
(1,054 Views)

I just realized that I can only graph numbers up to 255 (end of ascii table).  How do i resolve this so i can graph values larger than this? Up to around 2000.

0 Kudos
Message 20 of 39
(1,004 Views)