Shop OBEX P1 Docs P2 Docs Learn Events
AW: [basicstamps] Keyboard Simulation — Parallax Forums

AW: [basicstamps] Keyboard Simulation

ArchiverArchiver Posts: 46,084
edited 2002-03-11 19:31 in General Discussion
Hey Earl,

very good hints indeed. I asked a similar question some weeks ago and I did
get good answers, but you beat them all!!

Thanx again, uli



Urspr

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-02-28 16:10
    Hi all,

    after I got so much good advice I decided to try and do it.
    I followed your description, Steve and the Stamp runs, getting power from
    the PC.
    Also when the stamp reads clock and data both are high, which they should
    be.
    But whenever I try to send an eleven bit string over the PC just gives a
    BEEP from the system alert.
    Is there anything I got wrong about what byte to send?
    Could anyone tell me an example-byte that has to work if the program is
    right?
    Did I miss anything about make and break and all that?

    I will give you the code of my (not very elegant) programm below.

    Thanx for your help, Uli

    zeichen var byte
    clock con 11
    daten con 12

    debug cls
    debug? in11
    debug? in12
    pause 2000

    ***********************************************************


    rausschicken:

    input clock

    low daten

    gosub schieben ‚startbit
    '_________________________________________
    gosub schieben ,datenbits, 01001000
    input daten
    gosub schieben
    low daten
    gosub schieben
    gosub schieben
    input daten
    gosub schieben
    low daten
    gosub schieben
    gosub schieben
    gosub schieben
    '__________________________________________

    gosub schieben ‚parity bit
    input daten
    gosub schieben ,stopbit

    pause 6000
    goto rausschicken






    schieben:

    pause 20
    low clock
    pause 20
    input clock
    return

    ***********************************************************

    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-02-28 16:43
    Latest news:

    I am getting my first characters on the screen but: It works only every now
    and then, and it only repeats the last key I put in with a keyboard before,
    if I for example put in a "j" my keyboard simulator will then type j's too,
    no matter what number I send. and most of the time it sends just BEEPS. The
    host doesnot pull the data or clock line low, as far as my stamp tells me.

    what does all that mean :-(

    Thanx for help, Uli



    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-01 14:44
    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-01 16:00
    you are right in a way, Al, but I have a keyboard parallel and it works all
    the time, I also tried many codes that are listed as make or break codes and
    I also stuck to the protocol very carefully.
    I also have an eye on the data and clock line to check out if the PC is
    trying to send something to the stamp (which it would certainly do if it
    would detect a failure) but it doesnot.
    Could it be the stamp is too slow?
    I attach the new program I wrote to translate the hex codes and send it,
    maybe someone finds the mistake...

    Thanx Al, and all the others too, uli

    zeichen var byte
    clock con 11
    daten con 12
    z1 var bit
    einszaehler var byte

    dirs=%0000000000000000

    debug cls
    debug? in11 'check clock and datalines
    debug? in12
    pause 2000

    start:
    zeichen = 51 'keycodes to send
    gosub hexen
    debug cr

    zeichen = $F0
    gosub hexen
    debug cr
    zeichen = $2D
    gosub hexen
    debug cr

    pause 2000
    debug cls
    goto start


    hexen:
    einszaehler=0 'counter used for parity bit
    gosub nullschieben 'send a 0 as startbit
    z1 = zeichen.bit0
    gosub rausschicken 'send databits
    z1 = zeichen.bit1
    gosub rausschicken
    z1 = zeichen.bit2
    gosub rausschicken
    z1 = zeichen.bit3
    gosub rausschicken
    z1 = zeichen.bit4
    gosub rausschicken
    z1 = zeichen.bit5
    gosub rausschicken
    z1 = zeichen.bit6
    gosub rausschicken
    z1 = zeichen.bit7
    gosub rausschicken

    gosub parity 'send parity-bit
    gosub einsschieben 'send stopbit


    return




    rausschicken:


    branch z1,[noparse][[/noparse]nullschieben,einsschieben]
    'decide to send 0 or 1






    nullschieben:
    debug "0"

    low daten 'dataline low
    low clock ' clock by going low and high
    input clock
    return

    einsschieben:
    einszaehler=einszaehler+1 'parity-counter
    debug "1"
    input daten 'see above
    low clock
    input clock
    return

    parity:

    if einszaehler.lowbit=0 then hopp
    gosub nullschieben 'if number of ones odd then
    return 'send zero
    hopp:
    gosub einsschieben
    return

    alarm:
    debug cls 'tells if the host pulls any line low
    debug "HOST MELDET SICH!"
    if in11=1 then jumpa
    debug "CLOCK"
    jumpa:
    if in12=1 then jumpb
    debug "daten"
    jumpb:
    pause 1000
    goto rausschicken


    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-02 11:33
    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-10 15:30
    Hey Steve,

    this is how people write programs if they really know how to write
    programs... :-)
    Looks brilliant, can't wait to test it on monday!

    I will tell you if it works, thanks a big lot!

    Have a nice day, Uli


    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-11 07:28
    uli-

    Good. FWIW, your Stamp should also be able to simulate a PS/2 mouse
    using the same approach and I/O routines.


    Regards,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-11 19:31
    Hi Steve,

    I tested your program today and found that it works perfect with A BsSX
    (including the starting routine) but not with a Bs2, same problem as before.
    Maybe my PC demands faster information and has a quicker timeout that yours.
    So I will just use the Bs2X but thank you very much anyway!

    Have a nice day, Uli



    Urspr
Sign In or Register to comment.