LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read problem of Serial Communication in state machine

Hi, everyone!

I using the state machine in order to get the raw data of 16bit hexa type from STM32 board.

However, I have a one problem.

Data collection through the Serial Communication Read VI at LabVIEW is smooth in under 100Hz operation mode of STM32 board system return, but CPU load increases in 200Hz operation mode. (from 20% to 50% over)

 

Please advise if there is a problem in the attached VI source code.

 

20200429113640.jpg

0 Kudos
Message 1 of 8
(2,431 Views)

I'm confused.

 

What exactly is the problem you see?

 

Your state machine looks fairly simple.  I don't know enough about your "STM32" board to know if your protocol makes sense.

 

But if something is running twice as fast (200 Hz vs. 100 Hz), then it certainly makes sense to me that CPU load would be nearly twice as high.

0 Kudos
Message 2 of 8
(2,411 Views)

In short, you can understand that buffer data is transmitted at 100 Hz or 200Hz through the serial interface (Read VI) regardless of STM32 Board.

0 Kudos
Message 3 of 8
(2,398 Views)

You still haven't explained what your problem is.

0 Kudos
Message 4 of 8
(2,377 Views)

I will simply explain for you my problem again.
When loading the buffer data from Read Buffer (Read VI), CPU load status is different when fetching 100ea data (16bit hexa array) and 200ea data per one second from Read Buffer (Read VI) regardless the STM32 board and communication protocol.

For example, 100Hz transmits the 16bit hexadecimal type data every 10ms from UART. (200Hz is every 5ms)

 

- 100Hz of CPU Load is about 22.7%

- 200Hz of CPU Load is about 42.3%

0 Kudos
Message 5 of 8
(2,369 Views)

And I'll state again.  Why do you think that is a problem?

 

When you are telling a PC to do twice the work, why do you think it is a problem that it is trying to work twice as hard?

 

Your results seem pretty logical to me!

0 Kudos
Message 6 of 8
(2,344 Views)

Hi haechitech,

 


@schkorea_haechitech wrote:

I will simply explain for you my problem again.

- 100Hz of CPU Load is about 22.7%

- 200Hz of CPU Load is about 42.3%


This can be related to using BytesAtPort in your "Read" state: in "Init" state you switched off the TermChar so you should request a known number of bytes.

This also can be related to routines in this missing subVI "Queue_state".

And it can be related also to your loop converting the "Send_Command" to the "Send Message": there surely is a simpler way of conversion.

And it can be related too to your abuse of local variables when the terminals are unused in the block diagram!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(2,341 Views)

Based on what I am seeing in your code, a State Machine is not what you are trying to do here.  You are trying to make a Queued Message Handler.  So you don't need the state shift register.  Instead, move your Dequeue out of the case structure and have its output go into your Queue_State.vi.  And I will state that you really should make sure you are constantly attempting to read from the port and reacting to any data that comes through.


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
0 Kudos
Message 8 of 8
(2,320 Views)