-
Registered
PIC talking to PS/2 port?
Any one here worked on projects that involve the pic sending keyboard commands to the computer?
I would like to see some code if possible
I want the pic to send numbers to Rhino 3D so I can do some simple 2D digitizing. The numbers will come from rotory encoders with wheels rolling on a X Y plane.
Thanks
-
-
Registered
can you not use the Rs232 interface rather than the AT keyboard. I made benchsaw fence DRO using a couple if pics and the encoders from a mouse had to gear it right down but it worked a treat. there are plenty of microchip programing sites about.
-
Gold Member
Have a look at http://users.picbasic.org/?page=howtolist there are articles on how to talk to pc keyboards, should give you a good starting point.
-
Registered
Good info!! Thanks, as soon as the big proto board gets here will start experimenting.
-
-
Registered
PS/2 Library
mikroBasic provides a library for communicating with common PS/2 keyboard. The library does not utilize interrupts for data retrieval, and requires oscillator clock to be 6MHz and above.
Library Example
This simple example reads values of keys pressed on PS/2 keyboard and sends them via USART.
program ps2_test
dim keydata, special, down as byte
main:
CMCON = $07 ' Disable analog comparators (comment this for P18)
INTCON = 0 ' Disable all interrupts
Ps2_Init(PORTA) ' Init PS/2 Keyboard on PORTA
Delay_ms(100) ' Wait for keyboard to finish
do
if Ps2_Key_Read(keydata, special, down) = 1 then
if (down = 1) and (keydata = 16) then ' Backspace
' ...do something with a backspace...
else
if (down = 1) and (keydata = 13) then ' Enter
Usart_Write(13)
else
if (down = 1) and (special = 0) and (keydata <> 1) then
Usart_Write(keydata)
end if
end if
end if
end if
Delay_ms(10) ' debounce
loop until FALSE
end.
http://www.mikroe.com/en/compilers/ http://www.mikroe.com/en/compilers/
-
Registered
If only send a few keys, you can use a keyborad main board (get from a used keyboard), and connect its circuit with some I/O or some digital chip to do that.
Sorry for my poor English.
Posting Permissions