1
\$\begingroup\$

I need to programmatically pull a wire down to ground with a 1k resistor. I put the following schematic together on a breadboard and then programmed a GPIO pin on a STM32 microcontroller to alternate the +3.3V GPIO pin high and low every 1 second.

When I probe the resistance from "probe" to ground, sometimes it will alternate from no contact to 1kohm, other times it will alternate from no contact to 0 ohm, sometimes it will just stay at no contact. I'm clearly doing something wrong, since if I probe any other point, I'm getting the correct values.

schematic

simulate this circuit – Schematic created using CircuitLab

The device I'm trying to interface with measures the resistance to ground on a wire to tell whether a device is turned on or not. If the device is on, it expects 1kohm to ground. If it's off, it expects it to be floating.

\$\endgroup\$
5
  • 3
    \$\begingroup\$ You should put a base resistor to limit the current. Also I'd go with a mosfet. You also need to know how the "device" is "measuring" the resistance. The transistors need certain conditions to operate in the specific mode you are assuming (Ve). \$\endgroup\$
    – Eugene Sh.
    Mar 28, 2022 at 14:15
  • 2
    \$\begingroup\$ Are you measuring resistance/contact with a multimeter on a live circuit? Don't do that. \$\endgroup\$
    – Lundin
    Mar 28, 2022 at 14:15
  • 4
    \$\begingroup\$ Welcome! I sense an XY problem. Show your entire circuit. Why do you need to change the resistance? What's your end goal? \$\endgroup\$
    – winny
    Mar 28, 2022 at 14:17
  • \$\begingroup\$ @winny I'm creating a device that connects via comma.ai's OBD-C pinout. github.com/commaai/neo/blob/master/car_harness/OBD-C.sch.pdf I don't have access to the schematic for the other end, and I don't know how they are measuring anything. All I know is that SBU2 to ground needs to be 1k ohm when the vehicle ignition is on. \$\endgroup\$
    – jordan
    Mar 28, 2022 at 14:52
  • \$\begingroup\$ Then switch place of the resistor and transistor, add a base resistor and you are done. \$\endgroup\$
    – winny
    Mar 28, 2022 at 15:18

1 Answer 1

0
\$\begingroup\$

Bipolar transistors are controlled by the current between the base and the emitter. In your circuit, with the PNP transistor, you have no control over what potential is the emitter at, and thus you have no way of reliably turning the transistor on and off using a voltage source (GPIO) referenced to the collector.

Instead, you need to change the circuit such that the emitter will be connected to the node you control. You can achieve that with an NPN transistor - see the circuit on the left. The base resistor R1 is required to limit the base current, since the B-E connection is "just" a diode junction.

schematic

simulate this circuit – Schematic created using CircuitLab

I've tried that circuit with a 3.3V square wave, and it works as expected with a multimeter: the multimeter alternates between a reading slightly above 1kOhm, due to the collector-emitter saturation voltage, and open circuit (OVLD).

To get a more accurate resistance output, if such may be necessary, use an NMOS mosfet transistor instead. Even with a 2N7000, the error on probed resistance should be 1% or less. A more modern mosfet transistor, like BS170 or BSS138 will work even better and introduce essentially no resistance error.

For a mosfet, the gate resistor R1 is optional and not necessary in this circuit.

In either circuit we're using low power transistors, and the maximum probe current should be limited to 200mA max. This will always be the case, since we need to limit the probe voltage to about 20V so as not to exceed the voltage ratings of the transistors.

\$\endgroup\$

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.