Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Generates PS/2 Keybd Scancodes — Parallax Forums

BS2 Generates PS/2 Keybd Scancodes

PJAllenPJAllen BannedPosts: 5,065
edited 2010-10-13 11:27 in Robotics
Here's an implementation. It sends the scan codes for a and z, repeatedly.

You just have to get the interconnect right.

PS2_M_pins_plus.jpg

I was using a GOSUB routine to CLOCK with, but it was better to go with clock=0:clock=1.

Have the Stamp powered off when you plug_in the PS/2 connector.

The first time through it'll probably generate a post code. Maybe somebody can smooth that out.

It bangs out the MAKE scancode byte and then the BREAK scancode bytes.

NB - Those are the pins, not the solder cups on the reverse.

My favoured site/link was/is -- http://www.beyondlogic.org/keyboard/keybrd.htm

!!! - Found that the device wrote over my stuff because I had the IDE open and then I saved it. Bad things can happen with this stuff. Burned that copy and put in this _02 version

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 15:15
    I verified this with Notepad as my test bed.

    PE - I didn't write the program for speed, I wrote it to be illustrative, instructional.

    I was busy being helpful and recalled this having been asked about before and since I'd been on the floor, reaching behind the computer and everything, that I'd just make it a Completed Project, having slain the beast.
    Not so tough.
    Overcome, Advance.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 16:24
    Not much to see here, but pic attached.
    800 x 600 - 54K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 18:01
    I had the IDE oprn when I had the device connected and it wrote to my program and I saved it.

    See what happens when you start doing this stuff?

    Anyway, here's the working program that the device didn't write on.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 18:13
    When I change what's plugged into the PC keybd port, it does Post Codes and is a basketcase. When I plug in the project's connector, it results a much longer series. If I disconnect it and re-connect it, it's cool about it. Something to be cognizant of, as I'm discovering.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2010-09-04 20:57
    PJ Allen,

    Is this a boot issue from the PC side of things? IOW, can you have the "stamp keyboard" plugged in upon a PC boot and things settle (eventually)? ... or do you have to have a "PC keyboard" plugged in initially to get past the handshaking?

    I say this because I have had issue with the latter ... the PC keyboard needed to be plugged in to initialize with the PC or the PC would post code at me.

    What I did was to read the keyboard stream by tapping the signal lines. First I used a scope, but then moved on to a PIC program (<--Before Propeller existed) that would serialize the data so that a second PC could display the info. Since the data stream is open driven, meaning the PC can send data as well as the Keyboard on the same line, it was a matter of decoding who was who. Then finally after mimicking the PC keyboard I was using to test with, from the PIC, I could 'emulate' a PC keyboard.


    Edit: The Speed issue I mentioned in the other thread "...I didn't think the BS2 was fast enough..." ... It might be that what I found is that the BS2 can "send" ok, but for the initial handshaking it was not fast enough to receive and store the data to parse it .... it could be that you might be able to fake that portion out, by just looking to see when the data stream from the PC is done before you respond... In other words, pretend to listen, but do it your own way regardless (<- sounds like my 8 year old)
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 21:55
    It's a dumb terminal for sure.
    1) I do a cold start on the PC with the BS2_AT plugged in (but powered off) and the PC didn't find it and it couldn't find the keyboard afterward.
    2) I do a cold start with its keyboard plugged in, then unplug that and plug the BS2_AT in, unpowered, and then the PC starts post coding for a bit, it's verging on frantic. If I leave the BS2_AT off till the post coding stops then it behaves on Notepad.
    I'm not sure if I have a handle on all this. I agree there's likely a code set that could help mitigate this; reading and writing, really going to school.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 22:11
    Wrestling with dust bunnies on my hands and knees, getting P-O'd swapping cables back and forth, forgetting something, really irritating.
    A keyboard extension cable, 3feet, 6 feet - to facilitate my work.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 22:23
    But, yeah, it needs to tell the PC at boot up what it needs to see, on cue like, if without understanding; the Host can be outfoxed, afterall (?). Logic Analyzer times.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 22:31
    I wonder how this would go in parallel with the regular keyboard? Like if I made a Y-adapter?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-04 23:05
    The wikpedia article on the PS/2 connector calls into question: any practice of hot swapping (agree) and the durability of the interconnect (agreeing).

    Still, getting the connectors, for the Y-adapter. Any thoughts?

    Hey, I have two panel mount connectors. JB_Weld, flying leads, more Frankenstein. Tomorrow.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2010-09-04 23:08
    The 'Y' adapter should work... remember the signal is open collector driven.

    I hacked a "Cue-Kat" cable when I did it... that's basically a 'Y' adapter.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-05 07:29
    I have these

    miniDIN6Fbdmnt.jpg

    and another PS/2 plug.

    Should be aggravating.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-09-05 13:07
    Maybe I can fake it by replying to any Host generated traffic with $FA (being 'ACK')? Wait for Host query, output FA, (repeat loop x times).
    When does this Host:Keyboard traffic take place, when the PC is in BIOS looking for the peripherals, etc.?

    Post Edit - From what I'm reading, there's no time to lose in making replies to the Host query or it resets or something.

    PE -- A-ha, "the keybd provides the CLOCK for all data transfer."
    So, at first, the keybd (BS2_AT) should wait/look for the Host's having taken DATA Lo, being a Start bit that the PC wants to have clocked out?
    Oooh, I hate not knowing.
  • KaosKiddKaosKidd Posts: 296
    edited 2010-10-13 11:27
    PJ;
    I've been working on this very project with a Propeller. My intention is to 100% emulate the handshaking the existing PS2 keyboards do. Right now I'm still working on receiving reliable data from the host (currently a motherboard that posts with a ps2 keyboard) and a "ps2" cable from an old PC to plug into it (and a 2 5k resistors, one on the clock, one on the data)... still working on it.. my "electronics" skills rot, and my propeller programming skills are somewhat but not much better..

    KK
Sign In or Register to comment.