MATLAB Answers

Why does the CAN Receive block from Raspberry Pi support package not work with PiCAN 2 shield?

39 views (last 30 days)
I am using the PiCAN 2 CAN bus shield for Raspberry Pi. In my Simulink model, I inserted a CAN Receive block from the Simulink Support Package for Raspberry Pi. In the model's Configuration Parameters, I set the Interrupt Pin to 25. However, I am unable to observe any CAN bus signal.
When I use other tools such as Vector CANoe, I am able to observe the CAN bus signal. Why does the CAN Receive block from Raspberry Pi support package not work with PiCAN 2 shield?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Apr 2020
Edited: MathWorks Support Team on 24 Apr 2020
Raspberry Pi CAN blocks are designed to work with MCP2515 based CAN shields. For PiCAN2 shield however, the interrupt GPIO Pin is not saved correctly in the code from the model's Configuration Parameters. As a result, the interrupts triggered by the CAN shield are ignored.
To work around the issue, follow below steps:
1. Execute the following command at the MATLAB Command Prompt:
>> cd(fullfile(codertarget.raspi.internal.getSpPkgRootDir,'include'))
2. Update the file “MW_MCP2515_CAN.h” in the above directory with the following changes at line no 33. Replace
#define INTERRUPT_PIN 12
with
#define INTERRUPT_PIN (MW_CAN_INTERRUPTPIN)
3. Restart MATLAB.

  4 Comments

Show 1 older comment
Chris Hadamek
Chris Hadamek on 18 May 2020
This is not working. Im now in contact with the Support Team since March, 18.
Im defintely sure, that there is still somthing wrong with the Interrupt Pin because CAN_Trasmit works fine.
Python Code Examples working perfectly. But the simulink reveive blocks dont work. Or not work as you might think like they should. Its like a lottery.
I tried everything with no successs.
Simone
Simone on 31 May 2020
Dear Chris,
did you solve your issue with Simulink receive blocks?
I might be interested in working with these tools.
Thanks
Chris Hadamek
Chris Hadamek on 3 Jun 2020
Hi Simone,
here's the latest answer from Support:
"We have discussed your last post with our development.
Regarding data drop while receiving multiple messages, this is currently a limitation within our implementation of the CAN blocks.
We are working on it and fix will be available in future releases. We will document this in the next September release.
There is currently unfortunately no workaround."
It seems, that the CAN Receive Blocks were not made for can buses with more than one Signal which is very strange.
Im trying to trigger a python script on the raspberry Pi via Simulink which gives me back a list of received CAN Signals.
In that case you also have to use the python scripts for transmitting CAN Signals.
Kind regards
Christof

Sign in to comment.

More Answers (1)

Chris Hadamek
Chris Hadamek on 14 Oct 2020
Hi Support Team,
is there now a Solution for that? Because the Simulink "CAN Receive" Blocks doesnt support multiple messages on any CAN Bus. Python examples still work.
Kind regards

  0 Comments

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by