CAN Receive Block from Raspberry Pi Support Package: Why does CAN Message reception stops working after some time?

3 views (last 30 days)
I am trying to send Extended ID CAN Messages with 8 data bytes from an Arduino to a Raspberry Pi. For this I am using the CAN Receive Block from the Simulink Support Package for Raspberry Pi and an external MCP2515 based CAN Modul, more precicely the Joy-it SBC-CAN0 (MCP2515 Datasheet in Attachment). To debug the communication, the simulink modell implemented on the Raspberry Pi runs in External Mode so I can see when new CAN message arrive in realtime. Every 30ms The Arduino sends CAN Messages with an adjustable delay between the messages and increments the first data byte of the CAN Data by 1 or resets it to 0 in case the previous value was equal to 255.
The debug modell, which I added in the attachments, then also checks for every CAN Channel (=CAN Receive Block linked to a specific CAN ID) if the fist of the received Data bytes got incremented by more than 1 per send cycle (=30ms from arduino). This would indicate that a CAN Message has been missed.
The communication works just fine, but at some point I am not able to see any new messages arriving in the Simulink modell. You can see this behaviour at the saw-tooth- like plots in the Simulation Data Inspector. (Screenshot of plot in the attachment). The duration until the communication stops working varies from several seconds to over 100 sec, even if no parameters has been changed.
I have monitored the CAN Signal, the interrupt and the SPI Communication for the moment where the Communication stops. To do so I triggered the Oscilloscope to the Interrupt PIN of the MCP2515 connected to the Raspberry beeing low for longer then the delay between CAN Messages. This marks the point of the stopping of the communication because the process of reading the Receive and Error Registers of the MCP 2515 is initiated by a falling Interrupt edge. I have this information from the MW_CANInitializeInterrupt function in the MW_MCP2515_CAN.c file used in the Code Generation in Embedded Coder. I noticed that the last CAN message before communication stops is read properly from the MCP2515. But instead of returning to HIGH, the Interrupt pin stays LOW. Since there is no falling edge on the Interrupt Pin after that, no new CAN message is read from the MCP2515. If I manually apply a HIGH Level to the INT PIN an release in shortly afterwards so it turns back to a LOW Level, the raspberry starts reading CAN Messages from the MCP2515 once again, probably because there is a falling edge once again.
Valid CAN Messages from the Arduino keep beeing send, also if they aren't received an displayed in the Simulink modell anymore.
For cycle time of 30ms, if I decrease the delay between the sending of the CAN Messages, the communication stops more often an doesn't start at all if the delay is to short. Also the number of missed CAN Messages increases.
In addition, to initiate the communication in the first place, the Interrupt Pin has to be manually brought up to a HIGH Level and released again. If not, there is no falling edge and so no data is read from the MCP2515 registers.
In Conclusion, it seems to me that something in the MCP2515 causes the Interrupt Pin to stay LOW even if it shouldn't.
Does anyone know what could be the reason for the interrupt Pin to stay low? Or is there maybe a totally different reason why the communication suddenly stops?
I use a Raspberry Pi 4 modell B with the mathworks_raspbian_R20.2.0 image and the Matlab 2020b release.
The plot in the attachment was recorded with a delay of 600ms between the CAN Messages, a send cycle time of 30ms and a sample time of 0.1ms for the CAN Receive Blocks.
  7 Comments

Sign in to comment.

Answers (0)

Categories

Find more on Raspberry Pi Hardware 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!