Connecting two CANbus shields

Hello,

I’ve been trying for days to get this to work, but no luck yet. Maybe someone can help.

I have two Sparkfun CANbus shields that I would like to connect together to communicate from one Arduino to another. I’ve tried the SK Pang library, Canduino library, mcp2515 library, and others with no luck. I can get the shields to work in “loopback” mode just fine, so I know the SPI is working fine.

I basically set up the shields to constantly send messages and to constantly listen for incoming messages. I haven’t been able to send or receive anything yet between shields. When reading the CANINTF register, it always receives 10100000B which signifies MERRF and ERRIF. I’m not sure why those messages are being received.

I connected a logic analyzer to the CAN pin and it was also unable to read any bytes successfully, even when the shields were not connected.

I’m not sure what to do. I’m hoping somebody here has tried something similar. Has anybody connected two of these and gotten it to work?

Thank you!

Have you connected a 120ohms resistor on the line ?

Angelo

I didn’t have a 120 ohm resistor available, but I tried connecting both 100 ohm and 150 ohm resistors between the CANH and CANL lines. That didn’t seem to make a difference. How much does the exact values of the resistor matter? Should I get a 120 ohm resistor and try that?

The exact value is not important on a short line like your lab setup. Value from 60 to 200 ohms is ok.

Try measuring the lines with a scope, just to be sure levels, waveforms and bitrate are ok.

Angelo

I connected a scope and the signals do not appear to be right. There are pulses (on CANH only) but they don’t seem to be at the right baudrate and don’t seem to be anything useful either. I’m not sure why this would be the case considering that I am using the demo programs that others have used.

Finally figured it out! In case anyone was wondering, the CAN addresses of the two boards must be different. I was running the same send/receive code on both boards, including the CANbus address. Not sure what was going on with the scope earlier but it looks great now.

Also, the 120 ohm resistor MUST be on the line. As soon as it is removed everything stops working.

a CAN message contains an ID, which is not defined for a specific purpose except for priority during transmission. Many nodes could send frames with the same ID. You should also set acceptance filter to interrupt software only on IDs you are interested on. Or read all messages and filter them in software. In fact every message is sent as “broadcast” message. You could use ID as “sender address”, “destination address”, “message type identifier”,…

Angelo

Hello,

I’m new to CAN-bus and I’d like to see the code you wrote for 2 nodes.

I’m trying to connect 2 CAN-bus shields in order to make these communicate.

Thank you!

I’d like to see that as well. So I just get in line ;D

Hi - is the sample CAN-CAN code posted somewhere or can you please send it to me as well ? I need to connect 3 devices so I also need to research how wiring for additional devices work. If anyone has researched that please share it as well ! I will send the code out once it is done.

Thanks.

Hi… May I also get in line to have have the CAN-CAN code? because currently I am also doing a CPU-CAN-CAN-CPU communication.

Thank you!

Im kinda new to the Arduino can bus shield, so it would be great if I can also have a copy of the code and the library for it.

Thanks!