Shop OBEX P1 Docs P2 Docs Learn Events
BS2 sendkeys to computer? — Parallax Forums

BS2 sendkeys to computer?

Luis_PLuis_P Posts: 246
edited 2010-09-08 10:17 in BASIC Stamp
I really need to know how can I send keystrokes like it was a keyboard doing in it but with the BS2. How can I do that. Any suggestions?

Gracias!

Luis

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 07:31
    What didn't you like about the answers that you were getting in the other subject that you started on this matter?

    http://forums.parallax.com/showthread.php?t=125339

    I guess what you are after is a means of emulating a PS2 keyboard with a Stamp. All 101 keys or just a few? I don't know if you can do all 101, a tall order that, but several might be practicable. You need to decide what you can settle for, find out what those keycodes are, and then hammer it out.

    Pretty simple stuff to talk about, right?

    I have seen a board or two (who was it?) that can do this.

    Why don't/can't you set up your VB situation for communication via a serial port instead trying to come up with a way to emulate a keyboard?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-04 07:49
    In your other thread, I posted a link to a long article on the PS/2 keyboard protocol. This covers both hardware and software. The BS2 SHIFTOUT statement will generate the clock needed and shift out the data. You'll need to read and understand the protocol to see what has to be sent to the PC. It looks pretty straightforward.

    I believe others have done this before, but I don't have any links to their threads. You may just have to browse through the old forums, particularly the Stamp forum and the Completed Projects forum looking for these old threads.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 09:01
    Scancodes... scancodes...

    It's synchronous data, so you need DATA and CLOCK outputs from the BS2.

    There is a Make (key pressed) scancode and a Break (key released) scancode for each key.
    The Make for a is $1C (%00011100), the Break for a is $F0 (%11110000) and then $1C .
    The Make for enter is $5A (%01011010), the Break for Enter is $F0 and then $5A.

    The synchronous serial transmission is odd parity. The Parity bit for $1C is 0, for $F0 it's 1, and for $5A it's 1.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 09:19
    Anybody want to send me a PS/2 connector to try this out with or I should work for free? :lol:
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 12:39
    I think that there needs to be some communication before sending scancodes.
    I'm supposing that there may be an initialization routine.

    When I unplug my keyboard and then plug it back in, there is a series of beeps (like post codes) and then it kicks in and it works.

    I found a PS2 connector. I'm convinced that I have it set up properly. I wrote a bit-bang routine to knock out a $1C, $F0, $1C, but the PC does some Post-Code beeps and I don't see an 'a' typed in Notepad. So, something is up there.

    Yeah...
    A little Host:Keyboard conversation may well be required.
    http://www.beyondlogic.org/keyboard/keybrd.htm
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 14:11
    PS2_M_pins_plus.jpg

    [You can't Attach as part of "Edit"]
    Anyway, here is a pic of my interconnect.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 15:21
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2010-09-04 19:43
    PJ Allen,

    Would have never thought the BS2 was fast enough good job!!

    I made something about 7 years ago using a PIC that took a serial keyboard (UNIX style) and remapped the output for a PC-Keyboard. This was all in effort to have one keyboard between multiple computers and dual platform computers... Now there is software that will do it if the computers are networked together ... Ho Hum !!

    BTW) Yes, there is some post communication that goes on between the Keyboard and PC for it to handshake properly. I have some old notes on this if you would like me to get them. First I had built a line 'sniffer' that could monitor the signals on the keyboard connector and send them serially to a second PC for monitoring.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 20:41
    It's real Frankenstein's monster right now.
    The program that I wrote is pretty slow.

    The AT (PS/2 ?) Clock Idle is HI, it reads DATA on Clock's hi-to-lo transition. SHIFTOUT makes positive-going C-pin transitions. I think I can make that go with an inverter (CE).
    I Need a parity parse & calc routine.

    Maybe it'll go too fast.

    Post Edit -- Let's all chat at the other project from here.
  • Luis_PLuis_P Posts: 246
    edited 2010-09-08 10:17
    This is how I solved this issue.
    I installed resistors to different switches then the BS2 use RC time to measure resistance, sent values to PC using the serial port then My Visual Basic application read the communication port, receive the data and with some formulas I added to the code, the V.B application knows which switch is closed (according to ressitance value) and then the application use sendkeys to send keystrokes. Is that clear? mmmm
    By the way this is for a Fly simulator on my PC.
Sign In or Register to comment.