0
\$\begingroup\$

I have an existing 12V device with an active low input that I currently activate by grounding using a switch:

schematic

simulate this circuit – Schematic created using CircuitLab

Pretty simple. When the switch is open, the Input pin rises to 13.5-14V, so I assume it is being internally pulled up. The device is documented as:

Low: Vin < 3.5 VDC, or Rin < 375 Ω (input active) High: Vin > 8 VDC, or Rin> 100k Ω (input inactive)

Now, I'd like to additionally control this input with a Raspberry Pi 3.3V GPIO, such that:

  1. If SW1 is open, the RPi's GPIO has no effect. Input always floats.

  2. If SW1 is closed, and the RPi GPIO is high, then Input floats.

  3. If SW1 is closed, and the RPi GPIO is low, then Input is grounded.

  4. If the RPi itself is powered off, then behavior should match the old circuit (SW1 grounds Input when closed)

After a lot of trial and error (I do not have an electronics background), I managed to come up with this circuit, which at least appears to satisfy 1, 2, and 3:

schematic

simulate this circuit

However I have not been able to figure out a circuit that will also allow SW1 to ground the Input pin when the RPi is switched off. Obviously the circuit I came up with won't do it because there is no path to ground when the RPi is off. Am I at least on the right track?

In addition to the above, I don't know what transistor parts I would use in this application (2N2222, 2N3704, 2N3904, does it matter?) or what resistor values would be appropriate. Any tips besides go back to school?

TonyM
25.2k4 gold badges41 silver badges67 bronze badges
asked Sep 2, 2024 at 15:43
\$\endgroup\$
3
  • \$\begingroup\$ How is current going to reach to the input to your device, even if SW1 is closed? I guess I'm confused how your device receives power. \$\endgroup\$ Commented Sep 2, 2024 at 16:02
  • 2
    \$\begingroup\$ Hi Ryan, I've rearranged your original tall schematics to use much less height by being wider, so readers here have much less scrolling to do. With schematics, docs, specs etc, we draw/write it once but its read lots of times, so it's important to think of the reader when drawing it. \$\endgroup\$ Commented Sep 2, 2024 at 16:02
  • \$\begingroup\$ Colin, device has its own 12VDC power supply that I did not include in the schematic. \$\endgroup\$ Commented Sep 2, 2024 at 17:09

1 Answer 1

1
\$\begingroup\$

There are several ways to approach this. The most straightforward is to find some DC supply that is always present when your "device" is powered. Then connect your R1 to that rather than the 3.3V supply.

BTW, the optimal resistor values in any case will depend on the current that's coming out of your "device". If it's 50mA the resistors will have to be much lower than if it is 100uA.

Another approach would be to use a mechanical relay and drive that with a transistor from the 3.3V logic. There are small sealed 'telecom' relays that are suitable.

It's also possible to design a solid-state normally-closed circuit but that would be a bit more complex and would use some less common parts, so I would suggest exhausting the first two possibilities first.

answered Sep 2, 2024 at 16:41
\$\endgroup\$
4
  • \$\begingroup\$ Sphero, that makes sense. Device is powered by a separate 12VDC source that I did not include in the schematic. Using a circuit simulator, connecting R1 to that source seems to do the trick, thank you very much. So, in the new circuit, R1 controls the current going through Q1 (base to emitter) when GPIO is low, and it controls the current going through Q2 (collected to emitter) when GPIO is high. R2 would control current going into Q2's base. So they just need to be sized to not damage the transistors? There should be very little current coming out of the device's input pin. \$\endgroup\$ Commented Sep 2, 2024 at 17:21
  • \$\begingroup\$ @Ryan Please define "very little" in numerical terms. \$\endgroup\$ Commented Sep 2, 2024 at 19:07
  • 1
    \$\begingroup\$ @Sphero, no idea.. I'd have to measure it on the physical input pin. At this point I'll mark the answer as accepted though, thank you very much! \$\endgroup\$ Commented Sep 3, 2024 at 14:46
  • \$\begingroup\$ Okay, just roughly you can start with R1 = 1.1V/Iin (so if the input current is 10mA, R1 = 11K (10k is fine) and R2 = R1. That would be fine for 0<=Iin<=10mA. \$\endgroup\$ Commented Sep 3, 2024 at 14:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.