How to interface PC keyboard to uC...

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
This is the best link I can find...

MCU: PIC18F452
Language: C
schematics: PIC connected to a 7-segment LED (included)
software: included
description: included

http://www.pyroelectro.com/tutorials/ps2_keyboard_interface/index.html

Allen

OK, i have seen that link and understand the process..but what is the use of using buffer..and capture is working?

scan_code_buf[0] = scan_code_buf[1];
scan_code_buf[1] = scan_code_buf[2];
scan_code_buf[2] = scan_code_buf[3];
scan_code_buf[3] = scan_code_buf[4];
scan_code_buf[4] = scan_code_buf[5];
scan_code_buf[5] = scan_code_buf[6];
scan_code_buf[6] = scan_code_buf[7];
 

David_Baratheon

Joined Feb 10, 2012
285
It looks like you are trying to use an RS232 serial data link. A UART/USART.

Are you supposed to programme it in C or Assembley?

I presume this is for a university project?

The baud rate will be 9600 to answer your question

Does it have to be a software or hardware UART?

I had to do the same project and also I use the same PIC your using on a 44 pin demo board
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi again,

i am using this code for display keyboard char to terminal window at show 'k' as per testing serial comm. after that 0xFB is coming cont pressing keyboard is doing nothing,why???
 

Attachments

t06afre

Joined May 11, 2009
5,934
Where did you get this code Ritesh? Some link to the site you took this code from would be useful. As I doubt you have written this by your self
 

atferrari

Joined Jan 6, 2004
4,764
Hola RRITESH,

I see that for every new subject you start dealing with, you start as well a long thread of serial questions that, I have to tell you, shows that you do not read in detail whatever info is available.

I taught my micro 18F4520, starting from zero knowledge in this matter, to communicate with an optical mouse. As me, many before, let me tell you, did it with success.

Sure I look rude but you are lazy and insist in showing that. Instead of thinking and trying to understand info available in the Web, which by now, is a LOT, you come to the forums and shot a question. And another. And another...with no end.

That is horrible. I am convinced that you do not want really learn things.

I've reread many of your questions in your posts. You are not refraining yourself of that impulsive posing of question that could be replaced by judicious testing and attentive reading.

Do you know what testing a design is? Just noticing that it doesn't work as expected and then immediately running to post asking why?

This post is long, I know. Do not worry, I am not going to be in your way again as I never was in the past. For sure.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Where did you get this code Ritesh? Some link to the site you took this code from would be useful. As I doubt you have written this by your self
Here it is i searched for 0xFB it is used for 0xfb Set a single key to repeat.
one more question we receive data from keyboard can we send data also to keyboard but what the use of sending data to keyboard from PC, i am confused with tutoial.
 

John P

Joined Oct 14, 2008
2,025
I wish I could disagree with Atferrari, but alas, I cannot. Rritesh, you do have a terrible habit of asking endless questions here rather than doing any research of your own, and then not responding to the suggestions you get.

In the case of the reference you gave, almost the first thing I saw when I looked there was "Furthermore, the keyboard interface allows bidirectional data transfers so the host device can illuminate state LEDs on the Keyboard."

Here at Allaboutcircuits, you're asking "what the use of sending data to keyboard from PC". So now I have to wonder, is this a guy who reads his reference material, or is he someone who just won't do any work? And if he asks for help, do I want to offer any?
 

Eric007

Joined Aug 5, 2011
1,158
Rritesh does not have the spirit of an engineer but that of a *technician* who wants to get the job done without necessarily understanding what is going on...

Maybe He just want it done just to get paid or...I might be wrong but I'm surprised to see that after so many projects he has discussed he still hasn't matured yet!

I would understand when discussing your very first projects, like first 3 - 5 projects, but after that and with all the guidance, approaches provided here on this forum...you should have matured by now and know how to tackle projects!

Looks to me like you still don't know how to approach design, break it down, do researches, reading datasheets, ..., and use common sense!

You are really terrible! and what makes you terrible is the way you put it on the forum...If I have to discuss something here, that I am not familiar with, people will tell that I've thought about it for long and have done some high level design breakdown, have done proper researches and they will be willing to put me in the right direction...

And I told you that before that the *way* you ask questions put people off...

Anyways, all I'm trying to say is you need to improve on your way of doing things when it comes to engineering...

Like me right now I busy reading books to get basic concepts right and datasheets so when I come here I don't get shouted by big boys here :) ! it has happened before...but I was still very new...but you are nomore a newbie Rritesh, huh!

Anyway All the best!:)
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
0xFB Scancode for key Set specific key to typematic/autorepeat only (scancode set 3 only)
but when i press any key then also it does not change why??
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
I have noticed one thing the uc is sending cont 0XFB ...
just for checking i have disconnected the Vcc from PS/2 and some time shorted the Data with gnd for testing to see some changes on terminal wind but nothing happen don't know why??

i think some problem is here it is not updating scan code from keyboard.

Rich (BB code):
while(1)  
  {       ch=Scan_Data; 
 Hserout( ch);
 __delay_ms(1000);  
 ch=0;          
 Capture_init();//Initialise once again for next capture   
   }

The problem is something else i have disconnected 3 wires from ps/2 to uC then also FB is coming cont...
 
Last edited:

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
HI,

i have noticed in this many problem i have wasted time on it here is some:

const unsigned char Key[]={"0F FFFFF FFFFt` as cQ1 ZSAW2 CXDE43 VFTR5 NBHGY6 MJU78 ,KIO09 ./L;P- ' [=\\"};
some other also....
any way the is not working at all..
I have just connected my serial to USB RS232 and watching whether PS/2 is working yes it is working.
on giving supply all 3 led blink and pressing key give serial output i don't have oscilloscope so, after changing baund rate data also changing....
 

t06afre

Joined May 11, 2009
5,934
A thing I am puzzled about. The PS2 Keyboard communication uses a synchronous serial protocol. And hence the PIC UART should be set to work in synchronous mode, with the keyboard providing the master clock. Are you using the PIC UART in synchronous mode?
 
Top