Arduino Due CAN bus Communication via Simulink

12 views (last 30 days)
Hi,
I have Arduino Due with CAN shield to read and send CAN messages but some reason I was not able to read with the message via CAN receive block by Arduino Support Package.
I was successfully able to read the CAN message if I use the Arduino IDE but not with Simulink.
I did check both CP, SPI, and Inturrup Pin set up which matches what I have on Arduino IDE.
Can someone explain how this works?
My current blocks are
CAN Receive (Arduino Package) -> CAN Unpack (With DBC File) -> Scope.
THanks!

Accepted Answer

Min
Min on 6 Jun 2024
Forgot to answer and share the knowledge that I have since the issue has been conditionally resolved.
  1. It is possible to read the CAN message via Arduino as long as the hardware set up is appropriate.
  2. It is required to follow this step to not fail the CAN set up
  • Turn off the system
  • Plug the Arduino without turning the entire system on
  • Deploy the Simulinik model
  • Once it is deployed turn on the entire system
Sending CAN message is also posisble but with Arduino, it is limited due to its speed.
I am currently looking into using Raspberry Pi for higher speed (84 Mhz vs 1.4 Ghz).

More Answers (1)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU on 6 Jun 2024
Hi Min,
Simulink's CAN Receive block might not fully support Due's CAN bus. Consider using the S-Function Block for more control.
There could be mismatches between Simulink's generated code and your CAN shield setup. Enable Simulink's Hardware Logging to monitor CAN communication during simulation.
If these suggestions don't help, share details about your CAN shield, DBC file, and relevant code for further troubleshooting.

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!