0
\$\begingroup\$

As a hobby project, I created an IoT module that allows to control and monitor heating boiler remotely over CAN bus. The bus runs at 125k and is relatively short.

Usually, after a few hours of normal operation, when transmitting a frame from my module, I get a Bus Error on TX Data.

My module is connected as a stub (no termination - R9 not mounted). Looks like the bus is terminated inside boiler (getting 60Ohm between L and H). My MCU is ESP32 and I've choosen SN65HVD230DR (3.3V) as a transceiver. RS value is 47k and it should be theoretically optimal.

I've tried different drivers and BRP settings - still getting same error. Ended up with software workaround - reset and retransmit cached frame.

I suspect few things:

  • Voltage diff (this is 3.3V transceiver and might not be able to drive sufficient voltage level, but they say in datasheet it is compatibile with 5V transceivers).
  • Bit timings (clock drift or something, need to check it but I need some time to setup equipment in the basement).
  • ESP32 errata issue.
  • Slew rate.

What might be the cause of occasional bus errors? What should I try next?

Schematic

\$\endgroup\$
10
  • 2
    \$\begingroup\$ Tell us more about your power supply, and the ground connection between the furnace and your board. Is the cable shielded, where is the shield connected? Are the two grounds you show in the diagram the same ground? Any ferrites on cables? Are the errors correlated with anything happening, can you cause errors by switching on a high current mains device in the house? \$\endgroup\$
    – tomnexus
    Commented Feb 22, 2023 at 19:26
  • \$\begingroup\$ Power supply is a mobile charger (5V) connected to my board. Then there's AP7361C LDO with 4.7uF MLCC on each side. ESP32 has two capacitors 22uF and 100nF close to VCC/GND. Grounds are connected together (GND CANL CANH - both connectors). \$\endgroup\$
    – h4rdc0der
    Commented Feb 22, 2023 at 19:37
  • \$\begingroup\$ "when transmitting a frame from my module" - always when you TX? Ever during RX? \$\endgroup\$
    – rdtsc
    Commented Feb 22, 2023 at 20:26
  • \$\begingroup\$ I've used ecc register to capture and direction was always TX and seg was always TWAI_LL_ERR_SEG_DATA = 10. Well the retransmit mechanism that I've implemented also confirms that, because I'm now not missing any response when retrying to send frame after bus error (& reset) \$\endgroup\$
    – h4rdc0der
    Commented Feb 22, 2023 at 20:52
  • \$\begingroup\$ "My module is connected as a stub" How long a stub? \$\endgroup\$
    – Lundin
    Commented Feb 23, 2023 at 9:14

2 Answers 2

1
\$\begingroup\$

It looks like that the problem was caused by CANOpen device that periodically scans the bus by transmitting a frame on each possible SDO client slot.

This causes conflict between my SDO request and another one on the bus. It results in two CAN frames with same ID at once.

\$\endgroup\$
0
\$\begingroup\$

I get a Bus Error on TX Data

This sounds suspiciously similar to trying to send something while the transceiver is in standby (listen-only) mode. Why are you using SN65HVD230 instead of SN65HVD232 since you aren't using the standby feature anyway?

RS value is 47k and it should be theoretically optimal.

47k is a questionably high resistance value for a pull resistor. EMI on this pin (assuming industrial setting) might possibly trick the transceiver into entering standby mode. Recommended values for pull resistors in industrial systems is usually 4k7 or 10k. Although from what I remember you might as well tie it directly to ground.

Also of course check the usual suspects: supply, soldering, component values etc.

I would try to replace R2 with a 0R resistor/tie pin 5 ground/alternatively switch to SN65HVD232 (pin compatible) and see if this solves the problem.

Voltage diff (this is 3.3V transceiver and might not be able to drive sufficient voltage level, but they say in datasheet it is compatibile with 5V transceivers).

I have lots of experience in using these specific CAN transceivers TI/SN65HVD23x in production together with 5V transceivers. My experience is that the SN65HVD23x are not great - the signal tends to look much worse than one from a 5V transceiver - but they do work; the differential signal is very forgiving.

Additionally it is recommended to use a common mode filter on CANH/CANL, there are such parts specifically designed for CAN.

\$\endgroup\$
4
  • \$\begingroup\$ Soldered 220 resistor. No changes. Then tied to ground and ... no arbitration lost anymore. Will leave it for a day or two to check. \$\endgroup\$
    – h4rdc0der
    Commented Feb 24, 2023 at 8:30
  • \$\begingroup\$ @h4rdc0der Is it just 1 piece with this behavior or multiple? Because at 220R it ought to behave and if it doesn't I'd start to suspect ESD damage on the pin or maybe some PCB trace issue. For the long term solution maybe consider switching to SN65HVD232 anyway. \$\endgroup\$
    – Lundin
    Commented Feb 24, 2023 at 8:49
  • \$\begingroup\$ I decided to move towards MCP2525, will try it. \$\endgroup\$
    – h4rdc0der
    Commented Mar 6, 2023 at 9:09
  • \$\begingroup\$ @h4rdc0der That appears to be a controller with built-in tranceiver. Don't you already have a controller inside the MCU? \$\endgroup\$
    – Lundin
    Commented Mar 6, 2023 at 11:35

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