# What is the simplest hot swappable bus protocol?

After I figured that I2C bus is hard to be hot swapped unless use other hardware solution such as PCA9511A(very expensive industrial solution), I am planning to use another bus to replace I2C.

The requirement of the ideal bus should be:

1. require as less as the data lines ($\le$ 2 is the best)
2. MUST capable with hot swap
3. low manufacture cost (as low as possible)
4. stable
5. no specific transmit speed/bandwidth (< 2 kb should be fine)
6. no specific maximum networked devices (around 5 will be fine)
7. pure protocol hot swap(I know some USB are using the combination of long&short physical pins on the connector to control the priority of which module is detached first, but unfortunately it is not feasible in our design.. therefore we need a pure protocol contained hot-swap solution)

I hope there exist some protocol that matches my requirements but I am quite hard to find them and don't know hidden issues behind them. I know there are some modules designed products such as blocks can make that, so for any suggestions I am deeply appreciated, thanks...

Kind Regards

• I2C is amazing and fits your situation incredibly well. Not only is it less immune to data corruption from SCL-SDA crosstalk (due to data latching on the slow rising edges), its dead simple to implement electrically and can be extended many feet without too much issue. Not to mention the expansive I2C ecosystem. Is a $2 chip really too expensive? Also, have you looked at the TCA4311? Its$0.50-$1.00 cheaper. In quantity both chips are less than a dollar. Considering all the issues that come up during hot swapping operating data busses, I'd say that its worth the cost. – Los Frijoles Mar 9 '17 at 6:37 • Hi @LosFrijoles appreciated to your comments, I got one additional question, in the I2C ecosystem how many chips should I use? Just one in master device(the one always operates)? – Yank Mar 9 '17 at 6:43 • and I also heard that CAN bus is capable with hot-plug – Yank Mar 9 '17 at 6:46 • I2C is a multi-master bus, but most people use it in a single-master configuration. You generally have a microcontroller or some device acting as a master and a plethora of slave devices such as sensors or memories for it to talk to. Protocolwise, I2C is very transactional, so the master isn't always talking on the bus. In fact, most devices specify a minimum inter-transaction idle time. – Los Frijoles Mar 9 '17 at 6:47 • For CAN, you can hot swap it, but I believe you will need a transceiver capable of doing so. CAN is nice, but devices that can speak the protocol are usually more expensive. Its also gross overkill if all you need is 1kbps. There are many <$1 microcontrollers with I2C peripherals built in. I would challenge you to find a CAN-capable microcontroller in the same price range. The bus is also more complicated electrically (so it can operate very reliably in the electrically noise environment of a car). – Los Frijoles Mar 9 '17 at 6:51

I'm pretty sure you can make any bus hot swappable (I'm not aware of any hardware reason that would keep you from making a bus hot swapable). Powering the digital devices on the device is one of the biggest problems. A hot swappable device needs to take in power control as more of a consideration than the bus because it can cause a voltage spike in your system when its plugged in.

The problem is two fold:
1) There needs to be a way to detect that the bus is connected or not and the digital devices that are being swapped need to be powered before you start talking to it. There are connectors that exist that connect the ground first before any other power is applied to the pins. Why? because if you connect the digital lines (like VDD) first then you could have your transistors come up in a funny state (metastability). Especially if you have two different digital rails. This also allows for power caps to charge.

2) There also needs to be a way to detect if the 'bus' is plugged in, either with a switch or connector. Some connectors also come with pins that are as long as the ground so when the connector is plugged in, other digital logic can be alerted that there is a device and the software can talk to it. One thing I've done is put a pull up on the device and when it gets powered up, the microprocessor polls the pin of each device and when it detects the pullup the device gets turned on.

On the flip side, if you unplug it while its on, you need a way to quickly shut off power and digital logic (go to a high Z state on a buffer or microprocessor).

I've made a hot swappable SPI bus before with buffers on each device that wouldn't turn on until the processor enabled them.

You should be able to do this with I2C, if you wanted to do this with one I2C device on the bus and a buffer.

pure protocol hot swap(I know some USB are using the combination of long&short physical pins on the connector to control the priority of which module is detached first, but unfortunately it is not feasible in our design.. therefore we need a pure protocol contained hot-swap solution)

So one thing you will need to be concerned about is power, if you do indeed want a 'hot swappable' bus, you are going to have to control the power.

You could do a cold swapping approach where the software controls the power (via switches) on the outside and does not power up the device until it is fully 'plugged' in.

If you want a fully hotswappable device with power control on the device there exists IC's that do this Then its all software after that.

Most of the time its the software that really keeps you from hot swapping, it faults when it can't find the device after its removed.

I would recommend the 1-wire bus, developed by Dallas Semiconductor who were absorbed into Maxim.

It ticks all of your requirements and is very rugged. It's designed for quick contact connections so it inherently deals with hot-swapping.

You can find documents and specifications under:

www.maximintegrated.com/en/products/digital/one-wire.html

You can either use a dedicated bus master IC or implement one in software on a microcontroller, whichever suits your cost/volume situation best.