Attaching lots of switches to a Stamp2
In a message dated 10/26/00 8:32:22 PM Central Daylight Time,
richard@t... writes:
> I want to be able to hook a large number of on/off switches (say 32 or
> so) to my Stamp2, and I'd like to know of anyone knows of an IC that
> could help.
>
> I need to be able to tell what the state of any of the switches are,
> opened or closed, at any time. That is, a chip that just tells the
> Stamp when a single button has been "pressed" only won't do. It is
> quite likely that several switches will be closed at once, and the
> stamp needs to know about them all.
>
> I suppose I'm imagining that the chip would send serial notification to
> the Stamp. What I'm worried about, however, is that the stamp isn't
> going to be just sitting around waiting for incoming messages: it has
> lots of other things to do. As such, I'm worried that I may lose
> messages should one come when the stamp is doing other things. This is
> a time-critical application.
>
> It might work if there exists a chip that could be queried by the Stamp
> for its switches' states, though I don't want to waste the Stamp's time
> doing that if it can be helped. Or, even better, if the chip waited to
> send its messages until some sort of line went high (or something like
> that).
You can use four 74HC165 (parallel-in/serial-out) shift registers connected
in series. With three lines, you would be able to read all 32 switches --
with one SHIFTIN command, no less. Four bytes would be used to store the
state of your switches and through variable aliases, your code can be very
straightforward.
-- Jon Williams
-- Dallas, TX
richard@t... writes:
> I want to be able to hook a large number of on/off switches (say 32 or
> so) to my Stamp2, and I'd like to know of anyone knows of an IC that
> could help.
>
> I need to be able to tell what the state of any of the switches are,
> opened or closed, at any time. That is, a chip that just tells the
> Stamp when a single button has been "pressed" only won't do. It is
> quite likely that several switches will be closed at once, and the
> stamp needs to know about them all.
>
> I suppose I'm imagining that the chip would send serial notification to
> the Stamp. What I'm worried about, however, is that the stamp isn't
> going to be just sitting around waiting for incoming messages: it has
> lots of other things to do. As such, I'm worried that I may lose
> messages should one come when the stamp is doing other things. This is
> a time-critical application.
>
> It might work if there exists a chip that could be queried by the Stamp
> for its switches' states, though I don't want to waste the Stamp's time
> doing that if it can be helped. Or, even better, if the chip waited to
> send its messages until some sort of line went high (or something like
> that).
You can use four 74HC165 (parallel-in/serial-out) shift registers connected
in series. With three lines, you would be able to read all 32 switches --
with one SHIFTIN command, no less. Four bytes would be used to store the
state of your switches and through variable aliases, your code can be very
straightforward.
-- Jon Williams
-- Dallas, TX
Comments
> I need to be able to tell what the state of any of the switches are,
> opened or closed, at any time. That is, a chip that just tells the
> Stamp when a single button has been "pressed" only won't do. It is
> quite likely that several switches will be closed at once, and the
> stamp needs to know about them all.
You could probably use octal latching to multiplex 8x4 or therebouts. I
used a similar technique to create 64 output lines on a bs2. Your timing
issues go away with this methodology.
Sean T. Lamont, CTO / Chief NetNerd, Abstract Software, Inc. (ServNet)
Seattle - Bellingham - Vancouver - Portland - Everett - Tacoma - Bremerton
email: lamont@a... WWW: http://www.serv.net
"...There's no moral, it's just a lot of stuff that happens". - H. Simpson
I want to be able to hook a large number of on/off switches (say 32 or
so) to my Stamp2, and I'd like to know of anyone knows of an IC that
could help.
I need to be able to tell what the state of any of the switches are,
opened or closed, at any time. That is, a chip that just tells the
Stamp when a single button has been "pressed" only won't do. It is
quite likely that several switches will be closed at once, and the
stamp needs to know about them all.
I suppose I'm imagining that the chip would send serial notification to
the Stamp. What I'm worried about, however, is that the stamp isn't
going to be just sitting around waiting for incoming messages: it has
lots of other things to do. As such, I'm worried that I may lose
messages should one come when the stamp is doing other things. This is
a time-critical application.
It might work if there exists a chip that could be queried by the Stamp
for its switches' states, though I don't want to waste the Stamp's time
doing that if it can be helped. Or, even better, if the chip waited to
send its messages until some sort of line went high (or something like
that).
Any ideas or suggestions?
Thanks!
Richard
I'm making a control panel useful to animators creating stop-motion
animation. While in use, the panel remains connected to a computer to
control (and be controlled by) special video capture and playback
software.
The Stamp needs to send and recieve serial messages to and from the
host computer, control the state of about 50 LEDs and an 8-digit 7-
segment number display (I'm using two serially-connected MAX7219s for
this), many buttons and on/off switches, two rotary encoders, and (the
big one) I'd someday like to build a motion-control animation crane to
mount the camera on. That will require about 8 servos, and I'd like to
leave room for that (the Mini SSC II sounds good, but that's an issue
for the distant future). There is also a speaker and two slider pots
hooked up to the thing. This application is really going to push the
Stamp to the limit, I think. (If this is even going to be possible at
all.)
Anyway, I'm getting off the point here. The point is that I'd like to
be able to get the state of as many switches in as few Stamp lines as
possible. I don't know an exact count yet--I figure I'll just invent
reasons to add more switches as I write the software. When that
happens, I'd like to have lots of room to do so.
Jon Williams suggested I use four 74HC165 shift-registers connected in
series, and so far that's the idea I like best. It only uses three
lines, and can handle 32 switches. I can't afford to use 10 or 11
lines for this. My only concern is that the shift-register method may
be too slow. In particular, if the user spins a rotary encoder too
quickly the Stamp may miss signals from it......but I haven't got those
yet, so I'll deal with that as problems occur.
Anyway, there it is. Any further ideas or suggestions are welcome.
Thanks,
Richard
P.S. As you can all see, my philosophy to building hardware is to have
as many buttons, knobs, sliders, switches, beeps, blips, and little
blinking lights as possible.
>Richard, what exactly are you trying to do here?
>
>How may other tasks will the stamp be doing at the same time?
>
>A 6x6 matrix would give you 36 possible switch combinations using 12
>I/O lines, leaving 3 for other stuff. (BS2SX or BS2)
>
>A 6x5 matrix would give you 30 using 11lines
>A 6x4 matrix would give you 24 using 10 lines, etc.
>With multiplexing, you could even do better than that.
>
>Why so many switches?
>
>Doug