Shop OBEX P1 Docs P2 Docs Learn Events
IC Question - 40 switches — Parallax Forums

IC Question - 40 switches

ArchiverArchiver Posts: 46,084
edited 2000-09-05 09:21 in General Discussion
40 switches is a lot of input, but it can be done. One way is to
just use a lot of input lines, another is to use an ADC. Here's 40
switches both of these ways. I did it this was as if your new to
stampes it only requires one section of code and a for-next loop in
addtion to getting the pin values.

There may multiple ways to get multiple switches to be seen by the
Stamp. First, defining the preocess as either like a game show with
40 contestants, or as an alarm system with one horn.(all switches do
one thing and couild be wired in parellel on one pin)

The first scenario would require 40 individual circuits, the second,
only one circuit.

Assuming 40 separate switches, you can put 3 loops on one pin with
each switch having a resistor in parallel. One resistor is 1K, one is
2K and the third is 3K

Capacitor
|
||
5 V
|
| 3K switch
| /
/\/\
0__0----\
| / 2K \
| --<
/\/\
0__0
\________gnd
\ / |
\ 1K / |
\----/\/\
0___0---/ --/\/\-- to stamp
220

sw-1 sw-2 sw-3
sw-1 1K 666 545
sw-2 666 2K 1.2K
sw-3 545 1.2K 3K


Rctime will let you know the value of the loop.
Check page 298 for more on RCTIME.

I'll let you do the math to calculate the capacitor.
use 10K 20K adn 30K if you want, it keeps the ratio the same.

You can figure the resistance for individual switches, and multiples
by simple math. The problem is that you get pretty small differences
once you try to get more than three separate resistor/switches.
545 is 18% of 3K and 666 is 22% so they are close together already.

Also, if you have some master switches that override some of the
others, you can go direct with one (or more) switches per circuit.

If all you are doing is putting in switches, then this would all fit
on one BS2 by using 13 pins. If you need more inputs and outputs you
still have some options.

With this circut you can triple the pin count of switches per line,
then if you feed this to an ADC your switch count can go through the
roof. Even an 8 bit ADC will see the differences here, and a 4 point
ADC will yield 12 separate switch inputs, plus a possible 4
additional if you can have one master per line.

If you use an 11 point ADC you get 33 switches and use three pins for
the serial input. But as with the serial ADC input, you sacrifice
speed. That leaves you with 7 fast swiches directly to the stamp
pins.


This should handle your switch count, but this does not address
speed. You need to figure out if some are required to be
instantaneous (game show) or if serial input delay if OK (alarm).

Good Luck,

Dave



--- In basicstamps@egroups.com, mcmgamer@n... wrote:
> Does anyone know the best way to expand the I/O ports of a
basic
> stamp IIsx. I am starting a project which will require about 40
> different on/off buttons. I found an I/O expander that would work
> but it costs $14 for each IC. The way it worked was that it
accepted
> up to eight different (1 or 0) inputs and combined them into one 8
> bit binary number which was then sent to one of the stamps inputs.
> Since I would have to buy about 5 or 6 of these IC, it would
be
> very expensive. Does anyone know of any cheaper ICs that work
> similarly? Or, Does anyone have any better suggestions?
>
> P.S. - I am new to microcontrollers. Please keep this in mind when
> responding.
>
> THANK YOU!!!
Sign In or Register to comment.