# 1 AIO for 3 buttons ( need to know combinatoin key )

• posted

Hi All,

I have only 1 AIO, and I have to control 3 buttons. I need to know the combination pressing event.

Could you please adviec do I need what external ciruit ? or just resistor is enough?

BR/ Boki.

• posted

Resistor-encoded switches are a very common means of doing this job. Make sure you have sufficient gap between the voltages, and allow a small band for error detection as well.

You can run the switches in series (with parallel resistors) or in parallel (with series resistors), or in parallel so the resistors can be shorted. Either way works. Serial connection allows you to read combinations of switches easily, while parallel connection gives you an easy way of prioritising the switches, particularly if you wire them so that the higher priority ones completely mask out the lower priority ones. This also makes the calculations easier.

Regards,

Geoff

```--
Geoff Field
Professional Geek,```
• posted

• posted

Thnak you so much!

BR/ Boki.

• posted

Assuming AIO means analog input, the simplest method would be a R/2R network. After calibration the binary voltage read will be a complete description of the state of all the switches. This is only limited by the precision of the resistors and the resolution of the A/D converter. If the reference voltages at the encoder and decoder are the same (another wire) then the calibration is obviated. The switches would need to be SPDT. 1% resistors will normally suffice for 6 or 7 switches (bits).

+----- R -----+----- R -----+------ R -----+-------> A/D | 2R | o more 2R and switches in here / which I won't even try to draw. o o Terminate network ends in 2R | | gnd | +-----------+------------+---------------+------< VREF

Each node ('+' in top line) sees 2R impedance looking each way, in parallel with an injection impedence of 2R. So injected voltage is attenuated by two for each stage in the ladder. You can buy these networks already nicely matched.

```--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on ```
• posted

Now if you really want to do my homework for me, show me a circuit that only requires SPST switches. Just kidding about the homework...

• posted

Replace the switch with a complementary CMOS pair, to switch between VREF and GND. Use a resistor pair in series from Vcc to the gate, and a SPST to gnd at the resistor junction. Piece-a-cake. Now you need to make sure that the value of R allows for the gate impedances.

You can also invert the whole thing and inject currents, feeding the output to a virtual ground at an op-amp input. Then the input switches only need to shunt off the input current. Don't the schools teach anything about A-D-A conversion these days?

```--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on ```
• posted

It is R2R circuit, right? : )

Thanks!

Boki.

CBFalc> > snipped-for-privacy@ms21.h> >>

• posted

Or use a current source that feeds R, 2R and 4R with SPST's in series, measure the voltage across.

Meindert

• posted

R2R sounds like a good idea, but if you are interfacing to a keypad, R2R is not the best idea. R2R gives each switch (which must be SPDT, not typical in push button keypads) a binary weight. This means you get large separation between some buttons and very small separation between others. I think you would do better for a keypad with separate resistors on each one of values, R, 2R, 3R... But if the buttons are not mutually exclusive, then R2R makes sense.

snipped-for-privacy@ms21.h> It is R2R circuit, right? : )

• posted

I'll have to talk to the guy designing the keypad to let him know the snap dome switches must be replaced with complementary CMOS pairs. I don't think he is going to like that idea...

Current injectors! Yes, I am sure the keyboard designer would prefer that approach! Where can I point him to find snap domes with built in current injectors?

• posted

And why do you think it is ok to hand current drivers on the switches or to require double throw switches? I would like to use this to encode multiple switches on a single analog input. But I can't require the use of double throw switches or use anything as complex as current sources. It is very simple to use several different values of resistance with a simple SPST switch completing the circuit to ground. A single pullup resistor should allow encoding of 4 or 5 switches onto a single input with plenty of margin.

I am looking at using an inexpensive processor for a remote unit with display and keypad plus a couple of rotary switches. Using a dozen resistors I can encode as many switches and push buttons on two or three ADC inputs and save all those digital inputs.

• posted

On 03/03/2006 the venerable rickman etched in runes:

. . .

Since you seem to know all the answers already, why are you asking the question in the first place?

```--
John B```
• posted

For an example of parallel connection, see the following link, problems 7 and 8.

-- Dave Tweed

• posted

question in the first place?

I thought I might give you a chance to inform us of your ideas on the subject.

• posted

That is a different problem. You can do this nicely by feeding the common junction into a virtual ground, involving one op-amp. But you now need a range of R values, as R, 2R, 4R, 8R, etc. The practical limit is probably around 10 switches, for a range of about 1000:1 in resistor value. The low value will need to be better than 0.1% matched for this range. Beware contact potentials on the switches, and contact resistance. If the lowest current switched is 10 microamps, then the largest (for this range) will be about 10 milliamps.

The point is to suit the technique to the job.

BTW, the virtual ground lets you calibrate the system by adjusting that virtual ground to a potential slightly off real ground. That moves both the zero and the slope.

```--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on ```
• posted

... snip ...

He apparently doesn't and he didn't. He just came in later complaining that a solution for the OP didn't fit his particular requirements.

```--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on ```
• posted

Thanks for the suggestion, but adding an op-amp is almost as expensive as adding an I/O expander chip. I can easily put 5 resistors in series with a switch in parallel with each one. Then I can tie the common point to a pull up and measure the voltage. I did a quick spread sheet calculation for a 5 switch circuit and I get 8% change at the worse case if I use resistors of 1, 2, 4, 8, 16 at the switches and 32 for the pullup. I am pretty sure using a pull up equal to the series combination gives me the best resolution.

I did a couple of calculations and it seems that this resistor scheme costs me two bits of significance at 5, 6 and 7 switches. So to encode

7 switches I would need 9 bits of resolution (and accuracy) in the ADC. That is cutting it a bit close, but I feel very comfortable with 5 switches needing 7 bits when I have a 10 bit converter. In reality, the grouping of switches would indicate that I use 4 each on two inputs and 3 each on two others. I could push it and put 4 on one and 5 each on two, but there are a couple of rotary switches that are 4 and 3 each. It would make sense to keep each of these separate to keep the software cleaner.

So 14 switches and 4 analog inputs, sounds ok to me. Not sure if it is needed. The software is a bit bloated and we need to go to a 64 kB part which will likely have enough discrete I/O for these switches. Ah, the advantages of high level languages.

• posted

... snip ...

If you have rotary switches they can only be in one position at a time. All you do is let the rotor select a point on a voltage divider chain, with all Rs equal. 10 or 16 position switches should be no sweat. Just make sure the A/D input Z is high compared to the divider chain. Once more, suit the solution to the problem.

```--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on ```
• posted

That would be a 16 way switch with 16 outputs. These are binary encoded so that there are 3 outputs for 8 positions and 4 outputs for

16 positions. So weighting the switches is the best approach. Using an op-amp to sum weights linearly is good, but requires extra parts. Using the resistors in parallel just requries that you have two extra bits of resolution (and accuracy) in your ADC.

Yes, but first you have to understand the problem. ;-)

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.