Customer:
I am having problems using the MCP2518 CAN Bus Breakout Board with an Arduino Nano and the Soldered Arduino library. I have connected an Arduino Nano to the MCP2518 breakout and added an external 120-ohm resistor to connect to a CAN network. I loaded the code into Visual Studio with a gdb debugger rather than the Arduino IDE. I am unsure of the issue but suspect it may be related to the SPI setup. I have not yet analyzed the communication with a logic analyzer in detail. I am planning to eventually use this with an MSP430, but I want to get the quickstart working with the Nano first.
Attachment omitted in migration: test_setup.jpg
Attachment omitted in migration: VCODE_step1.png
Attachment omitted in migration: viewtool.png
Originally submitted via email support on 25 February 2024. Migrated to the forum for community visibility.
Soldered Support:
Check your wiring first. The default SPI pins on an Arduino Nano are: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). Verify your pinout and remember that MISO and MOSI are not swapped like RX/TX in Serial communication.
Can you clarify what the CAN monitoring window shows? Are you receiving any data at all from the Arduino Nano, or are CAN1 and CAN2 other devices on your network?
Customer:
I tried swapping the pins to check if I had mixed up the communication lines, and everything appears to be correct. I purchased extra long header pins which I will solder and connect to a logic analyzer for better debugging.
The CAN monitor has 2 channels. I connected them to verify that communication is working between those 2 CAN nodes. The missing CAN node is the one we expect to see from the MCP2518-Arduino circuit. I will write again after the weekend with more details from the logic analyzer.
Soldered Support:
The logic analyzer should tell us a lot, mainly if the CAN breakout is outputting anything at all, and if not—whether the Nano is communicating with it via SPI correctly. Let me know what you find.
Customer:
I have insight from the logic analyzer. I modified the code to call:
CAN.begin(CAN_125KBPS);
followed by send message commands every couple seconds:
CAN.sendMsgBuf(0x04, 1, 3, stmp); // Send data in CAN network
I tried changing the second parameter between normal and extended frame with no success. I can see messages between the MISO and MOSI lines, and the clock line aligns well with the CS. I have not yet studied the MCP2518 manual to understand the registers and data sending process.
Does the SPI communication look valid from the logic analyzer data? Does the chip appear to be working correctly? I am unsure why it is not sending CAN messages to my viewing tool. I also noticed something strange: when using the Arduino IDE with Serial.println() for troubleshooting, I got the same messages whether the MCP2518FD was wired or whether it was just the Nano standalone with nothing attached.
Attachment omitted in migration: SPI settings.png
Attachment omitted in migration: start_and_sending_messages.png
Attachment omitted in migration: logic_analyzer.jpg
Attachment omitted in migration: in_CSV.csv
Attachment omitted in migration: in_text.txt
Attachment omitted in migration: main.cpp
Customer:
I used an oscilloscope on the CAN line and captured two scenarios:
- Sending 1 message with the Gingko Viewtool
- Sending 1 message with the MCP2518 using a while(1){} loop after the CAN.sendMsgBuf() command
The MCP2518 output appears to show just a continuous attempt. I performed this test with the Viewtool unplugged.
Attachment omitted in migration: from_MCP2518.jpg
Attachment omitted in migration: message_1_close.png
Attachment omitted in migration: SPI settings.png
Attachment omitted in migration: start_and_sending_messages.png
Attachment omitted in migration: from_viewtool.jpg
Attachment omitted in migration: message_1.png
Attachment omitted in migration: logic_analyzer.jpg
Soldered Support:
After consulting with colleagues, we believe there is likely a fault in the library. I don’t have an exact timeframe for a detailed investigation as we have a busy schedule, but I recognize that you should have a working product. In the meantime, could you try another library? The RAK13006 MCP2518 library is available at https://www.arduino.cc/reference/en/libraries/rak13006-mcp2518-library/