From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

How to plot USART data on a graph

Hello!

 

My AVR microcontroller sends the result of an FFT algorithm through USART to my PC. It is really hard to evaluate the result on the terminal so I would like to display it on a graph. The result which is the spectrum of the measured signal is stored in an int array. I am new to LabView and I have trouble figuring out how VISA works and how to set up a graph to display the data. Please help me out.

 

 

 

0 Kudos
Message 1 of 22
(3,773 Views)

Hi Adam!

 

If you are new to Labview I suggest you to use NI Example finder during building your first applications. You can find a lot of useful, ready to use examples, that can suite almost all application needs.

 

To open this please start Labview >> Click on Help >> And please choose Find examples...

You have to wait for a minute, and than Example Finder opens in a separate window.

Choose Search tab, and search for "serial". You will see some result, inculding these:

 

Advanced Serial Read and Write.vi; Basic 2 port Serial Write and Read.vi; Basic Serial Read and Write.vi; and a lot more...

 

I thnik, using these you can create a VI, that suits the needs of your application.

 

To plot the data in LV, you can choose from Waveform Chart, Waveform Graph and XY Graph. (You can find them on Controls Palette => it appears when you right click on the front panel)

To see how they can be used, please refer to the context help. (Press ctrl+H) 

Here is an example: https://decibel.ni.com/content/blogs/DailyCLAD/2012/08/15/waveform-graph-series-5-of-5#comment-23123

 

I think the first step should be the communication, and to indicate the result on an array indicator. Aftare that should you try to plot the result on a graph.

 

I hope my answer will help you, if you have any questions, don't hesitate to post them.

 

Best regards,

CLA, CLED
0 Kudos
Message 2 of 22
(3,755 Views)

Based on the tutorials I made this VI.

Unfortunately there seems to be a problem. Even if I send nothing but zeroes a vibrating peak shows up on the front of the graph, it isn't just a flat line. I made a screenshot of this and attached it to this meassage along with the vi.
What is causing this and how could I fix it?

 

Download All
0 Kudos
Message 3 of 22
(3,738 Views)

Hi!

 

Your VI seems to be OK.

Do the VIs serial connection settings mach with the settings of your uC?

Do you use any handshaking, parity bit ? (Of course I see in your VI that you don't use these, but what about your uC?

 

Doess this peak appear random or always at the begining? Maybe you should not indicate the first few packets.

 

Best regards,

 

CLA, CLED
0 Kudos
Message 4 of 22
(3,719 Views)

It always appears in the beggining. I believe the MCU is set up properly.

0 Kudos
Message 5 of 22
(3,715 Views)

Hi!

 

So if it appears always at beginning of the communication you could "filter" it out. So you do not plot the first few incomming messages.

To do this you only have to use the String Subset function from String Palette before you convert the incomming data to U8.

Eg. you set the offset to 2 and then wire the substring to the String to byte Array.

 

Please let me know if it works as you expect.

 

Best Regards,

CLA, CLED
0 Kudos
Message 6 of 22
(3,713 Views)

It helped but only if I send zeroes. As soon as I send out anything other than zeroes similar errors occur elsewhere, periodically.

Sometimes it displays the data correctly, then there are about 3-4 sets of erroneous display and a correct one again.

I double checked the MCU's USART registers, they should correspond with the settings I am using in LabView.

No such errors occur on the hyper terminal though, so this might be the problem after all.

I tried to play around with delays but that didn't help either.

 

My final goal is to display the result of an FFT algorithm, which is the spectrum of a measured signal.

The result is stored in an 'int' array of 32 elements, I want to display this on a graph.

What I would like to achieve in LabView is something similar to the equalizer you can see on stereo systems.

 

I attached my modified VI to the post.

Oh, and by the way I'm from Hungary as well.

 

 

0 Kudos
Message 7 of 22
(3,695 Views)

Hi!

 

I think you should try out Visa Test Panel in MAX. (Measurement and Automation Explorer) This sw installs with Labview. 

I attached a picture to help you naviget to the right menu.

 

Using the Visa Test panel, you can configure your port similar in Hyper terminal, and you can see the incoming packets.

 

I made some changes on your VI. In my opinion it's important to put only the read function into a while loop. 

 

Please let me know how the incoming message looks like in test panels.

 

PS: I wrote in english, because if somebody would have later the same problem, these posts will be useful.

 

Best regards,

 

CLA, CLED
Download All
0 Kudos
Message 8 of 22
(3,676 Views)

Hello!

 

I've set up the VISA Test Panel, on the Input/Output panel I clicked 'read' and it gave me the following error:

 

Read Operation
Error

VISA:  (Hex 0xBFFF006C) An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.

 

Sorry for the late reply.

0 Kudos
Message 9 of 22
(3,647 Views)

Hi!

 

The error message indicates buffer overflow.

 

What configuraton settings are you using? Could you upload a screenshot from testpanels.

Did you set the receive buffer large enough?

 

Best Regards, 

CLA, CLED
0 Kudos
Message 10 of 22
(3,639 Views)