B
Bill Sloman
Guest
On Wednesday, 12 March 2014 19:25:08 UTC+11, Jasen Betts wrote:
I just said that "Using one of the nine spare states as a global reset - to turn them all off"
> And then you have a mess of asynchronous logic to handle this...
It doesn't have to be asynchronous. There's nothing to stop you from inspecting the states of the inputs at every rising (or falling) clock edge, and ignoring them for the rest of the time. You probably need to read up on "de-bouncing" switches.
Which is why most people go for clocked state machines.
Some of them have been listed in this thread. Some of us have tried to buy them from time to time and tend to prefer more general purpose parts that are likely to stay available for longer.
The shift register approach certainly uses up fewer pins.
--
Bill Sloman, Sydney
On 2014-03-12, Bill Sloman <bill.sloman@gmail.com> wrote:
On Wednesday, 12 March 2014 15:35:10 UTC+11, Robert Baer wrote:
Mike Miller wrote:
I want to be able to toggle 23 separate LEDs in my application. The design challenge is that I only have about 17 pins available on my SoC.
What are some options for this?
1.) Use another microcontroller with 23 available pins with some digital interface (spi/i2c) and then send over data to toggle the appropriate pins?
2.) Ideally I don't want to have to do additional firmware development on a second microcontroller.
Thank you for any ideas.
Clue: using N pins, one has available 2^N states.
So all you need to use is 5 pins to control those 23 devices, leaving
9 unused states.
You need 5 pins to be able to select any one of these devices. Selection - on its own - isn't quite what the OP is asking for. He wants to "toggle" the LEDs.
Admittedly, just selecting any one LED could serve to "toggle" it between "on" and "off" but since you don't know how they started up (or got reprogrammed by a recent lightning strike) this isn't all that useful. Using one of the nine spare states as a global reset - to turn them all off - would get around that problem. Adding a sixth pin - so you could set the selected LED explicitly "on" or "off" - would make life easier.
you could use one of the spare states to reset all the bits,
and have another spare state near that state for resting.
I just said that "Using one of the nine spare states as a global reset - to turn them all off"
> And then you have a mess of asynchronous logic to handle this...
It doesn't have to be asynchronous. There's nothing to stop you from inspecting the states of the inputs at every rising (or falling) clock edge, and ignoring them for the rest of the time. You probably need to read up on "de-bouncing" switches.
toggling any led then becomes an excursion through hamming space to toggle
the led and then a return through the same hamming space back to the rest
state to un-toggle all the leds you hit on the way to the target.
Which is why most people go for clocked state machines.
It'd make a good programming exercise but little else.
The shift register approach is to be preferred, IIRC there are some
led drivers that can control 30 leds from 2 input pins.
Some of them have been listed in this thread. Some of us have tried to buy them from time to time and tend to prefer more general purpose parts that are likely to stay available for longer.
The shift register approach certainly uses up fewer pins.
--
Bill Sloman, Sydney