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.
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.
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).
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.
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.