|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
|
Doubling Up On Inputs Part 2 A while ago, I had written an article on how to double up on inputs (see Doubling
Up On Inputs). The article mentions that you can use an A/D-capable pin
for several inputs. Wouldn't you know it, I soon had a design that was doing
just that. It was using one pin to determine the button states of a small keypad.
Here is a similar circuit.
The circuit doesn't work that badly for battery-powered low-noise environments.
If you are looking for something a little more robust, you might want to add
a capacitor to smooth things out. If you do, make sure that your key read routine
allows for the time constant that will be present when the buttons change states.
Considerable time was spent trying to figure out what resistor values to use
for each button. I (like most people, I suppose) spent way too much time with
a meter and a piece of scratch paper, punching away on my HP calculator before
using the marvelous invention in front of me (a "computer" for those reading
this on their cell phones) and a spreadsheet program. Click
here to see the table I came up with.
Remember that you will get a range of values for each button based on resistor
tolerance, so I included high and low (worst case) scenarios for each button.
Overlapping button ranges by the slightest leaves a chance for operation error.
I would recommend a safety zone of as much as possible.
The hard thing to foresee easily is to have multiple buttons pressed. In your application this may not be critical, but it could easily cause undesired operation. A spreadsheet might be a confusing way to show the likelihood of potential problems. A worded description in this article could likewise be confusing. The best tool that I felt that I could provide for you is a small program (Installation files are 2.7MB) that will do the number crunching for us.
It will provide the same information as the worksheet, and even has the schematic
above embedded in the program for reference. To the left of each resistor value,
there is a check box that will allow you to depress one or more buttons and
see the resulting range of possible values for the tolerance that you have specified.
A message box will pop up if you have overlapped any press of one button with
the combination of buttons that you have selected.
I have written the program in Visual Basic, so you will need to have the necessary
files on your computer to run programs created in Visual Basic. Note:
There is no tech support for this program.
I hope that the tools that I have provided might make the path of many buttons
into one pin a little smoother for you. A little trial and error on resistor
values, and you should be able to distinguish any combination of buttons that
are held down at a particular moment. That will leave you with the same flexibility
that you would have if you dedicated a pin to each button. Remember, a pin saved
is a pin earned.
|
|||||||||||||||||||||||||||||||||
|
Copyright © 2003 ChipCenter-QuestLink About ChipCenter-Questlink |
||||||||||||||||||||||||||||||||||