MKR CANBUS Packet loss

Hi all,
I have a MKR GSM 1400 + MKR CAN Shield plugged to a PEAK PCAN-USB.
On PEAK side I need to send 12 8byte messages with 3ms time cycle to my Arduino. The final goal is to send those messages to a server, but I have a big packet loss problem with CAN reading.

I'm using Sandeep Mistry's CAN lib and I loaded CANReceiver.ino into the MKR.
I set my Serial to 115200 and the CAN to 1000E3 (1Mbps, in according to PEAK).
The wiring seems ok and I powering the MKR with a USB cable.

The issue
If I send all 12 messages with the same time cycle, I'm getting a big packet loss on Arduino side.
E.g. 12MEX 3ms each: Sent 63516 - Received 24434 (61.54% lost)

Then, I removed all Serial.print() but one that printed a counter: Sent 47832 - Received 31875 (33.37% lost)
Then I printed the counter every 100 packets: Sent 44736 - Received 29800 (33.39% lost)

I reduced the 12messages to 6 only: Sent 21348 - Received 21000/21100 (1.64% lost)

I set 200ms instead of 3ms (sending 6 messages): Sent 474 - Received 316 (33.33% lost)
I changed while(Serial.available()) to a for 8Bytes and I removed all other check (CAN.packetExtended() or CAN.packetRtr()): Sent 696 - Received 538 (22.70% lost)

Eventually I set slightly different time cycles for 6 messages (200, 201, 202, 203, 204, 205) and I got all the messages!
I reduced again the time cycles to (3,4,5,6,7,8ms): Sent 26511 - Received 26372 (0.52% lost)

I think there're some buffer limitation I'm not aware about. CAN reading is also a new scenario to me and I wonder if I'm taking full advantage of my boards.

Thank you for helping me :slight_smile:

Apparently there was a bug in the lib.
With THIS PR I got 0% packet loss with 1Mbps CANBUS messages even with 3ms time cycles.

Are the grounds connected, if so post a schematic, not a frizzy thing.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.