Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 27, 2024, 03:01:39 15:01


Login with username, password and session length


Pages: [1]
Print
Author Topic: PS2 keyboard interface with PIC 16f877A  (Read 12781 times)
0 Members and 1 Guest are viewing this topic.
chithanh04dt2
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


« on: December 14, 2008, 05:53:56 17:53 »

Hello everyone.
i'm building project with ps2 keyboard. i'm using flowcode to programming ps2 keyboard interface with 16f877a, then display character on LCD. But i have some error when pic 16f877a receive data, when i press "A" on keyboard, LCD display "L".  Embarrassed Embarrassed
Sorry for my Englis.
Thanks.
Logged

Sorry for my English.
Regard !
h96089
Inactive

Offline Offline

Posts: 4

Thank You
-Given: 0
-Receive: 2


« Reply #1 on: January 15, 2009, 05:55:51 05:55 »

i have deal with ps2 computer pheripheral last time in my final year project. I wish to check your code for error, but i cant read your asm code properly. Can you upload your assembly code with text file format. By the way, from direct inspection of the error that you show to me, i think you most likely are having error in look up table pointer, which means that your controller do accept the correct keyboard signal, but in the process to map it to the actual display character, your code some how map it wrongly.
Logged
kayvee
Active Member
***
Offline Offline

Posts: 172

Thank You
-Given: 98
-Receive: 101


« Reply #2 on: January 19, 2009, 01:05:13 13:05 »

I find it useful in this type of project where you are attempting to track down a problematic section of code, is to include some simple debug routines and hardware.  On that device it is a simple matter to add a debug routine to intercept the data from your keyboard routine and transmit it out with the onboard hardware UART via a MAX232 to your PC com port.  I normally have a MAX232 board lying around which I can tack on in the event that it's needed.  This way you can isolate where the problem lies.

Are you receiving and displaying other keypresses correctly, by the way?
Logged
sukumar
Junior Member
**
Offline Offline

Posts: 38

Thank You
-Given: 5
-Receive: 47


« Reply #3 on: February 06, 2009, 06:32:50 06:32 »

Hi all,

      Interfacing PS2 keyboard is not that much difficult. Here is the algorithm,

        1. Store the PS2 keyboards "key values" in a array.
        2. Initialise the capture module for every falling edge....capture pin sholud be connected to CLK(not data).
        3. Wait for the first falling edge by polling CCPxIF for 1 and clear interrupt flag
        4. detect the next falling edge and read the data from the data pin.....collect it in a variable
        5. Disable capture
        6. wait for 40ms
        7. process the data......suppose the data is 20---read the character from 19th position of the array.       

note:
This is algorithm for all the languages...you can directly write assembly,c codes by using this algorithm

Regards,
sukumar
Logged

Regards,
M.Sukumar
Never say No
chithanh04dt2
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


« Reply #4 on: February 18, 2009, 03:39:03 03:39 »

Ok, thanhk all member for your help.
My project was successfully
Logged

Sorry for my English.
Regard !
kayvee
Active Member
***
Offline Offline

Posts: 172

Thank You
-Given: 98
-Receive: 101


« Reply #5 on: February 18, 2009, 07:20:44 07:20 »

Ok, thanhk all member for your help.
My project was successfully

That is good news, chithanh04dt2, good job.

Can you tell us what the problem was, how you resolved it, etc.  It may be useful to someone else too.

Logged
newboy
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 42
-Receive: 20


« Reply #6 on: February 18, 2009, 09:01:28 09:01 »

Ok, thanhk all member for your help.
My project was successfully

Can you share this succesfull project with us Smiley

I like to make it. Hope you dont mind to share it.

Thanks
Logged
DarthPic
V.I.P
Junior Member
*****
Offline Offline

Posts: 71

Thank You
-Given: 720
-Receive: 74



« Reply #7 on: February 18, 2009, 09:44:09 09:44 »

Hi everyone  Wink

I have done a similar project in Jan-09 for my robot and it work well.
The source are attached to the post.
Just the German keyboard Layout is done , for the English and French ASCII code
you have just to modify them in the keyboard.h file.(ATM it's a copy/paste from the German one)
That is coded in C with CCS for a little PIC16F688  Grin
It use only a little part of the cpu flash , so you can add other country kb
without problem in extending the keyboard.h file if needed.
The file name say "USB_Keyboard_16F688" but it's for PS2 too.

Regards.

PS : sorry for my English  Smiley
Logged

Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why Wink ...
chithanh04dt2
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


« Reply #8 on: February 23, 2009, 03:15:29 15:15 »

   Actually my program very nice, i had a mistake between Keyboard PS2 code and ASCII code, so have differrent when i press key on the keyboard and then print it on LCD.

I use crystal 20MHz, adding Look up Table (LUT)

@newboy.

It very easy to make, see post's sukumar and other, me too.

Sorry for my English.
« Last Edit: February 23, 2009, 03:19:30 15:19 by chithanh04dt2 » Logged

Sorry for my English.
Regard !
mr_byte31
Hero Member
*****
Offline Offline

Posts: 600

Thank You
-Given: 75
-Receive: 144



« Reply #9 on: March 02, 2009, 12:49:20 00:49 »

look you can use mukroC it contains lib for ps2 as i think
try it
Logged

Do not trifle with the Moderators , as you are small, and crunchy, and taste good with ketchup.
DarthPic
V.I.P
Junior Member
*****
Offline Offline

Posts: 71

Thank You
-Given: 720
-Receive: 74



« Reply #10 on: March 02, 2009, 01:22:27 13:22 »

@ chithanh04dt2

I have get the same strange PS2 -> ASCII when i have start my project.
That is a relevant error , it depend if your rs232 data are normal or inverted.
For use one of the rs232 mode i have add a extra rs232 setup in my code .
Then i just comment or uncomment the setup i need ...

Here the rs232 setup from my project coded with CCS C:

for invert mode i do ...

Code:
//#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5, FORCE_SW, BITS=8, STOP=1, PARITY=N)
#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5, FORCE_SW, BITS=8, STOP=1, PARITY=N, INVERT)

for normal mode i do ...

Code:
#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5, FORCE_SW, BITS=8, STOP=1, PARITY=N)
//#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5, FORCE_SW, BITS=8, STOP=1, PARITY=N, INVERT)

I hope it will resolve your problem  Grin

Logged

Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why Wink ...
chithanh04dt2
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


« Reply #11 on: March 06, 2009, 04:47:08 04:47 »

Thank DarthPic, but my project was finished ago one month.
Your way is nice,
Logged

Sorry for my English.
Regard !
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC