04-28-2020 09:37 PM
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.
04-28-2020 10:28 PM
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.
04-28-2020 10:55 PM
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.
04-28-2020 11:40 PM
You still haven't explained what your problem is.
04-29-2020 12:04 AM - edited 04-29-2020 12:05 AM
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%
04-29-2020 03:19 AM
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!
04-29-2020 03:43 AM
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!
04-29-2020 06:45 AM
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.