I would like to use Raspberry Zero as a 'smart switch' for my phono MC preamp. At the input connection I need to be able to select different resistor combination (connected between input and ground) to accomplish different configurable total resistance. Instead of using DIP switches can I connect all five resistors to 5 different GPIO and programmatically connect them to the ground?

Thanks, Marin

  • If I'm reading you correctly, you want the GPIO to switch from a high impedance state (input) to a ground state (output set low).
    – goldilocks
    Jun 8 '17 at 19:04
  • Well, I need to connect it this way: Input -> Resistor -> GPIO -> Ground. In this connection I want to programmatically connect/disconnect this connection. Jun 8 '17 at 19:58
  • There's nothing getting "switched" there, which implies the GPIO doesn't serve any purpose. So what I meant was (and what I think you mean is), if you want to be able to disconnect the ground, then this is the difference between a GPIO set as a low output (0V == ground), and set as input, in which case it is hi-z (the terms "input" and "output" here may be confusing in relation to what you are doing). High-z in signalling is the equivalent of a disconnected wire. It's sort of the opposite of a ground state, which is low impedance.
    – goldilocks
    Jun 8 '17 at 20:31
  • Anyway, yes, that's possible if 1) The source voltage is <= 3.3V, 2) The source current is <= 20 mA, 3) You are sure to place a resistor there (which relates to #2). For higher currents you need to use a transistor, but I suspect this is not the case here since it is about signal and not supplying power. If you want to add information to the question to clarify the constraints I can write up an answer for you.
    – goldilocks
    Jun 8 '17 at 20:31
  • 2
    Regardless of what you are trying to actually achieve (which is still unclear), connecting the Pi to a phono input WILL achieve one result; inject NOISE into your audio.
    – Milliways
    Jun 8 '17 at 23:58

First a caveat: I'm not an audio guy, so I don't know what the connection is supposed to accomplish, but I'll take it at face value that you want a number of lines with different resistances to ground, and you want to be able to disconnect them from that ground, which would result in a high impedance state.

GPIOs can be set one of three ways, logical high, logical low, and floating. The first two are output states, the last one is the input state.

Logical high -- when the pin is at ~3.3V -- may or may not be of use here, but probably not. Logical low definitely is, because it is the equivalent of ground, 0V. Beware that this means you can short through a GPIO set as a low output (the fact that this is an "output state" may be a bit confusing, since you will be sinking current to it).

There's only one input state, floating, because the major purpose of an input is to be sensitive to voltage changes. Without external influence, the voltage of the pin floats around. A characteristic of this state is that it is high impedance; I can't give you an exact figure, but presume it is too high for any significant amount of current to flow (unless you apply too much voltage), much like literally disconnecting a wire (where with enough voltage and the right circumstances a route to ground may include a "disconnected" wire, e.g., then through the air brightly to earth, but this is not our context).

So, if you want to programmatically control a route to ground and only a small amount of current is involved, you can do it by toggling a pin between an output driven low (= to ground) and an input (= disconnected).

A "small amount" here means <= ~20 mA; you may get away with a bit more. You will have to apply Ohm's law using the voltage from the preamp and the resistors you want to use to see if this can safely be done with a Pi.

If not, you can control a route to ground with a transistor using a GPIO.


simulate this circuit – Schematic created using CircuitLab

If you never look at schematics, the arrangement on the right is a BJT transistor and the squiggle up top a resistor, so it is clear we are not toggling a short circuit.

This is simpler in the sense that it's more intuitive, because you have a external physical connection to ground, and you control the transistor in an obvious way: Set the GPIO as an output, toggling it high connects the circuit, toggling it low disconnects.

However, there are some complications with regard to what a transistor will do to a signal passing though and I suspect in this case you should prefer the no transistor, ground through the GPIO method -- but again I'm not an audio guy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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