First of all: the voltage at the collector will be lower than the voltage at the base. Seems odd, but that’s how transistors work.
Let’s do the calculation: Supply 5V, minus forward voltage Led 1.6V, minus saturation voltage transistor 0.5V = 2.9V. You want 100mA so: Ohm’s law 2.9V / 0.1A = 29 Ohms. A standard value is 33 Ohms, giving you a tiny safety margin. One problem: this resistor will dissipate 0.3 Watts of heat. If the resistors in your box of stuff are ¼ W you’re good with 3 x 100 Ohms in parallel, if they are 1/8 W it’s borderline and you better make sure they get enough air (that is: keep the wires long enough to let them stand free from your breadboard).
For the resistor to the base: the collector current is 5 times higher, so will the base current. My previous calculation was 2kΩ, divide by 5 is 400Ω; pick 330Ω from your box. Nothing your output can’t handle.
For the resistor to the base: the collector current is 5 times higher, so will the base current. My previous calculation was 2kΩ, divide by 5 is 400Ω; pick 330Ω from your box.
For your information: I’m doing everything on paper, I don’t test anything. I don’t have enough stuff at home.
I just spotted an error in my calculation for the resistor from 3.3 to base....I used 5V in the calculations, not 3.3.
@stitech thank you for the detailes again. Can you tell me how you know the current to the collector is 5 times higher than that at the base please? I can't figure that out.
Also now I think of it, in your prior calculation you mentioned the output voltage of the microcontroller as 0.8VDD, that also lost me a bit i'm afraid.
I haven't read about Watts or heat yet, so thank you for the advice on that. Two steps forward but one step back. More googling for me tomorrow.
The collector current is five times higher than the previous calculation, not five times higher than the base current.
The output also is a transistor, actually 2 FETs in totempole configuration. The manufacturer gives some details in the datasheet and specifies the high output voltage as 0.8VDD. I never checked it but it sounds right, so I go with that number.
@stitech thank you, that makes sense now.
I have completed my little test with just a standard LED and it worked. I was surprisingly excited about making a transistor do what it is supposed to. Many thanks to everyone for the help.
I need to wait for my super-bright LED to be delivered, to take it to the next step, but I'm now a lot more confident that I won't destroy my new ESP32 while trying to flash an IR LED.
I'll try and drop a final note into the forum in the near future with the final details (resistor values etc and components)
Hi again,
First of all the super bright LED arrived and I put the circuit together and it worked! (small successes keep us happy) Just looking for more confirmation before I move forward.
Being over analytical I wanted to verify some things, as I don't know if it's just about to melt or working within perfect balance.
I (think) I measured the current traveling from 5V through the LED to GND as 4mA
and the current from 3.3V to GND as 1.2mA
(Image below)
So my questions:
are those values pretty sensible?
are those values good to produce a strong LED? (As it's IR I can only see it using my phone and have no idea if it's super bright or dull) LED details
Any comments welcome
(I'm not sure if I've drawn the 3 parallel 100ohm resistor correctly)
The 100 Ohm resistors are drawn correct, the 5V supply not. The large line of a battery indicates the plus. The minus is hanging in the air.
The 3.3V battery has the right polarity, but it’s not a battery, it’s an output.
For the resistor to the base I suggested a resistor of 330 Ohms, please explain what made you pick 2kΩ? I’m surprised your ‘box of stuff’ contained a non-standard value of 2kΩ.
Did you measure that 4mA in the LED? We aimed for a little less than 100mA.
The drawing I made is not necessarily the best way. It’s just the way I do it (with another program). I did put in voltages you should measure if things really are like in the drawing.
(Now I need to find the button to add my drawing to the forum.)
Again many thanks for your time @stitech I owe you a beer or two
I spent a bit of time measuring the voltage everywhere I could, and the values don't fit what I was expecting. I then tried measuring the current everywhere, but the values were constantly moving which was very confusing, is that normal? Should I get a better multi-meter? I gave up in the end.
It may be worth noting that I am using a square 9v battery plugged into the power board. The power board then drops the voltage down to 5V and 3.3V. Maybe the 9V battery can't cut it?
Below is the maths I used to work out the resistor from 3.3v to transistor. I used the datasheet to get the BtoE saturation voltage of 0.6 and also some current gain values of 35 and 100.
Is my maths going wrong?
I put the voltage measurements for the 2K resistor in blue, and the voltages for the 330ohm resistor in shocking pink (I stole one of the kids pens).
I don't think the power source is a problem.
The measurement of 2.7V between base and emitter is impossible. Either you've blown the transistor or you are using the wrong pins. (Or both.)
Go back to basics: read the typenumber of the transistor and find a datasheet (or let me find it for you).
Measure resistors, the colorcodes are not always easy to read.
Some multimeters have a diode setting that may give you the voltage between base and emitter, do some checking. (Outside the circuit.)
I did notice a typo of myself, the voltage at the LED should be 2.1V instead of 2.7V, not a problem for now.
Good advice on the transistor check, I didn't know I could do that, google is my friend. The transistor seemed to be fine using the diode function to look for voltage drops from E->B and B->C. I had three NPN transistors and the all seemed OK ( swapped one out just in case). I re-tested the resistors and the values are as expected.
I also added a jumper to join the GND from the 3.3 to the 5, good advice again thank you.
I've found another datasheet as the one I was using had a slightly different version, but I'm happy to see the details look identical and more importantly I believe I have the pins the right way round!
I suppose I should be clear that the LED does light up with both the 2k resistor and the 330 one, I'm just paranoid about either frying my esp32 or not having the LED bright enough to send a signal. (I am also enjoying learning new things.)
Should I proceed to using an ESP32 to trigger things? and if so, which resistor is the better choice?
`The resistor to the base limits the current in the base-emitter circuit. Both the 2k and the 330 keep your output safe.
There is more to it in the collector-emitter circuit. If the base current multiplied by the amplification factor is greater than is possible with the resistance in the collector circuit (LED + resistors) the transistor will work in saturation mode. That means that the collector circuit determines the current, and the voltage at the collector will be approximately 0.5V (it can’t get lower). The heat produced in the transistor = U x I. As the voltage is low, the heat is low.
If the base current is lower, the current in the collector circuit is determined by the actual current multiplied by the actual amplification factor. The voltage between collector and emitter will be higher. If the base current is really low, so will the collector current be and P = U x I will be low because of the low I.
Somewhere between that is a peak in the produced heat that may or may not destroy the transistor. I can, but don’t want to calculate that because in this case the saturated mode is the way to go. That simply means you’ve got to make the base current high enough.
If you measure 0.5V at the collector with the 2k resistor at the base (you better measure that voltage) you are just lucky to have found a transistor with high enough amplification factor, but if you get another transistor, same type/same box, let alone another type, you might not be so lucky. Therefore I advised you to pick the 330 Ohms resistor.
An update for those in the future who may read the conversation and wonder if the approach worked.
It did work to a degree. One microcontroller is using the built using the standard IR library to send a valid IR signal every 250 milliseconds. On a little car is an IR Receiver using the built using the standard IR library, with code set to trigger when it receives the correct IR code. The car goes round in circles a few times trying to detect the code, then narrows in on it.
However there are a handful of physical aspects which get in the way. You need to ensure the IR sender only sends the signal in a narrow direction, which has proven tricky as it flashes though cardboard and out of any whole, also the IR signal can reflect off items causing a false direction.
Also the IR receiver needs to only receive a signal in a narrow direction, which too has been challenging as the receiver seems impressively sensitive. I’ve built cardboard tunnels around both sender and receiver, but both seem to be sending/receiving signals through the cardboard when at close range.
These are not insurmountable physical problems, just an additional challenge above the coding and electronics.
You mention that the receiver is incredibly sensitive. You wanted a super bright LED, you’ve got a super bright LED. Maybe you were right in your first post about a sledgehammer. It is easy to reduce the brightness of the LED by changing the resistors in series. Just play with it.