I'm looking into basic components and experimenting with them. I'm quite uncertain how to use a PNP transistor as a switch. I've got a diagram of a working proof of concept (pnp_switch.png attachement).
NOTE: the extra closed switch on top is there to assist auto-wiring in the software, it is inteded to be closed all the time.
While this circuit seems to work in simulation ( EveryCircuit - PNP as Switch 2 Resistors ), I need either some validation that the concept is solid or any correction you might think of to make the circuit work better.
I can see why it would work. But why 2x 1K? They are effectively in parallel between the pnp base and ground, combining to make 500R. With around 20mA flowing from the collector, a single 1K would be enough to saturate the pnp's base I would think.
PaulRB:
I can see why it would work. But why 2x 1K? They are effectively in parallel between the pnp base and ground, combining to make 500R. With around 20mA flowing from the collector, a single 1K would be enough to saturate the pnp's base I would think.
Right! I was having trouble with that. Basically. I attached another screen to explain stuff.
Initial state: The transitor is "open" because base sinks current from emitter across R1 and R2. The switch is open. Switch pushed: The potential difference between Base and Emitter is 0, meaning transistor closes -> turns off light. It was important to have 5V right on the base to make sure that the transistor isn't open partially. When switch is pushed, the red and green lines are active. If you follow the green line, you can see the 5V on base, so you can see why R2 is needed.
As for R1: if it didn't exist, we'd just short to ground, base would see 0V, transistor would remain open, switch would not turn on.
Does that clear up my choices, Paul?
TomGeorge:
Hi,
Try this.
When you push the button, that is close the connection, the LED turns ON and vice-versa.
Tom...
That's pretty cool, Tom! I don't know why I didn't think of this. Also, rad Paint skillz
Isn't it a problem that I effectively leave the Base floating?
As for R1: if it didn't exist, we'd just short to ground
Only if you replaced R1 with a wire! Just remove it. Current will then flow thru R2 to ground, but the pnp will switch off because there is no reason for any current to flow from its base.
mightnotshort:
Isn't it a problem that I effectively leave the Base floating?
Nope. This is a BJT, not a FET. It's controlled by current, not voltage. If the base is floating, no current can flow from the base. So no current can flow from the emitter.
runaway_pancake:
As I see it, the Base should be pulled up --
Any reason, you picked 10k resistor?
PaulRB:
Only if you replaced R1 with a wire! Just remove it. Current will then flow thru R2 to ground, but the pnp will switch off because there is no reason for any current to flow from its base.
Nope. This is a BJT, not a FET. It's controlled by current, not voltage. If the base is floating, no current can flow from the base. So no current can flow from the emitter.
Right! Updated the schematic and it switches now as it originally did with one less resistor.
If you want fast switching (PWM), use both 1k resistors - the base-emitter resistor is responsible for clearing
stored charge from the device on switching off which is the principal cause of slow response of a BJT
used as a switch - make it small, typically the same size as the driving resistor is a good choice.
Of course if there's a physical switch between base and emitter that's going to be even better !
What's confusing me is the LED is on when the push-button switch is open, and turns off when you push the button. Is that what you intend? Seems backwards from the typical circuit.
I think OP's first circuit does work but if you wish to control this switch with an arduino pin, you need an additional resistor to limit current from the arduino pin. runaway_pancake's first circuit would work with an arduino pin pulling to GND to enable the switch and the to 5V or turning into input for turning off the switch.
ShermanP:
What's confusing me is the LED is on when the push-button switch is open, and turns off when you push the button. Is that what you intend? Seems backwards from the typical circuit.
ShermanP, there is a simulation of the circuit, which was updated to use 1 resistor on base but the logic is still the same. Here is the link again: EveryCircuit - PNP as Switch 2 Resistors
If you open it in a browser, you can play around with it, push the switch and see the current flow, to get an idea what was the starting point for this thread.
liuzengqiang:
I think OP's first circuit does work but if you wish to control this switch with an arduino pin, you need an additional resistor to limit current from the arduino pin. runaway_pancake's first circuit would work with an arduino pin pulling to GND to enable the switch and the to 5V or turning into input for turning off the switch.
Please see the the link above. In simlation, it seems to work, I haven't had the time to build the circuit for real yet. It should work.
I agree with Jiggy-Ninja. That is the best solution.
An alternative approach (that I always use for this sort of thing) is a DIL N channel mosfet.
These tiny DIL devices can switch a good current (1A or more), and are so easy to use. Also being DIL they fit perfectly into a breadboard or vero stripboard. All you need is a (say 10K resistor) between gate and source for stability.
If you prefer a high-side switch, then you can use a P channel DIL mosfet.