AT/PS2 Keybord - PIC Interface?


Closed Thread
Results 1 to 40 of 74

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Thanks heaps for that mytekcontrols. I really appreciate it

    Now to go thru all the code and work out what its doing

    I'll let u know how I go.

  2. #2
    mytekcontrols's Avatar
    mytekcontrols Guest


    Did you find this post helpful? Yes | No

    Default

    I hope it all works for you.

    Here are some additional items to note:

    If the code is used "as is" on a PIC18F type chip, then the following equates will probably need to be included:
    Code:
    TMR0IP  VAR INTCON2.2   ' TMR0 overflow interrupt priority bit
    INTEDG2 VAR INTCON2.4   ' External interrupt-2 edge select bit
    INT2IF  VAR INTCON3.1   ' INT2 external interrupt flag
    INT2IE  VAR INTCON3.4   ' INT2 external interrupt enable
    IPEN    VAR RCON.7      ' Interrupt priority enable
    Also if not using priority interrupts (another 18F feature) it will be necessary to change the define from "DEFINE INTLHAND myintL" to "DEFINE INTHAND myintL", and of course some of the following parameters will need to be changed to match your situation:
    Code:
        INTEDG2 = 0             ' INT2 (KBCLK) interrupt on falling edge
        INT2IP = 0              ' INT2 (KBCLK) set as low priority interrupt
        INT2IF = 0              ' INT2 (KBCLK) clear flag
        INT2IE = 1              ' INT2 (KBCLK) interrupt enabled 
    
        IPEN = 1                ' Enable priority levels on interrupts
        INTCON = %11000000      ' Enable all interrupts!

    If you're not using an 18F series PIC, then some of the following might apply:


    In the interrupt routine; there is a syntax problem. Below you will see 2 lines listed. The first is the currently used one in the interrupt routine. The second is the correct one to use on something other then an 18F series device (PIC16..., PIC17...).
    Code:
        rrncf   _KBcode,F       ; shift new bits right (do this only 7 times)
    ;    rrf     _KBcode,F       ; use this instead for non-18F PIC's
    !!! IMPORTANT !!! If you use an input other than INT2 (RB2) as your KBCLK line, be sure to change any INT2IE or INT2IF references in both the interrupt and KBmain routines to match your new assignment.


    Whew!!! I think that pretty much covers it. Good Luck!

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Ok cool. I spotted a couple of them already and changed them to suit a 16F84A, but i missed a couple. Thanks.

  4. #4
    mytekcontrols's Avatar
    mytekcontrols Guest


    Did you find this post helpful? Yes | No

    Question

    Kamikaze47,

    Just out of curiousity, what are you doing that requires a full keyboard instead of something like a keypad?

    Oh, and also just to let you know there are 2 keys that currently will not be decoded properly. The first is the PrntScrn/SysReq key which will put out a "*", and the other is the Pause/Break key which will mimic the NumLock key. I plan to do some more decoding for these, but simply haven't got to it yet. Any improvements you make and/or features you add, please post them here for all to see.

    Thanks,
    Michael

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    At the moment im going to be transmitting the decoded ascii characters over an RF link to another pic which will write them to an LCD screen. I've got the RF part working, so now just need to get the keyboard interface working.

    Another project im thinking of doing with this is a device that goes inbetween your keyboard and your pc which will convert the keyboard to DVORAK. A friend of mine wants to have 2 keyboards on his PC - 1 QWERTY and 1 DVORAK, but the keyboard settings in windows are global so you cant have 2 different keyboard layouts.

    Thanks for your help mytekcontrols. I'm sure this info will be usefull to a number of ppl on these forums.

  6. #6
    mytekcontrols's Avatar
    mytekcontrols Guest


    Did you find this post helpful? Yes | No

    Default

    Kamikaze47:
    At the moment im going to be transmitting the decoded ascii characters over an RF link to another pic which will write them to an LCD screen. I've got the RF part working, so now just need to get the keyboard interface working.
    Sounds like a very interesting project. Is this something you are doing for fun, or do you see it having commercial possiblities? If so, I hope it does well for you.

    Well I put together all the pieces into one file and tested it out stand-alone. And then I pushed the compile button, while remembering that famous Clint Eastwood line "do you feel lucky?". Well I think you can guess the answer to that one. Of course there were a few errors , but nothing too terrible.

    Here is what was missing:

    <img src="http://www.picbasic.co.uk/forum/images/icons/icon2.gif" align="absmiddle"> from the equates:
    Code:
    init var bit            ' flag to use timeout test alternate return path 
    ktable var word         ' translation table index
    <img src="http://www.picbasic.co.uk/forum/images/icons/icon2.gif" align="absmiddle"> and from the PIC18F aliases:
    Code:
    INT2IP  VAR INTCON3.7   ' INT2 external interrupt priority bit
    (I screwed up on this one, and accidentally cut & pasted the wroung item)

    Anyway once I fixed it, everything compiled and ran just fine. Total bytes required = 2626 (wow! pretty interesting result).

    Download the complete and tested file below.
    Attached Files Attached Files
    Last edited by mytekcontrols; - 10th November 2005 at 01:22.

  7. #7
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    cool. thanks.

    i havnt had time to get this running yet, i will work on it over the weekend and see how i go.

    yea im basically just doing it for fun. but there are a couple of projects that i have done in the past that i think would have commercial potential, but i wouldnt know how to go about doing anything about them.

Similar Threads

  1. MXcom "C-BUS" interface to PIC question
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st May 2014, 03:59
  2. Interface a pic with a Iphone/Itouch
    By Luckyborg in forum General
    Replies: 1
    Last Post: - 6th May 2009, 16:02
  3. 4 pin 4 x 4 keypad interface using pic basic pro
    By dunlao_john in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th January 2009, 05:21
  4. USB Interface using PIC
    By Tissy in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 22nd May 2006, 16:04
  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