0
\$\begingroup\$

I have a GPIO pin that reports when an accessory is connected to the device: the pin is high when there is no accessory and low when an accessory is connected. When an accessory is connected, I would like to close a circuit between a lead (0.5V@2.5μA) and ground.

The GPIO pin is 0.4V@1.6mA when low and I believe around 3.4V when high (the spec sheet doesn't say). There is also a voltage source around 3.7V.

Would a transistor be appropriate to act as a switch? From my research I believe a MOSFET could work well (compared to BJT) as it is toggled with voltage and doesn't draw a lot of current, is that right? One approach I came up with is to use a differential amplifier to subtract the GPIO pin's voltage from Vcc:

schematic

simulate this circuit – Schematic created using CircuitLab

  • The op amp subtracts the GPIO pin's voltage from Vcc to flip the high and low states.
  • When the GPIO pin is low, the op amp applies 3.3V to the MOSFET's gate, connecting Vin to ground.
  • When the GPIO pin is high, the op amp applies 0.3V to the gate, below the MOSFET's Vgs threshold, opening the circuit.
  • Rin and Rf have the same resistance values so the op amp doesn't amplify the voltage and are 1kOhm so that there's enough current to charge the transistor gate in a few hundred nanoseconds.
  • R1 and R2 also share resistance values and are 100kOhm so the GPIO pin doesn't draw too much current and drain the battery.
  • Do these resistor values make sense? Do there need to be any diodes (e.g. to prevent current from flowing into the GPIO pin) or capacitors to make the circuit better?

Am I on the right track or is there a simpler way to accomplish the original goal of connecting Vin to ground when the GPIO pin is low?

\$\endgroup\$
1
  • \$\begingroup\$ Tipp: If this is an actual product sold, check if what you doing is not patent protected... e.g. in case of a Automation Control System US2012043378A1 might apply. [patents trivial things very clever: any electomangetic procedure is covered.] \$\endgroup\$
    – schnedan
    Aug 29, 2020 at 13:11

1 Answer 1

1
\$\begingroup\$

This should do the trick for you- the first transistor diverts base current from the second when the input is higher than about 600mV.

schematic

simulate this circuit – Schematic created using CircuitLab

That will reduce the voltage at the collector of Q2 to maybe 10 or 20mV. If you want it lower than that, you can replace Q2 with a 2N7000.

\$\endgroup\$
3
  • \$\begingroup\$ The circuit posted by the threaded started would also work, right? I just want to know. \$\endgroup\$
    – varun
    Aug 29, 2020 at 4:24
  • \$\begingroup\$ @varun No, it won't work. The output voltage of the op-amp will always be railed 'near' GND (how near depends on the op-amp -- there is heavy loading of 2K to 3.7V on the output, and not all op-amps work on 3.7V, but regardless of that it will always be railed. The GPIO would have to exceed 3.7V for it to have a hope of budging. \$\endgroup\$ Aug 29, 2020 at 4:34
  • \$\begingroup\$ what if Rin = R1 = 5K and Rf = R2 = 10K. So Gain here would be 2. And GPIO will be connected to the inverting terminal of Opamp and Vcc will be connected to the noninverting terminal. When GPIO = 0.4V opamp output = 2* (3.7-0.4) ~= 6V (Transistor ON) WHen GPIO = 3.4V Opamp output = 2* (3.7-3.4)~= 0.6 (Transistor OFF) Would this work? \$\endgroup\$
    – varun
    Aug 31, 2020 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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