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.
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.
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.
Good info!! Thanks, as soon as the big proto board gets here will start experimenting.
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.
This simple example reads values of keys pressed on PS/2 keyboard and sends them via USART.
dim keydata, special, down as byte
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
if Ps2_Key_Read(keydata, special, down) = 1 then
if (down = 1) and (keydata = 16) then ' Backspace
' ...do something with a backspace...
if (down = 1) and (keydata = 13) then ' Enter
if (down = 1) and (special = 0) and (keydata <> 1) then
Delay_ms(10) ' debounce
loop until FALSE
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.