Hello friends, hope you all are fine and having fun with your life. Today’s post, as the name suggests is about How to Display Serial Data on Real Time Graph in Labview. In our previous post, we have seen that how to Get Continuous Data From COM Port in Labview. Today’s post is a sequel of this previous post so I would recommend that if you haven’t had a look on that post then first visit it as I am gonna start today’s post from where I stopped the previous one.

In the last post, we were able to get the continuous data from COM port using Labview and we have also separated the data based on a character which I have used this one “,” i.e. comma. Now, suppose you are sending 3 values from your COM port and these are the sensors’ values so tthe best way to display these value is by using a graph. In the last post we separated the values and displayed them in a 1D array, so today we are gonna display those values in a graph. As I have taken three values so today I am gonna plot 3 graphs. Each graph will show one of the values and display them in real time. Let’s start it.

Display Serial Data on Real Time Graph in Labview

• In the last post, we have the below vi at the end. This vi get continuous data from the COM Port and then display it in the Response and the 1D array.

• In the above image, the Data 1D displays the values separately and differentiate it on the basis of a characters “,” i.e. comma.
• In other words, Data 1D has a array, which consists of three values coming from the serial port.
• So if like we have sent the values 120,221,312, then the array(0) will have 120, array(1) will have 221 and finally the array(2) will have 312.
• In order to plot the values on the graph separately, what we need to do is to simply get array(0) and then plot it vs time and so on, which is shown in below figure:

• As you can see in the above figure, the logic we used is quite simple, what we did is we simply get the array just before Data 1D and then broke it into parts i.e. array(0), array(1) and array(2) and then fed it to the Graph plots.
• In this particular example I am using accelerometer IMUv2 and displaying its values on the graph.
• After adding these blocks you are done. Now press Ctrl+T and open the Front Panel. My front Panel looks like as shown in below figure:

• Now first of all select the COM port from which you are receiving the data. If you can’t find yours, then click on the Referesh, you will find in the drop down.
• Now, run the vi and then click on the Start button and you will start receiving the values. The values will be displayed in the Response as it is and then in the Data 1D and will also display on these graphs separately as shown in the below figure:

• Now, you can see the data is displayed. In this vi, we have displayed the data in three formats:
1. Response: It shows the complete data coming from the Serial Port.
2. Data1D: It separates the data and then displays it in digital format.
3. Graphs: They plot the real time graph of the coming data.

I have attached the vi below for download but I would recommend you guys to design it by yourself so that you learn the most out of it.

1. chris says:

Hi friend, excellent tutorial, my question is how do you send serial, for instance in Arduino is something like: ” Serial.println(measure_value);” then if I have three sensors, the thing will be something like this: ” Serial.println(measure_value); Serial.println(measure_value1); Serial.println(measure_value2);”

• Syed Zain Nasir says:

Hi,

No, I have explained this thing, sensor values are separated by commas so the values will be something like that:

Sensor1,sensor2,sensor3

And it will repeat on and on.

Thanks.

Hi Mr Syed Zain Nasir
I need a file DISPLAY SERIAL DATA ON REAL TIME GRAPH in labview 2013 version
please send me to my email ,
very thanks,

3. Akriti says:

Sir, can u please upload this VI file to be compatible with labview version 2013? I tried to build the VI file as shown in the image, however, I was unable to retrieve data.
The only difference is that the data I am receiving serially is from only 1 sensor. But that shouldn’t disturb the output?
Please guide? And upload the .Vi file compatible with LabVIEW version 2013, so that i can rectify my mistake.

4. Jonathas says:

Hi,

You close and open Serial communication in every iteration, no matter if you write or read. Each of these operations takes time.

Why don’t you start the serial com. at the beginning and close it to the end. Only once.

In attachment I’ve prepared a draft of how it should be easier for you to do it.

Paul

• Syed Zain Nasir says:

Yeah that would be obviously better, if you have a better design then send it to us and I will share it on our blog for others.

5. Jonathas says:

You have to Labview 2013?

• Syed Zain Nasir says:

6. zahra says:

Hi,

Thank you for this vi. Its half way through to what I need to do. I also need to be able to write data to the serial port. can you help me incorporate that in this code for yours.

Thank You

• Syed Zain Nasir says:

Yes we can provide you the complete project. Let me know the details. Its better to add on Skype.

• Nabeel says:

Salaam… I am working on a project that catches arduino 3 sensors data via serial input. I dont know how to separate it in labview. please give me any vi so that I may learn from it. Thanks. My email is nabeel001001[at]yahoo.

• Syed Zain Nasir says:

Add me on Skype and we will discuss it out. My skype id is theenggprojects.

7. roopesh.meleth says:

Hello Syed. I have a similar teensy program that loops in every 1000micoroseconds to send data to the serial port and i have used your code and i am unable to get a smooth sinusoidal wave ,while my input to the analog pin is sine wave of 1Hz frequency.
Can you post the teensy code or tell me what is your sampling rate for ADC in teensy.
Thanks .