Shop OBEX P1 Docs P2 Docs Learn Events
Keyboard decoding — Parallax Forums

Keyboard decoding

ArchiverArchiver Posts: 46,084
edited 2002-06-19 19:04 in General Discussion
Does anybody here have any experience with decoding the data sent
from keyboards into ASCII format using the BS2SX? Thanks for any
help.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-06-11 15:31
    The following link gives an example of decoding a keyboard's scan
    codes and an Fbasic program to handle the caps and nums lock. The low
    level timing of the clock and data lines is not covered. The real
    problem with the keyboard interface, as far as the stamp is
    concerned, is that the clock timing is generated by the keyboard.
    Therefor, the stamp has to be fast enough to detect the edges of the
    keyboard clock. Since the clock from the keyboard is usually about
    30KHz, the BS2 is usually too slow to catch the data.

    I think I remember seeing an article once about a fellow using an 8
    bit shift register and some flip flops with a BS2 to decode the
    keyboard interface, so that is a possibility also.

    You could always just purchase the TICkit processor mentioned in the
    article and use a 10 line program to convert the keyboard info into
    ASCII. The TICkit could send the resulting info via RS232 to the
    stamp.

    http://www.protean-logic.com/applications/an039.pdf



    --- In basicstamps@y..., "sethjaredjeromiejohnson" <sjohns10@h...>
    wrote:
    > Does anybody here have any experience with decoding the data sent
    > from keyboards into ASCII format using the BS2SX? Thanks for any
    > help.
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-12 13:49
    If you need to read a PS/2 keyboard in a one chip solution, have a look
    at http://www.al-williams.com/awce/pak6.htm - you can order these direct
    or through Parallax.

    Al Williams
    AWC
    * Floating point A/D
    http://www.al-williams.com/awce/pak9.htm



    >
    Original Message
    > From: ulibasic [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=05V0OBoIswgVgJHWR5LYR_NFGs7Mn2kGvZVBsDMU8TEruUHI6tGya2SdEhLw5-JnJ0t5k7takhtl_wva8aWkyqyNNLm-9C-HZbw-k6I]ulibasic@r...[/url
    > Sent: Wednesday, June 12, 2002 2:36 AM
    > To: basicstamps@yahoogroups.com
    > Subject: AW: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    >
    >
    > Hi Folks,
    >
    > you find all kinds of decoders at www.milinst.com
    > They have Keyboard to rs232 as well as rs232 to PC (keyboard
    > simulator).
    >
    > Regards, Uli
    >
    >
    >
    >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-14 07:33
    The PAK 6 works great for obtaining input from the keyboard, but I
    now need to send the obtained keystrokes back to the PC. I'm working
    on a product for my company that will take macros that are user
    defined, via the PAk 6, and send them to the PC to automate
    situations that can't be automated by software. I'm half way there in
    that the obtaining data into the BS2 is working, but I need to send
    it to the PC now. Do you have any clever suggestions on how to best
    achieve this? I'm basically making a wedge that will act as a macro
    sender without the need for a second PC to control the wedge. This is
    an interesting project and could result in the need for numerious PAK
    6 controllers as it will be used in automation within the validation
    of the PC hardware we make.
    Any help or advice on sending allready retrieved keystrokes is
    appreciated!
    I found someone has done the following and am investigating the
    possibilities of using this circuit for the output since the input is
    fine via the PAk 6 (http://www.al-williams.com/awce/pak6sim.htm):


    +
    +
    +
    o +5V
    | | |
    | 0.1uF / /
    +----||---+ \ 2.2K \ 2.2K
    | | / /
    | --- | |
    | Gnd +
    o Data
    | | |
    | | +
    o CLOCK)
    +
    + e | |
    | Vdd | 10K |/ BC547 | +---o GND
    | P0 |---/\/\/---|b (NPN) | |
    | BS2-IC | |\ | ---
    | | c | | Gnd
    | | --- |
    | | Gnd |
    | | e _________/
    | | 10K |/ BC547
    | P1 |---/\/\/---|b (NPN)
    | | |\
    | | c |
    | | ---
    | | Gnd
    | |
    | |
    | P2 |-
    | P3 |-
    | P4 |-
    | P5 |-
    | P6 |-
    | P7 |-
    | Gnd |
    +
    +
    |
    ---
    Gnd

    --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > If you need to read a PS/2 keyboard in a one chip solution, have a
    look
    > at http://www.al-williams.com/awce/pak6.htm - you can order these
    direct
    > or through Parallax.
    >
    > Al Williams
    > AWC
    > * Floating point A/D
    > http://www.al-williams.com/awce/pak9.htm
    >
    >
    >
    > >
    Original Message
    > > From: ulibasic [noparse][[/noparse]mailto:ulibasic@r...]
    > > Sent: Wednesday, June 12, 2002 2:36 AM
    > > To: basicstamps@y...
    > > Subject: AW: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    > >
    > >
    > > Hi Folks,
    > >
    > > you find all kinds of decoders at www.milinst.com
    > > They have Keyboard to rs232 as well as rs232 to PC (keyboard
    > > simulator).
    > >
    > > Regards, Uli
    > >
    > >
    > >
    > >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-14 14:07
    Depends on what you want to do. First, if you control the PCs consider
    just using a serial port to accept the data. You can use the Windows API
    to force keystrokes into the system even though they didn't come from
    the keyboard port. For an example, see http://www.wd5gnr.com/rfrem.htm

    If you really need to hook up to the PS2 port, it may be possible to do
    this with a Stamp although I personally have not tried it. The reason
    the Stamp can't easily read the keyboard is that the keyboard generates
    the clock and it is too fast for a standard BS2 to read. Even a faster
    BS (like the P) has to monitor for data all the time which makes it
    difficult to do anything else.

    However, if you want to LOOK like a keyboard, then the Stamp generates
    the clock and that should be a lot easier. In fact, Steve Parkis posted
    some code awhile back to do this that IIRC worked with a BS2SX but not a
    BS2:
    http://groups.yahoo.com/group/basicstamps/message/20092

    Good luck!

    Al Williams
    AWC
    * Easy RS-232 Prototyping
    http://www.al-williams.com/awce/rs1.htm



    >
    Original Message
    > From: dajames519 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=T0x-k7AKWc-qcsSLPZRWmYQDwW4_OXgOGd8hm-pTGMK-ly6Ljoqf0j1daFeQTZAEz24JDi0DLG_mTA]dajames519@y...[/url
    > Sent: Friday, June 14, 2002 1:33 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    >
    >
    > The PAK 6 works great for obtaining input from the keyboard, but I
    > now need to send the obtained keystrokes back to the PC. I'm working
    > on a product for my company that will take macros that are user
    > defined, via the PAk 6, and send them to the PC to automate
    > situations that can't be automated by software. I'm half way there in
    > that the obtaining data into the BS2 is working, but I need to send
    > it to the PC now. Do you have any clever suggestions on how to best
    > achieve this? I'm basically making a wedge that will act as a macro
    > sender without the need for a second PC to control the wedge. This is
    > an interesting project and could result in the need for numerious PAK
    > 6 controllers as it will be used in automation within the validation
    > of the PC hardware we make.
    > Any help or advice on sending allready retrieved keystrokes is
    > appreciated!
    > I found someone has done the following and am investigating the
    > possibilities of using this circuit for the output since the input is
    > fine via the PAk 6 (http://www.al-williams.com/awce/pak6sim.htm):
    >
    >
    > +
    +
    +
    o +5V
    > | | |
    > | 0.1uF / /
    > +----||---+ \ 2.2K \ 2.2K
    > | | / /
    > | --- | |
    > | Gnd +
    o Data
    > | | |
    > | | +
    o CLOCK)
    > +
    + e | |
    > | Vdd | 10K |/ BC547 | +---o GND
    > | P0 |---/\/\/---|b (NPN) | |
    > | BS2-IC | |\ | ---
    > | | c | | Gnd
    > | | --- |
    > | | Gnd |
    > | | e _________/
    > | | 10K |/ BC547
    > | P1 |---/\/\/---|b (NPN)
    > | | |\
    > | | c |
    > | | ---
    > | | Gnd
    > | |
    > | |
    > | P2 |-
    > | P3 |-
    > | P4 |-
    > | P5 |-
    > | P6 |-
    > | P7 |-
    > | Gnd |
    > +
    +
    > |
    > ---
    > Gnd
    >
    > --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > > If you need to read a PS/2 keyboard in a one chip solution, have a
    > look
    > > at http://www.al-williams.com/awce/pak6.htm - you can order these
    > direct
    > > or through Parallax.
    > >
    > > Al Williams
    > > AWC
    > > * Floating point A/D http://www.al-williams.com/awce/pak9.htm
    > >
    > >
    > >
    > > >
    Original Message
    > > > From: ulibasic [noparse][[/noparse]mailto:ulibasic@r...]
    > > > Sent: Wednesday, June 12, 2002 2:36 AM
    > > > To: basicstamps@y...
    > > > Subject: AW: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    > > >
    > > >
    > > > Hi Folks,
    > > >
    > > > you find all kinds of decoders at www.milinst.com
    > > > They have Keyboard to rs232 as well as rs232 to PC (keyboard
    > > > simulator).
    > > >
    > > > Regards, Uli
    > > >
    > > >
    > > >
    > > >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-17 07:04
    Thanks for the advice on sending keystrokes to the PC. Since I need
    to do this under multiple operating systems I cannot use the Windows
    API and will attempt what Steve had done. Do the keyboard data and
    clock lines need to be driven by a transistor or can the BS2 drive
    them (to the PC) directly?
    I'm thinking of attempting a method of 'hot-swapping' the keyboard
    via a latch or something so the stamp can control thes signals only
    when needed and the keyboard can be used normally when the stamp
    doesn't have control. Any suggestions?

    --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > Depends on what you want to do. First, if you control the PCs
    consider
    > just using a serial port to accept the data. You can use the
    Windows API
    > to force keystrokes into the system even though they didn't come
    from
    > the keyboard port. For an example, see
    http://www.wd5gnr.com/rfrem.htm
    >
    > If you really need to hook up to the PS2 port, it may be possible
    to do
    > this with a Stamp although I personally have not tried it. The
    reason
    > the Stamp can't easily read the keyboard is that the keyboard
    generates
    > the clock and it is too fast for a standard BS2 to read. Even a
    faster
    > BS (like the P) has to monitor for data all the time which makes it
    > difficult to do anything else.
    >
    > However, if you want to LOOK like a keyboard, then the Stamp
    generates
    > the clock and that should be a lot easier. In fact, Steve Parkis
    posted
    > some code awhile back to do this that IIRC worked with a BS2SX but
    not a
    > BS2:
    > http://groups.yahoo.com/group/basicstamps/message/20092
    >
    > Good luck!
    >
    > Al Williams
    > AWC
    > * Easy RS-232 Prototyping
    > http://www.al-williams.com/awce/rs1.htm
    >
    >
    >
    > >
    Original Message
    > > From: dajames519 [noparse][[/noparse]mailto:dajames519@y...]
    > > Sent: Friday, June 14, 2002 1:33 AM
    > > To: basicstamps@y...
    > > Subject: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    > >
    > >
    > > The PAK 6 works great for obtaining input from the keyboard, but I
    > > now need to send the obtained keystrokes back to the PC. I'm
    working
    > > on a product for my company that will take macros that are user
    > > defined, via the PAk 6, and send them to the PC to automate
    > > situations that can't be automated by software. I'm half way
    there in
    > > that the obtaining data into the BS2 is working, but I need to
    send
    > > it to the PC now. Do you have any clever suggestions on how to
    best
    > > achieve this? I'm basically making a wedge that will act as a
    macro
    > > sender without the need for a second PC to control the wedge.
    This is
    > > an interesting project and could result in the need for numerious
    PAK
    > > 6 controllers as it will be used in automation within the
    validation
    > > of the PC hardware we make.
    > > Any help or advice on sending allready retrieved keystrokes is
    > > appreciated!
    > > I found someone has done the following and am investigating the
    > > possibilities of using this circuit for the output since the
    input is
    > > fine via the PAk 6 (http://www.al-williams.com/awce/pak6sim.htm):
    > >
    > >
    > > +
    +
    +
    o
    +5V
    > > | | |
    > > | 0.1uF / /
    > > +----||---+ \ 2.2K \ 2.2K
    > > | | / /
    > > | --- | |
    > > | Gnd +
    o
    Data
    > > | | |
    > > | | +
    o
    CLOCK)
    > > +
    + e | |
    > > | Vdd | 10K |/ BC547 | +---o
    GND
    > > | P0 |---/\/\/---|b (NPN) | |
    > > | BS2-IC | |\ | ---
    > > | | c | | Gnd
    > > | | --- |
    > > | | Gnd |
    > > | | e _________/
    > > | | 10K |/ BC547
    > > | P1 |---/\/\/---|b (NPN)
    > > | | |\
    > > | | c |
    > > | | ---
    > > | | Gnd
    > > | |
    > > | |
    > > | P2 |-
    > > | P3 |-
    > > | P4 |-
    > > | P5 |-
    > > | P6 |-
    > > | P7 |-
    > > | Gnd |
    > > +
    +
    > > |
    > > ---
    > > Gnd
    > >
    > > --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > > > If you need to read a PS/2 keyboard in a one chip solution,
    have a
    > > look
    > > > at http://www.al-williams.com/awce/pak6.htm - you can order
    these
    > > direct
    > > > or through Parallax.
    > > >
    > > > Al Williams
    > > > AWC
    > > > * Floating point A/D http://www.al-williams.com/awce/pak9.htm
    > > >
    > > >
    > > >
    > > > >
    Original Message
    > > > > From: ulibasic [noparse][[/noparse]mailto:ulibasic@r...]
    > > > > Sent: Wednesday, June 12, 2002 2:36 AM
    > > > > To: basicstamps@y...
    > > > > Subject: AW: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    > > > >
    > > > >
    > > > > Hi Folks,
    > > > >
    > > > > you find all kinds of decoders at www.milinst.com
    > > > > They have Keyboard to rs232 as well as rs232 to PC (keyboard
    > > > > simulator).
    > > > >
    > > > > Regards, Uli
    > > > >
    > > > >
    > > > >
    > > > >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-17 13:12
    You should have no problem direct. Especially since the line "floats"
    high, so you'd simulate that by making the I/O pin an input.

    Al Williams
    AWC
    * Floating point A/D
    http://www.al-williams.com/awce/pak9.htm



    >
    Original Message
    > From: dajames519 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=eYxcDqdZOaeVKE64TPihdY-NFfmrB56B2UKrdUeWq742N8C-HCpmU6nU5ya3c1THCmJeuDbIsdyoevVexg]dajames519@y...[/url
    > Sent: Monday, June 17, 2002 1:04 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    >
    >
    > Thanks for the advice on sending keystrokes to the PC. Since I need
    > to do this under multiple operating systems I cannot use the Windows
    > API and will attempt what Steve had done. Do the keyboard data and
    > clock lines need to be driven by a transistor or can the BS2 drive
    > them (to the PC) directly?
    > I'm thinking of attempting a method of 'hot-swapping' the keyboard
    > via a latch or something so the stamp can control thes signals only
    > when needed and the keyboard can be used normally when the stamp
    > doesn't have control. Any suggestions?
    >
    > --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > > Depends on what you want to do. First, if you control the PCs
    > consider
    > > just using a serial port to accept the data. You can use the
    > Windows API
    > > to force keystrokes into the system even though they didn't come
    > from
    > > the keyboard port. For an example, see
    > http://www.wd5gnr.com/rfrem.htm
    > >
    > > If you really need to hook up to the PS2 port, it may be possible
    > to do
    > > this with a Stamp although I personally have not tried it. The
    > reason
    > > the Stamp can't easily read the keyboard is that the keyboard
    > generates
    > > the clock and it is too fast for a standard BS2 to read. Even a
    > faster
    > > BS (like the P) has to monitor for data all the time which makes it
    > > difficult to do anything else.
    > >
    > > However, if you want to LOOK like a keyboard, then the Stamp
    > generates
    > > the clock and that should be a lot easier. In fact, Steve Parkis
    > posted
    > > some code awhile back to do this that IIRC worked with a BS2SX but
    > not a
    > > BS2: http://groups.yahoo.com/group/basicstamps/message/20092
    > >
    > > Good luck!
    > >
    > > Al Williams
    > > AWC
    > > * Easy RS-232 Prototyping http://www.al-williams.com/awce/rs1.htm
    > >
    > >
    > >
    > > >
    Original Message
    > > > From: dajames519 [noparse][[/noparse]mailto:dajames519@y...]
    > > > Sent: Friday, June 14, 2002 1:33 AM
    > > > To: basicstamps@y...
    > > > Subject: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    > > >
    > > >
    > > > The PAK 6 works great for obtaining input from the keyboard, but I

    > > > now need to send the obtained keystrokes back to the PC. I'm
    > working
    > > > on a product for my company that will take macros that are user
    > > > defined, via the PAk 6, and send them to the PC to automate
    > > > situations that can't be automated by software. I'm half way
    > there in
    > > > that the obtaining data into the BS2 is working, but I need to
    > send
    > > > it to the PC now. Do you have any clever suggestions on how to
    > best
    > > > achieve this? I'm basically making a wedge that will act as a
    > macro
    > > > sender without the need for a second PC to control the wedge.
    > This is
    > > > an interesting project and could result in the need for numerious
    > PAK
    > > > 6 controllers as it will be used in automation within the
    > validation
    > > > of the PC hardware we make.
    > > > Any help or advice on sending allready retrieved keystrokes is
    > > > appreciated!
    > > > I found someone has done the following and am investigating the
    > > > possibilities of using this circuit for the output since the
    > input is
    > > > fine via the PAk 6 (http://www.al-williams.com/awce/pak6sim.htm):
    > > >
    > > >
    > > > +
    +
    +
    o
    > +5V
    > > > | | |
    > > > | 0.1uF / /
    > > > +----||---+ \ 2.2K \ 2.2K
    > > > | | / /
    > > > | --- | |
    > > > | Gnd +
    o
    > Data
    > > > | | |
    > > > | | +
    o
    > CLOCK)
    > > > +
    + e | |
    > > > | Vdd | 10K |/ BC547 | +---o
    > GND
    > > > | P0 |---/\/\/---|b (NPN) | |
    > > > | BS2-IC | |\ | ---
    > > > | | c | | Gnd
    > > > | | --- |
    > > > | | Gnd |
    > > > | | e _________/
    > > > | | 10K |/ BC547
    > > > | P1 |---/\/\/---|b (NPN)
    > > > | | |\
    > > > | | c |
    > > > | | ---
    > > > | | Gnd
    > > > | |
    > > > | |
    > > > | P2 |-
    > > > | P3 |-
    > > > | P4 |-
    > > > | P5 |-
    > > > | P6 |-
    > > > | P7 |-
    > > > | Gnd |
    > > > +
    +
    > > > |
    > > > ---
    > > > Gnd
    > > >
    > > > --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > > > > If you need to read a PS/2 keyboard in a one chip solution,
    > have a
    > > > look
    > > > > at http://www.al-williams.com/awce/pak6.htm - you can order
    > these
    > > > direct
    > > > > or through Parallax.
    > > > >
    > > > > Al Williams
    > > > > AWC
    > > > > * Floating point A/D http://www.al-williams.com/awce/pak9.htm
    > > > >
    > > > >
    > > > >
    > > > > >
    Original Message
    > > > > > From: ulibasic [noparse][[/noparse]mailto:ulibasic@r...]
    > > > > > Sent: Wednesday, June 12, 2002 2:36 AM
    > > > > > To: basicstamps@y...
    > > > > > Subject: AW: [noparse][[/noparse]basicstamps] Re: Keyboard decoding
    > > > > >
    > > > > >
    > > > > > Hi Folks,
    > > > > >
    > > > > > you find all kinds of decoders at www.milinst.com They have
    > > > > > Keyboard to rs232 as well as rs232 to PC (keyboard simulator).
    > > > > >
    > > > > > Regards, Uli
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 14:39
    Hi, I'm a new user of BS2e OEM version. There is a DB9 connector mount on PCB
    used to download programs from the PC. Is there any possibility to decode a key
    press from the PC by using this existing connection thus affecting the flow of
    the program? (something like the input command used in other basic languages)

    Thank you



    --
    __________________________________________________________
    Sign-up for your own FREE Personalized E-mail at Mail.com
    http://www.mail.com/?sr=signup

    Save up to $160 by signing up for NetZero Platinum Internet service.
    http://www.netzero.net/?refcd=N2P0602NEP8
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-19 19:04
    Dimitris-

    This is very simple to do using the DEBUG window on the newer
    stampw.exe versions. Use SERIN in your program to accept keystrokes
    from the PC:

    x VAR BYTE

    SERIN 16,16468,[noparse][[/noparse]x]

    This will cause your program to halt until a character is received
    from the PC over the programming cable. Upon receipt, it will be
    stored in the variable x. Then you can use BRANCH, IF or whatever
    to do the right thing based on the byte received. Another pretty
    nifty feature from the Parallax wizards.

    You can even define macros to send a sequence of characters with a
    single keyboard stroke.

    With a bit more work, you can do the same thing with a terminal-like
    program of choice that also communicates with your Stamp over the
    programming cable.

    Regards,

    Steve

    Dimitris Tsabouras wrote:

    > ...Is there any possibility to decode a key press from the PC by
    > using this existing connection thus affecting the flow of the
    > program?
Sign In or Register to comment.