Electronically Interlocking Radio Buttons (*improved!*)

Introduction: Electronically Interlocking Radio Buttons (*improved!*)

About: The nickname is because I couldn't spell "Frobscottle". Loving getting back into electronics as a hobby after a break of many years. Now I work as an EPOS engineer, so I spend my days fixing tills in…

The term "radio buttons" comes from the design of old car radios, where there would be a number of push buttons pre-tuned to different channels, and mechanically interlocked so that only one can be pushed in at a time.

I wanted to find a way of making radio buttons without having to buy some actual interlocking switches, because I want to be able to select alternative preset values in another project which already has a rotary switch, so I wanted a different style to avoid mistakes.

Tactile switches are plentiful and cheap, and I have a load dismantled from various things, so they seemed the natural choice to use. A hex D-type flip flop, the 74HC174, performs the interlock function nicely with the help of some diodes. Possibly some other chip could do a better job but the '174 is very cheap, and the diodes were free (board pulls)

Some resistors are also needed, and capacitors to de-bounce the switches (in the first version) and provide power-on-reset. I have since found that by increasing the clock delay capacitor, the switch debounce capacitors are not needed.

The simulation "interlock.circ" runs in Logisim, which you can download here: http://www.cburch.com/logisim/ (Sadly no longer under development).

I have produced 2 improved versions of the circuit, in the first, just the debounce capacitors are removed. In the second, a transistor is added to enable one of the buttons to be activated at switch on time, giving a default setting.

Supplies

  • 1x 74HC174
  • 6x tactile switches or other type of momentary switch
  • 7x 10k resistors. These can be SIL or DIL packaged with a common terminal. I used 2 packages containing 4 resistors each.
  • 6x 100n capacitors - exact value is not important.
  • 1x 47k resistor
  • 1x 100n capacitor, minimum value. Use anything up to 1u.
  • Output devices, eg small mosfets, or LEDs
  • Materials for assembling circuit

Step 1: Construction

Assemble using your preferred method. I used double sided perforated board. It would be easier to do with a through hole DIL packaged chip, but I often get SOIC devices because they're usually much cheaper.

So with a DIL device, you don't have to do anything special, just plug it in and wire it up.

For an SOIC, you need to do a little trick. Bend alternate legs up a little so they don't touch the board. The remaining pins will be at the correct spacing to match the pads on the board. Here's a guide to how I bent mine (UP means bent up, DOWN means leave alone)

  • UP: 1, 3, 5, 7, 10, 12, 14, 16
  • DOWN: 2, 4, 6, 8, 9, 11, 13, 15

This way 4 of the diodes can be connected to pads and only 2 need to be connected to raised legs. Part of me suspects this would be better the other way around, however.

Lay the diodes out to either side of the chip and solder them in place.

Fit the pull-down resistors for each of the D inputs. I used 2 SIL packs of 4 resistors each,

Fit the pull-down resistor for the clock input. If using SIL packages, connect one of the spare resistors instead of a separate one

Fit the switches next to the resistors.

Fit the de-bouncing capacitors for the switches as close to them as will fit.

Fit your output devices. I used LEDs for testing and demonstration, but you could fit some other device of your choosing to get multiple poles on each output, for example.

  • If you fit LEDs they only need 1 current limiting resistor in the common connection, as only 1 LED is lit at a time!
  • If you use MOSFETs or other devices, pay attention to the orientation of the device. Unlike a real switch, the signal still has a relationship to the 0v connection of this circuit so the output transistor must be referenced to it.

Wire everything together according to the schematic. I used 0.1mm magnet wire for this, you may prefer something a bit less fine.

Step 2: How It Works

I've provided 4 versions of the schematic: the original with switch debouncing capacitors, with and without output mosfets, and a further two versions where the clock delay capacitor has been increased, so that debouncing the switches has become unnecessary, finally with the addition of a transistor which will virtually "press" one of the buttons when the power is turned on.

The circuit uses simple D type flip-flops with a common clock, conveniently you get 6 of these in the 74HC174 chip.

The clock and each of the D inputs of the chip is pulled to ground via a resistor, so the default input is always 0. The diodes are connected as a "wired OR" circuit. You could use a 6 input OR gate, then you wouldn't need the pull down on the clock input, but where's the fun in that?

When the circuit is first switched on, the CLR pin is pulled low via a capacitor to reset the chip. When the capacitor charges, the reset is disabled. I chose 47k and 100nF to give a time constant approximately 5x that of the combined debounce caps and pull down resistors used for the switches.

When you press a button, it puts a logic 1 on the D input it's connected to and via a diode triggers the clock at the same time. This "clocks in" the 1, making the Q output go high.

When the button is released, the logic 1 is stored in the flip-flop, so the Q output remains high.

When you press a different button, the same effect takes place on the flip-flop it is connected to, but because the clocks are commoned, the one which has a 1 on it's output already now clocks in a 0, so it's Q output goes low.

Because the switches suffer from contact bounce, when you press and release one you don't get a neat 0 then 1 then 0, you get a stream of random 1's and 0's, making the circuit unpredictable. You can find a decent switch debouncing circuit here: http://www.labbookpages.co.uk/electronics/debounce.html

I eventually found that with a sufficiently large clock delay capacitor, debouncing individual switches is un-necessary.

The Q output of any flip-flop goes high when it's button is pressed, and the not-Q output goes low. You can use this to control a N or P MOSFET, referenced to the low or high power rail, respectively. With the load connected to the drain of any transistor, it's source would typically be connected to 0v or the power rail, depending on polarity, however it will act as a switch referenced to some other point, as long as it still has headroom to turn on and off.

The final schematic shows a PNP transistor which is connected to one of the D inputs. The idea is that when power is applied, the capacitor at the base of the transistor charges until it reaches the point where the transistor conducts. Because there is no feedback, the collector of the transistor changes state very quickly, generating a pulse which can set the D input high and trigger the clock. Because it is connected to the circuit via a capacitor, the D input returns to it's low state and is not noticeably affected in normal operation.

Step 3: Pros and Cons

After I built this circuit I wondered if it was worthwhile doing. The objective was to get radio button like functionality without the expense of the switches and mounting frame, however once the pull-down resistors and de-bouncing capacitors were added in, I found it a bit more complex than I would have liked.

Real interlocking switches don't forget which switch was pressed when the power is turned off, but with this circuit it will always return to it's default setting of "none", or a permanent default.

A simpler way to do the same thing would be to use a microcontroller, and I don't doubt someone is going to point this out in the comments.

The problem with using a micro is, you have to program it. Also you have to either have enough pins for all the inputs and outputs you need, or have a decoder to create them, which instantly adds another chip.

All the parts for this circuit are very cheap or free. A bank of 6 interlocking switches on eBay costs (at the time of writing) £3.77. Ok so that's not much, but my 74HC174 cost 9 pence and I already had all the other parts, which are cheap or free anyway.

The minimum amount of contacts you normally get with a mechanical interlocking switch is DPDT, but you can easily get more. If you want more "contacts" with this circuit, you have to add more output devices, typically mosfets.

One big advantage compared to standard interlocking switches is that you can use any type of momentary switches, positioned anywhere you like, or even drive the inputs from entirely different signal.

If you add a mosfet transistor to each of the outputs of this circuit, you get an SPCO output, excepts it's not even really that good, because you can only connect it 1 way. Connect it the other way and you get a really low powered diode instead.

On the other hand, you can add a lot of mosfets to an output before it gets overloaded, so you can have an arbitrarily large number of poles. By using P and N type pairs, you can also create a bi-directional outputs, but this also adds complexity. You can also use the not-Q outputs of the flip-flops, which gives you an alternative action. So there is potentially a lot of flexibility with this circuit, if you don't mind the extra complexity.

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Space Contest

      Space Contest
    • Organization Contest

      Organization Contest

    9 Comments

    0
    throbscottle
    throbscottle

    8 months ago

    Well, I can't fault your PCB design :) Don't worry about it being long and thin, I was making worst-case assumptions. If you have a ground plane that's really good, if you have a power plane that's fantastic.
    I'm curious, did you build a prototype before ordering the PCB's? Please don't tell me you relied on the simulation for your final design!!!
    Check you haven't created any solder bridges when you built it. On my home-made boards it happens easily, I'm guessing your commercially made ones are more resistant to it, but check carefully anyway. Also check for manufacturing defects. You might have just been unlucky.
    Unfortunately though my best guess is now in the difference between the 74HC174 and the 40174, unless there's something extra connected in a way that affects it but you just can't see that it does (easy mistake, I do it all the time).
    Try the smaller R or smaller C or both in the clock delay, this might be all it needs. Try individual de-bounce caps on the switches. It might be that the type of switch you are using has some effect - extra-bouncy, perhaps? So you could try substituting a regular tactile switch for one of them and see what happens (just wire it in parallel). In fact I'd do that first to get a clue to what's going on. If the tactile switch works, you might need to give each footswitch it's own snubber network. The possible knock on effect could be that my simplistic design won't work like this - I really don't know. If that's the case you'll need a Schmidt trigger or a monostable.
    So apart from these ideas, your simplest solution might be to try the HC174 and regulator, and put up with voltage level shifting - not too bad if your switch outputs are transistors anyway.
    Nice work.

    0
    richard.senior
    richard.senior

    Reply 8 months ago

    I can get 5 PCB's made up by a company in China, and shipped half way around the world to the UK for about 40 quid (assuming I save on postage by having several different PCB's made in the same order).
    This particular PCB excluding postage cost around 2 pounds a board.
    I find large complicated circuits difficult to breadboard. I make constant mistakes to the point where at the end of the process I don't even know if I got it right.
    Then when you design the PCB a whole new set of mistakes can creep in.
    If you just start from a working spice model, and have the board made, you know what to amend, and it saves hours and hours of hard work.
    I'm fundamentally lazy. When it comes down to it I'd rather throw 50 quid at something than spend a week stripping jumper wires and triple checking my work.

    When it comes to manufacturing defects, the boards get a flying probe test for free, so you know they'll be exactly as you designed them. So you've really only got yourself to blame if they don't work. The quality is just astounding for the price.
    I actually had this board quoted by a UK manufacturer who was going to charge me 200 pounds for 5 boards..
    I got 6 of these boards, plus six of another, including posting, tax and import duty for 60 pounds. the cost difference is gut-wrenching really.

    The worst case I've had so far is I got to revision 4 of one PCB.
    But that particular PCB was small and costing me about 50p each to have made.

    I think this one is more or less working with one possible bug in the implementation of the CD4051 audio switching system. What looks at the moment to be down to possibly requiring three pulldown resistors, but I don't know yet.

    Once again thank you for your help..
    If you're interested in seeing the finished thing working, I'll post a little video here for you.

    0
    throbscottle
    throbscottle

    Reply 8 months ago

    I love to make things from scratch, and I love to fix things - so when my builds go wrong I'm quite happy to spend hours and days fault finding. For me it's more about the tinkering and learning than getting a useful product at the end of it. I'm also quite proud of the PCB making setup I have now. Still under development. There's a an overly-complicated drill project coming along soon, in that dept. ("soon" means like, any year soon. I have about 5 other instructables in draft form...)

    Anyway I'm glad this has proved useful. I'm convinced the design can be improved, but I stopped modifying when I got something that does what I wanted...

    0
    richard.senior
    richard.senior

    Reply 8 months ago

    I bought a small CNC router/engraver last summer (look up CNC3018 pro). If you make your own pcb's, they are worthwhile. Especially for drilling.

    0
    richard.senior
    richard.senior

    8 months ago on Step 3

    I dearly hope you're still monitoring this page.
    I created an LTSpice model based on your ideas (attached).
    It all works well in LTSpice, but when I built this up the latch isn't happening.
    That is, it powers up in bypass (the cap on the clear pin of the 40174 works) but when
    pushing any of the buttons that flipflop only stays on while the button remains pressed.
    Pretty please, could you look at my diagram and spot my obvious mistake?

    cd40174.png
    0
    throbscottle
    throbscottle

    Reply 8 months ago

    Your problem seems like switch bounce, you are getting the same effect I had in the early stages of the experiment. Without seeing how you actually built it I can't offer much help. The schematic looks ok so there's a good chance the problem is due to construction. In particular check the 0v connections, create nice solid bus, or use a star connection here. Also make sure you've got a bulk capacitor (a few uF's) connected where the DC supply connects to the circuit, and a small decoupling cap connected across the IC supply pins. Connect the LED anodes so they draw power where it enters the circuit. Check the supply voltage isn't being significantly altered (like, a few volts) when you press a switch. A few 100mV change should be fine.

    However...

    I looked at the 40174 datasheet, what stood out to me is the maximum rise/fall time of 15uS for the clock pulse. By comparison, the 74HC174 doesn't specify this maximum time, so I guess it's more tolerant. Given that the 1k/100n clock-delay combination gives has a time constant of 100uS, this might be causing a problem inside the chip.

    So first of all, check all the connections very carefully. Check it with a continuity tester. Check for shorts, especially between IC pins. Also try reducing the clock-delay time constant by a factor of 10 - but you might have to introduce individual switch debounce capacitors if you do this. Another option is to replace the clock-delay RC with a monostable or insert a schmidt trigger - but this introduces a whole extra chip and/or other components, rather against the "simplicity and economy" design principle.

    Lastly, you could try to obtain a 74HC174 and use that instead.

    I'd be interested to know how it goes - good luck!

    0
    richard.senior
    richard.senior

    Reply 8 months ago

    Thank you for your reply.
    This is actually a project a few months into conception. I've actually designed and had made some PCB's (and populated one, see below)
    Your comments about keeping things close to the power supply entry points are rather worrying for me because one of my design compromises was to make the board long and thin (to keep down PCB cost, and provide foot room between the switches). I have used a ground and 9V plane and a big smoothing capacitor, but still.. things are spread out somewhat.

    I'm playing my cards a little close to my chest at the moment because this project, whilst not groundbreaking is relatively unique (as far as I can tell) and might make me a small amount of money in the long run (if I can get it working).
    However, if after checking the things you've mentioned (swapping the CD40174 for the 74HC version etc.) I still can't get it to work, and you're still willing to help, I'll share the files with you (including the LTSpice files etc.)

    Once again thank you, it is greatly appreciated.

    PS I've just realised there'll be a problem with the 174 vs 40174, which is that the 40174 can have a VCC of 9V, but 174 is rated 6V max. I'll test by using 5V but if that's the problem I'll need to introduce a 78L05 etc.

    UPDATE :
    I simply replaced the debounce capacitor (C4 in the diagram above) with a 50nF capacitor and the whole thing began to work. So I think you were right about the CD40174. But it works, and the debouncing is pretty flawless so far.
    The diodes in the above diagram that output to labels A,B,C are to create a BCD input for an analogue signal switching chip.. Which is currently working for two of the 5 inputs, so I have work to do on the analogue side now, but thank you so much I think the digital bit is working! I'm so pleased, it's snowing badly here and my fingers were starting to freeze!

    By way of thanks I've added another circuit below which allows you to choose between two outputs, using re-pressing of active buttons to deactivate them (ie, it requires no third reset button).

    IMG_20201223_155108.jpgezgif-1-60e42ae8c83f.gifblah.png
    0
    throbscottle
    throbscottle

    Reply 8 months ago

    Well done getting it to work. I'm glad you weren't tripped up by the mistake (now corrected) in my last comment!
    I feel I must re-iterate, the primary function of what you are calling the debouncing cap (C4 in your diagram) is to delay the clock signal slightly. De-bouncing is a fortunate bonus.
    I was going to suggest that if it starts to get more complicated, you'd be better off using a small microcontroller. It all comes down to total pin counts, when you include the pins of the passive components as well.
    But anyway, really nice to see it working - I didn't expect anyone to be interested in this, so getting your message was a nice surprise :)
    Thanks for the alternate circuit. Clever getting it to toggle as well.

    0
    richard.senior
    richard.senior

    Reply 8 months ago

    Yes the capacitor does delay allowing the input to be high when the clock pin is raised. I understand.
    This blog post of yours was actually far more useful than you might imagine.
    The art of 74xx digital design is not as well documented on the internet as you might think considering how long it's been around.
    And in fact, I was surprised even to find out that there were a lot of people on electronics stack exchange that didn't know what was meant by 'radio buttons'.
    Aside from the stuff I've added to the internet whilst researching this, I think this is one of maybe only three articles on digital radio button design.
    And of those, this is by far the best.
    What I like about your design is how efficient it is.