0
\$\begingroup\$

I am trying to connect a new board to my CAN bus and I have an issue with the voltage. The new board is a Raspi 4 and has a "RS485 CAN HAT" connected to it. To debug, I use can-utils.

When I am testing the bus and sending some dummy CAN frames, I have the following : CAN BUS with can0 down

However, when my board is connected to the CAN bus AND I activate the link (sudo ip link set can0 type can bitrate 125000 + sudo ifconfig can0 up), I obtain the following :

CAN BUS with can0 up

It looks like to me that the signal is not at all correct. Interestingly, if the link is disabled (sudo ifconfig can0 down), I get the normal waveform.

I already checked the resistance and it's 60 ohm between CAN_L and CAN_H. (in both cases)

Does anyone know what's happening? (My suspicion is that the CAN hat is not working properly.)

\$\endgroup\$
5
  • \$\begingroup\$ waveshare.com/w/upload/1/1d/RS485_CAN_HAT_Schematic.pdf \$\endgroup\$ Jan 4, 2022 at 18:05
  • \$\begingroup\$ Looks like you have 5V RS485 driving a 3V bus. with an average DC of 2.25V ? why 5V? Although differential looks clean \$\endgroup\$ Jan 4, 2022 at 18:06
  • \$\begingroup\$ Did you set the config.txt file to the correct oscillator frequency? I'm guessing the issue is incorrect baud rate causing the Rpi to flag the frame as error frame. Could be caused by incorrect oscillator setting. \$\endgroup\$
    – Klas-Kenny
    Jan 4, 2022 at 18:30
  • \$\begingroup\$ It appears like a termination problem. I am assuming the bus was properly terminated then when you add the CAN hat you are adding another termination resistor. It is also possible you have the two CAN lines crossed. Per the schematic that 120 Ohm resistor is not removable from the circuit without modification to the Hat. \$\endgroup\$
    – Gil
    Jan 5, 2022 at 0:57
  • \$\begingroup\$ Your CANH got the wrong voltage. It might work still since differential is 2V, but there's some hiccup with your CAN transceiver. The second picture is an error frame. Yet another CAN beginner with only one node on the bus? See What are the most common causes of CAN bus communication errors? \$\endgroup\$
    – Lundin
    Jan 5, 2022 at 7:43

1 Answer 1

0
\$\begingroup\$

My error was to assume an 8M crystal (according to the pdf datasheet). However, the webpage of the CAN HAT specifies that the new version has a 12M crystal. (It needs to be dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25,spimaxfrequency=2000000 in /boot/config.txt)

Thank you Klas-Kenny for the tip !

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.