caoc10
Posts: 4
Joined: Tue Dec 08, 2015 11:18 pm

Help with Transistor for Fan Control!!

Tue Dec 08, 2015 11:39 pm

Hi, I'm new here so I don't know if I'm putting the topic in the right place, so if it isn't, I'm sorry. :oops: :oops:
To the problem...
I've bought a case with a fan to my raspberry pi 2 in order to help him with the temperatures of the overclocking.
I don't want the fan everytime working, so I've made a python script that runs on startup and controls a transistor to turn on and off the fan.
The problem it's in the transistor that don't work properly! :x
I'm an informatic engineering student, so I don't know nothing about electronics (maybe a little bit because of arduinos and things like that)! :oops:
I've already tried to read books, search on google, see videos and just don't understand nothing about choose the right transistor!
So I would like to have some help with that!
Currently I've a NPN BC547B transistor and my fan is very slow!
It needs 0.2A and 5V to work properly, so what transistor should I choose and what is the resistor capacity that connect's to the base?
Thank you!
:D :D
I'm sorry for bad english but I'm giving my best!

User avatar
DougieLawson
Posts: 40239
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 8:37 am

caoc10 wrote: I've bought a case with a fan to my raspberry pi 2 in order to help him with the temperatures of the overclocking.
That was a complete waste of money. There is NO NEED to add any fan or heatsink to ANY raspberry at any level of overclocking.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 8:40 am

DougieLawson wrote:
caoc10 wrote: I've bought a case with a fan to my raspberry pi 2 in order to help him with the temperatures of the overclocking.
That was a complete waste of money. There is NO NEED to add any fan or heatsink to ANY raspberry at any level of overclocking.
I agree, but getting it to work would be a useful learning experience.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 8:46 am

caoc10 wrote:Hi, I'm new here so I don't know if I'm putting the topic in the right place, so if it isn't, I'm sorry. :oops: :oops:
To the problem...
I've bought a case with a fan to my raspberry pi 2 in order to help him with the temperatures of the overclocking.
I don't want the fan everytime working, so I've made a python script that runs on startup and controls a transistor to turn on and off the fan.
The problem it's in the transistor that don't work properly! :x
I'm an informatic engineering student, so I don't know nothing about electronics (maybe a little bit because of arduinos and things like that)! :oops:
I've already tried to read books, search on google, see videos and just don't understand nothing about choose the right transistor!
So I would like to have some help with that!
Currently I've a NPN BC547B transistor and my fan is very slow!
It needs 0.2A and 5V to work properly, so what transistor should I choose and what is the resistor capacity that connect's to the base?
Thank you!
:D :D
I'm sorry for bad english but I'm giving my best!
Your English is fine.

What size resistor do you have on the base?

The BC547B seems to have a rating of 100mA collector current. This is too low for your fan. You need an NPN transistor with a higher Ic rating.

caoc10
Posts: 4
Joined: Tue Dec 08, 2015 11:18 pm

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 9:19 am

First of all thanks for your answers.
After overclock the raspberry I've noticed that the fan isn't needed but once that I have it why not to put it in use and learn something new!
In the base I have a 6.8k resistor.
I know that my transistor has an Ic value to low for my fan, but the problem is that I can't understand almost anything on the datasheets, so I can't pick up the right transistor.
It would help a lot if you can give me a transistor model that is perfect to the situation once that I just can't figure it out!
If you also know any good tutorials to learn something about this I would appreciate it!
Thank you all!

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 9:34 am

caoc10 wrote:First of all thanks for your answers.
After overclock the raspberry I've noticed that the fan isn't needed but once that I have it why not to put it in use and learn something new!
In the base I have a 6.8k resistor.
I know that my transistor has an Ic value to low for my fan, but the problem is that I can't understand almost anything on the datasheets, so I can't pick up the right transistor.
It would help a lot if you can give me a transistor model that is perfect to the situation once that I just can't figure it out!
If you also know any good tutorials to learn something about this I would appreciate it!
Thank you all!
Ok, don't worry about the Ic limit. Your transistor might get warm.

The simplest way to think about a transistor is a current multiplier. Current in the base is multiplied to current in the collector. The multiplier (or gain) is known as hfe. You can find it on the transistor datasheet, but you can use a value of 100 for estimating the result.

So, if you want 200mA through the collector you need 200/hfe mA in the base, which is 200/100 = 2mA.

Assume your base is at a voltage of 3.3V because the GPIO is high. The current through the base resistor can be calculated with Ohm's law as Ib=(Vb-0.6)/Rb. We subtract 0.6V because there is a small voltage drop across the base-emitter junction (it's about one diode-drop...). So, your base current is
Ib=(3.3-0.6)/6.8k = 0.4mA

It's too low.

If you use a smaller resistor, the base current will be higher, so the collector current will be even higher. But, you shouldn't draw more than about 13mA from the GPIO or you will damage it.

The typical value for a base resistor for a transistor switch is 1k, because everyone has one in their junk box. Try one and see if it works. If the fan is still slow, try something smaller like 680R.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 9:56 am

Transistors amplify current. The amount they amplify is called beta or HFE. It's generally around 100.

You need the transistor to go into saturation, so it is trying to pass more current than is flowing. Otherwise it will get hot. So HFE has to be comfortably more than you need.

The GPIO will output a maximum of around 16mA, so you are looking for a transistor with a HFE of at least 200mA/16mA = 12.5
The base-emitter junction drops 0.7V, so the base resistor needs to be (V = I R, 2.6V / 16mA = 163) 163 Ohms. Call it 180ohms, which is the next preferred value and check HFE again... current will be 2.6 / 180 = 14.4mA, so HFE is 200/14 = 14.3
There is still some headroom there, so I'd be tempted to use a 470 ohm resistor to limit the current the GPIO has to source:
The base current would 2.6/470 = 5.5mA, HFE needs to be 200/5.5 = 36.4

Your 6.8k resistor cuts the current to 2.6 / 6.8k = 0.4mA, so you'd need a HFE of 200/0.4 = 500. That's too high to find in a simple transistor.

Ic is the maximum collector current -- the maximum current that the transistor will pass. That needs to be comfortably more than you are actually trying to pass, since you never ever run electronics at their rated numbers if you want them to live long.

So you are looking for a 470 ohm resistor and a transistor with say a HFE of at least 50 and an Ic of 500mA or more.

You'll also want an NPN transistor so you can connect the emitter to ground. The base is referenced to the emitter. If you used a PNP you'd have to give it an input referenced to +V, which would be difficult.

That's all you need to know about transistors until you want to get fancy.

It would also be a good idea to put a reverse-biased diode across the fan, because motors generate a reverse voltage that transistors don't like.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 9:57 am

Is there an echo in here?

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 10:12 am

At least we agree. ;)

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 10:18 am

rurwin wrote:At least we agree. ;)
Perhaps you were echoing my sentiments. ;)

Massi
Posts: 1691
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 10:33 am

Now that you have learnt how to use a bjt, buy a mos for your circuit :)

caoc10
Posts: 4
Joined: Tue Dec 08, 2015 11:18 pm

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 12:51 pm

After read your answers about 100 times i think that I have understood how it works!
So first I need to calculate a supposed HFE.
Once that i don't want to stress the gpio pin, I just want to get 6mA from him.
HFE = 200mA / 6mA = 33.4
Now I have to calculate my resistor value.
res = (3.3v - 0.7v) / 6mA = 0.44 = 440 ohm
Once that 440 ohm resistor doesn't exist it needs to be the 470 ohm and now I need to recalculate the amperage getted from the GPIO in order to calculate the right HFE.
GPIO_DRAWN_AMPERAGE = 2.6v / 470 = 5.5mA
HFE = 200 / 5.5 = 36.4
Now I need to use a resistor of 470 ohm and buy a transistor with the following characteristics:
-> HFE > 40
-> Ic > 5.5 mA
-> Vce > 5v

After a search for one compatible I've found the BC635 that has the following characteristics:
-> HFE: 40 - 250
-> Ic > 1A
-> Vce > 45v

So my questions are:
It's right what I have understood?
The BC635 should work properly with a resistor of 470 ohm for what i want?
Thank you.

drgeoff
Posts: 11242
Joined: Wed Jan 25, 2012 6:39 pm

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 1:03 pm

Yes you have understood but you have a small error in:

"Now I need to use a resistor of 470 ohm and buy a transistor with the following characteristics:
-> HFE > 40
-> Ic > 5.5 mA
-> Vce > 5v"

The collector current is not 5.5 mA. That is the base current.
Quis custodiet ipsos custodes?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 1:18 pm

caoc10 wrote:After read your answers about 100 times i think that I have understood how it works!
So first I need to calculate a supposed HFE.
Once that i don't want to stress the gpio pin, I just want to get 6mA from him.
HFE = 200mA / 6mA = 33.4
Now I have to calculate my resistor value.
res = (3.3v - 0.7v) / 6mA = 0.44 = 440 ohm
Once that 440 ohm resistor doesn't exist it needs to be the 470 ohm and now I need to recalculate the amperage getted from the GPIO in order to calculate the right HFE.
GPIO_DRAWN_AMPERAGE = 2.6v / 470 = 5.5mA
HFE = 200 / 5.5 = 36.4
Now I need to use a resistor of 470 ohm and buy a transistor with the following characteristics:
-> HFE > 40
-> Ic > 5.5 mA
-> Vce > 5v

After a search for one compatible I've found the BC635 that has the following characteristics:
-> HFE: 40 - 250
-> Ic > 1A
-> Vce > 45v

So my questions are:
It's right what I have understood?
The BC635 should work properly with a resistor of 470 ohm for what i want?
Thank you.
That's pretty much it.

You usually don't calculate hfe. You will find it on the data sheet, or you can assume it is 100.

Generally the important figure is Ic. But it just has to be big enough, not huge.

You will also find a small number of very common transistors that everyone uses all the time, such as BC547B, 2N3904, 2N2222, so find a common one and buy a dozen so that you have some for future projects.

Maybe the BC635 is common and easy for you to buy, but if it isn't, find another one. 2N2222A would work for this application.

caoc10
Posts: 4
Joined: Tue Dec 08, 2015 11:18 pm

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 1:59 pm

I just have one doubt.
My Ic just has to be greater than the amperage that I need or it has to be calculated?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help with Transistor for Fan Control!!

Wed Dec 09, 2015 2:09 pm

caoc10 wrote:I just have one doubt.
My Ic just has to be greater than the amperage that I need or it has to be calculated?
Just greater.

The load (the fan) will draw the current it needs. The transistor must be capable of passing that current.

FallChallenge
Posts: 18
Joined: Wed Feb 01, 2012 2:28 pm
Contact: Website

Re: Help with Transistor for Fan Control!!

Thu Dec 17, 2015 7:54 pm

Hi guys, here a little project to control the fan with a Node.js based App: https://github.com/roccomuso/rpi-fan ;)

Return to “Beginners”