Author Topic: "selector switch" using push buttons (e.g. like source selection on an hifi amp)  (Read 1549 times)

0 Members and 1 Guest are viewing this topic.

Offline Lupin III.Topic starter

  • Contributor
  • Posts: 35
Let's say I have several LEDs (4-6, not the actual thing I want to control, but makes the explanation easier) and I want to select which of them is lit by pressing a corresponding push button (so one button for each LED). If I push a button, it should clear whatever other LED is lit and light up (and keep it lit) the new one. In essence it should behave like the typical input source selector buttons on an hifi amplifier.

The other functional requirements are low. A defined startup state, like a "default" LED, would be nice, but no LED lit up is not a problem. The switching doesn't have any time constraints (except being fast enough to feel "instant", so <50ms). The only thing that should not happen is two LEDs being lit up simultaneously even a short time. It wouldn't break anything, would just lead to annoyed users ;) . But there's no need for a lockout if multiple buttons are pushed at the same time. If multiple LEDs would light up in that case and are staying lit that's fine. It's the user's fault ;) .

What would be the simplest (in parts count) way to build something like this? I could obviously throw a microcontroller at it. But I also have a box of old logic ICs. No even sure any more what's exactly in there, but if there was a "project" where some of them could be useful, I don't think anything better will come around soon.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5869
  • Country: de
Biggest part of the circuit will probably be debouncing.

I you want bullet proof operation, a priority encoder like the MC14532, followed by a 3-bit latch and a 3:8 decoder will do the job.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Benta's idea should work and may be lower parts count than my suggestion below.  You'll need a delay between MC14532 Eout and the latch strobe or clock in to allow setup time for the latch data inputs and additionally for debouncing.

Alternatively, if you don't want to encode the state to store it, conceptually you need a flipflop for each LED, with one button wired to SET it, and all other buttons logically ORed together to RESET it.  No debouncing needed.  It doesn't matter *how* many times you press the same button as the expected result state is still the same.  Implementation depends on the chips available.  If you've got SR flipflops (or D or JK flipflops with individual S and R  inputs) you might as well use them.  Otherwise you could build them from individual gates.  The RESET logical OR is difficult for large numbers of buttons as you need N of them with N-1 inputs.  For large N, you'd need to cascade or wire-OR.  Heck it could even be done with discrete transistor Flip-Flops and diode logic for the RESET circuit.
« Last Edit: November 30, 2021, 06:48:20 pm by Ian.M »
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1560
  • Country: gb
This is how it is done on the QUAD 34 control unit (sorry for the scruffy photo of a less-than-perfect photocopy, but at least it's legible!)

One 4000 series quad NOR gate (IC11), some R's and a C to ensure power-up in a known state, and transistors to drive the LEDs
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5869
  • Country: de
Crikey.
Then I like my priority encoder/latch/decoder idea better.
Thinking about it, only the three-bit latch needs to be debounced (the clock), which makes it even simpler.
 

Offline Lupin III.Topic starter

  • Contributor
  • Posts: 35
As mentioned I got a lot of old logic ICs (they came with electronic components I bought by the kg on ebay a long time ago; the ICs were in the not really useful category). I searched through it for flip-flop type ICs. I found the following three types (or rather two because one is more or less the inverted output of the other). If I can't use those in a way I'll go for a µC. The project is a bit of a "use what I got" challenge. Resistors, capacitors, transistors, or the random IC.

So I got DM74S174, a hex-D-flip-flop with clear, and SN74AS373, an octal D-type latch. I also got SN74AS533, but that is, as far as I can see it, an SN74AS373 with the outputs inverted. I'm only need a few buttons (pretty sure it won't be more than 6), which means a single one of these ICs should be enough. And if it isn't, I found at least 10 of each.

I think it should be possible with those, in line with Ian's "alternative", with a few additional diodes and the clever use of an RC circuit to trigger "clear", "clock", "latch enable" or "output enable" with the right timing. (Only problem: right now I'm too hungry to do clever stuff. ;) )
« Last Edit: November 30, 2021, 06:28:38 pm by Lupin III. »
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1560
  • Country: gb
You really, really, don't want to use Schottky S or, even worse, AS series logic here. Much, much too fast, and too power hungry. Old, slow, 4000 series is ideal for the job.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5869
  • Country: de
Sorry, but I'm with nfmax.
74xxx, 74Sxxx and 74ASxxx is landfill. All power hungry, and 'S and 'AS difficult to use. For Ian's solution still possible, but you'll either need a lot of gates as well, or diode logic instead to get the reset logic to work.
 

Offline Lupin III.Topic starter

  • Contributor
  • Posts: 35
Power consumption shouldn't be an issue. I'll pretty much use only a single one of them, and it's neither a battery powered device nor something that's on more than a few hours a week. As long as an LM7805 can handle it, it's fine.

But what do you mean with difficult to use?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
D type latch approach with active low outputs:

For each D input, wire one button to pull it low against a pullup.  Combine them all with diodes + a pullup to drive an inverter (or use a wide NAND).   The inverter may be a single BJT (+ a diode to increase its Vbe threshold).  RC delay the inverter output to drive the latch clock.

Powerup needs a longish RC delay diode coupled to 'force' one of the buttons and the clock inverter so it doesn't start with multiple outputs active.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Sorry, but I'm with nfmax.
74xxx, 74Sxxx and 74ASxxx is landfill. All power hungry, and 'S and 'AS difficult to use. For Ian's solution still possible, but you'll either need a lot of gates as well, or diode logic instead to get the reset logic to work.

On the contrary, I use quite a few of those old chips when repairing arcade boards and other vintage equipment. Far from landfill they are very useful parts that while mostly still available have been getting more expensive.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5869
  • Country: de
"vintage equipment".
Well, Yes.
 

Offline Lupin III.Topic starter

  • Contributor
  • Posts: 35
All power hungry, and 'S and 'AS difficult to use.

I think I know understand what you mean by "difficult to use". Especially that high "low level" input current. Makes use of pull-down resistors impossible (I'd like pull downs in this case, because low level should be the "default" and I want transistors for the open-collector output).

I breadboarded up some circuits.

For the 74S174 nothing really worked as expected (never kept the corresponding LED lit when releasing a button, if it even lit up in the first place). It was a little bit better with a 74F174 (it at least lit up the right LED, but also mostly "lost" it when releasing the button). I guess manual buttons and gates that rely on transistions really don't mix.
I also found a 74HCT174 (yes, the CMOS version!). It kind of worked with that (90% of the time), but was still glitchy. Still even for that there was a fine line of component values (see the cirsuits below; the resistors and capacitors after the diodes to create the clock pulse). A clock transistion that came through too fast, would mean the buttons hadn't settled from bouncing. A "slowed" pulse would glitch the result on the CP transition back to GND.

A little bit more successful is a circuit with a 74HCT573 (that's an 8-times latch like the 373, just with different pinout). That's the circuit which is currently on the breadboard (schematic also below). The circuit is very similar to the D-flip-flop version, just needed to make sure the latch's "load" pin is "held" shorter than the button itself. I'd say it works as expected on 99% of button pushes (short button pushes creating most of the problems of those). Still fiddling with component values is needed.


What did I learn from all of this: use a microcontroller ;) . If this wasn't for fun, I wouldn't even have started with logic gates. Also considering how many additional components (resistors, diodes, capacitors, transistors) are necessary to make it work, it's not worth it for anything else but fun. As for the box of old logic ICs: maybe I should shred them and check if some had gold bond wires? ;)
 
The following users thanked this post: Lazyboy

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
If you have a CMOS '4028 or similar 4 to 10 line decoder then this circuit is pretty minimal, no additional debounce circuit required.
Small series RC network on required input will give fixed power up selection.
Jim
 
The following users thanked this post: Ian.M

Offline Lupin III.Topic starter

  • Contributor
  • Posts: 35
If you have a CMOS '4028 or similar 4 to 10 line decoder then this circuit is pretty minimal, no additional debounce circuit required.

Oh, that's a nice one! A bit of a head scratcher at first, but after realizing that the signals just have to take a second "round" actually quite clever. I was looking for some kind of flip-flop before the first replies came in to this thread, because I thought I'd definitely need something like that. But I would never have thought of using an 4028 in this way. I might even have some of those lying around. Although it does not look easy to expand if more than 4 buttons would be needed, except for turning it into another grave for additional "logic" diodes.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5869
  • Country: de
@jimmc:
Very nice one.  :-+

 

Online thm_w

  • Super Contributor
  • ***
  • Posts: 6352
  • Country: ca
  • Non-expert
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: gb
Here is a circuit I designed years ago. I have not actually built it to test its function but hope it would suit your needs. If you want "faster" response, you can use a clock source of higher frequency, like the rectified DC(100Hz or 120Hz) or build a simple astable oscillator using CMOS gates.

The circuit works as follow: clock pulses is continuously provided to the CD4017 counter but its /CE pin is held high with no push button activated by user. So the CD4017 will sit idle on a certain output Qn(n=0~9), which is at a high logic state. When a push button other than the Qn pin is depressed, the "low" output of the CD4017 Qx pin will pull the /CE low via the 33K resistor and counting of the CD4017 is enabled. The counting will eventually reach the Qx pin and the Qx pin goes high. This will stop the counting via the 1N4148 diode which force the /CE pin high again. When user released the push button, the /CE pin remains high so the current selection "sticks".

If more than one push button are pressed, e.g. Qx and Qy, then the counting will stop at the Qx or Qy stage, but might jump to the other stage if one is released piror to the other. However, there will never be a case that more than one output is activated at all time.

edit: there should be a push button from the Q1 pin
« Last Edit: December 04, 2021, 07:05:21 am by eblc1388 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf