Thursday, October 16, 2014

Dynamiting Fish

Was just helping someone at the RPF rig up a Cree LED to "pulse" for a prop they'd built. Used an Arduino, because we had one.

Which is like dynamiting fish in a bucket. It is a deceptively simple problem; detect a trigger button, turn on an LED then dim it out. If it were an incandescent bulb, a capacitor would do it all. But LEDs can't really be dimmed that way. You need to PWM them; that is, you switch them on and off too rapidly to see, and you change the ratio between the time it is on and the time it is off.

Which you could do with the old 555 -- possibly the most-used IC ever after the 741 opamp, and certainly one of the most elegant chips ever. Use an external capacitor to change the timing as it discharged. I used to do that trick when I had 555's as sound generators. Even hooked one up to a resistor ladder attached to a binary counter. Made a wonderfully complex sound.

But you'd have to hold the button in until the LED turned "off" completely. So use the 556; the dual timer in a 14 pin DIP. One is operating in one-shot mode and detects the button and then holds the circuit "on" until the next button press. The other is switching the LED on and off rapidly, while a capacitor discharges to change the pulse ratio.

In the old days, you'd set it up on breadboard with a bunch of potentiometers while you dialed in the behavior, then start pulling pots, measuring them with the multitester and replacing them with fixed resistors. Which wouldn't quite work the same, because of all sorts of capacitive leakage between the various elements and other parasitic effects, so you'd pull those and randomly test a bracket of values until it worked again.

The last complex circuit I did in the pre-micro days, I didn't even use a 555. I used a hex inverter chip (which isn't an anti-magic shield, but six digital inverters in one package). You could make a pretty decent oscillator out of two or three inverters and the right discretes. If I remember correctly, it was a "power up" thing for a friend. Had a big rocket switch, and when you switched it a bar graph would crawl up to the top while a whine from a small speaker rose in pitch. All of that driven by a single beefy capacitor.

And these days, it is all micros. Because especially with the ATtinys, you are paying about as much per chip as you would be for the old integrated circuits -- or a pair of transistors, if you want to be really old-school -- and you tweak the timing in software instead of by trying out different resistors from your parts box. And they aren't any bigger; you can run the things basically naked, with their internal oscillator instead of adding an external crystal. And of course the program is stored on the same chip in non-volatile flash.

It is still dynamiting fish, but at least it is a bigger bucket. The example above, we had to fade the LED and latch the trigger button. That's just enough to make it easier to use a micro. The picture to the right, I soldered that up quick for a fire effect, using code to generate a random flicker on the red and green channels of the Cree (which, combined, make a more-or-less amber color).

And this episode reminded me once again, I really should get that PCB made. Ignore the RF for now; that's been distracting me too long. Just three MOSFETs, an ATtiny, some arbitrary ballast resistors, and a terminal or two to connect button or sensors. I just picked up some Chinese RGB's for under five bucks each, and I should be able to make the PCB for about another $5 even at the prices of a limited run at a fab house. So I could offer the complete kit for $15; a digitally controlled 3W RGB that could be user programmed and used in props or cosplay.

No comments:

Post a Comment