I'm trying to build a selector switch using momentary push-buttons to achieve the following effect: you have a row of push-buttons each with an LED next to it. When you push one of the buttons, its LED lights up. When you push a different button, the previous LED goes out, and the new one (next to the switch you just pushed) goes on. In this way you get the effect of a digital selector switch.
I've come up with a few design ideas, but I can't quite get it to work. Here's an example (the boxes are S-R flip-flops)
Any help you might be able to provide would be greatly appreciated. I feel like I'm missing something very obvious here.
This is the sort of app that's begging for a small, cheap, simple micro. One chip will do the job easily.
There are many that would serve. My first choice would be a Picaxe
18X, which won't require that you buy a programmer or facce a steep learning curve. Free development system and easy to program for small tasks such as this one.
I absolutely agree. One inexpensive chip will take care of debouncing and logic for this application.
Andrew - Once you try out a micro for stuff like this, you will never go back to discrete logic chips. Even the ubiquitous 555 timer is being replaced by an 8-pin micro because of the flexibility and accuracy.
You're not allowed to say "use a micro" here unless you provide a full schematic and source code. And it has to work.
To the OP, you need to isolate the outputs of your "reset" pulsers from each other - either use open-collector gates (with a pullup resistor), an OR gate, or diode logic (which will also probably need a pullup).
What's happening is the outputs are competing for drive, which has all kinds of unintended consequences. If you wanted to get exotic, you could use tri-state gates and gate them with your "reset" pulse, but that's a little overboard. ;-)
Congratulations! That's a neat design. I came out with one on my writing pad but it has more logic and requires monostables to work. Does the RSFF set first or reset first when a switch is pushed? Does the RC next to the button also takes care of the debounce ?
First, when a switch is closed, the logic high goes to the S input by way of the low-pass filter, the 10K and the 100 nF. At the same time, the pulse is differentiated through the other 100nF, so that the R input is activated immediately. After that pulse goes away, (the 100 nF discharges, or maybe charges, but it reaches a steady state), then when R is released, whichever latch has its S input high gets switched on.
R/S, no, but you can get 8 D latches in a '273 or '373 - you'd need a little more logic: the "or" of the inputs goes to the "Clear" input, and then after a small delay, say a few gate delays, like in your first circuit, (apparently you have the gates lying around ;-) ) you clock it - whichever button is pressed sets its section.
I just realized you'll need more than a few gate delays between the first switch closure and the clock pulse, maybe 10 ms, to wait for it to stop bouncing. Also, since the "clear" is active low, and the clock is high, and they're all positive logic, you might need either inverters of DPDT swithes with pullups on the NC side.
Wo, the switches' C are ground, the NOs all go to diodes, with a pullup on the output of the diode OR, that's differentiated through a cap, clears the '273, and starts a one-shot. When the one-shot times out, its ~Q goes high, which clocks all of the latches - so either you'll need an inverter (the button is still down) or an NC contact that could be pulled up at this point.
You could use a C555 or something like an HC221 one-shot for the pulse.
On Tue, 21 Aug 2007 21:23:58 -0700, snipped-for-privacy@gmail.com wrote:
After I mentioned the micro solution, someone wanted the schematic and the code. Took me a while to put it together, but here it is. The code and sorta-schematic are shown below.
The programmer/editor are available as a free download from
formatting link
. If you live in Europe, that's also a good source for the Picaxe18X chip.
In the US, you can obtain the chip from
formatting link
for $8.45.
After downloading and installing the development software from RevEd, you can connect your computer's RS232 jack directly to the Picaxe RS232 leads, as shown in the sketch. No special programming hardware is required.
RadioButtons.bas S1 on in0, S2 on in1, S3 on in6 LED1 on out0, LED2 on out1, LED3 on out2 Switches are low-active, LEDs are high-active Switches behave as debounced momentary-contact latching #endrem
symbol S1 = pin0 symbol S2 = pin1 symbol S3 = pin6 symbol LED1 = 0 symbol LED2 = 1 symbol LED3 = 2 Main:
low LED1 low LED2 low LED3 do if S1 = 0 then gosub DoS1 elseif S2 = 0 then gosub DoS2 elseif S3 = 0 then gosub DoS3 endif loop end
DoS1:
do pause 5 loop until S1 = 1 pause 5 high LED1 low LED2 low LED3 return
DoS2:
do pause 5 loop until S2 = 1 pause 5 low LED1 high LED2 low LED3 return
DoS3:
do pause 5 loop until S3 = 1 pause 5 low LED1 low LED2 high LED3 return
--
When a switch is closed, the RESET pulse goes to all the latches but
it only lasts for a short time before it decays. In the meantime,
the 100nF cap going to the SET input has been charging up and when
it charges to the threshold voltage of the SET input it\'ll set the
latch.
That was the plan, anyway, but there\'s a problem in that bounce on
release of the switch will cause the latches to reset and if the
level on the SET goes below the threshold voltage before the
bouncing stops, the latch will end up reset.
The fix is to make the delay of the decay of the signal on the SET
input longer than the bounce time, and here\'s how:
. ____
.+V>--+--O O--+--[1N4148>]--+
. | |
. [10K] |
. | |
. [1N4148] |
. |K | +----+
. +-------+-----|-----------------------|S Q|
. | | | | _|
. [100nF] [3M] | +------|R Q|
. | | | | +----+
. GND GND | |
. | |
. | |
. | |
. ____ | |
.+V>--+--O O--+--[1N4148>]--+ |
. | | |
. [10K] | |
. | | |
. [1N4148] | |
. |K | | +----+
. +-------+-----|----------------|------|S Q|
. | | | | | _|
. [100nF] [3M] | +------|R Q|
. | | | | +----+
. GND GND | |
. | |
. | |
. | |
. ____ | |
.+V>--+--O O--+--[1N4148>]--+-----+ |
. | | | |
. [10K] | [10nF] |
. | | | |
. [1N4148] | | |
. |K | | | +----+
. +-------+-----|-----|----------|------|S Q|
. | | | | | | _|
. [100nF] [3M] | +----------+------|R Q|
. | | | | |K +----+
. GND GND [10K] [10K] [1N4148]
. | | |
. GND GND GND
That\'s assuming release bounce lasts less than about 200ms.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.