ibanezmatt13
Posts: 128
Joined: Fri Dec 28, 2012 9:49 am

NPN Transistor and DC motor

Sat Feb 23, 2013 11:49 am

Hi,

I would like to use an NPN transistor to turn on a DC motor from my Raspberry Pi. I have a 12V motor which cannot go anywhere near the Pi! Yet, I need to somehow connect the Pi to activate the motor...

Here is my current configuration, but it didn't work; on some occasions I nearly fried my Pi:

Jumper cable from GPIO pin through a 1K resistor into the transistor base.
The emitter of the transistor goes to the motor and then from the motor to the ground rail.
The collector is connected to +12V from a battery.
The other side of the battery is connected to the ground rail.
The ground rail is connected to GPIO pin 6.

When I activate the GPIO, nothing happens! In fact, the transistor becomes scorching hot and so I have to throw them away.

Could somebody please tell me what is happening. I am really confused.

Thanks
Matt

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: NPN Transistor and DC motor

Sat Feb 23, 2013 11:58 am

To turn off and on a motor you're better off using a relay circuit activated by a transistor or 2 transistors arranged in a darlington pair.
By having a relay controlled switch you can isolate the high voltages required to drive the motor from interacting with the Pi.
There are plenty of relay circuits online if you look hard enough or if you prefer the easy route you can purchase ready made relay modules from eBay i.e. http://www.ebay.co.uk/itm/2-channel-rel ... 0989734397

Richard S.

User avatar
Burngate
Posts: 5967
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: NPN Transistor and DC motor

Sat Feb 23, 2013 12:16 pm

The way you have it connected, what's happening is :

Your GPIO goes to 3.3v, and pulls the base (via the 1K resistor) to about that voltage - not much current into the transistor, so not much voltage drop across the resistor.

The emitter will therefore be 0.6v below the base, so there'll be ~2.6v across the motor.
The motor won't turn - the volts will be too low. But current will go through it, and that's coming from the 12v battery.

And that current will be going through the transistor. And the transistor collector-base junction will have >8v across it
Volts * Amps = Power, so with even a modicum of current, it'll be trying to dissipate more power than it can handle

Put the motor in the collector of the transistor:
Jumper from GPIO pin through 1K to transistor base
Emitter to ground
Battery negative to ground
Battery +12v through motor to collector

That way, the transistor gets ~3mA into its base, and turns hard on. The collector-emitter voltage will be ~0 and the full 12v will be across the motor

As the motor speeds up, the current through it will drop, but at start-up it could still be quite large, so make sure you use a transistor that can handle that current

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: NPN Transistor and DC motor

Sat Feb 23, 2013 12:34 pm

ibanezmatt13 wrote:Hi,

I would like to use an NPN transistor to turn on a DC motor from my Raspberry Pi. I have a 12V motor which cannot go anywhere near the Pi! Yet, I need to somehow connect the Pi to activate the motor...

Here is my current configuration, but it didn't work; on some occasions I nearly fried my Pi:

Jumper cable from GPIO pin through a 1K resistor into the transistor base.
The emitter of the transistor goes to the motor and then from the motor to the ground rail.
The collector is connected to +12V from a battery.
The other side of the battery is connected to the ground rail.
The ground rail is connected to GPIO pin 6.

When I activate the GPIO, nothing happens! In fact, the transistor becomes scorching hot and so I have to throw them away.

Could somebody please tell me what is happening. I am really confused.

Thanks
Matt
you're running the transistor in common collector mode - in this mode, the voltage at the emitter can't be any higher than the voltage on the base - so 3.3v. The transistor is dropping 12-3.3=8.6v which is why it's getting hot.

Move the motor to the collector of the transistor and put a reverse biased diode in parallel with it - which will short any reverse emf when you stop the motor (which may destroy the transistor) and off you go.

Bu do make sure the transisor is actually capable of sinking the current that you're putting through the motor...

e.g.:

Image

Also, this was the first google hit I got for motor control with transistors:

http://www.me.umn.edu/courses/me2011/ar ... ntrol.html

do read it!

-Gordon
--
Gordons projects: https://projects.drogon.net/

ibanezmatt13
Posts: 128
Joined: Fri Dec 28, 2012 9:49 am

Re: NPN Transistor and DC motor

Sat Feb 23, 2013 4:14 pm

Burngate wrote:make sure you use a transistor that can handle that current
Hi,

Having read your reply, my knowledge of transistors has increased ten fold so thank you very much for your time. Could you tell me how I can identify whether my transistor is up for the job? I typically use a 2N4401 NPN transistor.

Thank you very much.
Matt

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: NPN Transistor and DC motor

Sat Feb 23, 2013 4:28 pm

ibanezmatt13 wrote:
Burngate wrote:make sure you use a transistor that can handle that current
Hi,

Having read your reply, my knowledge of transistors has increased ten fold so thank you very much for your time. Could you tell me how I can identify whether my transistor is up for the job? I typically use a 2N4401 NPN transistor.

Thank you very much.
Matt
http://www.lmgtfy.com/?q=2N4401+datasheet

And you'll find that it can take 600mA or 800mA peak.

So a smallish motor.

-Gordon
--
Gordons projects: https://projects.drogon.net/

Return to “Automation, sensing and robotics”