# Automatic CAN bus termination

I have two CAN busses which are each terminated on each end by a 120Ω resistor, as shown in the diagram below. The CAN bus consists of a CAN high, CAN low and ground connection. To terminate it, a 120Ω resistor connects CAN high and CAN low.

Sometimes I want to use both CAN busses completely separate but in some situations, I want to connect the devices D3 and D4 together, making a single bigger CAN bus.

To connect the two, I need to remove the two resistors R2 and R3 and then connect the CAN bus together. My CAN connection currently terminates in a D-SUB connector X1 (at each end D1, D3, D4, D6) to easily connect other CAN devices. At the same time I have a switch (S1) that will enable or disable the CAN bus termination, as can be seen in the schematic below.

What I want to do is to remove the manual operation of the switch S1 by including something in the D-Sub connector X1. When nothing is connected to it, the terminating resistor R1 will connect CAN high and CAN low. But when I connect another device to the connector X1, the resistor R1 will not connect CAN high and CAN low anymore.

I would appreciate any tips that point me towards a possible solution. I should also mention that connecting and disconnecting any device will happen when everything is powered off and does not need to happen during operation.