Arduino Forum

Using Arduino => General Electronics => Topic started by: mcookieman on May 17, 2011, 12:48 pm

Title: PNP transistors... how to use them?
Post by: mcookieman on May 17, 2011, 12:48 pm
Hello all,
I understand how a NPN transistor works and what it does, but I can't figure out how to use a PNP transistor and what it does. At first, sorta due to only having really basic electronics at school, I thought it did the opposite of a NPN and when the base was low the output would be high and vice versa. But after some research this doesn't seem to be the case. I tried using the Java circuit sim/visualiser/thingymajigy to help explain it but I'm still confused. Could someone explain what it does please?

Thanks in advance.

edit: I want to make a really really simple intervalometer for my camera, but do not have any NPN transistors handy.
Title: Re: PNP transistors... how to use them?
Post by: Grumpy_Mike on May 17, 2011, 01:36 pm
You just use a PNP like an NPN transistor but the power rails are swapped over.
It is an upside down transistor.
Quote
I thought it did the opposite of a NPN and when the base was low the output would be high and vice versa

Yes it does but remember that the emitter instead of going to ground has to go to plus. And the collector instead of going through the load to plus goes through the load to ground.
Title: Re: PNP transistors... how to use them?
Post by: MarkT on May 17, 2011, 05:56 pm
If you use the convention that positive voltages are always above ground and negative below ground, then the conversion from NPN to PNP is exactly like a mirror flipping the circuit upside-down - positive supply becomes negative.

In a circuit where 'ground' is the negative rail then the PNP treats the positive supply in the same way an NPN treats ground.  For instance a PNP can switch a load on the 'high side' whereas an NPN switches the ground (low side) of the load.

Hope that less confusing rather than more confusing!!  Basically in a PNP all voltages and currents swap sign from the NPN case.

There is a similar relation between n-channel MOSFETs and p-channel MOSFETs BTW
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 10:36 am
Hey guys , excuse me for kicking up settled dust, i understand how the PNP switches the high side which means to go about actually switching we apply negative to the base...but how does one go about that? let me explain
I have an arduino , and  i would like to pulse width modulate to vary the speed of a small dc motor.
and yes  i do have NPN transistors and i have done it like this just fine  , but if in reality a PNP can replace an NPN then how do i pulse width modulate with a PNP
using the arduino?
If my understanding of PWM is simply ranging from 0-5 volts,lets say on pin 9 , that would be feeding the base of an PNP positive charge , which is not what i need.
so how do i go about this.
Title: Re: PNP transistors... how to use them?
Post by: Grumpy_Mike on Jul 06, 2011, 10:44 am
No it is only a negitave voltage with respect to the emitter. As the emitter is sitting at +5V then applying a 0V signal is like applying. -5V signal.
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:00 am
okay  i think i understood that, its not really negative charged its just less positive then the emitter,so the more positive the base gets in other words the closer to the emitters 5v the more current will flow?
And  i just wired it
motor is directly connected to a ground and the other side to the emitter of the PNP and the collector to positive 12v and the base to an arduino pwm pin , bu its just ran straight and did not vary in speed .. so obviously i did not get it huh
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:05 am
a picture would help, but your words imply you wired it wrong!

I would expect (for a PNP)
emitter to +volts
base (via resistor) to Arduino pin
collector to motor, other side of motot=r to ground

ALSO
reverse biased diode across motor
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:13 am
i have exactly like that and once i add the common ground the motor just runs straight no pwm going on at all
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:16 am
I suspect without "PMW running" the output pin is LOW so I would expect it to do just that
try getting PMW running - it ought to slow down!
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:16 am
drawing a quick picture right now
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:18 am
another thing to try
disconnect the resistor from the arduino and connect it to +volts
that should stop the motor
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:23 am
okay ill try that in a sec, while i do that this is my connections, however i did not draw the resistor or diode so simplicity sake and i wanted to draw it fast before you logged out heheh (http://i54.tinypic.com/6jj7lv.jpg)
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:24 am
this connection shown above makes the motor run just all out , no pwm.
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:27 am
as a matter of fact with that connection right there the arduino doesnt even have to have power for the motor to run so i am basically making a complete circuit.
swtich the C and E connections makes absolutely nothing happen . so i dont know
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:36 am
you can't just swap pins around and hope
(well you can but the magic smoke will soon leak out if you do)

a) you MUST have a resistor between base and arduino - to keep the magic smoke in the arduino
b) you have emiiter and collector the wrong way round - transistor will work backwards, but very badly and the smoke will soon leak out
c) you MUST put a reverse diode across the motor, the back emf will kill the transistor - and you know what happens to the magic smoke!
d) did you try connecting the resistor to +12? - it will turn the transistor off - and the motor should stop

I can't tell which transistor you are using so can't tell if E B and C are correct
also what size motor is it? (no not inches - current rating!)
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:42 am
motors is 9-18v thats about all its said in the little radioshack bag. transistor is TIP42G
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:43 am
the magic smoke reminds me of that show Lost.
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:43 am
did you do anything about
a)
b)
c)
or
d)
??
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:48 am
LOL i do have all those in place sir , i posted that for times sake i just did not draw them in , but the smoke is at bay! and connecting the resistor to 12v in fact shuts it off
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:53 am
in that case it's working
now all you need to do is get the PMW signal up and running and Bob can marry your mother's sister

(hey and less of this sir stuff!)

cheers
Mike
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 11:57 am
haha thanks for the insight!

like you said , Cheers!

(i didnt get the Bob reference) 
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 11:59 am
you heard the expression "Bob's your uncle"?
means it's ok!
Title: Re: PNP transistors... how to use them?
Post by: eddiea6987 on Jul 06, 2011, 12:06 pm
never heard that in my 24  years hahaha but now i understand why he would marry my mothers sister.
Title: Re: PNP transistors... how to use them?
Post by: Grumpy_Mike on Jul 06, 2011, 12:20 pm
Quote
the emitter of the PNP and the collector to positive 12v and the base to an arduino pwm pin

You can't do that because the only way to turn the transistor off is to put 12V on the base, the arduino can only supply 5V so there is no way to turn the transistor off. Hence it is on all the time.
You need an NPN transistor to generate a 0 to 12V signal to use to turn the PNP on and off.
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 12:33 pm
fair cop
I was assuming (silly me) that the motor was running from 5 volts as well!)
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 12:43 pm
something like this?...

but you'd use 12v (can't find a suitable Fritz symbol :( )

my transistors go E B C for both
yours are different
Title: Re: PNP transistors... how to use them?
Post by: Grumpy_Mike on Jul 06, 2011, 01:02 pm
No like this:-
(http://www.electro-tech-online.com/attachments/electronic-projects-design-ideas-reviews/45863d1282879427-avr-microcontroller-current-source-switch-design-lamp_source2.gif)
Title: Re: PNP transistors... how to use them?
Post by: mmcp42 on Jul 06, 2011, 03:01 pm
I guess R2 is to ensure T2 really does get turned off?
Title: Re: PNP transistors... how to use them?
Post by: Grumpy_Mike on Jul 06, 2011, 03:08 pm
Well yes R2 is the thing that keep the transistor off in the absence of an on signal. In the old days there was always a pull down resistor like this on NPN transistors as well. This was because with germanium transistors the base threshold was only 0.25V and this could be triggered by pickup.
Title: Re: PNP transistors... how to use them?
Post by: gerg on Jul 07, 2011, 01:42 pm

you heard the expression "Bob's your uncle"?
means it's ok!


I had never heard that before either. Turns out (http://en.wikipedia.org/wiki/Bob%27s_your_uncle), unless you live in or under rule of Britain, its not likely to have been heard.

This is a well timed thread as I was just started to read up on transistors.

Thanks.