Electronic – Electronically connecting/disconnecting device from a CAN bus


What I'm trying to do can be best described by the following circuit based on an electromechanical relay:


simulate this circuit – Schematic created using CircuitLab

However, is there a simpler solution not involving any mechanical/moving parts? [[ edit: as pointed out by Lundin's answer, switch bouncing and EMI from the coil could mean that this approach is entirely unsuitable ]]

The "complication" is that CAN is a broadcast bus with open-collector-like connections (not sure whether they are implemented as true open-collector) to emulate a "wired-AND" (any device can assert a logical 0). However, I'm not sure how exactly the physical "driver" (on the device's connection to the bus) is implemented, since it is differential, with states being: both lines at 2.5V for a differential voltage of 0V, and (CAN_H,CAN_L) = (5V,0V) for a differential voltage of 0V (not sure whether it is always like that, but this seems to be one common scheme).

Would a MOSFET transistor acting as a switch do the trick? What about a solid-state relay? Would the SSR be able to transmit the 1Mbps (Megabit per second) signal when in its "closed" state?

Reaction time (time it takes to connect or to disconnect the device) is not important. [[ edit: the intended notion was "disconnect latency"; as long as the actual disconnection happens fast, it does not matter that it takes 100ms from the time we decide that we want to disconnect to the time when we actually disconnect it ]]

Best Answer

The first concern here is that whenever you cut up a CAN bus live, there will be a high risk of error frames if there are on-going transmissions. The system as whole must be able to deal with them if you are to do this. The slower the toggle, the more error frames you'll get.

At 127 received error frames, CAN controllers enter an error passive state, and at 255 error frames they consider the bus "dead" and enter bus-off state. In the worst case, 1MB baudrate, it only takes around ~10ms for 255 error frames to pass, after which you have killed the entire bus.

The ideal switching device only gives one single error frame. So what you call "reaction time" is important. A slow or unreliable switch can crash the whole bus, particularly at higher baudrates.

For the above reasons, a plain relay is entirely unsuitable for the task. Not only is it incredibly slow, it also has contact bounces. It means even more data losses on the bus as whole. Plus EMI concerns depending on how the coil is handled.

A MOSFET or solid state relay is less bad, as they won't have the bounces, but they are still very slow and not suitable for high speed data signals.

What you should use is an analog switch, which is fast, with low on-resistance and low losses. Which one to pick probably doesn't matter that much, though a 2 channel one would obviously be ideal.

Alternatively you could also just disable your CAN transceiver, if you don't need to unplug it physically.

Related Topic