# Getting the most from an LED

Hi guys. I have recently written the walkthorugh on how to transmit serial data with an IR led and it works fine. Now to the next step: i want to achieve the highest range possible with my LED, without using external aids such as lenses. (that is: only with electronics).

I have a TSAL 6100 from Vishay ( http://www.farnell.com/datasheets/93358.pdf ). If I am right, to achieve the most out of it, i have to get a current similar to the "peak current" value from the manual in the LED. But as for the voltage i guess i just need to give it at least a value equal to its forward voltage.

Problem is, i am not sure about the things i have just written... :) Is it really the right way to do it?

Suppose it is, i cannot give enough current to the LED with an output pin, so i think i'll be using either a mosfet or a standard NPN. But again, how do i exactly know what current i will get with it? As far as i know i have to measure the "amplification value"( hFe?) with my multimeter and multiply that to the current entering the base. Am I right?

## Comment viewing options

but wait, i don't get one thing: if i use a transistor and its hFe (which should be Ic/Ib  where Ic is current passing thorugh the collector and Ib current reaching the base) is, say, 100, and i have an output pin that gives out 20mA, what is going to happen?

In other words, these are the things i don't know about:

- current of the output pin: what is it? is it the max amount of current it can give out?

- when a current of 1mA reaches the base of the transistor (hFe=100) does it mean that 100mA CAN pass through collector-emitter or WILL pass through collector-emitter?

Yes, it is possible for a 1 mA base current to turn into 100 mA of collector current if the collector resistor is the right size to allow 100 mA. Starting at the voltage source of 5 volts. There is a voltage drop across the CE junction of transistor. maybe 0.3 at 100 mA or so, on up to 1 volt at 500 mA or more. Depends on the spec sheet of the transistor. hFe is a highly variable quantity across the range of currents possible and should only be used to note possible performance.. The resistor limits the amount of current delivered.

first attempt was a failure. I followed oddbot's schematic except for a 10k resistor instead of a 1k and the PWM pin connected instead of the v+ (to the collector). The led flashes but the receiver reads "0"....don't really know why. According to my calculations it should have received the "opposite" (aka inverted value) of 100 (which is the value i was trying to transmit), like it happened with my previous setup when i exchanged the anode and cathode (pwm to cathode and serout to anode with inverted signal).

(but still, if i am going to use it that way, i don't think i'll gain much more power)

One thing: what happens if i setup two NPNs (in order to "connect" pwm signal and serout signal and send them both in the base of the primary transistor)? i mean...the current will be very high, won't i risk destroying something?  Sya the outputs offer 20mA, do i have to stay under that current?

The schematic I gave you was based on experience as I've done this before. You need the 1K resistor to the base of the transistor to ensure transistor saturation thus allowing max current through the LED.

Your PWM should connect to the base of the transistor via that 1K resistor (MCU output). The transistor will amplify the PWM output and the resistor in series with the LED will limit it to a safe value.

By connecting the collector to the PWM output, the current through the LED was limited to what the processor was capable of sourcing on a pin (probably 25mA max) assuming the transistor conducted at all as you have not told us what you connected it to?

If you want to go for the 200mA output then use a 18ohm resistor in series with the LED.  Just make sure your duty cycle is 50% or less and that your frequency is above 5KHz as suggested by Robologist.

wait wait, i know that by doing that i won't get a high-power transmission, that was just a test to see if the comunication would work. Eventually, to achieve a high-end transmission, i am gonna (i think) AND the serout signal and the PWM signal and send the to the BASE of the transistor, while the collector will get connected to V+.

But now i am not trying to do that. I was just trying to comunicate the "standard way", just to see if everything worked as it shoul so i just connected the serout to the BAE and the PWM to the collector, but nothing got transmitted...even if the LED flashes...

Both signals need to be ANDed to the base (the resistor driving the base) for proper operation. Connecting PWM to the collector can get a burned out processor pin as it tries to sink 200 mA when the transistor is off.

yes. i was thinking about a scrappy ANDing since i don't have an AND gate: that is using another transistor. But i am worried this may lead to some "too much current" issues, and don't really know how to understand if it will really be like that.

This is what i was thinking of:

Here's a link to a transistor based AND gate :

http://hyperphysics.phy-astr.gsu.edu/Hbase/Electronic/trangate.html

It uses NPNs as high side drivers and compensates for the 2 transistor drops by having a higher supply voltage, but you might be ok with just a 5 volt supply. Their explaination of the circuit is a bit weird too. You might sub 1ks where they have 10ks.

sounds fun! i am gonna try that asap!
one thing: instead of using two transistors (PNP & NPN), what about using one NPN like in OddBot's schematic and use True signals (which means using "T" instead of "N" in the serout command)?