Calculating the 2 Resistors for a 2N3904 with an IR LED, at 100mA

Hi

I am using Arduino Nano (5v), and I want to transmit an IR Signal using an IR LED.

I am using this IR LED: Vishay - TSAL7400

Since Arduino Output Legs can give a max of 40mA,
I am currently connecting the IR LED directly to an output leg, with a 100ohm resistor,
meaning around 37mA now.

My IR LED can accept a max of 100mA,
so I want to use a 2N3904 NPN BJT transistor, to drive the IR LED.

This is the transistor that I have: Fairchild - 2N3904

What I know now, is that the IR LED should be connected to the transistor like this:

What is the correct value for the Resistor in series with the IR LED?

Some notes:
At 100mA, the Voltage Drop on the IR LED is 1.4v

So:
5v-1.4v-Vce = Vresistor

Now the question what is my Vce here?

On which graph should I look at the transistor's Datasheet?

Thank you

That's indeed how you connect it. If the transistor is saturated, Vce is like 0. So calculate the resister as if you just connect it to 5V.

Btw, damn, 100mA for that LED. Great you provided us with the datasheet, otherwise I would have doubt it :smiley:

hfe (current gain) is listed at 30 minimum, so use that to calculate your base resistor R1. That is, the current through the base resistor should be 1/30th (or more) of the current through the LED. 1K should work.

Since we want to saturate the transistor, we are calculating the minimum base current (or the maximum resistor value). You want a small-enough resistor to saturate the transistor, but not so small that you draw too much current from the Arduino output, or “push” too much current into the transistor base. The idea not to find the “perfect” resistor, just find one in a range that will work. (R1 is less critical than R2.)

If you choose a resistor with low-enough resistance to allow for tolerances & approximations, you can assume VBE is zero (for practical-engineering purposes) and assume that the full 5V is dropped across the resistor.

On the datasheet VCE(sat) (Collector-Emitter saturation voltage) is listed as 0.2V. That’s a typical value for a normal bipolar transistor.

For most practical-engineering purposes we just assume zero volts. But, if you want to make a more-accurate calculation, subtract that from the total voltage too. i.e VR = VCE - VLED - VCE.

In high power situations where you are concerned about heat you can use the voltage drop and current to calculate power dissipation at saturation. But most of the time, we just assume (pretend) there is no voltage drop across the transistor when it’s fully-on (saturated).

Hi septillion and DVDdoug
Thank you for your reply :slight_smile:

Allow me to focus first on the Resistor in series to the IR LED
(I am leaving aside the base resistor, I will go to it after finishing witht he IR LED's resistor)

You wrote:

septillion:
That's indeed how you connect it. If the transistor is saturated, Vce is like 0. So calculate the resister as if you just connect it to 5V.

DVDdoug:
For most practical-engineering purposes we just assume zero volts.

Wow, this is a surprise.
I thought I should always calculate while including Vce in the calculation, and didn't know I can just skip it..
(skipping it definately saves some time, since finding it in the Datasheet, in the relevant graph, etc, can take some time, for each transistor)

OK,
then according to your tip, my calculation is as follows:
5v-1.4v=Vresistor
So Vresistor (for the IR LED's resistor) is 3.6v.
I know that I want 100mA going there, so 3.6v/0.1A=36ohm

So 36ohm is the value for the IR LED's resistor.

Now regarding the Base resistor.

You mentioned the hFE value,
but If I unerstood correctly, when using a transistor as a Switch (versus as an Amplifier), then the hFE/beta value is not relevant for us,
and instead we just need to make sure the current gets the transistor to be Saturated.
Am I correct?

If yes, what current value is that? and where do I find it in the Datasheet?

I thought I should always calculate while including Vce in the calculation, and didn't know I can just skip it.

Calculate with and without and see what little difference it makes.

but If I unerstood correctly, when using a transistor as a Switch (versus as an Amplifier), then the hFE/beta value is not relevant for us,

It is relevant. The point is that the gain of a transistor goes down with base current and collector current. Sometimes this saturation current is quoted in the data sheet other times it is not.
It is standard practice to assume a gain of 10 or 20. We call that "forced gain" because in practice it will probably be higher.

Great,
thank you very much.

BTW,
I am ordering this MOSFET transistor:

2N7000:

Is the circuit with the MOSFET transistor going to be the same like with the BJT transistor?
(except removing the base resistor)

And is the calculation for the IR LED's resistor the same, or a bit different?

Thank you

No gate resistor needed with this small mosfet.

According to the datasheet, rDS(on) could be ~6ohm@Vgs4.5volt.
I would use a 33ohm current limiting resistor.

! ESD sensitive. Connect the gate last, and disconnect first.
Leo..

It is normal to use a gate resistor to limit the surge current especially if you are going to apply PWM to it.
This is because the gate looks like a capacitor and when a discharged capacitor has a 5V signal applied to it then for a very brief time the current can exceeds the Arduino's maximum capacity. So normally a 120R resistor is used.

Thank you both..

Wawa:
According to the datasheet, rDS(on) could be ~6ohm@Vgs4.5volt.
I would use a 33ohm current limiting resistor.

Great.
33ohm is good for 200mA, right?
I ask this because in the Datasheet, where it says the rDS(on), it talks about 75mA, If I understand the datasheet correctly...
So we don't know the rDS for higher currents..

Grumpy_Mike:
It is normal to use a gate resistor to limit the surge current especially if you are going to apply PWM to it.
This is because the gate looks like a capacitor and when a discharged capacitor has a 5V signal applied to it then for a very brief time the current can exceeds the Arduino's maximum capacity. So normally a 120R resistor is used.

A 2N7000 mosfet has 60pf gate capacitance. Insignificant compared to an average logic TO-220 mosfet.

card5:
33ohm is good for 200mA, right?

I ask this because in the Datasheet, where it says the rDS(on), it talks about 75mA, If I understand the datasheet correctly...
So we don't know the rDS for higher currents..

I thought you wanted 100mA.
There is a 3.6volt drop across the "resistor + transistor" (5 - ~1.4). That's 36ohm for 100mA.
Fet = 6ohm, so resistor = 30ohm. I picked the next standard value of 33ohm.

For 200mA, total resistance is 18ohm. Fet = ~6ohm. Resistor = 12ohm.

You don't know the exact pulse current untill you measure the volt drop across the resistor with a scope.
Maybe use 22ohm if you want to be on the safe side.
Leo..

Wawa:
I thought you wanted 100mA.

I wanted 100mA on the 2N3904, because that's the maximum it can provide.
Now we're on a 200mA transistor, and the IR LED can also give 200mA (for pulses, which is what I do with it),
so that's why the 200mA..

Wawa:
There is a 3.6volt drop across the "resistor + transistor" (5 - ~1.4). That's 36ohm for 100mA.
Fet = 6ohm, so resistor = 30ohm. I picked the next standard value of 33ohm.

For 200mA, total resistance is 18ohm. Fet = ~6ohm. Resistor = 12ohm.

Terrific, thank you.

Wawa:
You don't know the exact pulse current untill you measure the volt drop across the resistor with a scope.
Maybe use 22ohm if you want to be on the safe side.

Luckily I have a scope :slight_smile:
So I will do these experiments once all components arrive..

BTW,
regarding Current measurements for an IR LED,
If I have a Remote Control (IR) - a standard one like all of you have several in your homes,
and I want to measure the current that it gives to the IR LED inside it,
is there an easy way to do it with my scope?

The problem is that I don't know where the resistor is on the circuit there, and if the resistor is SMD then it's going to be impossible to attach to it with a scope,
so is there maybe another way to measure the current that it gets when it gets the pulses?
(the current for the "1" part of the wave)

card5:
regarding Current measurements for an IR LED,
If I have a Remote Control (IR) - a standard one like all of you have several in your homes,
and I want to measure the current that it gives to the IR LED inside it,
is there an easy way to do it with my scope?

Look for a low value resistor next to the IR LED.
That might be as low as 10ohm, because most remotes run on 3volt (2xAAA).
Led current will highly depend on battery state.

If you have a scope, then try this.
Poke an IR LED into the BNC socket of the scope, with one pin in the center hole and one pin against the inside ground.
Use one with short pins if you can, because the high impedance will pick up hum.
You now have a perfect remote tester. Use it to compare remotes.

I said IR LED, not IR photodiode...
Polarity is important.
Pulses have to go up, not down.

You can make this permanent by mounting the led inside a BNC plug (not easy).
Leo..

Wawa:
Look for a low value resistor next to the IR LED.
That might be as low as 10ohm, because most remotes run on 3volt (2xAAA).

OK I will.
Hopefully I would be able to attach to that resistor.

Wawa:
If you have a scope, then try this.
Poke an IR LED into the BNC socket of the scope, with one pin in the center hole and one pin against the inside ground.
Use one with short pins if you can, because the high impedance will pick up hum.
You now have a perfect remote tester. Use it to compare remotes.

I said IR LED, not IR photodiode...

Interesting.
But this is not a direct way to measure the current..
We're indirectly measuring the current
(and we don't know how to calculate after we see the Voltage result shown on the scope..)

It's a way to see the result, the light output, which is more important.
Your transmitter could also have two IR LEDs in series, and a 10ohm resistor.
You might get more range with less current.
Three LEDs probably won't work because of the LED forward voltage (~1.2-1.4 each)
Leo..

Wawa:
It's a way to see the result, the light output, which is more important.

Nice.
There's another way to see the IR..
Take a digital camera, even what you have in your smartphone, and look at the remote's IR LED, and press a button.
You can see it as a light..

Wawa:
Your transmitter could also have two IR LEDs in series, and a 10ohm resistor.
You might get more range with less current.
Three LEDs probably won't work because of the LED forward voltage (~1.2-1.4 each)

Thank you, definately worth a try..

Wawa:
A 2N7000 mosfet has 60pf gate capacitance. Insignificant compared to an average logic TO-220 mosfet.

All that does is limit the time the maximum current is being exceeded not the peak current.

Grumpy_Mike:
All that does is limit the time the maximum current is being exceeded not the peak current.

Sure, but 60pf is nothing to worry about.
A wire from an output pin to a row on a breadboard could have the same total capacitance.
If it worries you, put a 220ohm or 1k resistor in series with the gate.
Leo..

The Fairchild 2N7002 has a typical input capacitance of 20pf. and a maximum of 50pf. I'm not sure about the generics I'm using.

It would be nice if someone who has a card from a "big gun" company, would ask Atmel for clarification on that part of the spec (output pin max current).

aarg:
It would be nice if someone who has a card from a "big gun" company, would ask Atmel for clarification on that part of the spec (output pin max current).

It is written in the Datasheet of every Microcontroller they make.

For example, the ATmega328 (and many others by Atmel), can provide a maximum of 40mA per Output leg.

card5:
It is written in the Datasheet of every Microcontroller they make.

For example, the ATmega328 (and many others by Atmel), can provide a maximum of 40mA per Output leg.

I know. But the specification is not that simple.