Shop OBEX P1 Docs P2 Docs Learn Events
Switch Matrix on BS2 — Parallax Forums

Switch Matrix on BS2

ArchiverArchiver Posts: 46,084
edited 2001-09-06 01:32 in General Discussion
Hello,
I'm trying to read an 8x8 switch matrix by scanning (pulling cols low
one at a time and reading the rows). The problem is, the switch is
hit for such a short period of time, that by the time I scan the last
two cols, the rows are already reading low because the switch no
longer has contact.

Is there any way to extend the length of time on the contact, just
long enough to be able to scan the entire 8x8.

Thanks is advance, Dean

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-09-04 14:35
    Take a look at Scott Edwards' Stamp Application #22 (December 96) at

    www.nutsvolts.com/stmpindx.htm

    Regards,
    Marylou
    _________________________________


    --- In basicstamps@y..., dean1888@y... wrote:
    > Hello,
    > I'm trying to read an 8x8 switch matrix by scanning (pulling cols
    low
    > one at a time and reading the rows). The problem is, the switch is
    > hit for such a short period of time, that by the time I scan the
    last
    > two cols, the rows are already reading low because the switch no
    > longer has contact.
    >
    > Is there any way to extend the length of time on the contact, just
    > long enough to be able to scan the entire 8x8.
    >
    > Thanks is advance, Dean
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-04 16:48
    >Hello,
    >I'm trying to read an 8x8 switch matrix by scanning (pulling cols low
    >one at a time and reading the rows). The problem is, the switch is
    >hit for such a short period of time, that by the time I scan the last
    >two cols, the rows are already reading low because the switch no
    >longer has contact.
    >
    >Is there any way to extend the length of time on the contact, just
    >long enough to be able to scan the entire 8x8.
    >
    >Thanks is advance, Dean

    It should be possible to scan the 8x8 in less 10 milliseconds. Maybe
    your scanning code could be optimized? Are you scanning the keyboard
    using all 16 stamp pins for the 8x8?

    If your program has to go off and do a lot of other tasks between
    each scan, that is another matter. It is possible to set up a matrix
    keyboard with capacitors in parallel with the switches to "hold" the
    state like a dynamic memory.

    Another alternative would be an external keyboard scanning chip, such
    as the PAK?? that Al offers for sale.

    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-04 17:34
    --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > >Hello,
    > >I'm trying to read an 8x8 switch matrix by scanning (pulling cols
    low
    > >one at a time and reading the rows). The problem is, the switch is
    > >hit for such a short period of time, that by the time I scan the
    last
    > >two cols, the rows are already reading low because the switch no
    > >longer has contact.
    > >
    > >Is there any way to extend the length of time on the contact, just
    > >long enough to be able to scan the entire 8x8.
    > >
    > >Thanks is advance, Dean
    >
    > It should be possible to scan the 8x8 in less 10 milliseconds.
    Maybe
    > your scanning code could be optimized? Are you scanning the
    keyboard
    > using all 16 stamp pins for the 8x8?
    >
    > If your program has to go off and do a lot of other tasks between
    > each scan, that is another matter. It is possible to set up a
    matrix
    > keyboard with capacitors in parallel with the switches to "hold"
    the
    > state like a dynamic memory.
    >
    > Another alternative would be an external keyboard scanning chip,
    such
    > as the PAK?? that Al offers for sale.
    >
    > -- Tracy



    Tracy,
    I'm scanning a dartboard switch matrix which does not allow much
    time. I have to scan while the dart is hitting the board. My code is
    a simple for loop:
    For pin = 8 to 15
    low pin
    if (pins 0-7) are low goto disp
    next

    I don't have the code with me but that is about the same (minus
    correct variables). I had tried switching from a BS2 to a BS2sx which
    helped a little, but not enough. Also, when the dartboard is on the
    floor, it works fine, once hanging on the wall, it seems the dart
    hits for less time causing bad scans.

    Any ideas?

    Thanks, Dean
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-04 23:25
    > Another alternative would be an external keyboard scanning chip, such
    > as the PAK?? that Al offers for sale.
    >
    > -- Tracy
    >
    Hi all,

    The 74C922 and 74C923 (Fairchild Semiconductors) are 16-key and 20-key
    encoders. The 74C922 is expendable to 32 keys. This chip has a built-in
    debounce circuit, a latch for the last key code, plus a rollover logic on 2
    keys (that means, when you hit a key when the last one is not yet released).
    May be is it a solution... and a cheap one (the price in Belgium is 1 or 2
    $).

    Phil.
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-05 00:35
    Yes, a PAK-VI will read a PS/2 keyboard with little effort and has some
    buffering. With a wireless keyboard it is really fun to type and control a
    robot with no wires. You can order them direct or from Parallax.

    Regards,

    Al Williams
    AWC
    * Connect a PS/2 keyboard to your next Stamp project
    http://www.al-williams.com/awce/pak6.htm

    >
    Original Message
    > From: Philippe Derenne [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=CuEnTlMoyxueVETmULYR9M7fvOj0av_HS_5fjbYCkl0VE2tYulTcukefvyKMKJhqoleMj9AgGg]derennep@s...[/url
    > Sent: Tuesday, September 04, 2001 5:25 PM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] Switch Matrix on BS2
    >
    >
    > > Another alternative would be an external keyboard scanning chip, such
    > > as the PAK?? that Al offers for sale.
    > >
    > > -- Tracy
    > >
    > Hi all,
    >
    > The 74C922 and 74C923 (Fairchild Semiconductors) are 16-key and 20-key
    > encoders. The 74C922 is expendable to 32 keys. This chip has a built-in
    > debounce circuit, a latch for the last key code, plus a rollover
    > logic on 2
    > keys (that means, when you hit a key when the last one is not yet
    > released).
    > May be is it a solution... and a cheap one (the price in Belgium is 1 or 2
    > $).
    >
    > Phil.
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-05 05:52
    At 4:34 PM +0000 9/4/01, dean1888@y... wrote:
    >Tracy,
    >I'm scanning a dartboard switch matrix which does not allow much
    >time. I have to scan while the dart is hitting the board. My code is
    >a simple for loop:
    >For pin = 8 to 15
    > low pin
    > if (pins 0-7) are low goto disp
    >next
    >
    >I don't have the code with me but that is about the same (minus
    >correct variables). I had tried switching from a BS2 to a BS2sx which
    >helped a little, but not enough. Also, when the dartboard is on the
    >floor, it works fine, once hanging on the wall, it seems the dart
    >hits for less time causing bad scans.
    >
    >Any ideas?
    >
    >Thanks, Dean

    Hi Dean,

    Back in late June/early July there was another thread about a dart
    board started by Wayne Fulcher. It turned out I think that the dart
    board had a capture circuit attached to it, that he was able to read
    hits out successfully (?) using a SHIFTIN command. Maybe you have
    the same dart board??

    No? Oh well. One millisecond is too short a window for the Stamp,
    even with the fast logic you suggested.

    * One alternative would be to design a circuit with discrete latches,
    shift registers etc. It could get ugly.

    * Another alternative would be to implement the scan in a PIC or SX
    chip with the same logic you are using in the Stamp. No big deal, but
    you have to work in assembler to make it fast.

    * A third alternative would be, make it happen with the BASIC Stamp.
    Put a capacitor across each of the 64 switch contacts in the matrix.
    The .301*RC time with your pullup resistors should be about 300
    microseconds, say 0.1uf with 10kohm. The Stamp starts by charging up
    all the caps to 5 volts, by bringing all the column lines low. Then
    all the column lines (as well as the row lines with the pullups to +5
    volts) are made inputs. Each capacitor remains charged to +5
    volts--that is, unless a dart comes along and discharges it by
    hitting its parallel switch. Later, one by one the column lines are
    brought low by the program and immediately the entire row is read
    into a variable, before any discharged capacitors have time to charge
    back up. The time from a "OUTL=$ff" to an "X=INH" is about 140
    microseconds. A discharged capacitor will read low on its
    corresponding input, while a charged capacitor will read high. Leave
    the column line low for a few milliseconds to recharge all the
    capacitors on that row back to +5 volts. Then, turn that column back
    to an input, and on to test the next column. With this scheme you
    should not scan too often, because there is a danger that the dart
    will come along right at the instant you are recharging the
    capacitors, and you will miss a hit that happens to come along at
    that very instant. 0.1uf monolythic ceramic capacitors can hold
    their charge for a minute or more at room temperature, if there are
    not other leakage paths. Maybe it would work.

    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2001-09-06 01:32
    I would basically have to agree with what Tracy said. However, my
    disagreement is on the chip type. I personally use the Atmel AVR
    because of their speed and low cost (in both hardware and
    software). For the price of a PICBasic Pro compiler, you can get an
    AVR development board, an AVR basic compiler (NOT PBASIC rip, uses
    QBASIC syntax) and loads of chips to start you off. Better yet the
    chips always use flash, so you can program them over and over again.
    They are also faster than PIC because they can perform almost all
    instructions in one clock cycle, rather than the 4 needed for all
    PIC instructions. I wouldn't reccomend them as a replacement for the
    stamp, but they are definitely great support chips. You can see
    more info at www.avrfreaks.com which is an AVR website.
Sign In or Register to comment.