andrew700andrew
Posts: 62
Joined: Thu Dec 19, 2013 10:26 pm

GPIO details and PNP transistors

Sat Feb 07, 2015 12:23 am

Hi, I'm working on a project and the raspberry pi will be interfacing with NPN and PNP transistors. Anyway, it's important for me to know how the GPIO pins in the Pi work. I understand that when they are set to HIGH 3.3V is connected to them. However, I'm confused as to what happens when they are set to LOW, does the pin actualy disconnect like an open switch or does it just become ground?

I want to know mainly for the PNP transistor I will be using. Assuming that the GPIO pin is connected to Base and the collector is connected to 3v3 pin and emitter to GND, will setting the GPIO to LOW allow current to flow from Colector to Emiter? Or do I have to do something else?

Thank you.

User avatar
SpazzTechTom
Posts: 15
Joined: Sat Jan 31, 2015 12:50 am
Location: Glen Rock, PA. USA
Contact: Website

Re: GPIO details and PNP transistors

Sat Feb 07, 2015 1:31 am

andrew700andrew wrote:Hi, I'm working on a project and the raspberry pi will be interfacing with NPN and PNP transistors. Anyway, it's important for me to know how the GPIO pins in the Pi work. I understand that when they are set to HIGH 3.3V is connected to them. However, I'm confused as to what happens when they are set to LOW, does the pin actualy disconnect like an open switch or does it just become ground?

I want to know mainly for the PNP transistor I will be using. Assuming that the GPIO pin is connected to Base and the collector is connected to 3v3 pin and emitter to GND, will setting the GPIO to LOW allow current to flow from Colector to Emiter? Or do I have to do something else?

Thank you.
When the pin goes low there is 31.3 Ohms between the pin to ground. I just measured it by using a program that very slowly toggles a pin. When the pin goes low, the resistance to ground is 31.2 Ohms according to my Fluke.

I think you will want some resistors in your circuit, but where and what values will depend on the datasheets of your other components and what you are trying to accomplish. You may need a diode as well. Your circuit might work connecting the GPIO direct to the base of your PNP, but it may not be best practice.
SpazzTechTom
Having fun with technology!

User avatar
Tage
Posts: 287
Joined: Fri May 24, 2013 2:29 am
Location: St Thomas, Ontario Canada

Re: GPIO details and PNP transistors

Sat Feb 07, 2015 1:47 am

if you want to use pnp transistors you should connect emitter to 3.3V and base to GPIO through a resistor. the load is connected from collector to GND.
if you know the load current I you can select the resistor value
R=10*(3.3V-0.7V)/I

to explain the expression:
the factor 10 comes from the gain of the transistor. you typically need about 1/10 of the collector current flowing in the base to get the transistor to turn on fully.
3.3V is your 3.3V supply on the Pi
0.7V is the voltage drop from emitter to base on the transistor
I is your load current that you want to control.
andrew700andrew wrote:Hi, I'm working on a project and the raspberry pi will be interfacing with NPN and PNP transistors. Anyway, it's important for me to know how the GPIO pins in the Pi work. I understand that when they are set to HIGH 3.3V is connected to them. However, I'm confused as to what happens when they are set to LOW, does the pin actualy disconnect like an open switch or does it just become ground?

I want to know mainly for the PNP transistor I will be using. Assuming that the GPIO pin is connected to Base and the collector is connected to 3v3 pin and emitter to GND, will setting the GPIO to LOW allow current to flow from Colector to Emiter? Or do I have to do something else?

Thank you.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO details and PNP transistors

Sat Feb 07, 2015 3:14 am

when programmed as an output, setting the pin high will open one or several transistors (depending on set driver levels) between 3V3 to the GPIO pin, when setting the pin low, one or more transistors will connect the GPIO pin to GND.



And yes, the GPIO drive strength is programmable, opening one of more paralleled transistors to do the job.

see the Broadcom peripherals documentation document, and Gert van Loo's extra application notes.

Return to “General discussion”