I tried to use the Arduino MKR ZERO to control the Arduino MKR CAN shield to send CAN signal to another device, but I failed to receive the signal when using an Arduino UNO with mcp2515 CAN module as a receiver.
I used the sample codes in the mcp2515 library (GitHub - autowp/arduino-mcp2515: Arduino MCP2515 CAN interface library) for the test and these codes worked when I tried to set up the communication between two Arduino UNO. So I am wondering if the MKR ZERO is not compatible with the MKR CAN shield.
there was nothing wrong with the compiling and uploading of the code, I just could not receive anything from the Arduino UNO. I tried to change the CS to another pin but it still didn't work.
Can the Arduino MKR ZERO work with the Arduino MKR CAN shield?
Definitely.
There are some important things to know:
The markings on the silkscreen on the bottom of the MKR CAN Shield may be wrong. On mine, the CANL and CANH markings are switched with each other. The correct order of the pins on the terminal block is:
VIN
CANH
CANL
GND
The other important thing is that the shield's CS pin is pin 3. So on the sketch you upload to your MKR Zero, you should have this line:
MCP2515 mcp2515(3);
As for the Uno, it just depends on which pin on the Uno you connected the CS pin of your MCP2515 module to.
There are some important things to know:
The markings on the silkscreen on the bottom of the MKR CAN Shield may be wrong. On mine, the CANL and CANH markings are switched with each other. The correct order of the pins on the terminal block is:
VIN
CANH
CANL
GND
Amazing! I get the signal!
I tried several different libraries and none of them worked yesterday, because it was unimaginable that the silkscreen was wrong on the shield.
Thank you very much!
pert:
The other important thing is that the shield's CS pin is pin 3. So on the sketch you upload to your MKR Zero, you should have this line:
MCP2515 mcp2515(3);
As for the Uno, it just depends on which pin on the Uno you connected the CS pin of your MCP2515 module to.
I try to use the new library for both MKR and UNO, and it seems like the signal received from the UNO is not the same as that sent from the MKR. What I send from the MKR should be
40000310 5 0 0 0 0 3E
40000310 5 0 0 0 0 3E
40000344 5 0 0 0 0 3E
40000310 5 0 0 0 0 3E
40000310 5 0 0 0 0 3E
40000350 5 0 0 0 0 3E
40000310 5 0 0 0 0 3E
40000310 5 0 0 0 0 3E
40000344 5 0 0 0 0 3E
...
And the updating speed in the UNO is much faster than the speed of sending signals from the MKR.
I've read the document for the modified library and it seems like that the pin allocation is for UNO instead of MKR (e.g. in GitHub - milesfrankland/arduino-mcp2515: Arduino MCP2515 CAN interface library, the SI and SO should be connected to D11 and D12, respectively. However, the MISO and MOSI of MKR and the CAN shield are pin 10 and pin 8.) I am wondering if this is the reason. Did you have the same problem and if you have any potential solution for that?
Thanks again for your answer.