The Godfather talking
You can run, but you can't hide.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2016, 01:27:45 13:27


Login with username, password and session length


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

Posts: 63

Thank You
-Given: 97
-Receive: 9


« on: December 14, 2008, 06:53:56 18: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, 06:55:51 06: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
***
Online Online

Posts: 145

Thank You
-Given: 81
-Receive: 90


« Reply #2 on: January 19, 2009, 02:05:13 14: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
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 5
-Receive: 37


« Reply #3 on: February 06, 2009, 07:32:50 07: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
**
 Muted
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


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

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

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

Posts: 145

Thank You
-Given: 81
-Receive: 90


« Reply #5 on: February 18, 2009, 08:20:44 08: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
**
 Muted
Offline Offline

Posts: 94

Thank You
-Given: 42
-Receive: 20


« Reply #6 on: February 18, 2009, 10:01:28 10: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
Junior Member
**
Offline Offline

Posts: 54

Thank You
-Given: 453
-Receive: 55



« Reply #7 on: February 18, 2009, 10:44:09 10: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
**
 Muted
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


« Reply #8 on: February 23, 2009, 04:15:29 16: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, 04:19:30 16:19 by chithanh04dt2 » Logged

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

Posts: 544

Thank You
-Given: 49
-Receive: 144



« Reply #9 on: March 02, 2009, 01:49:20 01: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
Junior Member
**
Offline Offline

Posts: 54

Thank You
-Given: 453
-Receive: 55



« Reply #10 on: March 02, 2009, 02:22:27 14: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
**
 Muted
Offline Offline

Posts: 63

Thank You
-Given: 97
-Receive: 9


« Reply #11 on: March 06, 2009, 05:47:08 05: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