Flutterby™! : Frustration of the day

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

Frustration of the day

2003-03-05 00:07:41.90173+00 by Dan Lyke 8 comments

Okay, I can say pretty much unequivocally that solder is not my favorite language. I've spent the day diddling about with various hardware issues, I'm trying to set up a mouse to have an optical input instead of a button, and this should be trivial, but I'm never sure whether my IR LED is lit, and when I give it the current the specs say it wants my 1/4 Watt resistor gets amazingly hot (but the voltage drop over the LED looks right), and the change in voltage across my phototransistor is so slight that I'm sure I'm doing something wrong, 'cause I know all this stuff was easy when I did it in the game port of an Apple ][ back in High School for physics class, and... sigh. At this point I'm about ready to go back to mechanical switches.

[ related topics: Apple Computer Children and growing up Hardware Hackery Dan's Life ]

comments in ascending chronological order (reverse):

#Comment made: 2003-03-05 19:02:53.293898+00 by: aiworks

I don't know if this is all that helpful, but my experience has been that video camcorders make the IR LED blinking visible on tape/screen.

I discovered this when playing with a JVC camcorder hooked up to a G4. I was suprised to see (on playback) the LED on the camcorder remote visibly blink a kind of bluish white. I tried a few other remotes that were handy and saw the same result.

#Comment made: 2003-03-05 19:33:00.024435+00 by: Dan Lyke

Cool. Nathan tells me via email "...as far as knowing if your IR LED is lit, try looking at it through one of those cheap webcams. It works for TV remotes."

#Comment made: 2003-03-05 21:30:33.662668+00 by: Brian [edit history]

The voltage drop over the LED will always be right: the I/V curve of a diode goes straight up at the forward voltage, so basically it's drawing as much current as it needs to bring the voltage down to its characteristic forward voltage (usually about 2V for LEDs). The math you want to be using is:

current = (supply_voltage - led_Vf) / resistor

You start by choosing the desired current (I use 10mA for LEDs.. the LED specs should tell you what it can handle). That tells you what resistance to use. Then you have to calculate how much power the resistor is going to be burning off to determine how big a resistor (wattage) you need.

power = current * (supply_voltage - led_Vf)

You want a power supply that is just slightly over the LED's forward voltage, otherwise you're burning off a lot of energy. 5V is reasonable, 12V is not. My usual setup involved a 5V logic output and a 330ohm resistor, which tended to give me reasonable results.

Putting a visible LED in series with the IR led (and adding the Vf values, assuming they'll take the same current) is an easy "tell me the transmitter is transmitting" trick. If you're driving it with a logic-level output, having a separate buffer for each LED is probably a better idea, since Vf and survivable current wil vary from LED to LED, especially between different families.

Phototransistors are touchy. Apart from being easy to rig up wrong, they don't tend to be very IR-specific. Most commercial IR (remote controls) modulate the signal at 40kHz and use a notch filter in the receiver (as well as a plastic IR filter) to reduce the DC component you'll get from, say, sunlight. It's entirely possible your phototransistor is being saturated by visible light.

Sharp makes some CIR receiver units (half-inch cubes, power/ground/signal, sold for $5 at radio shack or digikey) that are great. You should be able to modulate a 40kHz signal through the emitter and will probably get a better signal out of those modules than you would with a raw phototransistor. Just remember to ground the module's case: the amplifier inside is pretty high-gain and can get swamped by stray AC fields.

-Brian (who remembers Dan's high school physics class, and that Apple 2 hack he did)

#Comment made: 2003-03-06 02:40:39.178754+00 by: Dan Lyke

My supply voltage in this case was 4.8 volts, the spec sheet for the IR LED says 150mA and 1.3V typical, when I dropped that into the

resistor = (supply voltage - led forward voltage) / current

(a simple restating of your first equation) I got 23 Ohms. The heat off that little 1/4 Watt resistor convinced me of the error of my ways.

I'm not terribly concerned about ambient light on the phototransistor as this whole assembly will be boxed, and I'm putting the phototransistor and LED in an aligned jig with lots of shielding (solder tubing to the support, then cut the tubing, to make sure of alignment). If I have to put an oscillator in there lots of the project becomes a whole lot more complex, and I start thinking about replacing the Via Eden[Wiki] with a PIC[Wiki] or Atmel[Wiki] chip.

When I put the phototransistor in across where the switch on the mouse was I measured 4.7v across it when it wasn't exposed to the LED, that dropped to 3.5v or so when I put it in front of the LED. So there seemed to be an effect, just not enough of one. Maybe I got polarity backwards or something bizarre. I also tried it in the standard "10kOhm to Vcc, phototransistor to ground" configuration and didn't get the results I was hoping for.

Current needs seem to be drastically different between different LEDs, but I think I've got two green LEDs that, in series, should be equivalent to one IR LED.

Anyway, next step is to use fresh parts (just in case), put it on an experimenter board completely bypassing the mouse and making sure I can get it working there before I try to integrate it with the mouse electronics. If that doesn't work this evening, then I panic and try something else. Maybe a mechanical switch, although Doug at the machine shop will snicker evilly if I have to resort to that.

So you remember the phototransistor hack (was that from plans that Vernier Software published?), did my software for driving the ultrasonic rangefinder stay around for any time? I've no idea what I'd do with it now, but that was cool.

#Comment made: 2003-03-06 03:17:28.137722+00 by: Brian

Yeah, 3.5V across 23ohms will give you 150mA, so a little over half a watt. Take four .25W 100ohm resistors in parallel, that'll probably avoid the flames. My rule is to double-check the math any time the resistance drops into the double digits or the current rises above 100mA.

That's one honkin IRLED there. Make sure it's happy with being driven continuously.. some of those units are designed with a 50% (or less) duty cycle in mind.. IrDA applications, usually.

I usually blow up a transistor or three when I try to design them into circuits, but I think the Vcc--10k--collector, emitter--ground layout, with the input coming off the collector, is the right approach. Remember that it's essentially a diode, so getting it backwards (emitter above collector) should just give you an open circuit. (As long as you don't drive it with too high a voltage.. anything will break if you push it hard enough). Also, the fact that it is basically a diode will affect the kind of voltage drop you can get across it. You may need to add another transistor or a comparator as a second stage. Those CIR units had amplifiers inside them.

I don't remember the rangefinder.. I was thinking of some drop-the-ball-and-measure-gravity timing gear on those old machines in the physics lab (Mr. Cisko? old crazy guy with curly hair and more patience than a rock). Now I'm not sure if it was your hardware or some commercial thing they picked up, though.

#Comment made: 2003-03-06 03:56:05.896176+00 by: Dan Lyke [edit history]

Yep. Did that calculation this evening and realized that since most of these mice are marked "100mA" on the bottom that was probably stressing a whole lot.

The package says:

Reverse voltage:5V
Continuous forward current:150mA
Forward voltage:1.3v typ., 1.7V max.
Radiant power output:13-15mW
Wavelength at peak emission:950nm

What's the scaling factor? Will less current make it dimmer linearly? If this doesn't work I'll give up on the Radio Shack[Wiki] parts and go to Electronics Plus[Wiki] where I have to spend more time looking through a catalog, but now that I've blown up enough parts to have a clue I might have better luck there.

Yep. I at least assembled a set of those gates from instructions and parts and wrote some software to talk to them, and soldered together a kit that consisted mainly of one of the scrap transducers from the autofocus unit of the then recently discontinued Polaroid[Wiki] camera. Physics teachers were Dr. Smith (who also did chemistry) and... damn, I don't think it was Cisko, and I should remember this 'cause that was my freshman homeroom teacher too, and I liked him. I'm thinking it was more syllables than Cisko, but it wasn't Chervansky, he was the biology teacher I loathed.

(Edits: Note to self, <th> is indeed a valid tag. Fix the damned code.)

#Comment made: 2003-03-06 04:14:36.213605+00 by: Brian

Should be linear, at least until you hit the very very top and then it tends to drop rather quickly (with apologies to Python). Amidst much smoke and flame.

If you're driving both ends of this with that Eden board, you might want to use the floppy cable as a power supply instead of the PS/2 port. You should be able to get an easy amp or two out of that, whereas the PS/2 port is probably fused to prevent kids with paperclips from causing too many sparks.

Argh, you've made me drag out my old yearbook and look up his name. Edmund Chesto. Gack. Now there are some pictures I didn't need to see again..

#Comment made: 2003-03-06 04:25:40.212285+00 by: Dan Lyke

Bingo. I think. I need to dig up the brass mounts I built for it yesterday and mount the phototransistor shielded from stray light (as you predicted) rather than just with positioned pieces of whatever I had handy while I was holding test pieces together, but as of right now the IR LED appears to be working with a 10 Ohm resistor on the 1.9V feed to the red LED that's in there for aesthetics, which should draw about 60mA. Maybe a little high for the mouse, but probably within bounds for the PS/2 port.

And given that the mouse switch is just a normally open SPST, with about 2.5v potential across it, I put the phototransistor across that with nothing additional.

Need to do a little catching up as the guys who built the stepper board have changed the protocol a bit (for the better, I think), but I think I'm suddenly ahead of schedule. I'm actually going to put the Eden board in a full-sized case so I can use the main power supply to drive the steppers (and hopefully that won't cause a discontinuity in the switching power supply) and the auxiliary boards, so if I get really nervous and serious I'll try driving the IR LED off of that power supply.


And yes, Edmund Chesto is he.