0
\$\begingroup\$

PNP transistors open when you connect their base to ground. For the use with processors, NPN transistors are recommended because you can open them by emitting high signal through them. However I don't have any of these and I'm in the middle of something right now. I'd like to finish the job with PNP transistor.

What I tried was to connect transistor's base to ground through great resistance. This leaves it open by default, but if you also connect it to VCC, the transistor closes.

schematic

simulate this circuit – Schematic created using CircuitLab

The circuit above works, but only if I use actual switch to connect base to VCC. If I use processors LOW signal, it doesn't work - instead the relay that is connected to transistor only opens for a brief moment every time signal changes. Strangest thing is that the same happens when signal goes from LOW to HIGH and vice versa.

The processor I'm using is ATTiny13, IO pin 3 in particular.

\$\endgroup\$
  • 1
    \$\begingroup\$ What is the relay current requirement to turn it on? Can you mention actual resistor and voltage values? \$\endgroup\$ – Umar Dec 12 '16 at 3:02
  • 3
    \$\begingroup\$ The relay is active and powered, by default, and is inactive and unpowered when you press the switch, correct? What voltage are you using for the ATTiny13? What voltage does the relay require? \$\endgroup\$ – jonk Dec 12 '16 at 3:10
  • \$\begingroup\$ @jonk It's all 5 volts, the relay runs on approx 100mA. It started working when I instead used two 10kOhm resistors, putting one to ground, one to base of resistor and digital output between them. I'm now mostly curious if what I did is theoretically correct. \$\endgroup\$ – Tomáš Zato Dec 12 '16 at 5:31
  • \$\begingroup\$ You'd need to draw the new circuit to be sure. Your words are not entirely clear about it. But I can kind of guess what you meant, I think. Yes, that should probably work. I figured about \$22\:\textrm{k}\Omega\$ as a pull-down. You've got almost that much. Placing your I/O pin in the middle allows you to pull it up, too. So that works. \$\endgroup\$ – jonk Dec 12 '16 at 6:41
  • 1
    \$\begingroup\$ @DanielTork I don't think so: He writes that the transistor is "open" when the base is connected to GND using a resistor and that it is "closed" when the base is short-cut to the emitter. This would mean that "open" means "conducting" and "closed" means "non-conducting" for him. \$\endgroup\$ – Martin Rosenau Dec 13 '16 at 6:56
1
\$\begingroup\$

Unlike field effect transistors bipolar transistors are not controlled by a gate voltage but by a base current.

The voltage between the base and the emitter is nearly constant as long as the transistor is conducting. This means that the voltage between the base of the transistor and ground (this is the voltage drop over the "pull down" resistor) is nearly constant.

When you operate the switch in the schematic you posted the voltage drop over the "pull down" resistor will be higher than this constant voltage. This means that the voltage between the emitter and the base of the transistor (which is the voltage over the resistor R2) will be too low so no more current can flow out of the transistor's base.

Once again: When working with bipolar transistors you have to think about currents (and to forget about voltages):

You have to design the circuit in a way that current or no current flows out of the transistor's base depending on the microcontroller's software.

If you operate your microcontroller with 5 V you might try to connect the 20 kOhms resistors to the I/O pin instead of ground. Don't place any "pull down" resistor!

If the I/O pin is "low" there is a voltage difference between the transistor's base and the I/O pin. A current will flow through the resistor; this current also flows out of the base of the transistor. The transistor will be conducting.

If the I/O pin is "high" there is no voltage difference over the resistor. No current flows and the transistor will not conduct.

If you operate the microcontroller with 3.3 V things will get more complicated. The easiest way would be to modify the circuit in the schematic you posted in this case:

Put a "small" NPN transistor between the resistor and ground and operate the NPN transistor using the I/O pin:

When the NPN transistor conducts a current can flow out of the PNP transistor's base and the PNP transistor will also conduct.

When the NPN transistor does not conduct no current will flow out of the PNP transistor's base and the PNP transistor will also not conduct.

It started working when I instead used two 10kOhm resistors, putting one to ground, one to base of resistor and digital output between them. I'm now mostly curious if what I did is theoretically correct.

The 10 kOhms resistor between the I/O pin and ground should have no effect in this case.

However the effects you describe sound very strange with this configuration.

Could you measure the voltage at the I/O pin (to ensure it really switches to high/low) as well as the voltage drop over the 10 kOhms resistor between the transistor and the I/O pin?

By the way:

Some microcontrollers use an open-drain output with a pull-up resistor. In this case the microcontroller can output 0 V very easiely but there will be a voltage drop inside the microcontroller when the output is "high". In this case you have no chance to get a "high" voltage on the I/O pin when the 10 kOhms resistor between the I/O pin and ground is fitted.

According to the data sheet ATtiny 13 does not work like this but you can never know...

\$\endgroup\$
  • 1
    \$\begingroup\$ While yours is the most reasonable solution,he mentioned that he doesn't have an NPN. \$\endgroup\$ – Daniel Tork Dec 13 '16 at 10:21

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.