NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » Easy Transistor Question

August 18, 2011
by jimmyw404
jimmyw404's Avatar

I'm creating a fan control circuit with my nerdkits using PWM modulation from a temperature sensor. I'm using as a platform to start. I'm using a power supply set to 12v to power the fan and the 9v battery to power the system. I'm using a 1.5v battery with a potentiometer-based voltage divider to replace the temperature sensor I broke =(

The transistor that comes with the nerdkits isn't rated for the amount of amps I'm pulling (Around 2-3 amps at 12volts). I went to radio shack and purchased a BJT transistor (TIP120 ) to replace the 2N7000 MOSFET that came with nerdkits.

The system appears to work okay with one discrepancy. With the 2N7000 I can get a range of 3v to 12v when I get the PWM value on the LED to approach 0 and reach 512 respectively. When changing in the TIP120 I can only get a range of 8v to 12v, even though the display outputs the same PWM values.

What is the reason for the discrepancy? Is there something I'm doing wrong? Can I not replace a mosfet with a BJT like this? Should I just get a more powerful mosfet like ? Is there not enough information here to show what I'm doing wrong?


August 19, 2011
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Jimmy,

I'm assuming that you've got the the TIP120 connected as follows: emitter to ground, collector to one side of the fan, and base directly to a microcontroller pin -- essentially swapping terminals G,D,S of the MOSFET with B,C,E of the BJT, respectively.

There are two issues I see:

  1. There's nothing to limit the current into the base of the TIP120. Right now, the microcontroller pin's output drive capability is limiting the current into the base, and if you took a multimeter and measured the voltage from base to ground, you'd probably get about 1.6 to 1.8 volts, at which point the microcontroller is struggling to push 40 or 50 mA into the transistor -- more than you need. With a minimum current gain of 1000, to drive your 3A load you need 3mA into the base. Let's say we double it for "safety" to 6mA. The two 0.7V diode drops (two because the TIP120 is a Darlington pair, containing two transistors) mean we can roughly approximate (5 - 2*0.7)/0.006 = about 600 ohms would be a good resistor value to put in between the microcontroller output pin and the base of the transistor. Can you try putting a resistor, roughly 500 to 1K ohms, in there (in series with the base) and see if that helps? (Excess base current can be bad -- overheating and far worse switching performance.)

  2. BJTs can be slow for switching applications like PWM control. They're quite fast in analog applications like amplifiers, but when they have to switch modes on-off and off-on, they can be surprisingly slow. This goes doubly so for darlington pairs. You probably want to reduce your PWM frequency to be low. Can you try increasing the prescaler division ratio in the pwm_init function?

Switching to a beefier MOSFET would also work. :) In a pinch, you can also try putting multiple 2N7000s in parallel to handle more current for the same V_GS.

Let me know if those two changes make a difference!


August 19, 2011
by bretm
bretm's Avatar

In a pinch, you can also try putting multiple 2N7000s in parallel to handle more current

And don't try that with BJTs. MOSFET current flow goes down as they heat up, so MOSFETs in parallel automatically self-balance. BJT current flow increases as they heat up, so if one overheats it will take more and more of the load away from the others which is the opposite of what you want.

August 20, 2011
by jimmyw404
jimmyw404's Avatar

Thanks, Mike and Bretm for your help.

1_ I think the resistor was the big thing I was missing, I should have picked up on the fact that at a high duty cycle the LED display started to dim.

I tried limiting the current with a 680ohm resistor but that didn't have an effect (Though my display no longer dimmed!) I did the same with a ~1500 and a 3300ohm resistor to no avail. Finally I jumped up to 33k and it created a range from 4v to 12v, which was very exciting! I am sure your math is fine, but I don't know if I am missing any other component that prevented the 680ohm resistor from performing as it should. I am not worried about it very much.

2_ I have to admit I do not know how to increase the prescalar division ratio in the pwm_init function. As you know the code in that function is

OCR1A = 512;// set for 28.8Khz cycle
TCCR1A = (1<<COM1B1) | (1<<WGM11) | (1<<WGM10);  
TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS10);

I looked at the ATmega168.pdf document in the members section and found the descriptions of the registers, but could not accurately determine how to decrease the PWM frequency. So instead I just guessed it had to do with OCR1A.

When I set OCR1A to 256 (using the 33k ohm resistor) the minimum was 4v, but it sharply increased to 12v as the PWM increased. When I set it to 1024 it was 4v at a low duty cycle and sharply increased to 12v again, but the PWM actually jumped very high as well. I did not investigate this because the choice to change OCR1A was based on guessing.

3_ I purchased some new mosfets:

I will try these out when I get them.

Thanks again for your help!

Post a Reply

Please log in to post a reply.

Did you know that you can use a transistor to interface between different voltage levels of digital logic? Learn more...