LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform graph behaves like a Chart

Dear all,

 

I have an MCU which performs spectrum analysis, the magnitude is stored in an array which I send serially to my PC. I would like to plot this on a graph but I've run into a problem.

 

I wrote a test program which continuously sends an array containing numbers from 0 to 7.

 

int data[8]={0,1,2,3,4,5,6,7};

while(1)
{            
            for (int i=0;i<8;++i)
            {
                
                while (!(UCSR0A & (1 << UDRE0)));
                UDR0 = data[i];    
            }                                      

}

 

 

I expect to see a linear function on the graph, as seen on my first screenshot.

However, the plot keeps shifting from right to left just like on a Waveform Chart and I get the sawtooth like plot seen on the second screenshot.

How can I stop the graph from shifting?

 

Regards,

Adam

 

Download All
0 Kudos
Message 1 of 10
(3,376 Views)

Hi Adam,

 

when you want to plot your data beginning with zero and ending with largest value you should also adapt your data aquisition to "trigger" at the correct data points...

 

Right now you just fetch the data coming from the serial port. You don't take any measures to analyze those data, you just read in the bytes from the buffer. Now you wonder about missing synchronization...

 

Possible solution:

- send a "End of transmission" char and use it as TermChar for the InitSerialPort vi!

- Get rid of the BytesAtPort node, it's most of the times not needed for serial communication!

- Analyze your data when you need a certain plot...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,357 Views)

Thank you for the help.

I'm thinking about assigning two start/stop characters and sending them before and after the array elements.

The first one would start the waveform plotting which would be in a while loop that is stopped by the second, closing character.

The problem is I don't know how to check every byte in the buffer and determine which one is the designated start/stop character.

0 Kudos
Message 3 of 10
(3,354 Views)

Can anyone help me please?

0 Kudos
Message 4 of 10
(3,311 Views)

Hi Adam,

 

to answer your question


how to check every byte in the buffer and determine which one is the designated start/stop character


you may try that:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(3,303 Views)

I managed to modify my VI to display the data the way I wanted, however, there's a new issue.

The graph keeps flickering. How can I get rid of this problem?

0 Kudos
Message 6 of 10
(3,274 Views)

Hi Adam,

 

to have the graph not flickering you should not write data to it that fast... 🙂

 

Please attach your VI with some example data for further suggestions!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(3,272 Views)

I attached the VI.

I don't know how to give you example data though.

My MCU is continuously sending a 63 element array, containing the magnitude of a signal's spectrum.

 

 

0 Kudos
Message 8 of 10
(3,257 Views)

Hi Adam,

 

your VI is reading the serial buffer each 150ms. Then it cuts the received string and converts the string to U8 array. That U8 array data is presented on the graph - roughly 6 times per second.

 

What else do you expect than flickering?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(3,242 Views)

I see.

The reason why I did not increase the delay is because I'd like to plot the spectrum's magnitude in real time, so if there is a change in the signals frequency it is immediately displayed.

0 Kudos
Message 10 of 10
(3,228 Views)