Connect with us

Digital push-button selector switch?

Discussion in 'Electronic Basics' started by [email protected], Aug 22, 2007.

Scroll to continue with content
  1. Guest

    Hello Friends,

    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)

    <http://ayeats.nfshost.com/schematic_draft.gif>

    Any help you might be able to provide would be greatly appreciated. I
    feel like I'm missing something very obvious here.

    Thanks very much for your help,

    Andrew
     
  2. Tom2000

    Tom2000 Guest

    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.

    http://www.rev-ed.co.uk/picaxe/

    Good luck!

    Tom
     
  3. John Fields

    John Fields Guest

    ---
    Try this: (View in Courier)

    ____
    +V>--+--O O--+--[1N4148>]--+
    | |
    [10K] |
    | | +----+
    +-------+-----|-----------------------|S Q|
    | | | | _|
    [100nF] [1M] | +------|R Q|
    | | | | +----+
    GND GND | |
    | |
    | |
    | |
    ____ | |
    +V>--+--O O--+--[1N4148>]--+ |
    | | |
    [10K] | |
    | | | +----+
    +-------+-----|----------------|------|S Q|
    | | | | | _|
    [100nF] [1M] | +------|R Q|
    | | | | +----+
    GND GND | |
    | |
    | |
    | |
    ____ | |
    +V>--+--O O--+--[1N4148>]--+-----+ |
    | | | |
    [10K] | [100nF] |
    | | | | +----+
    +-------+-----|-----|----------|------|S Q|
    | | | | | | _|
    [100nF] [1M] | +----------+------|R Q|
    | | | | |K +----+
    GND GND [10K] [10K] [1N4148]
    | | |
    GND GND GND
     
  4. John Fields

    John Fields Guest

    ---
    Here's the LTSPICE circuit list:

    Version 4
    SHEET 1 1204 964
    WIRE 112 -384 -16 -384
    WIRE 240 -384 192 -384
    WIRE 256 -384 240 -384
    WIRE 368 -384 320 -384
    WIRE 240 -320 240 -384
    WIRE 864 -304 720 -304
    WIRE 864 -256 784 -256
    WIRE 1024 -256 960 -256
    WIRE 128 -224 128 -336
    WIRE 240 -160 240 -240
    WIRE 784 -160 784 -256
    WIRE 784 -160 240 -160
    WIRE 1024 -144 1024 -256
    WIRE 240 -128 240 -160
    WIRE 784 -128 784 -160
    WIRE 128 -16 128 -144
    WIRE 176 -16 176 -336
    WIRE 176 -16 128 -16
    WIRE 240 -16 240 -64
    WIRE 240 -16 176 -16
    WIRE 784 -16 784 -48
    WIRE 784 -16 240 -16
    WIRE 1024 -16 1024 -64
    WIRE 1024 -16 784 -16
    WIRE 1024 32 1024 -16
    WIRE -16 48 -16 -384
    WIRE 112 48 -16 48
    WIRE 240 48 192 48
    WIRE 272 48 240 48
    WIRE 368 48 368 -384
    WIRE 368 48 336 48
    WIRE 240 112 240 48
    WIRE 720 128 720 -304
    WIRE 848 128 720 128
    WIRE 848 176 768 176
    WIRE 1008 176 944 176
    WIRE 128 208 128 96
    WIRE 240 272 240 192
    WIRE 768 272 768 176
    WIRE 768 272 240 272
    WIRE 1008 288 1008 176
    WIRE 240 304 240 272
    WIRE 768 304 768 272
    WIRE 128 416 128 288
    WIRE 176 416 176 96
    WIRE 176 416 128 416
    WIRE 240 416 240 368
    WIRE 240 416 176 416
    WIRE 768 416 768 384
    WIRE 768 416 240 416
    WIRE 1008 416 1008 368
    WIRE 1008 416 768 416
    WIRE 1008 464 1008 416
    WIRE -16 480 -16 48
    WIRE 112 480 -16 480
    WIRE 240 480 192 480
    WIRE 272 480 240 480
    WIRE 368 480 368 48
    WIRE 368 480 336 480
    WIRE 384 480 368 480
    WIRE 416 480 384 480
    WIRE 512 480 480 480
    WIRE 640 480 512 480
    WIRE 720 480 720 128
    WIRE 720 480 640 480
    WIRE 768 480 720 480
    WIRE 240 544 240 480
    WIRE 384 544 384 480
    WIRE 512 544 512 480
    WIRE 640 544 640 480
    WIRE 768 560 768 480
    WIRE 848 560 768 560
    WIRE 848 608 768 608
    WIRE 1008 608 944 608
    WIRE -16 640 -16 480
    WIRE 128 640 128 528
    WIRE 240 704 240 624
    WIRE 768 704 768 608
    WIRE 768 704 240 704
    WIRE 1008 720 1008 608
    WIRE 240 736 240 704
    WIRE 768 736 768 704
    WIRE -16 848 -16 720
    WIRE 128 848 128 720
    WIRE 128 848 -16 848
    WIRE 176 848 176 528
    WIRE 176 848 128 848
    WIRE 240 848 240 800
    WIRE 240 848 176 848
    WIRE 384 848 384 624
    WIRE 384 848 240 848
    WIRE 512 848 512 624
    WIRE 512 848 384 848
    WIRE 640 848 640 608
    WIRE 640 848 512 848
    WIRE 768 848 768 816
    WIRE 768 848 640 848
    WIRE 1008 848 1008 800
    WIRE 1008 848 768 848
    WIRE 1008 896 1008 848
    FLAG 1024 32 0
    FLAG 1008 464 0
    FLAG 1008 896 0
    SYMBOL voltage 128 -240 R0
    WINDOW 0 -53 5 Left 0
    WINDOW 3 -242 110 Invisible 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V2
    SYMATTR Value PULSE(0 5 1 1E-6 1e-6 .1)
    SYMBOL diode 256 -368 R270
    WINDOW 0 32 32 VTop 0
    WINDOW 3 0 32 VBottom 0
    SYMATTR InstName D1
    SYMATTR Value 1N4148
    SYMBOL res 224 -336 R0
    SYMATTR InstName R1
    SYMATTR Value 100k
    SYMBOL cap 224 -128 R0
    SYMATTR InstName C1
    SYMATTR Value 1e-7
    SYMBOL res 768 -144 R0
    SYMATTR InstName R4
    SYMATTR Value 10e6
    SYMBOL Digital\\srflop 912 -208 M180
    SYMATTR InstName A1
    SYMATTR Value2 trise 1e-6 tfall 1e-6 vhigh 5v
    SYMBOL res 1008 -160 R0
    SYMATTR InstName R5
    SYMATTR Value 10k
    SYMBOL voltage 128 192 R0
    WINDOW 0 -53 5 Left 0
    WINDOW 3 -242 110 Invisible 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V1
    SYMATTR Value PULSE(0 5 2 1E-6 1e-6 .1)
    SYMBOL diode 272 64 R270
    WINDOW 0 32 32 VTop 0
    WINDOW 3 0 32 VBottom 0
    SYMATTR InstName D3
    SYMATTR Value 1N4148
    SYMBOL res 224 96 R0
    SYMATTR InstName R6
    SYMATTR Value 100k
    SYMBOL cap 224 304 R0
    SYMATTR InstName C3
    SYMATTR Value 1e-7
    SYMBOL res 752 288 R0
    SYMATTR InstName R9
    SYMATTR Value 10e6
    SYMBOL Digital\\srflop 896 224 M180
    SYMATTR InstName A2
    SYMATTR Value2 trise 1e-6 tfall 1e-6 vhigh 5v
    SYMBOL res 992 272 R0
    SYMATTR InstName R10
    SYMATTR Value 10k
    SYMBOL voltage 128 624 R0
    WINDOW 0 -53 5 Left 0
    WINDOW 3 -242 110 Invisible 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V3
    SYMATTR Value PULSE(0 5 3 1E-6 1e-6 .1)
    SYMBOL diode 272 496 R270
    WINDOW 0 32 32 VTop 0
    WINDOW 3 0 32 VBottom 0
    SYMATTR InstName D5
    SYMATTR Value 1N4148
    SYMBOL res 224 528 R0
    SYMATTR InstName R11
    SYMATTR Value 100k
    SYMBOL cap 224 736 R0
    SYMATTR InstName C5
    SYMATTR Value 1e-7
    SYMBOL cap 480 464 R90
    WINDOW 0 0 32 VBottom 0
    WINDOW 3 32 32 VTop 0
    SYMATTR InstName C6
    SYMATTR Value 1e-8
    SYMBOL res 368 528 R0
    SYMATTR InstName R12
    SYMATTR Value 10k
    SYMBOL res 496 528 R0
    SYMATTR InstName R13
    SYMATTR Value 10k
    SYMBOL res 752 720 R0
    SYMATTR InstName R14
    SYMATTR Value 10e6
    SYMBOL Digital\\srflop 896 656 M180
    SYMATTR InstName A3
    SYMATTR Value2 trise 1e-6 tfall 1e-6 vhigh 5v
    SYMBOL res 992 704 R0
    SYMATTR InstName R15
    SYMATTR Value 10k
    SYMBOL sw 208 -384 M270
    WINDOW 0 21 143 Left 0
    WINDOW 3 12 110 Left 0
    SYMATTR InstName S2
    SYMBOL sw 208 48 M270
    WINDOW 0 17 145 Left 0
    WINDOW 3 15 110 Left 0
    SYMATTR InstName S3
    SYMBOL sw 208 480 M270
    WINDOW 0 19 141 Left 0
    WINDOW 3 14 110 Left 0
    SYMATTR InstName S4
    SYMBOL voltage -16 624 R0
    WINDOW 0 -53 5 Left 0
    WINDOW 3 -242 110 Invisible 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V4
    SYMATTR Value 5
    SYMBOL diode 656 608 R180
    WINDOW 0 -42 32 Left 0
    WINDOW 3 -79 -4 Left 0
    SYMATTR InstName D2
    SYMATTR Value 1N4148
    TEXT 136 880 Left 0 !.model SW SW(Ron=1 Roff=10Meg Vt=0.5 Vh=0)
    TEXT 144 912 Left 0 !.tran 5
     
  5. Guest

    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.

    BRW
     
  6. Rich Grise

    Rich Grise Guest


    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. ;-)

    Good Luck!
    Rich
     
  7. Allen Bong

    Allen Bong Guest

    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 ?

    Is there any cmos/ttl that carries 8 RS F/Fs ?


    Allen
     
  8. Rich Grise

    Rich Grise Guest

    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.

    Hope This Helps!
    Rich
     
  9. John Fields

    John Fields Guest

     
  10. Rich Grise

    Rich Grise Guest

    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.

    Good Luck!
    Rich
     
  11. Allen Bong

    Allen Bong Guest

    Thanks Rich,

    I'll try to work it out and see if I can get the logic right.

    cheers,

    Allen
     
  12. Rich Grise

    Rich Grise Guest

    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.

    Have Fun!
    Rich
     
  13. Tom2000

    Tom2000 Guest

    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
    http://www.rev-ed.co.uk/picaxe/ . If you live in Europe, that's also
    a good source for the Picaxe18X chip.

    In the US, you can obtain the chip from
    http://www.phanderson.com/picaxe/ 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.

    Good luck with your project!

    Tom


    ======================================


    +5 16 uF tantalum
    Gnd | + | |
    | o-------| |---- Gnd
    | | | |
    5 | | 14
    +5 +-------------+
    | | | ______
    | | |------|______|---o---------- RS232 In
    | | | | 3 22 k |
    | |4.7 k | | | |
    | | | | | | 10 k
    | | | | |
    +-------| | |
    4 | | Gnd
    | |
    | |----------------------------- RS232 Out
    | | 2
    | |
    | |
    | |
    | | +5
    | | |
    | | | | 10 k
    | | | | _______
    | | | |
    | | | | |
    | |-------o---------+ +--- Gnd
    | | 17 S1
    | |
    | |
    Picaxe | |
    18X | | +5
    | | |
    | | | | 10 k
    | | | | _______
    | | | |
    | | | | |
    | |-------o---------+ +--- Gnd
    | | 18 S2
    | |
    | |
    | |
    | | +5
    | | |
    | | | | 10 k
    | | | | _______
    | | | |
    | | | | |
    | |-------o---------+ +--- Gnd
    | | 15 S3
    | |
    | |
    | |
    | | _____
    | | _____ | |
    | |-----|_____|-----| LED |-- Gnd
    | | 6 330 |_____|
    | |
    | |
    | |
    | | _____
    | | _____ | |
    | |-----|_____|-----| LED |-- Gnd
    | | 7 330 |_____|
    | |
    | |
    | |
    | | _____
    | | _____ | |
    | |-----|_____|-----| LED |-- Gnd
    | | 8 330 |_____|
    | |
    +-------------+




    ======================================


    #rem

    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



    =======================================
     
  14. Tom2000

    Tom2000 Guest

    I forgot to mention that, with this design, there are two inputs
    and five outputs available for you to add functions to the rest of
    your circuit.

    The inputs are either digital or 8/10 bit ADC, and the outputs are
    digital, with one available as eiter digital or PWM output.

    Tom
     
  15. John Fields

    John Fields Guest

    ---
    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.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-