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?
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?
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.
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”,…
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.