Questions about operation with Serial Receive block

19 views (last 30 days)
Kohei Sagawa
Kohei Sagawa on 12 Nov 2024 at 8:00
Answered: Kanishk on 18 Nov 2024 at 11:30
Hi
I would like to use the serial reception of the Instrument communication tool box for communication with a microcontroller. When I try to run the Simulink model, it too slows just by using the serial receive block. Using the serial transmit block does not slow down operation.
If you know of any, please share your solutions.

Answers (1)

Kanishk
Kanishk on 18 Nov 2024 at 11:30
I understand you are experiencing slowdown in serial receive block while using Simulink. This should not be the case as the block is designed to handle serial data efficiently. Also, you are not experiencing any slowdown in serial send(referred as serial transmit in the question) therefore, the slowdown you are experiencing might be due to specific configurations within the serial receive block.
Attaching the model in the question would be very helpful in identifying the exact issue and resolving it effectively.
In the meantime, here are some common troubleshooting steps that might help resolve the issue:
  1. Ensure that the baud rate and other serial port settings (data bits, stop bits, parity) in the Serial Receive block match the settings of your microcontroller. Mismatched settings can lead to communication errors and slowdowns.
  2. Verify that the buffer size is appropriately set. A small buffer might cause frequent interruptions, while a buffer that is too large might delay processing.
  3. Check if the data being received is processed efficiently. Consider using smaller data packets if possible.
  4. Adjust the sample time of the Serial Receive block. A very small sample time can cause the model to slow down due to frequent execution. Experiment with different sample times to find a balance between performance and data freshness.
  5. Ensure that the data processing logic within your Simulink model is optimized. Any heavy processing tasks should be offloaded to dedicated blocks or functions if possible. Create a simple Simulink model with only the Serial Receive block and minimal processing to isolate the issue. This can help determine if the problem is with the block itself or interactions with other parts of the model.
If the issue persists after following these steps, please share your Simulink model, as it will help the community pinpoint the issue more effectively.
Please go through this official MATLAB documentation of serial receive block to learn more.
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!