LED help needed from the Experts!

Ask and answer questions, share tips and resources for installing lighting and other electronics in your models.

Moderators: Sparky, Moderators

Post Reply
User avatar
robiwon
Posts: 2930
Joined: Wed Oct 18, 2006 3:56 pm
Location: Kentucky

LED help needed from the Experts!

Post by robiwon »

So some of you may have seen my Cricket Phaser threads. One was built with a Playmates board with limited functionality, the other was built with an expensive board. Here's my question for you tech savy members.

With very limited space, how can I have hook up 4 or 5 LEDs and have them come on, one at a time, using one button and then go off one at a time using a seperate button?

I think this may have to be some sort of traced board with the LEDs and two micro switches mounted to it. It would need to handle 4.5v from three 357 pill batteries.

Here is a video of what I am looking for.
http://www.youtube.com/watch?v=E_u_vI2K1zA

I'm just looking for the ability turn them on and off, one at a time. I already have the sound/fire button/light function. I just need a board to add to this. I might even be looking at having someone do a small run of this "add on board" for the Playmates board if it's feasible and not too expensive to have done.
"Dead or alive, your'e coming with me"
User avatar
tetsujin
Posts: 2353
Joined: Mon Feb 28, 2005 6:08 pm
Contact:

Post by tetsujin »

I designed a small microcontroller board: the goal of the project was to develop something that I could conveniently fit into any model or prop.

Raven controller board
Raven installed in a Sonic Screwdriver

The board hosts a 14 pin TSSOP PIC (16F688 or another PIC with the same pin layout) and breaks out 8 I/O lines with series resistors - and another 3 I/O lines (including the reset pin) without series resistors.

Soldering a board like that can be a challenge, since it's all surface mount. I solder them by hand, it took a bit of practice but I'm at the point where I can do that pretty successfully. But another option would be some kind of reflow system (some people use hot plates or toaster ovens for this...)

I had the boards fabricated at BatchPCB (v6 - 10mm x 14 trimmable to 10mmx10mm) and v5 (13mm x 9mm), if you want to order some, the designs are posted there - but expect a lead time of a few weeks and a total cost of around $20 ($10 per order "set-up fee", $2.50 per square inch, and shipping - but shipping is cheap if you choose cheap shipping. For $20 you could get yourself a dozen Raven boards or possibly more...)

The PIC, of course, can be programmed to do whatever you want. I mostly work in assembly but there are C compiler options as well (I think Microchip offers something - and I've tried sdcc a few times, too...)

(These days I tend to prefer AVR over PIC - but the thing about this particular PIC is that it's very small. I've looked at the options for small AVRs, and there's nothing with that combination of features: a good number of I/O lines, a form factor small enough for a 1cm x 1cm board, and something I could solder by hand... If I get set up for reflow soldering, then maybe I'll redesign the board for an AVR...)

Of course, that cricket phaser isn't super-small: I don't know what the interior looks like but you might be able to use something like the Arduino Pro Mini (18mm x 33mm) - much larger than a Raven obviously, and without the onboard series resistors - but if it'll fit in your prop it could be a very convenient way to go.
---GEC (三面図流の初段)
There are no rats.
The skulls eat them.
User avatar
robiwon
Posts: 2930
Joined: Wed Oct 18, 2006 3:56 pm
Location: Kentucky

Post by robiwon »

Thank you tetsujin, that was awesome. But, it was over my head on the technical side. So, let me ask this question. Could you use one of your boards to mount momentary switches to it, and have it control 5 LEDs? Push one button and one LED comes on, push again and second comes on, push the other button and they go off? I have no clue on the programming of PICs or anything of that nature.
"Dead or alive, your'e coming with me"
User avatar
tetsujin
Posts: 2353
Joined: Mon Feb 28, 2005 6:08 pm
Contact:

Post by tetsujin »

robiwon wrote:Thank you tetsujin, that was awesome. But, it was over my head on the technical side. So, let me ask this question. Could you use one of your boards to mount momentary switches to it, and have it control 5 LEDs? Push one button and one LED comes on, push again and second comes on, push the other button and they go off? I have no clue on the programming of PICs or anything of that nature.
My board, and the Arduino I linked, aren't designed for having buttons mounted right on 'em. They're general-purpose boards: having buttons mounted in specific places is a bit more specialized.

But apart from that detail: yes, I could take one of my boards, hook up two pushbuttons and five LEDs, whip up a program that handles the buttons' input and produces appropriate output on the LEDs. Really, an 8MHz CPU is overkill for a job like that: but microcontrollers are pretty cheap ($2-$5 for most of 'em). It also makes the wiring of the circuit dead-simple (very low components count) and it means that changing or enhancing the behavior of the circuit later doesn't require rewiring/redesigning the whole thing. (want to add overload mode? Make the LEDs pulse? Make the LEDs auto-power-off after a while? Have the circuit also drive the "emitter" LED? It's pretty easy to do these things in code without changing the circuit at all. Doing this stuff without a microcontroller would mean redesigning the circuit for each little change...)

If you were to do this without a microcontroller, you could do the up/down count with a simple IC like the 4510 up/down counter. (Well, it outputs BCD so you'd need to add a BCD decoder like the 4028...) Wire its inputs straight to your buttons, wire the decoded outputs through some resistors to some LEDs. And that would do the basic job very well: but when you start getting more specific about what you want the circuit to do, the solution becomes more complicated:
  • Do you have a number of LEDs that isn't 10? (I know you said there's 5 LEDs, but the BCD counter has 10 states...) If it's more than 10 you need more than one decade counter. If it's less than 10 you need to stop the counter from counting higher once it reaches the limit...
  • Oh, and don't forget that BCD decoder would just light one LED at a time, what you want is a bargraph that "fills" - so you'd probably need to add one OR gate per LED - so probably add another IC, unless you find a bargraph driver IC that would do the job...
  • Do you want the LEDs to always be on or do you want them to automatically turn off after a while? If you want auto-off behavior, combine all your button inputs with an OR gate, connect that to a timer circuit "reset", and use the timer to control power flow to the rest of the circuit (or to reset the counter to zero after a certain amount of time with no button presses)
  • Do you want to implement the "overload" feature? If so, add a second light-show circuit (a decade counter with the appropriate connections would probably do the trick) and circuitry to switch between the two modes... Maybe another four or five ICs.
You can see where this kind of solution gets complicated pretty quickly. Even the most basic implementation using discrete logic circuits results in a large number of ICs pretty quickly (even the basic version used two, because the up/down counter I found is BCD...) - and that eats up valuable real estate inside the prop. You could program a single microcontroller to do all those tricks: it would be one IC instead of two (for a simple implementation) or several (for a full-function implementation...)

If you wanted a board with pushbuttons in specific places, probably the way to go would be to design a PCB, including the required pushbuttons in those places, and have that PCB produced. This would also give you the opportunity to create a board design that's tailor-made to fit in the prop. I'm really just a beginner at producing PCBs (the Ravens are the first PCBs I've designed, and I actually made a mistake in the first run of them...) but I managed to get through it. :) A popular choice for PCB design (if you decide to design a PCB) is the "Eagle" software. There's a free trial version that will do everything you need for a simple board like this.

Do you have any programming skill? If you're capable of working with C (or at least willing to sweat it out long enough to learn) then I'd say give Arduino a try. It's an easier place to start than a raw PIC board would be, and the skills you pick up would be easy to translate to AVR controllers in general once you got the hang of it.

With regard to the programming thing - bear in mind that conceptually at least, the problem you're trying to solve is very simple. Turning the idea into an actual piece of working code does complicate things, but because it's a conceptually simple problem, the solution (in code) isn't going to be too complicated, really...
---GEC (三面図流の初段)
There are no rats.
The skulls eat them.
User avatar
robiwon
Posts: 2930
Joined: Wed Oct 18, 2006 3:56 pm
Location: Kentucky

Post by robiwon »

Tetsujin, I am sending you a PM. :8)
"Dead or alive, your'e coming with me"
Post Reply