# Transistor weak current when switched from microcontroller

I have ATMEGA328 (running on 5V) connected to a C4793 NPN transistor which controls the TEC1-12706 thermal component.

I'm using the code below to turn the transistor on and off:

#define F_CPU 8000000UL

#include <avr/io.h>
#include <util/delay.h>

void delayms( uint16_t millis )
{
while ( millis )
{
_delay_ms( 1 );
millis--;
}
}

int main( void )
{
DDRD = 0b00000001;

while ( 1 )
{
PORTD = 0b00000001;
delayms( 10000 );

PORTD = 0b00000000;
delayms( 10000 );
}

return 0;
}


simulate this circuit – Schematic created using CircuitLab

Everything is working great, except that the thermal module only gets 0.6A of current, even though the datasheet of the C4793 transistor states that it can handle 1A of current.

If I connect the base of the transistor directly to the VCC, I get 1.07A to the thermal module, which is exactly what I need.

I can't understand why I only get 0.6A when doing the same thing from the ATMEGA328. I thought maybe it's because ATMEGA328 puts out only 20mA from the PIN, but isn't the transistor triggered by the voltage instead of current? Any suggestions please? Thanks!

• Please provide a schematic to show how you have connected things together. There is a built-in schematic editor you can use to add the schematic to your question. – Elliot Alderson Feb 7 at 12:56
• Just label a wire to show that it is the signal from the microcontroller, but be sure to also show us how all of the grounds are connected together. – Elliot Alderson Feb 7 at 13:04
• You need a resistor from uC to base of transistor, or the uC pin will be toast. Minimum value of resistor in ohms = (5.0-0.7)/0.02 – Indraneel Feb 7 at 13:46
• "If I connect the base of the transistor directly to the VCC ..." - That's a good way to destroy a transistor! (most BTJs are not rated for high base currents) – marcelm Feb 7 at 15:08
• Your schematic makes little sense. Are you sure your voltage source is the right way around? – Hearth Feb 7 at 15:31

You are using a NPN transistor for high side switching. This means the bjt will never turn on fully. Voltage at base needs to be about 0.7 V more than voltage at emitter for NPN to turn on fully.

Here's the circuit with low side switching (transistor connected to ground, instead of +ve rail):

simulate this circuit – Schematic created using CircuitLab

Additionally, I do not recommend running the uC pin at full current it is capable of. So minimum resistor should be (5.0-0.7)/0.02 = 220 ohms. But 330 ohms is better. Typically, 1K is used. Which means, for an optimal design, you need a transistor with higher gain. You can do this yourself by putting 2 transistors in a darlington configuration.

simulate this circuit

You can replace the transistors with a single logic level mosfet. A cheap and (somewhat) commonly available one that will work here is AO3400.

NOTE that your load no more has a common ground with the rest of your circuit. If this is a problem, you will have to use high side switching. However, this will require PNP BJT or P-channel mosfets. It will also invert the switch on/off logic. If the load operates at more than 5V, it will also mean an additional NPN switch for the PNP switch.

Alternately, in the first schematic, 2SC4793 can be replaced with the TIP122, which is a complete darlington pair transistor in a TO220 package... quite cheap and common, has great characteristics, and finds many uses in the lab and for projects.

In the second schematic, one can replace the specialized, hard to find and expensive 2SC4793 with the very cheap and common BD139 which has both higher gain and higher current capability. [2SC4793 has a Vceo of 230V, so better to keep it for special uses, since it is expensive.]

• Thank you very much for your answer! To confirm I understood correctly the reason I would use 2N3904 is because that way I would be getting the current from the power source directly instead of getting it from the microcontroller and therefor I would get all of the amount of current required to turn on the C4793 fully correct? – Kristian Feb 7 at 14:26
• @Kristian yes, that is correct. The small current from uC is amplified by 2N3904. Since this is about 20-30 mA, the gain can be quite high (about 200). So much less than 1 mA comes from uC. The 30 mA from 2N3904 is enough to allow almost 1 A to flow through C4793 at a gain of about 30 (which is almost at its limit at 1 A, so not recommended. A better transistor would be BD139). The voltage at base of 2N3904 is now 2x0.7 V when it is on (2 diode drops, one for each transistor). So max base current for 2N3904 can be (5-(0.7*2))/1000 = 3.6 mA (with the 1K resistor). – Indraneel Feb 7 at 15:49
• @Indraneel: You tell the OP that they're using high-side switching, but don't explain that you're showing low-side switching. Maybe edit your answer a bit? Maybe insert a second sentence that says something like "Here I show how to do the job using low-side switching, which makes better use of the transistor." – TimWescott Feb 7 at 15:57

The answer from Indraneel is sort of correct, but a few more comments are in order:

Connecting the transistor as a high-side switch, as you did in your original schematic, is actually valid, provided you consider the implications. You have been told about the 0.7V drop from base to emitter, so your load will see a voltage that is 0.7V less than the voltage at the output pin of the microcontroller. If that's OK, you can use this kind of circuit.

Another consideration is the current gain of the transistor at this operating point. You can consult its data sheet to find this out. In case of the C4793 (actually 2SC4793), you will find that at very low collector-to-emitter voltages the current gain drops significantly. This means that the transistor needs correspondingly more base current, which has to come from the output pin of the controller. This typically makes its output voltage drop, hence the voltage at the emitter will also drop. See the controller data sheet for valid current values. This may well have been a significant effect in your case. If you want to use a single transistor, you need to select one that has sufficient current gain at the operating point you are interested in.

If you can't get enough current gain from one transistor, you need to come up with a different circuit, for example one that uses two transistors. You have been shown how.

• The 2SC4793 is unsuitable for this application on many counts. Price would be top of my list. This has a Vceo of 230V, which is why it is expensive, and performs poorly at low voltages. The TIP122 darlington would be the best choice, and is also quite cheap, and useful all around. That is, if one does not have those smd mosfets (like the AO3400 or IRLML2502). – Indraneel Feb 8 at 1:43