Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Need advise] would my idea work? PIC uC simulate keyboard

Status
Not open for further replies.

Angie_MY

Junior Member level 1
Junior Member level 1
Joined
Oct 10, 2007
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
well, i am trying to build a system that simulate the keyboard input.

PIC microcontroller --> P/2 port --> computer

i searched thought the internet, and i found this
it take input from keyboard and output to RS232.
https://www.electronic-engineering.ch/microchip/projects/keyboard/v1xx/keyboard_v1xx.html

i am thinking to reserve the process, microcontroller output the keyboard signal (microcontroller simulate as keyboard.)

that page i mentioned above, show that,

The keyboard is free to send data to the host when both KBD data and KBD clock lines are high (idle). The serial clock is generated by the keyboard.

The transmission of data in the forward direction, i.e. keyboard to host, is done with a frame of 11 bits. The first bit is a start bit (logic 0) followed by 8 data bits (LSB first), one parity bit (odd parity) and a stop bit (logic 1). Each bit has to be read on the falling edge of the clock.

kbd2host.gif


therefore, i am thinking to do like this

keyboard clock ==> PORTA, 1
keyboard signal ==> PORTA, 2

bsf PORTA, 1 ; GENERATE THE CLOCK (RAISING EGDE)

bsf PORTA, 2
or ; EITHER WILL GENERATE THE SIGNAL 0 OR 1
bcf PORTA, 2

bcf PORTA, 1 ; GENERATE THE CLOCK (FALLING EGDE)

this will repeat continuous to send signal to computer.

would my idea work?
how fast should i set to send the signal?


Thanks.

i am very new to microcontroller, please guide me

thanks.

Added after 3 hours 40 minutes:

anyone,..?
please advise me ...
 

Yeah that is quite possible, but I don't think you want to use anything to do with RS232. You correctly identified that you need to generate a clock and data to go with it - at 5V logic levels. I've written code that reads from a keyboard, so I'd imagine it'd be just as easy to write some code that writes to a pc (as if it is a keyboard) - especially if you only want a VERY simple interface - then it could be very easy to do.

There is a very comprehensive specification of keyboard comms here:
**broken link removed**

and included in there is a list of scan codes:
**broken link removed**

that should get you started =) Good luck!
 

    Angie_MY

    Points: 2
    Helpful Answer Positive Rating
Re: [Need advise] would my idea work? PIC uC simulate keyboa

I am also looking for a project simply based on ATMEL 8051 + PS2 keyboard which when any button pressed accessed by atmel and show on LCD or 7 Segments.

regards
 

Hi sn_burki. I have some code written for the PIC which does this if you are interested... I must say my documentation isn't very good, so it probably would be difficult to read, but if you are stuck it could be a help?

ps - check out the links I posted in my previous post - I used the information in them to design my code.
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

Thank you BoBtHePlUmBeR for you respose, I would like you to help in this regards, please upload you codes or pm me. If you have same code for atmel then please send me.
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

i try to do what i mentioned above, but obviously, it doesn't work..

i posted the code here.

anyone could advise me..?
 

by the way, i use single core cable to connect them. would this affect them?
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

OK, well it looks like several people are interested in some code. Here is some C source (written for hitech picc) that I'm using. It uses a polling function called 'RunKeyboardHandler' to capture data from the keyboard, then uses handlers to determine if a key was pressed / released and then another handler to determine what key was presse from the scan code (it is never as easy as scancode = ascii...)

Some parts have comments some don't. I'm sorry I'm a bit busy at the moment, so I'll post code and if you have any q's I'll try to get back to you.
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

Angie_MY said:
by the way, i use single core cable to connect them. would this affect them?

Hi Angie_MY, all you have to have (if you just want to read data from keyboard) is:

Pin1 - Clock - Connected to an input on your micro with a pullup resistor to 5V (10K)

Pin 2 - Data - Connected to another input on your micro with a pullup resistor to 5V (10K)

Pin 3 - Not Connected

Pin 4 - Ground

Pin 5 - 5V

and that's it! If you have the supply hooked up correctly you should see the caps/num/scroll lock light flash when you turn power on to the board (regardless of data / clock connections).

Does that help?
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

BoBtHePlUmBeR said:
Angie_MY said:
by the way, i use single core cable to connect them. would this affect them?

Hi Angie_MY, all you have to have (if you just want to read data from keyboard) is:

Pin1 - Clock - Connected to an input on your micro with a pullup resistor to 5V (10K)

Pin 2 - Data - Connected to another input on your micro with a pullup resistor to 5V (10K)

Pin 3 - Not Connected

Pin 4 - Ground

Pin 5 - 5V

and that's it! If you have the supply hooked up correctly you should see the caps/num/scroll lock light flash when you turn power on to the board (regardless of data / clock connections).

Does that help?


well, i am not reading signal from keyboard, instead, i am using PIC microcontroller to simulate keyboard signal to computer..

when i plug the ps2 to computer, the pic microcontroller was running (as the led flashing, as i wrote the code to flash the led while sending the signal)

but computer dont give me any respond..

what make me fail for the computer read my microcontroller signal...??:cry:
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

Angie_MY said:
what make me fail for the computer read my microcontroller signal...??:cry:

OK, well if you are sending data to the PC, then you should be using something like an open collector circuit to interface between your computer and microcontroller. Each signal should have a weak pullup resistor and the microcontroller should turn on an NPN transistor, which will short the signal to ground (when active). Directly connecting micro pins could cause your microor PC harm.

Lets see if we can get your communication working by starting with an arbitrary value. Lets say you want the computer to think you've pressed the letter 'a'. What data would you send the computer?

You would send 0x1C (make) followed by 0xF0 0x1C (break) but don't forget to add the even parity! So we'd get...

000111000 111100001 000111000

send that and you should get a letter a appearing on your screen.
 

Re: [Need advise] would my idea work? PIC uC simulate keyboa

BoBtHePlUmBeR said:
Angie_MY said:
what make me fail for the computer read my microcontroller signal...??:cry:

OK, well if you are sending data to the PC, then you should be using something like an open collector circuit to interface between your computer and microcontroller. Each signal should have a weak pullup resistor and the microcontroller should turn on an NPN transistor, which will short the signal to ground (when active). Directly connecting micro pins could cause your microor PC harm.

Lets see if we can get your communication working by starting with an arbitrary value. Lets say you want the computer to think you've pressed the letter 'a'. What data would you send the computer?

You would send 0x1C (make) followed by 0xF0 0x1C (break) but don't forget to add the even parity! So we'd get...

000111000 111100001 000111000

send that and you should get a letter a appearing on your screen.

thanks.
i will try out tonight..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top