How to convert a working serial communication model into a Desktop Real-Time one?
7 次查看(过去 30 天)
显示 更早的评论
Hello, I have created a communication model using Simulink to read physical values from an IMU. The IMU is connected to the computer via serial port. The goal is to implement this communication model using Simulink Desktop Real-Time.
So far I have created a working model, which is attached. In the model I use the Serial Receive block, which unfortunately does not work for Desktop Real-Time applications. The IMU continuously send messages of 77 bytes, where the first 4 bytes are always identical and thus are entered as headers. Afterwards the bytes are split by the demux block.
Is there a way to transfer this working model to a Desktop Real-Time capable model?
My first approach was to work with the Packet Input Block. I took the settings from the Serial Receive block and then added the FIFO Write and FIFO Read Binary blocks to be able to enter a header and cache the data.
Unfortunately this way does not work. The messages arrive but do not reflect the movements of the IMU. Also, when trying to run the model with Desktop Real-Time, an error message occurs "Dot indexing is not supported for variables of this type."
If anyone can help me with this problem, I would appreciate it very much.
Thanks in advance
0 个评论
回答(1 个)
Vidip
2024-3-20
To transfer your working Simulink model for use with Simulink Desktop Real-Time, especially for serial communication with an IMU, you'll need to replace or adapt any blocks that are not supported in real-time environments, such as the Serial Receive block. The Packet Input block is a viable alternative for this purpose. It's crucial to correctly configure this block, including setting up the header correctly to match your IMU's data packets and ensuring the payload size is accurately defined. Additionally, using FIFO blocks for buffering can help manage the data flow, but you must ensure these blocks are configured with the correct size and data type to handle your IMU's output.
The "Dot indexing is not supported for variables of this type." error suggests an issue with how data structures are accessed or manipulated in your model, possibly within MATLAB Function blocks or in the way you're processing the serial data. Addressing this will likely involve reviewing and adjusting any custom code or data handling logic to ensure compatibility with real-time execution constraints.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!