3-way input selector using CMOS gates

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

BradM

Well-known member
Joined
Apr 14, 2006
Messages
113
Location
Palo Alto, CA
Hi all,

I'm trying to create an input selector switch for 3 input sources.  I'd like to have three momentary pushbutton switches control some logic circuitry that allows me to actuate relays that switch between A, B, and C.  For instance, when the unit is powered on it defaults to input A.  Then if I press C it turns off A and B and turns on C.  If I then press B it should turn off A and C and turn turn on B.  If I were to press B again, it should do nothing.  And so on.

If it was simply two inputs I could easily implement a flip flop circuit using a NAND gate that would do the trick nicely.  I thought I could use a 3-input NAND gate to do what I wanted, but when built the circuit, I could only get it to switch between any two inputs, while the third input source would always stay high. 

Does anyone have any insight how to make this kind of thing work using 4000 series or similar logic gates?

thanks,
Brad
 
Hi Brad,
I use the attached circuit to switch 6 sources. You may adjust it for 3 sources simply by leaving out the 3 extra switches. If you need one particular source to switch on by default at power-up, you should connect 1 cap across that switch. The value of the cap will need to be determined experimentally but IME 1uF/63V MKT should do the job.

Regards,
Milan
selector_multi.jpg
 
Hey this is a great circuit.  I searched and try to devise my own thing for years (in my limited CMOS/logic knowledge).  Thanks for posting this.

CC
 
This is fantastic!  Thanks, Milan.  I'll give this a shot.  Just to confirm--this circuit only allows you to have one input active at a time right?

Anyone else have any other techniques?

Brad
 
Hi guys!

Well, this isn't a bullet proof solution I'm afraid.
If you push only one switch at a time, only its output will engage while other outputs will be off. No problems here.
However, if you push two or more switches simultaneosly (say, by accident), all their outputs will turn on.
If you then push a single switch, all the outputs that were simultaneously on will turn off and only this single output will be on.
A bullet proof solution (one that would allow only 1 switch at a time to be on, regardless of how many were actually pushed by accident or not) would require a more complex circuitry, including for instance D-flops with external
R and S control inputs (CMOS4013 for example). I believe I may have such a circuit stored somewere on my hard drive. If I find it, I'll post it here.

Regards,
Milan

 
 
moamps said:
However, if you push two or more switches simultaneosly (say, by accident), all their outputs will turn on.

Only if the first contact bounce of the switches all happen within a few hundred ns. With electromechanical switches that is extremely unlikely, even if you were to glue the switches together. Odds are that only one of the outputs (hard to predict which) will go active.

The only way the schematic as drawn will routinely get multi-outputs is if there's a lot of hidden capacitance on the clock line (or you use diodes much slower than a 1N4148).

JD 'microcontroller' B.
 
Hi JD,

As a person who has built this circuit many times, I'm speaking from experience - the switches can be and were pushed simultaneously (no glue involved). What I wrote earlier is exactly what happened to me at one time or another. That is why I said the solution is not bullet-proof.

I haven't as yet been able to find the "bullet-proof" circuit I mentioned, so please feel free to jump in with your solution.

Regards,
Milan
 
moamps said:
As a person who has built this circuit many times, I'm speaking from experience - the switches can be and were pushed simultaneously (no glue involved). What I wrote earlier is exactly what happened to me at one time or another. That is why I said the solution is not bullet-proof.

With the circuit exactly as drawn? I have experience with similar circuits, and like I said if you're getting occasional multi-hits I'd be looking for (cable?) capacitance on the clock node.

moamps said:
I haven't as yet been able to find the "bullet-proof" circuit I mentioned, so please feel free to jump in with your solution.

For one and only one output active at any time? As I hinted, these days I'd pick a $1 microcontroller or CPLD.

If you're allergic to programming stuff I don't see a simple one-chip solution. A multi-chip approach could have the buttons tied to a priority encoder (74HC148). The outputs of the '148 go into a transparent latch (74HC373); drive the latch enable of the '373 with the GS output of the '148, as this signal is only active when at least one button is pushed. The outputs of the latch go to a 3-to-8 decoder like the 74HC138. All these should be easily available in DIP packages; I'm sure that 4000-series CMOS equivalents exist too. Note that I might have glossed over drive polarities or setup/hold times; just painting the general picture here.

Mind you, for multi-press events the last button to be released will stick, even though the output may initially reflect a different button if it had a higher priority. You can replace the latch with an edge-triggered register, but then you just get whatever button bounces first. Hard to get around all that without resorting to a microcontroller.

JDB.
[if you only need three lines, you can leave out the 3-to-8 decoder and just use inputs 3/5/6 (positive logic) or 1/2/4 (negative logic) of the priority encoder]
 
In binary there is one, two, and "many".

This is a case where two is easy and three gets very hard.

I've putzed with such schemes; you should own Don's TTL Cookbook and CMOS Cookbook.

But in this 21st century, if I were fussy, I'd go all the way to a CPU. BASIC Stamp is easy to manage.

Look how your PC keyboard works. There's no "simultaneous", the keys are scanned in a sequence. Debouncing may be handled by requiring a key to be "down" for 2-3 scans before being valid. Multiple key-downs are recognized in scan-order, and may be FIFO-ed if you want to know all key-downs without regard for overlap (rapid typing). Many keyboard frills are pointless in your application, but with a CPU you have the power to logic-out your response, enforce a 1-of-3 output, power-up to a certain state, etc.

The cheapest BASIC Stamp can (I think) manage 3 pushbuttons and 3 relays. Drive relays with a 5K to a TIP120.

JDB will tell you to use a PIC or a LART. Very true if you want to make more than one.
 
Guys,

Brad specifically asked " Does anyone have any insight how to make this kind of thing work using 4000 series or similar logic gates?".  Naturally, I was under the impression that we were supposed to stay within the boundaries of limited CMOS/logic knowledge for him to be able to use our solutions. Of course there are modern (21st century) answers to the problem, involving microprocessors and programming, but that's not what Brad asked for, or is it?

Later,
Milan

 
moamps said:
Brad specifically asked " Does anyone have any insight how to make this kind of thing work using 4000 series or similar logic gates?".

Errr.... did I not do exactly that in my previous post?

jdbakker said:
If you're allergic to programming stuff I don't see a simple one-chip solution. A multi-chip approach could have the buttons tied to a priority encoder (74HC148). The outputs of the '148 go into a transparent latch (74HC373); drive the latch enable of the '373 with the GS output of the '148, as this signal is only active when at least one button is pushed. The outputs of the latch go to a 3-to-8 decoder like the 74HC138. All these should be easily available in DIP packages; I'm sure that 4000-series CMOS equivalents exist too. Note that I might have glossed over drive polarities or setup/hold times; just painting the general picture here.

[if you only need three lines, you can leave out the 3-to-8 decoder and just use inputs 3/5/6 (positive logic) or 1/2/4 (negative logic) of the priority encoder]

JD 'no need to shout' B.
 
jdbakker said:
Errr.... did I not do exactly that in my previous post?

I believe you'd be even more exact by posting a workable (if not tried and tested) schematic. ;)

Later,
not-shouting Milan
 
moamps said:
I believe you'd be even more exact by posting a workable (if not tried and tested) schematic. ;)

Sure, and I suspect a PCB layout would be even better.

I believe I've given enough information that, with the parts' datasheets, any interested party can draw up their own schematic. I'll be happy to give feedback on any such schematic, and willing to answer specific questions if there are any holes in my description that I didn't think of.

JD 'too much like work, but without the pay' B.
[plus any schematic that I can't easily draw in LTSpice needs to come off my not-networked CAD machine, by way of screen capture, Photoshop and USB stick. Five minutes drawing time, half an hour of post-processing]
 
jdbakker said:
JD 'too much like work, but without the pay' B.

Sorry you feel that way.  :-[

OK then, I'll see if I can dig up the schematic I was talking about earlier.
If not, I'll try to re-draw it from memory (and test it if necessary).

Back to work with no pay,
Milan  ;D
 
JD gave my favorite answer on a platter.  Sorry it wasn't Vermeil! 
If you download the datasheets on the chips mentioned the schematic is silly simple.  The datasheets even have example transistor drivers for relays and lights.  A simple search on google yields the 4000 series equivalents. 
I call that circuit mux/demux going back to the dreaded EE101.  I like the addition of the latch.
Mike
 
OK, here we go...

Sadly, I couldn't find the schematic I was referring to earlier. However, in the meantime I have managed to come up with something even cleverer. ;D

The schematic below is custom-designed (by yours truly  :-*) for this purpose and should be self-evident as it is very simple. Parts are easily available, no programming required.

It is bullet proof in a sense that only 1 input can be switched on at a time, no accidents allowed.  ;)

Regards,
Milan

switch%201-3.JPG


 
forgive the promotion, but this could be done with one of digital controller boards and a few of the relay cards over at expat audio.
(http://www.expataudio.com)

It's a small tweak in software I'd be happy to make for you.

If I've understood correctly, what you want is for each button to switch on, and switch off the other two? (and for those to control some relays?)

let me know if that sounds about right.

Cheers

/R

 
Wow, a lot has happened since I last looked at the thread.  I really appreciate all the input, guys.  I'm very new to logic circuits so some of this discussion is beyond my comprehension.  But hey, that's how we learn right?  I'm definitely going to have to pick up a copy of the CMOS Cookbook now. ;)

I built Milan's first circuit last night with resistors and LED's hanging off the outputs.  I must admit it was a little tweaky.  The outputs didn't want to latch.  There appeared to be either some stability or bouncing issues.  I tried a number of things involving RC debouncing circuits, but wasn't getting consistent results.  I wasn't actually using switches but was just using pieces of wire to short to V+, so maybe I wasn't accurately simulating the behavior of the switch. 

I'm going to have to try the new circuit Milan proposed.

thanks,
Brad
 
Hi Brad!

As regards the 1st circuit: I don't think the wire was the probem. Are you sure you connected the RESET pin to the power pin (+5 to 15V)?

Regards,
Milan
 
Yeah I did connect the reset pin to the power pin.  I emailed you, by the way.

Maybe I can make a little video showing how it was performing.

Brad
 
Back
Top