Running super bright IR LEDs at 38khz off PN2222

Hello, everyone.
I'm still fairly new to electronics, so please forgive any silly assumptions or mistakes.
I'm working on a project that is essentially a very barebones IR touch surface.

I don't need multitouch or position - just on/off on a 3'X3' glass surface (i.e. is someone touching the glass, yes or no).
I'm trying to accomplish this with an array of super bright IR LEDs and IR receivers:

Plan here is to keep the cost of electronics as low as possible while also avoiding loading the CPU with blob detection from a webcam.

It's working like a charm at low-range (~ 6") when driven directly off an Arduino Uno and modulated by the IRremote library.

#include "IRremote.h"

#define PIN_IR 3
#define PIN_DETECT 2
#define PIN_STATUS 13

IRsend irsend;
void setup()
{
  pinMode(PIN_DETECT, INPUT);
  pinMode(PIN_STATUS, OUTPUT);
  irsend.enableIROut(38);
  irsend.mark(0);
}

void loop() {
  digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
}

Putting a couple of fingers against the glass reflects the IR light back to the reciever, and I assume that giving the IR LEDs more current will increase the range considerably (they're probably only getting about 15ma right now).

I'm using this diagram to run a few LEDs off of a PN2222:

And it doesn't work at all.

Could this be a timing issue introduced by the transistor? I assumed that the PN2222 would still turn on/off quickly enough to maintain the timing I need.

PN2222 is plenty fast (any transistor is). Not even a consideration until you're in the MHz range.

Can you provide details on what LEDs, resistors, voltages you're dealing with? A schematic of precisely what you're using is what is needed.

You say "this diagram" and then provide a link to a whole page with several diagrams
and no clear component values...

You want about 1k to 2k base resistor, emitter to ground, collector to IR LED + current limit
resistor (about 100 ohms, other end to 5V supply - you'll get about 40mA then

The '2222 will switch in < 0.3us worst case with 15mA load, probably < 1us for
40mA, so no issue with switching speed.

Yep, my bad. Here is EXACTLY what I did.
Diagram of my wiring attached.
+6v came from selectable DC power supply.
LEDs are the super bright IR 5mm from adafruit with 1.6V forward voltage.
They can take up to 1A when pulsed, I was trying to drive them with 100mA in this case.
Transistor was PN2222.

IR receiver picks up 38khz signal at short range when I wire a 330ohm resistor and 1 of the LEDs directly to the Arduino output pin running the same code (without the transistor setup).

Everyone always recommends looking at the LEDs through your phone camera to see if they're on, but all the new phone cameras have IR filters built in. Any other way to test whether or not they're actually pulsing?

led_wiring.tiff (66.2 KB)

all the new phone cameras have IR filters built in. Any other way to test whether or not they're actually pulsing?

But the filters are not that good that will block all the light from an IR diode. You will still see this if they are on.

Test your camera with a remote control. Not one from something like a Roku, that one is Bluetooth.

OK, I am at a complete loss.
The good news: the front camera on an iPhone 5 does not have an IR filter, so I can check on the LEDs with my phone camera after all.
I have done a great deal of searching, and everything I've seen points to the schematic I posted being the correct way to wire this setup.
When I wire the LED directly to the modulated Arduino pin, the IR receiver works within a 6-8" range.
I can confirm through my phone camera that the LED is fairly well lit.
When wired up like the schematic I posted to try and get about 100mA through each LED, the IR receiver doesn't work at all, and the IR LEDs look extremely dim through the phone camera. They are indeed lit, but it's so dim that I can only tell by pointing the camera directly at them and plugging/unplugging them to see if there's a difference.
I have tried replacing the resistor coming from the Arduino output pin to the base with a 220ohm to ensure that the base is getting enough current. No improvement.
Any ideas?

P.S. I should add that I've also tried sending 5v directly to the base pin (non-modulated) and it's not any better.

TIFF is not a good choice for the web. If you use JPG, we can see your schematic without having to download it.

I'd use a 470 ohm resistor. Right now at best you have about a 40:1 ratio of current. But when you are trying to drive a transistor into saturation, the gain drops drastically. Plus, you want to make sure it is overdriven. I use between 10:1 and 20:1 collector current vs base current. 470 ohms will get you around 8.5mA base drive (voltage out of an Arduino pin drops below 5V when you draw current) for about a 12:1 current ratio.

But then you've eliminated that as the problem with a 220 ohm resistor.

What about your 6V supply? Where is it coming from? What is the actual voltage, both without blinking the IR LEDs and while blinking them?

Do you have an oscilloscope you can monitor this with? What does the waveform on the transistor collector look like?

Your iPhone almost certainly has an IR filter, otherwise plants in sunlight will have their color balance messed up. More likely is that, like every other camera with an IR filter, it just doesn't block out all IR.

Jpeg posted.
If it does have an IR filter, the front camera's filter is definitely not as good as the rear camera's.
When I power the IR LED normally (or even use a remote control), it's not visible at all through the rear camera but plenty visible through the front.
As I mentioned, I tried switching R1 out with a 220 ohm with no improvement.
6V power supply is just a 1000mA DC wall wart. I've tested that by powering other things off of it and it's working fine.
It's a switchable supply, I just chose 6V because it made the most sense with the kind of current I was trying to push and the resistors I had on hand.

Measurements....

As in with an oscilloscope? Don't have one. :frowning:

Try using only two LEDs you bill find the Vsat of the transistor is taking up a volt or so.
Check the transistor is the right way round, maybe post a photo correctly sized.

Try using a pull-up resistor (i.e. 1K) connected from the 6V power to the collector. I suspect, at 38khz, the signal at the collector would have a fast fall-time but have a very slow rise-time.

dlloyd:
Try using a pull-up resistor (i.e. 1K) connected from the 6V power to the collector. I suspect, at 38khz, the signal at the collector would have a fast fall-time but have a very slow rise-time.

And how is that going to help, another 6mA of collector current?

And how is that going to help, another 6mA of collector current?

Well, I've seen this problem before, with a similar circuit using 2 IR leds in series in a communication circuit for a measuring device. Its just the intrinsic capacitance and low "switching speed" of most leds. Also, the circuit is open-collector, which inherently has fast turn-on and slow rise time.

The 1K is strong, but I assume the circuit won't be battery powered (an adapter is used). If so, then 4.7-10K may work. An oscilloscope tells all.

38kHz isn't really fast, though.

I suspect this has more to do with not enough difference between 6V and the total LED drop.

The suspicion that the transistor has C and E reversed is a good one, too. Generally, a BJT will work with them reversed, but at a much lower gain and seriously degraded saturation.

dlloyd:

And how is that going to help, another 6mA of collector current?

Well, I've seen this problem before, ...................

I can't see anything in that explanation that would account for it being a fix for anything. I find the terms turn off and rise time confusing in the open collector context.
Even if your explanation were true then according to you the LEDs would be on for too long ( slow turn off ) but as the OP says they look dimmer not brighter. They would look brighter if the turn off were to be too slow not dimmer.

I can't see anything in that explanation that would account for it being a fix for anything. I find the terms turn off and rise time confusing in the open collector context.

Equipment: Arduino Due, OP293A IR LED (2), PN2222A, 1K (2), 18R
Approx 100mA switched through the IR leds, powered by 5V.

No pullup

With 1K pullup

Switching time of PN2222A

A pullup helps a bit on the waveform shape for optical transmission, but what's even more important is the biasing circuit for the receiver (unknown/not posted).

Replacing the PN2222 with a 2N4123 would make an improvement (re: previous reply-last image):

[color=navy]PN2222  Input: [color=red][b]30[/b][/color]pF, Collector-Base: [color=red][b]8[/b][/color]pF
2N4123  Input:  [color=green][b]8[/b][/color]pF, Collector-Base: [color=green][b]4[/b][/color]pF[/color]

I don't need multitouch or position - just on/off on a 3'X3' glass surface (i.e. is someone touching the glass, yes or no).

Uh-oh ... I've been thinking in terms of communication where signal quality is critical. It might not be so critical here - depends on the receiver's photo detector/preamp circuit. :blush:

Referring to the receiver's application circuit and if I didn't have an oscilloscope, I would just try connecting a 10K resistor from pin 1 (OUT) to +Vs (see diagram on page 1).