Switch Matrixs
Archiver
Posts: 46,084
I need help with a problem that I am sure the basic stamp can handle; mybrain just isn’t working today.
·
I am trying to make the basic stamp be able to read an electronicdartboard head.
I will describe this problem in a different fashion to keep it simple.
Image I want to set Pins 0 – 7 to output and set them to High.
Then I set Pins 8 – 15 to input.
·
Basically I want to be able to wire a button between any pin (0-7) andconnect it to any pin (8-15), when I push the button I want to be able todetect which two pins I connected.
I would initialize all the INS to 0.
Of course when an input pin goes high I know that is the input pin thebutton is connected to.
·
My questions are:
1. How would I detect which of the output pins the button/switch isconnected to?
2. Using +5V, is there a simple circuit design using resistors and capacitorsto eliminate noise and protect the stamp.
3. Referring to the real project (Dartboard), when the dart hits theboard it will click a button for a millisecond, do I need to store energy in acapacitor to make sure I get a reading when the dart hits.
·
Thanks a lot.
·
Wayne Fulcher
wayne@ddinet.com
·
·
I am trying to make the basic stamp be able to read an electronicdartboard head.
I will describe this problem in a different fashion to keep it simple.
Image I want to set Pins 0 – 7 to output and set them to High.
Then I set Pins 8 – 15 to input.
·
Basically I want to be able to wire a button between any pin (0-7) andconnect it to any pin (8-15), when I push the button I want to be able todetect which two pins I connected.
I would initialize all the INS to 0.
Of course when an input pin goes high I know that is the input pin thebutton is connected to.
·
My questions are:
1. How would I detect which of the output pins the button/switch isconnected to?
2. Using +5V, is there a simple circuit design using resistors and capacitorsto eliminate noise and protect the stamp.
3. Referring to the real project (Dartboard), when the dart hits theboard it will click a button for a millisecond, do I need to store energy in acapacitor to make sure I get a reading when the dart hits.
·
Thanks a lot.
·
Wayne Fulcher
wayne@ddinet.com
·
Comments
the Basic I/O as input, this circuit work very well
I've used it a lot of time.
--- Wayne Fulcher <wayne@d...> escribi
>Maybe you can use this desing but you will need all
>the Basic I/O as input, this circuit work very well
>I've used it a lot of time.
>
>Attachment Converted: "c:\internet\eudora\attach\Keyboard.bmp"
Alberto,
a lot of time (and money, to pay in europeaen countries) also to download
your long attached file. With 24 color BMP it seems to be the maximum if
possible length = 498.848 of that file. Compressed to one color gif -
formated it is 2.541 Bytes = 0.51 percent of length. We see the same
scheme ! Regards K. Zahnert
To: basicstamps@yahoogroups.com
Date: Thu, 28 Jun 2001 00:03:42
>>Attachment Converted: "c:\internet\eudora\attach\Keyboard.bmp"
>
>Alberto,
>a lot of time (and money, to pay in europeaen countries) also to download
>your long attached file. With 24 color BMP it seems to be the maximum if
Agreed!
It wasn't even in a format that everyone could read either. Believe it or
not, not everyone in the World uses a PC!
--
Regards,
Derryck Croker
What software did you use to draw your design?
Where can I purchase?
How much?
Thanks,
Wayne Fulcher
wayne@d...
I used a software that is call PROTEL you can find
information about it in www.protel.com, this software
is excellent and you can do electronic desing,
simulation and a lot of thing more.
The problem is that this software is very expensive.
Best Regards.
--- Wayne Fulcher <wayne@d...> escribi
>handle; my brain just isn't working today.
>I am trying to make the basic stamp be able to read an electronic
>dartboard head.
>I will describe this problem in a different fashion to keep it simple.
>Image I want to set Pins 0 - 7 to output and set them to High.
>Then I set Pins 8 - 15 to input.
>
>Basically I want to be able to wire a button between any pin (0-7)
>and connect it to any pin (8-15), when I push the button I want to
>be able to detect which two pins I connected.
>I would initialize all the INS to 0.
Hi Wayne,
There is no INS command on the BASIC Stamp II. You want DIRS:
DIRS=$ffff ' p0 to p15 are inputs
Each input rail p8 to p15 should have a pullup resistor of, say, 10kohms.
Will your matrix will have 64 switches in an 8x8 matrix, with the
"rows" connected to p8 to p15, and the "columns" connected to p0 to
p7. Something like this (4x4 matrix)?
O = open keyswitch
X = closed keyswitch
10kohm x4
O----O----O----O
;---/\/\--;
| | | | | |
O----X----O----O
;
/\/\--|
| | | | | | |
O----O----O----O
;
/\/\--|
| | | | | | | |
O----O----O----O----;
/\/\--|
| | | | | | | | |
P0 P1 P2 P3 P8 P9 P10 P11 +5
columns rows
The rows have pullup resistors and are always inputs to the Stamp.
The columns will not have pullup resistors, and will normally be
inputs to the stamp, except when the column is scanned, one column
pin at a time is made a low output.
>Of course when an input pin goes high I know that is the input pin
>the button is connected to.
>
>My questions are:
>1. How would I detect which of the output pins the button/switch is
>connected to?
You usually do this by scanning. You start with all of the columns
configured as inputs. Then you make p0, p1, p2, p3 etc. in turn a
low output, and at each step read in the value of p8-p15. If a
switch is closed in that column, it shows up as a low on the input.
If a switch is not closed, the pullup resistor assures that the input
level will be high.
' scans the columns
' one at a time is low output
' while the others are inputs
' displays the key state matrix in debug.
dirs=$ffff
outs=$0000
ix var nib
loop:
debug home
for ix=0 to 3
dirA=dcd ix ' 0001, 0010, 0100, 1000
debug bin4 inC,cr
next
goto loop
>2. Using +5V, is there a simple circuit design using resistors and
>capacitors to eliminate noise and protect the stamp.
Put a 220 ohm resistor in series with each of the stamp pins (before
it attaches to the above circuit). That will not affect the
operation of the circuit, but it will protect the pins if something
gets hooked up wrong. What kind of switches?
>3. Referring to the real project (Dartboard), when the dart hits the
>board it will click a button for a millisecond, do I need to store
>energy in a capacitor to make sure I get a reading when the dart
>hits.
If the switch is in fact going to be closed for such a narrow
interval, then yes, you will need to store energy in a capacitor or
in a latch. I think the capacitor technique would actually work
(although I haven't tried it in a matrix). Put capacitors in parallel
with the switches in the above circuit. The time constant (RC with
the pullup resistor) would have to be greater than one millisecond.
That is so that the capacitor will hold the charge for at least time
it takes in the program from column low to input read. The capacitor
will recharge through the pullup resistor. On the other hand, the
input column has to stay low long enough (several time constants) to
recharge the capacitor if it had been discharged. The program would
need some extra code. There would be a possibility that the switch
would close during the recharge interval, so the program would have
to account for that by repeatedly reading the input. There would
still be a small chance for missing an event.
>Thanks a lot.
>Wayne Fulcher
><mailto:wayne@d...>wayne@d...
--I hope that helps,
Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...
Okayyyy, that should be
dirs=$0000 ' to make all the pins inputs.
(Sorry, the PIC I was just working with has the opposite convention)
> ' scans the columns
> ' one at a time is low output
> ' while the others are inputs
> ' displays the key state matrix in debug.
> dirs=$ffff
make that dirs=$0000 for all inputs
> outs=$0000
> ix var nib
> loop:
> debug home
> for ix=0 to 3
> dirA=dcd ix ' 0001, 0010, 0100, 1000
> ' one pin at a time is output
>
> debug bin4 inC,cr ' show row
> next
> goto loop