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

Keyboard Simulation

ArchiverArchiver Posts: 46,084
edited 2002-03-26 15:28 in General Discussion
Hello,

Does anyone know of a way that you can connect a basic stamp to a
standard keyboard port on a computer and simulate pressing a specific
key. If this is not possible, does anyone know how to make a visual
basic program repond to a key press on the keyboard? I want to use
the basic stamp to control the keyboard so that I can make a remote
for my computer.

Thanks advance!

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-02-22 05:41
    Here's another idea: Have your Stamp send serial strings (codes / commands)
    to the PC to control your program. It will be cleaner, perhaps easier and
    won't interfere with other programs. You can find a couple of Stamp/VB
    programs in the "Nuts & Volts of BASIC Stamps" books. Another good reference
    to have is Jan Axelson's "Serial Port Complete." Jan's book covers serial
    stuff in VB and for the Stamp as well.

    -- Jon Williams
    -- Parallax

    In a message dated 2/21/02 11:06:39 PM Central Standard Time,
    travis_gm@y... writes:


    > Does anyone know of a way that you can connect a basic stamp to a
    > standard keyboard port on a computer and simulate pressing a specific
    > key. If this is not possible, does anyone know how to make a visual
    > basic program repond to a key press on the keyboard? I want to use
    > the basic stamp to control the keyboard so that I can make a remote
    > for my computer.
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-02-22 12:06
    Yes you can do this with a basic stamp.
    I would suggest you use the RS232 to AT keyboard protocol converter method.
    By this I mean that you send RS232 commands to a converter that converts the
    commands to AT keyboard commands.
    It's a lot easier to debug things if you have problems.
    The trick would be to study how the RS232 to AT keyboard protocol conversion
    units work. You can keep it simple and use one stamp to serve as the RS232
    to keyboard converter and use another stamp to send the converter the
    keyboard commands. If that works well you can then combine the two as one
    unit if you like.

    Has info on how the PC AT keyboard interface works.
    They also have a nice article on using a MC68HC05 MCU as a RS-232 to AT
    Keyboard
    converter too. You could easily swap out MCU's for whatever you'd like to
    use.
    http://www.beyondlogic.org/keyboard/keybrd.htm

    Has a lot of nice info about what to send, receive and to do with the serial
    data.
    http://www.repairfaq.org/filipg/LINK/PORTS/F_Keyboard_FAQ.html

    Of course if you don't want to bother with the whole thing you can buy
    a RS232 to keyboard protocol converter from this company. Then you can use
    the Stamp's serial port
    to send ccommands to the converter.
    http://www.vetra.com/Convert2.htm

    Regards,
    Earl



    Original Message
    From: travis_gm [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=z_bGz2T7b9FOsitkWK-h7X2muKBPn10gyFph8G0eRyIwC07XE33jU6y-sJnm8rz0kH4R1zSTGaEcGvik]travis_gm@y...[/url
    Sent: Thursday, February 21, 2002 11:05 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Keyboard Simulation


    Hello,

    Does anyone know of a way that you can connect a basic stamp to a
    standard keyboard port on a computer and simulate pressing a specific
    key. If this is not possible, does anyone know how to make a visual
    basic program repond to a key press on the keyboard? I want to use
    the basic stamp to control the keyboard so that I can make a remote
    for my computer.

    Thanks advance!


    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 2002-02-22 13:49
    I was thinking the same thing. If you want to control programs you
    didn't write, have a look at my remote control clicker at
    http://www.al-williams.com/wd5gnr/rfrem.htm -- this is just a Radio
    Shack doorbell that I modified. The C program runs on the PC and turns
    the doorbell press into any keystroke you want. No reason you couldn't
    read a character from the serial port and then convert that into a
    virtual keystroke using the same method (you do have to worry about
    VK_SHIFT and all but the code shows that).

    This is the same doorbell project that I use to make two Stamps talk to
    each other wirelessly in this month's project of the month.

    Al Williams
    AWC
    * Floating point math for the Stamp, PIC, SX, or any microcontroller
    http://www.al-williams.com/awce/pak1.htm



    >
    Original Message
    > From: jonwms@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Uon-BBkAAsl-JaUS6mogtCFEa5jCy-cUxHJTwKZEBrvc8m_yRVsClHDw43qY1p8SX6dPg1Q]jonwms@a...[/url
    > Sent: Thursday, February 21, 2002 11:42 PM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] Keyboard Simulation
    >
    >
    > Here's another idea: Have your Stamp send serial strings
    > (codes / commands)
    > to the PC to control your program. It will be cleaner,
    > perhaps easier and
    > won't interfere with other programs. You can find a couple
    > of Stamp/VB
    > programs in the "Nuts & Volts of BASIC Stamps" books.
    > Another good reference
    > to have is Jan Axelson's "Serial Port Complete." Jan's book
    > covers serial
    > stuff in VB and for the Stamp as well.
    >
    > -- Jon Williams
    > -- Parallax
    >
    > In a message dated 2/21/02 11:06:39 PM Central Standard Time,
    > travis_gm@y... writes:
    >
    >
    > > Does anyone know of a way that you can connect a basic
    > stamp to a
    > > standard keyboard port on a computer and simulate pressing
    > a specific
    > > key. If this is not possible, does anyone know how to make a visual
    > > basic program repond to a key press on the keyboard? I want to use
    > > the basic stamp to control the keyboard so that I can make a remote
    > > for my computer.
    > >
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > 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 2002-03-01 12:38
    Uli-

    Tut mir leid--I apologize for delay in responding--have been fighting
    some winsock gremlins.

    Did you add the disconnect switch as I suggested earlier? It's
    possible/likely that the keyboard is interpreting the Stamp's pulses
    as commands from the PC (such as "Repeat Last Transmission").

    I'll dig into this some more as time permits. I hope we can get it
    working...seems like a good Stamp application if possible.

    Regards,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-01 14:55
    I'm going to guess. The PC sends lots of commands to the keyboard. It
    also expects data in a pretty rigid format. So if you don't respond to a
    reset, for example, or if you don't send the right make/break codes (for
    example, a break without a make) the BIOS is probably deciding you are
    defective.

    I haven't tried going in that direction, but that's my guess.

    Al Williams
    AWC
    * Control 8 servos at once
    http://www.al-williams.com/awce/pak8.htm


    >
    Original Message
    > From: ulibasic [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=L4Aehd7oasITCkFopACDSmUYWttqRo6q-0EqbkNaLln7rfe5xwDCv2X0Agu10l3Vwp0V6gIhz8Uo-03rs-fHyazgKB2knGBs2Dl9Hg]ulibasic@r...[/url
    > Sent: Friday, March 01, 2002 8:45 AM
    > To: basicstamps@yahoogroups.com
    > Subject: AW: [noparse][[/noparse]basicstamps] Keyboard Simulation
    >
    >
    > hey stampers,
    >
    > is there anybody who can contribute anything to the keyboard
    > protocol topic? I got so far and only the last step seems to
    > be missing... for those who missed the beginning: I am trying
    > to build a Stamp device that can send characters through ps2
    > to a computer instead of a keyboard. I wired it parallel to a
    > keyboard to avoid haveing to do the booting stuff and that
    > works fine. I am sending characters according to the prozocol
    > but all i get is a system BEEP from the pc... What did I do wrong?
    >
    > Thanx, Uli
    >
    >
    >
    >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-02 14:36
    The Stamp is too slow to read the keyboard (which is why we make the
    PAK-VI). However, I am under the impression that the PC will accept a
    slow clock -- maybe not, though?

    Al Williams
    AWC
    * Control 8 servos at once
    http://www.al-williams.com/awce/pak8.htm


    >
    Original Message
    > From: ulibasic [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=fYtXzF0TFrldew8F_5-atVG17V1tqJSPVVhaM9CMVhb-XeuCojEfjhfhpFZaXJnWXD7-phG1bWpgnLjFZ6fEhSc9oZPSNUwIHg]ulibasic@r...[/url
    > Sent: Saturday, March 02, 2002 5:34 AM
    > To: basicstamps@yahoogroups.com
    > Subject: AW: [noparse][[/noparse]basicstamps] Keyboard Simulation
    >
    >
    > Hi Steve,
    >
    > yes I did put in the switches, but still no sucess, I also
    > tried to track what the keyboard really sends by make the
    > stamp 'listen', but the stamp seems to be too slow to read
    > the keyboard. Maybe taht is the whole problem, it is too
    > slow.. What do you think?
    >
    > Thanks and regards, uli
    >
    >
    >
    >
    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-09 08:24
    uli-

    The following BS2 program works with my PC. In fact, it works as a
    complete replacement for the keyboard--handles system initialization
    as well as virtual keystrokes.

    This program is tuned for the 4-command initialization sequence on my
    PC--I'm sure it will differ from one system to another. Thirty
    seconds after the final initialization command is handled, the Stamp
    issues a "dir" command. As written, the program doesn't do much
    useful, but serves as a foundation for further development.

    Regards,

    Steve

    ' __________
    ' SER TX <-| 1 24 |-- PWR
    ' SER RX ->| 2 23 |-- PWR GND
    ' SER ATN ->| 3 22 |-- RESET
    ' SER GND --| 4 21 |-- +5V
    ' I/O 0 --| 5 20 |-- I/O F
    ' I/O 1 --| 6 19 |-- I/O E
    ' I/O 2 --| 7 18 |-- I/O D
    ' I/O 3 --| 8 17 |-- I/O C
    ' I/O 4 --| 9 16 |-- I/O B Data
    ' I/O 5 --| 10 15 |-- I/O A |
    ' I/O 6 --| 11 14 |<> I/O 9
    |----\/\/\--+5
    ' I/O 7 --| 12 13 |<> I/O 8---|
    ' |__________| |----\/\/\--+5
    ' |
    ' BS2-IC Clock

    clock_pin CON 8
    data_pin CON 9

    from_pc VAR BYTE ' byte from PC meant for keyboard
    to_pc VAR BYTE ' "keyboard input" to PC
    i VAR BYTE ' utility variable
    key VAR BYTE ' keyboard scan code
    j VAR NIB ' utility variable
    parity_bit VAR BIT ' parity bit in PC<--> keyboard traffic
    stop_bit VAR BIT ' stop bit in PC-->keyboard traffic

    OUTC = %0000
    DIRC = %1100

    FOR j = 1 TO 4 ' handle four commmands from PC
    GOSUB getPC
    DEBUG CR,HEX2 from_pc
    LOOKDOWN from_pc,[noparse][[/noparse] $ED, $F2, $FF ],i
    BRANCH i,[noparse][[/noparse] setLEDs, idKeyboard, reset ]

    reset:
    to_pc = $FA ' send ack
    GOSUB putPC
    to_pc = $AA ' send self-test successful
    GOSUB putPC
    GOTO commandComplete

    idKeyboard:
    to_pc = $FA ' send ack
    GOSUB putPC
    to_pc = $AB ' send ID info
    GOSUB putPC
    to_pc = $83
    GOSUB putPC
    GOTO commandComplete

    setLEDs:
    to_pc = $FA ' send ack
    GOSUB putPC
    GOSUB getPC ' get LED parameter
    to_pc = $FA ' send ack
    GOSUB putPC
    GOTO commandComplete

    commandComplete:
    NEXT

    PAUSE 30000 ' wait 30 seconds
    key = $23: GOSUB sendKey ' "d"
    key = $43: GOSUB sendKey ' "i"
    key = $2D: GOSUB sendKey ' "r"
    key = $5A: GOSUB sendKey ' CR
    here:
    GOTO here

    sendKey:
    to_pc = key: GOSUB putPC ' send closure scan code
    to_pc = $F0: GOSUB putPC ' send release scan code
    to_pc = key: GOSUB putPC
    RETURN



    putPC:
    parity_bit = to_pc.BIT7 ^ to_pc.BIT6 ^ to_pc.BIT5 ^ to_pc.BIT4 ^ to_pc.BIT3 ^
    to_pc.BIT2 ^ to_pc.BIT1 ^ to_pc.BIT0
    awaitIdle:
    FOR i = 1 TO 10
    BRANCH INC,[noparse][[/noparse]awaitIdle, awaitIdle, awaitIdle] 'await idle clock & data
    NEXT
    DIRC = %1110 ' lower data line for start bit
    DIRC = %1111 ' clock start bit out
    DIRC = %1110
    DIRC = %1100 ' release data line
    FOR i = 1 TO 8
    DIR9 = ~to_pc.BIT0 ' set up data line
    to_pc = to_pc >> 1 ' rotate to_pc for next time
    DIR8 = 1 ' clock data bit out
    DIR8 = 0
    DIR9 = 0 ' release data line
    NEXT
    DIR9 = parity_bit ' set up data line
    DIR8 = 1 ' clock parity bit out
    DIR8 = 0
    DIR9 = 0 ' release data line
    DIR8 = 1 ' clock out (high) stop bit
    DIR8 = 0
    RETURN


    getPC:
    BRANCH INC,[noparse][[/noparse]getPC,gotStart,getPC,getPC] ' wait for data = 0, clock = 1
    gotStart:
    FOR i = 1 TO 8
    DIRC = %1101 ' lower clock line
    from_pc = from_pc >> 1 ' rotate from_pc
    from_pc.BIT7 = IN9 ' set from_pc bit to match data line
    DIRC = %1100 ' release clock line
    NEXT
    DIRC = %1101 ' clock in parity bit
    parity_bit = IN9
    DIRC = %1100
    DIRC = %1101 ' clock in stop bit
    stop_bit = IN9
    DIRC = %1100
    DIRC = %1110 ' lower data line for ack
    DIRC = %1111 ' clock out ack bit
    DIRC = %1110
    DIRC = %1100 ' release data line
    RETURN


    ulibasic wrote:

    > ...I solved the problem. Simple reason why it didn't work: Bs2 is
    > too slow! Now I am using SX and it works!! Maybe a Bs2 would be
    > fast enough...maybe someone has an Idea how to speed it up...
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-26 15:28
    Hi Stampers,

    after I struggeled with the Keyboard simulator for weeks I found that they
    sell them at Milford Industries for about $80...
    They also have the other way round (keyboard to RS232)

    But: My Stamp can run up to eight PCs at a time! So all the effort (yours
    and mine) was not in vain...

    Have a nice day and happy easter,

    Uli


    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.