Arduino Uno + SeeedStudio CANBus Shield v1.2 -- Basic Example not working

Hi

Please go easy as I am very new to Arduino.

I have two Arduino Uno and I want them to communicate over a CANBus. I have two Canbus --CAN-BUS Shield V1.2 | Seeed Studio Wiki and tried to run the basic example of two Arduino talking to each other. I believe the default pin layout match with each other(MISO-MISO etc, D9 default Select pin etc), and I directly inserted the Shield over the arduino.

I am sure my circuit is good as I have tested continuity (CANH/CANL from one CANBus is connected to other, tested when powered off and common ground removed), voltage (Both CANH/CANL seem to be 2.55v), and Resistance (these CANBus come with 120 ohm termination resistance, the effective resistance between the CANH/CANL was 60 ohm when connected) with a multimeter. When I run the experiment, I also have a common ground with the two micro-controllers and use jumper wires to connect CANH-CANH and CANL-CANL.

However, I am not able to run even the basic experiment (one is a sender, the other a receiver). Looking at the return values of various calls, the CANBus initializes successfully with Pin 9 as default, but I see that sendMsgBuf returns CAN_SENDMSGTIMEOUT for 5 times, followed by CAN_GETTXBFTIMEOUT forever. The board shows the Tx light on the sender light up, however the Rx on the receiver doesn't. I have experimented with baud rates from 5KBPS to 500KBPS.

I have tried various libraries too
GitHub - Seeed-Studio/Seeed_Arduino_CAN: Seeed Arduino CAN-BUS library - MCP2518FD&MCP2515&MCP2551 (Master and v1.2)
GitHub - Longan-Labs/Aruino_CAN_BUS_MCP2515: Arduino CAN Bus library, MCP2515/MCP2551 (v1.1)
GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library
GitHub - autowp/arduino-mcp2515: Arduino MCP2515 CAN interface library

But the results have been the same everywhere.

Could anyone provide any insight on what is wrong in my setup? Can I use jumper-wires to connect CANH/CANL or is something else required?

Thanks!

when programming the canbus shield I used

the shield was connected to a commercial canbus device
the pinout on the shield and target device were different so I had to make a converter but you should not have this problem
I found it useful to have a USB-CAN adapter so I could monitor traffic on the bus

Do you have an oscilloscope to look at CAN_H or CAN_L? If you tried my library and demos (and adjusted the CS and INT pins accordingly), I suspect there is a hardware problem with the shields.

Hi coryjfowler, thanks for your reply!

I unfortunately don't have an oscilloscope on hand, but can try to find one.

You suggested adjusting CS and INT pins, this image (https://raw.githubusercontent.com/SeeedDocument/CAN_BUS_Shield/master/image/PINMAP.png) of my board suggests pin 9 for CS, and pin 2 for INT. That is what I chose, is it correct? I have trie pin 10 for CS too, it fails to initialize.

I have exchanged sender and receiver and have the same result. I have also replaced both shields with new ones, and have the same problem.

Also, I think I have found something weird.

If I connect the power via a AC/DC adaptor that outputs 5V/2A (to both or either one Arduino (with shared V_in) and common ground), I get the same CANH/CANL = 2.5V
However, If I connect it via a Serial to USB cable to a laptop, results can vary. If connected to the sender, I get CANH=3.0V and CANL = 2.0V as the sender voltage dominates, and if I connect it via receiver, I get CANL/CANH = 2.5V.

In short, if the power is through the adaptor, CANH/CANL is always 2.5V. However, if power is taken via the
USB serial cable, it lets the arduino with the power dominate the CANH/CANL voltage. Although it looks like the sender does legitimately try to send the data, the receiver still doesn't receive it (even at 3.0/2.0 Voltage levels).

Sorry for the long reply.

Thanks!

Just as a follow up -- taking power from Serial to usb wires solved the problem.

Must be something wrong with the adaptors. Or are the shields not supposed to be powered by the adaptors or v_in/gnd pins?

Just to clarify -- I tried

  1. two adaptors, one for each arduino.
  2. one adaptor, but the other one getting v_in and gnd from the other.
  3. one serial cable and two adaptors together
  4. one serial cable and one adaptor, separate
  5. one serial cable, but the other one getting v_in and gnd from the other.

None of them worked. what worked was two independent serial cables powering one arduino each.

You said you were using Arduino Unos, are those official versions or clones? Using VIN should have no real effect on the operation... I have one at my desk right now that is running off the VIN input.

Sorry, I forgot about this post.

I guess I wasn't clear, the arduino works fine with any of the power input. However, the voltages on the shield's CANBUS terminals are different.

My guess is that getting power through the adaptor or sharing through v_in pins supplies a small amount of current, that interferes with getting proper voltage on the terminals.