588,328 active members*
4,705 visitors online*
Register for free
Login
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2005
    Posts
    828

    PIC talking to PS/2 port?

    Any one here worked on projects that involve the pic sending keyboard commands to the computer?

    I would like to see some code if possible

    I want the pic to send numbers to Rhino 3D so I can do some simple 2D digitizing. The numbers will come from rotory encoders with wheels rolling on a X Y plane.

    Thanks
    Dennis

  2. #2
    Join Date
    May 2006
    Posts
    3
    can you not use the Rs232 interface rather than the AT keyboard. I made benchsaw fence DRO using a couple if pics and the encoders from a mouse had to gear it right down but it worked a treat. there are plenty of microchip programing sites about.

  3. #3
    Join Date
    May 2005
    Posts
    162
    Have a look at http://users.picbasic.org/?page=howtolist there are articles on how to talk to pc keyboards, should give you a good starting point.

  4. #4
    Join Date
    Aug 2005
    Posts
    828
    Good info!! Thanks, as soon as the big proto board gets here will start experimenting.
    Dennis

  5. #5
    PS/2 Library
    mikroBasic provides a library for communicating with common PS/2 keyboard. The library does not utilize interrupts for data retrieval, and requires oscillator clock to be 6MHz and above.


    Library Example
    This simple example reads values of keys pressed on PS/2 keyboard and sends them via USART.

    program ps2_test
    dim keydata, special, down as byte

    main:
    CMCON = $07 ' Disable analog comparators (comment this for P18)
    INTCON = 0 ' Disable all interrupts
    Ps2_Init(PORTA) ' Init PS/2 Keyboard on PORTA
    Delay_ms(100) ' Wait for keyboard to finish

    do
    if Ps2_Key_Read(keydata, special, down) = 1 then
    if (down = 1) and (keydata = 16) then ' Backspace
    ' ...do something with a backspace...
    else
    if (down = 1) and (keydata = 13) then ' Enter
    Usart_Write(13)
    else
    if (down = 1) and (special = 0) and (keydata <> 1) then
    Usart_Write(keydata)
    end if
    end if
    end if
    end if
    Delay_ms(10) ' debounce
    loop until FALSE
    end.

    http://www.mikroe.com/en/compilers/ http://www.mikroe.com/en/compilers/

  6. #6
    Join Date
    Jul 2007
    Posts
    1
    If only send a few keys, you can use a keyborad main board (get from a used keyboard), and connect its circuit with some I/O or some digital chip to do that.

    Sorry for my poor English.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •