pic as ps/2 keyboard


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Update:

    Ok messed up some of the scancode's. I can now send normal characters
    by sending the reversed scancode with shiftout

    For example : if i send 0x15 = 00010101, LSB first = 10101000 = "q" on screen, that's perfect. I tried other codes and they work also.

    There was an error with the parity calculator also, so i skipped that ....

    But now, i want to use Left-shift + q, which, when looking at the scancode
    table this would be 0x12 for left shift, 0x15 for "q", 0xF0 for release, 0x15 for release "q" and 0xF0 and 0x12 for release left shift.

    Doing this results in an F10 being received ??

    Here's the code :
    Code:
    sendthis = %01001000 'left shift       
    test = 1 'parity bit
    gosub calsub
                             
    sendthis = %10101000 'q 
    test = 0
    gosub calsub
                      
    sendthis = %00001111 'Release       
    test = 1
    gosub calsub
    
    sendthis = %10101000 'q
    test = 0
    gosub calsub
    
    sendthis = %00001111 'Release 
    test = 1
    gosub calsub  
      
    sendthis = %01001000 'left shift        
    test = 1
    gosub calsub
           
    goto start       
    
    
    calsub:
        sendthis = sendthis << 1 'move over to insert start bit  
        sendthis.0 = 0 'start bit
        sendthis.9 = test 'parity
        sendthis.10 = 1 'stop bit
        shiftout kbddata,kbdclk,1,[sendthis\11]
    return
    Best regards, UB

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    not sure but i think you have to send some other code(s) + sendthis as well.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Mister_e,

    I found some source code in basic stamp, the author claims it works.
    Apart from the fact that everything is inverted (he inverts the inputs in his
    schematic using transistors) i can't find anything other tahn my code ?

    Code:
    ' -----[ Program Description ]----------------------------------------
    '
    ' This simple program shows how to connect a BASIC Stamp II to the AT
    ' keyboard port on a PC and to send characters when one of three buttons
    ' is pressed. Please read KEYBTST.TXT for more information about it's
    ' limitations and for a simple schematic.
    
    ' -----[ Constants ]--------------------------------------------------
    '
    datpin      con 0   'Keyboard Data
    clkpin      con 1   'Keyboard Clock
    btn00       con 2   'Button 0
    btn01       con 3   'Button 1
    btn02       con 4   'Button 2
    
    ' -----[ Variables ]--------------------------------------------------
    '
    temp        var B2  'Temp variabel
    char        var W2  'Variabel containing the character
    breakcode   var W3  'Variabel containing "Breakcode"
    extcode     var W4  'Variabel containing "Extended charcode"
    
    ' -----[ Initialization ]---------------------------------------------
    '
    
    'Set pin 0 and 1 as outputs, rest as inputs 
     Dirl= %00000011
    
    'Set datpin and clkpin default to high (1)
     low datpin
     low clkpin
    
    'Define breakcode
    '           s--DATA--PS (s=start, DATA=LSB First, P=parity, S=stop)
     breakcode=%11111000000 '/F0H
    'Define extcode
    '         s--DATA--PS (s=start, DATA=LSB First, P=parity, S=stop)
     extcode=%11111100010 '/E0H
    
    ' -----[ Main Code ]--------------------------------------------------
    '
    
    start:
    
    temp=0
    pause 1000
    button btn00,0,255,100,temp,1,button00
    button btn01,0,255,100,temp,1,button01
    button btn02,0,255,100,temp,1,button02
    
    goto start
    
    ' -----[ Test Characters ]--------------------------------------------
    '
    '      s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    'char=%10110101110 '/SPACE
    'char=%11100011110 '/a
    'char=%11010010100 '/CR
    'char=%11011001110 '/b
    'char=%11100101110 '/t
    'char=%10100101100 '/r
    'char=%10011101110 '/d
    'char=%10101111100 '/F1
    'char=%11111000110 '/INS
    
    button00:
    'Assign char a character with startbit, parity and stopbit. OBS inverted !
    '     s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    char=%11100011110 '/a
    gosub sendchar
    goto start
    
    button01:
    'Assign char a character with startbit, parity and stopbit. OBS inverted !
    '     s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    char=%11010010100 '/CR
    gosub sendchar
    goto start
    
    button02:
    'Assigne char a character with startbit, parity and stopbit. OBS inverted !
    '     s--DATA--PS (s=startbit, DATA=LSB First, P=paritybit, S=stopbit)
    char=%11111000110 '/INS
    gosub sendextchar
    goto start
    
    ' -----[ Subroutines ]------------------------------------------------
    '
    sendchar
      'Send character
      shiftout datpin,clkpin,1,[char\11]
      'Send breakcode + character
      shiftout datpin,clkpin,1,[breakcode\11]
      shiftout datpin,clkpin,1,[char\11]
    return
    
    sendextchar
      'Send extcode + character
      shiftout datpin,clkpin,1,[extcode\11]
      shiftout datpin,clkpin,1,[char\11]
      'Send extcode + breakcode + character
      shiftout datpin,clkpin,1,[extcode\11]
      shiftout datpin,clkpin,1,[breakcode\11]
      shiftout datpin,clkpin,1,[char\11]
    return
    
    ' -----[ End ]--------------------------------------------------------
    Best regards, UB

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    YEAH as i thought... it's all there... sequence of char, breakcode and extcode. I knew something was missing.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Smile

    Thanks guys, for thinking this over with me ....

    Above code does seem to work !

    Best Regards,
    UB

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Smile Out of interest

    Out of interest - I wonder what the requirements would be to get a PC to boot with a PIC attached rather than the actual keyboard. Anyone done this?

Similar Threads

  1. PS/2 keyboard emulation
    By CumQuaT in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 25th September 2009, 04:32
  2. I've made keyboard with pic, but i have a problem.
    By XErTuX in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th November 2008, 00:40
  3. Pic to PC AT keyboard caracters
    By sezgin05 in forum General
    Replies: 5
    Last Post: - 27th March 2007, 10:45
  4. PS/2 mouse and keyboard
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2006, 16:29
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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