IR Question not directly related to Teensy 3

Status
Not open for further replies.

taskman

Well-known member
I am trying to get more light from my IR LED. I am using the TSAL6100 http://www.vishay.com/ir-emitting-diodes/list/product-81009/
Currently I have it connected directly to one of the pins of the Teensy 3 and I wonder if I haven't just been lucky that it didn't burn the pin out, I do have a +-1k ohm resistor on it, but I used a 5 ohm resistor last night

So the questions
I read the Teensy 3 pins supply 3.3V so I have been supplying 3.3V to the LED. I am planning on running the Teensy 3 on a LifePo4 3.3V battery that can supply 20A+
Now looking at the datasheet of the LED it seems it can run at 3V max and draw 1.5A current if it is on for less than 100 us. Is this correct? So I can use the the 2N2222 transistor principle, same as when I need to run a motor at high current (http://forum.arduino.cc/index.php?topic=148611.msg1116551#msg1116551) to run the LED? According to this website http://led.linear1.org/1led.wiz if I enter the values 3.3, 3, 1000 it shows I can use a 1 ohm, 2W resistor. I will probably go double for safety. Will this blow the 2N2222 transistor? What kind of damage can I do?

This is my IR pulse code. The IR LED is only on for 8 us and then cools down for 8 us so it is well under the 100 us on time when using 1.5A. I have read some people don't even use a resistor when using this LED in their laser tag gear. They probably also use some kind of transistor or mosfet?
Code:
void IrCommons::pulseIr(unsigned int messagePart) {
  byte firstWaitTime = 8;
  byte secondWaitTime = 8;
  
  unsigned int count =  (messagePart / PULSE_TIME) + 0.5;
  for(byte i = 0; i < count; i++) {
    digitalWrite(IrSendPin, HIGH);
    delayMicroseconds(firstWaitTime);
    digitalWrite(IrSendPin, LOW);
    delayMicroseconds(secondWaitTime);
  }
}

Sorry probably babbled more than asking
 
Now looking at the datasheet of the LED it seems it can run at 3V max and draw 1.5A current if it is on for less than 100 us. Is this correct? So I can use the the 2N2222 transistor principle, same as when I need to run a motor at high current (http://forum.arduino.cc/index.php?topic=148611.msg1116551#msg1116551) to run the LED? According to this website http://led.linear1.org/1led.wiz if I enter the values 3.3, 3, 1000 it shows I can use a 1 ohm, 2W resistor. I will probably go double for safety. Will this blow the 2N2222 transistor? What kind of damage can I do?

Plenty of damage is possible with those numbers!! 1.5 amps is crazy.

The datasheet mentions a pulse current of 200 mA max. I'd recommend using that as an upper limit.

You should connect the LED+resistor between the 2N2222 collector and the positive for the battery. Do not try to power it from the +3.3V pin on Teensy3.

The LED is 1.35V, the 2N2222 is saturation voltage is probably about half a volt, and your battery is probably 3.7. That means about 1.85 volts on the resistor. For 200 mA, use 9.25 ohms (or something close, maybe round up to 10 ohms). Do NOT use a wirewound resistor. Almost all resistors over 1/2 watt are either wirewound or very expensive, so read the fine print if using a big resistor. You want a non-inductive resistor, like ordinary metal film. Power in the resistor will be 0.37 watts while on, so if you run a low duty cycle a 1/4 watt resistor should be ok.

Actually, I would start with a 22 ohm resistor for testing, then swap it to 10 or 9.25 ohms only after everything is definitely working!

The 2N2222 transistor will have a current gain of about 50, so you need at least 4 mA in the base to saturate it. With 3.3V from the pin and 0.7 on the base, you'll need 650 ohms to get enough base current (and that's based on my guesswork). I'd round it down to 560 or 470 ohms. Don't go below 260 ohms between the Teensy3 pin and the 2N2222 base.
 
Do you know of a digital variable resistor I can use for this? I can use pins 16 and 17 if it is an I2C chip. The chips I have found are all in the thousands of resistance, e.g. 5k/10k and so on

I need to be able to digitally control the range of the weapon so I need to control the intensity of the LED. I don't think I can't change my pulse code because that will change the frequency so then the hits will not land, because the message will change

Maybe another idea?
 
Looks like this guy uses transistors to lower the distance
http://letsmakerobots.com/node/22720

Seems he has different pathways each with different resistors. The more ranges I want the more pathways and the more transistors and the more pins I will need if I went this route

So this is the plan
V+ -> resistor + LEd -> IR message Transistor (2N2222 collector) -> Ground


Lets say I do this to change the brightness
V+ -> resistor + LEd -> PWM Transisor -> IR message Transistor -> Ground

If I use PWM and a transistor to reduce the voltage, will the IR message transistor sometimes receive no power? Does the transistor block off power and let power through very very fast when using PWM? Does it have noticable drops in power at the 8 us speed that I am pulsing the IR LED?
 
I'm confused by your use of the term "PWM", which ordinarily means "Pulse Width Modulation". Over time, PWM emulates analog intensity because the observer (eg, a human eye) responds slowly. But in this application, we're talking about fixed width pulses required by some type of IR receiver, not a low bandwidth observer that will naturally low-pass filter rapid pulses to observe different intensity.

Normally when talking about electronic circuitry, a schematic and "reference designators" (eg, "Q1", "Q2", "Q3" for transistors) are used. Maybe if you post an image here of the schematic you have in mind, with every part labeled by a reference designator, then we can talk more clearly and meaningfully about it?
 
Please have a look at the idea, but this is probably not going to work. As you say PWM works for the human eye, not for a circuit that pulses at 8 us

LED Transistors_schem.jpg
 
I tried using the Teensy 3 diagram, but went over to the Teensy 2, because the Teensy 3 isn't finished yet
 
This is the second idea, but I don't like it much because I need more and more transistors for the different distances of the weapons and it is "hard coded". It will be great for marketing if I can say 200m range down to 0m range completely configurable dynamically. All other weapons have 2 to 4 "hard coded" distance settings

LED Transistors v2_schem.jpg
 
Those circuits might work, but they don't use NPN transistors the best way.

For this project, rearrange things so the emitter of every transistor connects to ground. Always connect a resistor to the collector. If you use more than 1 transistor, connect each of those resistors to the cathode of the LED. Then connect the LED anode to the battery positive.

Always connect a resistor from the base of the transistor to the Teensy pin driving it. So for every transistor, you should have 2 resistors, one on the base and the other on the collector.

Hopefully that's clear enough so you can try a new schematic?
 
I am wondering if this can't work

I tested some pots today and they are tight to turn, but they probably loosen with time as all screws seem to do
I have a mini servo here from an electronics kit. My plan is to use the servo to change the pot. I can 3D print an adapter I believe to connect the servo to the pot. So that will give me a hybrid mechanical/digital variable pot. I can then pulse the servo every minute or maybe everytime someone shoots just to make sure the pot is still in the right place. The pot will make sure the transistor gets the right amount of current and the transistor can do the job of pulsing the IR LED

LED Transistors v4_schem.jpg
 
I don't have time to draw (or test) this, but basically you can use 1 transistor to PWM the IR LED on- and off with a 8 us cycle, and a 2nd transistor to adjust the current that will flow when the LED is on:
Do supply..LED..Q1_collector..Q1_emitter..Q2_collector..Q2_emitter..5_ohms..GND
Drive Q1's base via your PWM output and the previously recommended base resistor of ~ 270 ohms (actually you can go lower). Drive Q2's base from a PWM (let's call this PWM2) output of the Teensy (this creates an analog signal when averaged) through another 270 ohm and add a capacitor from the base to GND. The 270 +cap will filter the PWM2 to generate an average voltage on the base; the current that can flow in the LED is (VBASE-0.7)/5_ohm. So by adjusting the PWM2 value (from 0..255) you can adjust the current available when PWM1 pulses on.

You'll need a relatively large capacitor (try 10 uF). Basically this creates a variable supply for the LED -- just like a DAC.

There are many parts of this that might not be robust over temperature and other variations, so you'll need to be careful. One improvement could be to replace the LED..Q1_collector..Q2_emitter... above with a PMOS FET ==> V+..PMOS_source..PMOS_drain..Q2_coll etc. Drive the PMOS gate directly from the PWM1 output (the sense is inverted now -- 90 % duty cycle corresponds to 10 % on). You'll need a PMOS that operates with low VGS.
 
Nice. I will try this setup and the setup of Jp3141. I feel proud of this tiny circuit. Thank you for the help
 
Some feedback.

The idea of Jp3141 works, I just need to fix the capacitor and then see what happens. I am using a 100nF capacitor, because it is all I have at the moment

My IR signal starts with a header of 900

When I pulse Q2 (distance reducer) at 254 everything is perfect, ofcourse because it is the full power going through the LED
Going down to 250 I get an error message about every 5th time, the header is still 900, but there are errors, the wrong command is sent. Weapon 1 shooting weapon 2 actually change the team of weapon 2. That could be a big problem in the field :)

When I change the pulse to 244 I start getting alot of error messages, the header comes through as 200 or 600 or some other number. I tried to compensate by changing the pulse speed of Q1 down to 1 microsecond delay to 15 microsecond delay. It didn't make much difference

I hope if I fix the capacitor I will get less errors

I will let you guys know, ordering capacitors tonight
 
Capacitor voltage ratings are the maximum voltage that capacitor can handle. You always want the voltage on the capacitor to be less than the maximum rated voltage it can take.

It's much like current ratings on power supplies or AC mains. If you have a AC socket capable of 15 amps (the rating of the breaker or fuse), it's ok to draw anywhere from 0 to 15 amps.

Capacitors have a lot of other complex issues to consider. No capacitor is perfect. Usually the non-ideal properties are modeled as an equivalent resistor and inductor in series with the capacitor. The type of material in the capacitor really matters. For larger values, the construction of the metal also matters. In this case, you probably want a ceramic type capacitor, because the ceramic ones work very well at higher frequencies (low ESR and ESL). Ceramics come in several quality grades denoted by 3 letter codes. NP0 and C0G are the best (those two designations mean pretty much the same thing). For this job, X7R and X5R might work fine too. You probably want to avoid the lower quality Y5V and Z5U types.

You might be able to eliminate R1 and Q1 completely from that circuit, and just connect the LED cathode to Q2's collector. The LED will turn off when the voltage at Q2's base falls below about 0.7 volts.

R2 and C1 form a low-pass filter, so you'll get an analog voltage at the base of Q2. The voltage on R3 will be approximately that base voltage minus 0.7 volts. So for PWM which makes more than 0.7 volts at Q2, current will conduct through the loop which goes through the LED.

This circuit has limited voltage range. Assuming the battery is about 3.7 volts and the LED uses about 1.4 volts, the voltage at the collector of Q2 will be about 2.3 volts. Q2 needs about 0.5 volts between collector to emitter to work, which imposes an upper limit of about 1.6 volts at the base of Q2, before raising the voltage higher doesn't result in more current through the LED.

Of course, the low-pass filter of R2 and C1 limits the speed you can change the LED current. Look at the waveforms on this PWM page to see the trade-off between filter response and the shape of the waveform.

Using Q1 might be nice, so you could leave the PWM at a desired value (and let it slowly achieve that voltage before turning Q1 on and off). But Q1 will eat up another 0.5 volts (approx), so you'll be limited to about a very small range of 0.7 to 1.1 volts on the base of Q2. Below 0.7 and Q2 turns off. Above 1.1 and the saturation voltage of the 2 transistors comes into play, preventing you from getting much more current. Also, be aware these are not perfectly hard limits... the transistor does conduct slightly with less than 0.7 volts and you do get slight increases as the transistor goes farther into saturation, but they are diminishing returns. The range that will give a nice fairly linear response in LED current to applied voltage from the PWM is the region where Q2 is between off and saturation.
 
Last edited:
Any of those caps will work. Higher voltage rating caps are physically larger then low voltage ones, but will work fine. If you use an electrolytic cap (tantalum or aluminum), be sure to get the polarity correct (there's a + and - on them).
 
Seems when it comes to ceramic I need multilayer. All multilayer ceramic caps that are 1uF and higher with quality of C0G or X7R are on back order at RS electronics.
 
Are the pathways I drew right?
Are these resistors in parallel?

I had a look at resistor parallel calculations and I can't see how to setup the resistors. Lets say I use 5 ohm at R9 and 25 ohm at R10 and I switch on Q1 and Q2 then my resistance will be 4.1 ohm according to the calculators. How should I use this circuit?
If I pulse Q2 and it is in the off state then electricity will just bypass it and flow to the LED so I won't get a pulse, will I?
Should I pulse the transistors on/off that I want the path to flow through, e.g. Q1 and Q2 at the same time?

LED Transistors v3_schem.jpg
 
Yes, this wil work. Note that Paul said to use resistors in a power-of-two ratio -- e.g. 5, 10, 20 ohms. This forms the elements of a DAC. Now if you just drive 1 transistor, you will get 100, 50, 25 mA (example). If you need finer resolution, you can drive combinations as in a binary number -- so for 125 mA, drive Q1 & Q3 (== binary 101). For 75 mA drive Q2 & Q3 (== binary 011) etc. Note this circuit doesn't have enough inherent accuracy to be worth increasing the DAC to more than the 3 bits shown.
 
That 4-transistor circuit looks right. Of course, actually building and testing it is the real test.

Jp3141 is correct about the resistor values. For a highly linear DAC, you'd probably need to adjust them slightly to compensate for the differing transistor saturation voltage with higher current, but if you just use approximately 10, 20, 40 and 80 ohms it should come out pretty close.

I would also agree, beyond 3 or 4 bits is probably worthless for more resolution unless you tune things very carefully. Then again, binary weighting for a linear scale may not be the best for your application. Maybe you want 4 really high currents and 3 relatively low ones?
 
Status
Not open for further replies.
Back
Top