13

I have a Pi 3b+ in a MIDI foot controller and part of the I/O is a pair of expression pedal sockets. After, ahem, getting the tip and sleeve round the wrong way, they are working correctly now.

But, during testing, I disconnected one while the system was powered up and it shorted out the Pi, which is now dead. The circuit feeds 3.3 V to the ring, which is connected to the pedal potentiometer, and measures the voltage off the tip (connected to the pot's wiper). When the pedal is disconnected, the plug temporarily shorts the ring (3.3 V) to ground. So I added a 150 Ω resistor on the 3.3 V supply wire. But I don't know if that's enough, and I'm not game enough to try it without being fairly certain I won't destroy another Pi.

Is a current limiting resistor enough? If so, what value is "enough"?

Or do I need something more complicated to protect the Pi?

I don't know exactly how long the short lasts for, but it's well less than a second in practice.

Note: The circuit has an switch in the socket, so I can add a little bit of extra resistance when the jack is plugged in. That way, I can detect the "unplugged" state (ADC reads full 3.3 V) and max plugged voltage 3.1 V as separate states.

The solution I settled on was using a 470R current limiting resistor on the power going to the jacks. This is working just fine.

fret
  • 264
  • 2
  • 9
  • 1
    I see the EE guys use 330R. I sometimes use 470R, and if I want to play safe 520R. – tlfong01 Feb 12 '20 at 05:13
  • 1
    @tlfong01 Ok sounds like a need a slightly higher value. Still would like to know what the "proper" solution to something like this is. – fret Feb 12 '20 at 06:27
  • OK, so we have agreed on the current limiting resistor value. Now let us brainstorm to get a "proper" solution. First thing first, let us look at the (1) schematic: https://imgur.com/gallery/aRTIokz, (2) QUESTION: https://electronics.stackexchange.com/questions/480171/why-is-my-linear-pot-is-causing-a-non-linear-voltage-at-my-adc-input/480198?noredirect=1#comment1220708_480198.. / to continue, ... – tlfong01 Feb 12 '20 at 06:57
  • Let us agree what hardware and software we are talking about: (1) Pedal EV-2, (2) ADC ADS1115: (1) EV-2 Expression/Volume Pedal - Fractal Audio Systems $120 https://shop.fractalaudio.com/ev-2-expression-volume-pedal/

    (2) ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier - AdaFruit $15 https://www.adafruit.com/product/1085

    – tlfong01 Feb 12 '20 at 07:00
  • Now let us agree on how to connect the treadle pot to Rpi: (1) Positive side of pot to B, (2) Middle of pot to A, (3) Pot ground to C. I am not using names such as Vcc, tip, sleeve, ring etc to avoid confusion. You might like to comment on my naming, or make counter suggestion. – tlfong01 Feb 12 '20 at 07:08
  • Now I am drafting an answer. You might like to let me know how you are going to connect the treadle to ADC ADS1115, and Rpi GPIO power pins (5V0 or 3V3) and Rpi GPIO signal input pins (input range between 0V and 3V3), input current preferably less than 2mA.. – tlfong01 Feb 12 '20 at 07:21
  • Question: The treadle schematic shows only terminal A, B, and C. How come you inserted the extra terminal that causes all the trouble? – tlfong01 Feb 12 '20 at 07:25
  • Question 2: Why are you suing ADS1115 I2C 16 bit ADC? This ADC si not that user friendly, comparing the much more popular SPI 10 bit/12bit MCP3008/Mcp3208. If you are not following as tutorial/instructable, I would suggest you to start with MCP3008, and if everything goes well, you can upgrade to ADS1115. MCP3008 10bit can do 2 ** 10 = 1,024 steps, and MCP3208 12 bit can do 2 ** 12 = 4,096 steps (no proof read dodgy calculation) which I think is more precise and sensitive than my stupid human foot! – tlfong01 Feb 12 '20 at 08:04
  • 2
    I already have a bus of i2c devices... and code to work with the ADS1115... it already all works. Bar the short circuiting issue. – fret Feb 12 '20 at 09:22
  • I see. So the plug is the only problem. It is not clear why you need the extra terminal in the plug to tell Rpi that no pedal is available. And do you mean to connect this no pedal signal to let GPIO to read. But why no ADS1115, as it is already there? – tlfong01 Feb 12 '20 at 09:27
  • 1
    If there is no connection to the ADC when the pedal is unplugged the ADC value just floats randomly. By tying it to 3V3 I get a valid signal when unplugged. The ADS1115 is already there in the circuit reading the value off the socket. Both the plugged and unplugged states are fine. Just the transition between where it shorts. – fret Feb 12 '20 at 10:20
  • Ah, let me see. Why not just use a Vcc pull up resistor, say 10k, connected to the input pin of the single ended ADC1115 input channel? Of course you can either pull the otherwise floating input pin to ground, if you like. If you don't like the little difference between Vcc or Ground that might mislead Rpi, you can easily offset the treadle pot output a little bit. – tlfong01 Feb 12 '20 at 10:31
  • Like this: https://www.circuitlab.com/circuit/kpbne4b569at/ev02-20_2020feb1202/ – tlfong01 Feb 12 '20 at 10:43
  • How about using connectors that you can't plug the wrong way in? – Mast Feb 12 '20 at 14:11
  • Do you need to use a Pi3b+ for this? A Raspberry Pi Zero-W can be had for $5. – Z4-tier Feb 12 '20 at 23:34
  • Related: https://raspberrypi.stackexchange.com/a/104348/96642 – snex Feb 23 '20 at 13:32

2 Answers2

14

How do I avoid a temporary short circuit from destroying the PI?

It's very easy really:

  • power down your Pi
  • alter the connections
  • power on the Pi again

Electronics are not hot-pluggable by nature, they have to be designed in a special way to be hot-pluggable. People start to forget that because many modern interfaces support hot-plugging, notably USB. In older times you would apply the procedure above if you needed to connect an external keyboard to your laptop.

If you want to design a hot-pluggable interface, you have two options:

  • make sure the connector prevents unwanted contacts and ensures the correct connect-disconnect sequence (as USB does)
  • make sure your device survives any possible connections in any sequence

The latter is how audio jacks are designed: amplifiers have current limitation so they can survive a short, and a headphone can handle 2x voltage if it gets accidentally connected between L and R instead of L/R and GND.

Current limiting resistors are often used in JTAG/UART/debug adaptors to make them hot-pluggable or at least more robust. Whenever such a resistor will be enough depends on the circuit you have designed.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
  • Yes I think in all the discussion a current limiting resistor is the right solution, but you don't actually look at what value would be a good choice in this situation? That is the crux of the question. – fret Feb 13 '20 at 00:48
  • @fret There's no way to give a value without a schematic. On a theoretical level, the resistance must be (a) small enough so as not to interfere with your circuit, and (b) big enough to limit a short circuit current to a safe value. If value (a) is bigger than value (b), you're in luck: pick a value somewhere in the middle. If (a) is smaller than (b), the resistor is not a viable solution. – Dmitry Grigoryev Feb 13 '20 at 07:53
  • The solution that worked for me was adding a current limiting resistor on the power going to the jacks. The value I settled on was 470R. I can now hot swap the expression pedal with no ill effect. – fret May 01 '20 at 11:25
5

If you short circuit the 3.3V rail to Gnd you will instantly kill the Pi.

Frankly anyone who connects a power rail to external circuitry (from the Pi or any other device) is just asking for trouble!

You can use the power rails to provide power to external circuitry with suitable care - which excludes a TRS plug which is practically guaranteed to cause a short - they are designed for audio (or occasionally video) signals. You should NEVER connect power on a live system - devices which are designed for hot plugging e.g. USB use special connectors to ensure safe connection.

No responsible engineer would connect a live power rail to use for logic connection without protection and would not use a TRS jack for power!

If you are powering an external circuit any series resistance will compromise its operation (unless the current is minimal). You DON"T put resistors in power rails.

No one can design your circuit for you, even if you published a proper specification.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • 1
    So USB has a way to "ensure safe connection". I'd be interested to know what methods are used to allow hot plugging of devices? Also the series resistance in this case just takes away from the total range I can read at the ADC. It's not like a IC that needs a certain voltage, it's just a potentiometer connected via a TRS cable. Lots of similar devices do this, so I assume there is a standard way. That's what I'm asking for... – fret Feb 12 '20 at 06:30
  • 3
    USB has connectors designed for the purpose. TRS jacks ARE NOT Despite other answers NOTHING you can do will help if you wire 3.3V to a TRS jack because the tip and ring make contact with Gnd on insertion. – Milliways Feb 12 '20 at 09:02
  • @Milliways I completely agree with you in principle (TS speaker cords, for another example), but the audio industry has only recently come up with some purpose-designed connectors for specific things. Thus, we still have the same connector used for myriads of things that it shouldn't, even by otherwise reputable brands, with the resulting confusion among consumers, hobbyists, and even some professionals. – AaronD Feb 12 '20 at 16:13
  • 2
    @fret USB uses contacts of different lengths inside the plug to control which lines connect first. – T.J.L. Feb 12 '20 at 19:34
  • 1
    @fret on top of what TJL said, USB is designed with connectors in parallel (relative to the axis of insertion) and a keyed system to prevent an incorrectly-oriented plug from entering, so no contact on either end ever touches a contact on the other end it wasn't meant to at any point during the insertion/removal process. – Doktor J Feb 12 '20 at 22:02