How to receive and transmit multiple CAN-Messages in a single time-step on a Raspberry Pi 3B?
Show older comments
Hi all,
I am trying to set up a Simulink model on a Raspberry Pi 3B with Matlab 2021b. The model has to receive sensor-data and transmit results via a CAN-Bus with a bitrate of 500000. As CAN-Hat I am using the 2-CH CAN HAT from Waveshare (https://www.waveshare.com/wiki/2-CH_CAN_HAT).
The model has to send and transmit multiple CAN-messages in a single time-step. The implementation essentially looks like this:

The CAN_read subsystem runs at a shorter sample-time than the rest of the model to ensure all messages are received.
In the testet scenarios the model is removed so that I can enable mat-file logging and the system runs without task-overruns.
With the CAN_write subsystem commented out, the CAN messages are received normally. A Signal may look like this:

With the CAN_write subsystem active the same signal will look like this:

When comparing both plots it can be seen that with CAN_write enabled there are large gaps between the received messages of this signal.
Does anyone know what may cause this behavior, and how I can solve this?
Can I even use Receive- and Transmit-Blocks in such a manner? Is it not recommended to use more than one CAN-Transmit block?
Answers (1)
Enrico Landolfi
on 23 Nov 2021
Edited: Enrico Landolfi
on 23 Nov 2021
0 votes
Hi,
I have a similar problem with more than one can message featured by more signals, it seems that there is a delay between the CAN transmit and CAN receive, using two raspberry connected throgh CAN bus.
Any solution?
Categories
Find more on Vehicle Network Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!