50
\$\begingroup\$

I made the very stupid mistake of hot plugging stuff many times before. My problem is that I rushed and it's just so easy for me to forget I have the Arduino on or some other expensive IC or hardware plugged in.

Today I hotplugged the PWM input of my ESC to my Arduino digital pin. I saw the magic smoke escape. Bye bye a group of digital pins! I hate myself now.

Why do things not like being hot plugged?

Is there an easy way I protect against this?

\$\endgroup\$
7
  • 45
    \$\begingroup\$ Keep blowing stuff up and you'll eventually learn. \$\endgroup\$
    – Andy aka
    Commented Nov 16, 2017 at 12:58
  • 3
    \$\begingroup\$ Electrify the connectors? \$\endgroup\$
    – Trevor_G
    Commented Nov 16, 2017 at 13:01
  • 13
    \$\begingroup\$ why do things not like being hot plugged? Simple: they're not designed for it. Design some "stuff" yourself and make those hot-plugging capable and you can hot-plug all you like. When designing those you might find that your "stuff" becomes more expensive and maybe suffers in other ways like less flexibility for example. \$\endgroup\$ Commented Nov 16, 2017 at 13:01
  • 4
    \$\begingroup\$ Assume everything is NOT plug-and-play and you probably will have no problems. @Trevor solution is a tad drastic, but it would probably work. Over time evolution would kill off the violators. \$\endgroup\$ Commented Nov 16, 2017 at 14:57
  • 8
    \$\begingroup\$ "it's just so easy for me to forget I have the arduino on or some other expensive ic/hardware plugged in" Err, don't you have a power-on LED light? If you don't, buy a $5 power-strip that does. Turn off the damn power every time you're modifying the circuit. In fact don't turn it on until you've triple-checked your circuit is correct and ready. Should save you >>> $5 in no time. \$\endgroup\$
    – smci
    Commented Nov 16, 2017 at 23:57

4 Answers 4

8
\$\begingroup\$

Two other effects, in addition to these already mentioned, can upset very delicate circuitry:

-Shielded cables and coaxial cables are actually capacitors, which can hold a charge. This charge can be misinterpreted as a signal and cause unwanted state changes (eg a processor crash), or even...

-Latchup. With the IC powered, some types of unprotected CMOS inputs cannot stand any voltage above the supply voltage even for microseconds, since this will trigger a positive feedback effect (the whole device suddenly looks like a thyristor with these voltages applied) leaving the device in a crashed state or even acting as a near short circuit across its supply rails.

\$\endgroup\$
84
\$\begingroup\$

enter image description here

Notice the two pins on both sides are longer, and the two in the center are shorter. This ensures connections are made in the proper order (and also broken in the proper order when unplugging).

If the connector is not designed for hot plugging, there is no such guarantee.

The order you want is:

  • First, Ground/shield.

This ensures both sides agree on what "0V" is, and also discharges any static electricity safely. Sometimes a tiny spark is visible. You do not want to connect the ESD sensitive pins first!

  • Second, power supply.

  • Third, signals

Order is very important. You really want to avoid applying voltage to the signal pins of an unpowered chip, as current will then flow through the ESD protection diodes, and the chip will be powered from its IO pins. This can damage the chip.

Also, if ground connects last, then the signal lines will act as ground instead, and current will flow in them. If the device contains 3V3 chips powered by a LDO from the +5V from USB and ground isn't connected, who knows what the voltages inside the device are going to be...

An excellent example of how NOT to do it are audio RCA connectors.

enter image description here

Notice how the tip makes contact first. I'm sure you've done this before. The loudspeakers let out a very loud hum, until the grounds are connected.

why do things not like being hot plugged?

It's because the pins connect in the wrong order.

Since you mention an ESC, I guess you have voltages and currents large enough to fry some chips. In this case not connecting the ground first can really hurt...

is there an easy way I protect againest this?

Use a connector that is hotplug-safe. If it does not carry the power supply, only signals and ground, then you could get away with large value resistors on the signal lines instead... but it's a hack.

Unfortunately these connectors are very uncommon. Headers like the ones used with arduino's are designed to be a part of a finished product that will only be plugged during manufacture, so they will not be hotplug-safe.

Hotplug-safe connectors will be available for the usual standards (USB, HDMI, whatever) but this will not be what you need for your application.

So, I guess you're stuck doing it carefully, powering down before messing with the circuit...

\$\endgroup\$
9
  • 31
    \$\begingroup\$ +1 yes those RCA connectors are awful. \$\endgroup\$
    – Trevor_G
    Commented Nov 16, 2017 at 14:39
  • 21
    \$\begingroup\$ TRS is also bad, because it basically shorts everything with everything while plugging. \$\endgroup\$ Commented Nov 16, 2017 at 16:27
  • 23
    \$\begingroup\$ 'The loudspeakers let out a very loud hum, until the grounds are connected.' Oh, my... so that's why! +1 \$\endgroup\$ Commented Nov 16, 2017 at 17:32
  • 3
    \$\begingroup\$ Yes, both chassis grounds will be at different AC potentials due to transformer leakage etc, so when you connect the "hot" center pin to the input without connecting the grounds, this AC voltage becomes your signal! A fix is to hold the ground of one male RCA pressed against the ground of the female one, then plug the other male RCA... kinda "connect the grounds first, manually!" Or connect one RCA into an unused input (which connects the grounds) then connect the other RCA into the live input, then move the first one into its proper position... what a mess! \$\endgroup\$
    – bobflux
    Commented Nov 16, 2017 at 17:58
  • 5
    \$\begingroup\$ It should be OK because the gear is designed to allow it (it if wasn't, warranty returns would kinda be a problem...) \$\endgroup\$
    – bobflux
    Commented Nov 16, 2017 at 21:05
17
\$\begingroup\$

Hot swaping is bad for a few reasons:
1) If you connect the Vcc before ground current can flow into your circuit in anomalous ways. For example if Vcc is connected and a digital or analog pin before ground, power can flow into Vcc and out of the pin potentially short circuiting that pin and burning out that part of the circuit.

2) Can cause a "brown out" from the voltage dropping temporarily on a system bus or power supply.

3) Upon disconnect inductors in the circuit or cables can exhibit high voltages if disconnected.

(I had a cable that was not hot-swappable in a product that service reps would hot swap on accident. Because of the mutual inductance in the cable (and an improper cable design with straight wires running next to each other for a meter or so) it would blow out the digital drivers on both sides of the cable. Upon further inspection it was discovered that when the cable was disconnected a digital CMOS line would rise to 7V!)

I have also had great success in implementing both strategies below. One thing you can do in design if your rolling your own hot swap system is find a standard connector (I used sca2 for my bus, but you could use sata, or another industry standard connector, just make sure people understand they can't plug other stuff into it).

Precharge Circuitry:

A long pin and current limiting resistor may be used to limit inrush current to a device. The long pin mates first; the current limit must be set so that the host system power rails stay within specification, but the device charges up adequately before the power and signal pins make connection. Care must be taken when choosing a pre-charge resistor value, the following scenarios show some common problems: If the pre-charge resistor value is too small, the device will still draw too much current on insertion, causing the system power rails to drop out of regulation.

enter image description here

enter image description here

Hot swap controller

A hot swap controller IC controls inrush current to a device. Hot swap controllers typically incorporate electronic fusing, and in high current applications it may be difficult to distinguish between inrush current and a short circuit. The components are more expensive than pre-charge resistors and in some cases the use of more active components in the system may introduce reliability concerns.

enter image description here

Image and text source: Design Considerations for Hot Swap

\$\endgroup\$
2
  • 1
    \$\begingroup\$ BTW brownouts are important because they can put digital logic (and some analog circuitry) into strange states. And not necessarily just the circuitry on the schematic, can include e.g. parasitic components. Look up "Latchup". \$\endgroup\$ Commented Nov 16, 2017 at 21:53
  • \$\begingroup\$ Yeah, I had to tune the resistors in on the hot swapped board to the load to make sure they were not dropping out the other boards on the bus. So the other boards could continue operation \$\endgroup\$
    – Voltage Spike
    Commented Nov 16, 2017 at 22:09
8
\$\begingroup\$

It really depends on the circuit and in some cases the connector itself.

When you disconnect or connect something, the connections do not all happen at the same time. That means there is an unpredictable connection state during the process. Some of those connections can put large voltages or large current where you really do not want them to be. Worse, connectors are usually tight, meaning the user wiggles them around to get them to come apart, creating even more random makes and breaks in the process.

Some connectors, like card edge connectors, are also notorious for shorting adjacent pins out while inserting or removing before they mate properly. One should never even think about plugging or unplugging one of these in hot.

If whatever is being disconnected does not care, for example, a two pin plug going to a LED with a simple pull-up pulldown drive, nothing bad will happen assuming you do not zap it with ESD. But most things are not that robust.

You can of course design things to be hot-pluggable, but that is complicated and expensive, and non-functional for most of the life of the product and is hard to justify if it is not a specific design requirement.

Having said that, systems should always be designed such that if the thing is powered up when sensor A is not plugged in, output B should not go into some state that depends on that sensor. If the loss of that sensor will cause a failure or danger, then appropriate measures need to be added to detect that loss and gracefully enter a safe state.

But generally, unless you REALLY know what MIGHT happen, do not hot plug!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I wish I'd known that card edge conntectors are evil in this way. Once I blew up over 300 quids worth of pc components because I forgot I had it on stand by power. The pc switched itself on as soon as I plugged the gfx card in. THAT wasn't funny!! I \$\endgroup\$
    – Ageis
    Commented Nov 21, 2017 at 2:43

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