Open Harvie opened 4 years ago
1.) The voltage levels:
According to https://en.wikipedia.org/wiki/PS/2_port the PS2 communication is 5V.
You can buy bidirectional level converters like this:
Or make one yourself. It's just one transistor per channel, quite simple and elegant. I am not sure how it works in PS2 scenario, where we sometimes drive hard and sometimes just provide pullup. Probably you might need to add some series resistor to protect the lines from being driven too hard by the transistor.
2.) I am not sure about LED bitmap. I was trying to google this and i wasn't really successful. However this is probably easy to determine by simple test. If you figure out which bit is which LED, please let me know, so we can add it to the README doc.
3.) Tip jar will be hopefully available in a week or so at this URL: https://github.com/sponsors/Harvie
Some fun fact finding on my part! First, the 3.3v output of my Arduino was not a problem at all! Further, my PS/2 ports happily power a MCU and USB keyboard. Finally, my SGI Octane is "stricter" than my Dell. After enabling the serial debug prompt in the core library, I found that ps2dev was shouting into a void waiting to be acknowledged.
Happily, I was able to quickly get around this. I added two commands before the "0xAA" loop, these request PS/2 port enables:
@@ -227,6 +227,8 @@ int PS2dev::read(unsigned char * value)
void PS2dev::keyboard_init()
{
+ write(0xAE);
+ write(0xA8);
while(write(0xAA)!=0);
delay(10);
return;
Once I did that, I was able to get my keyboard recognized & log in to my system! Now I have to bother coding up the signals for my USB translator past Alpha, Space, Period and Enter. :D As you might guess, the older system doesn't have a very complex password.
References: SGI PCKeyboardDoc - http://nixdoc.net/man-pages/IRIX/man7/pckeyboard.7.html FlingOS Keyboard Doc - http://www.flingos.co.uk/docs/reference/PS2-Keyboards/
So as a summary on this "issue" so far:
3.3v I/O works, so long as you won't fry your MCU
If 3.3V is enough, but you are afraid about damaging the MCU, then you can just put 1K resistors in series between the 3.3V and 5V device. That should provide enough protection.
You can also check if the datasheet of your MCU says that some of the pins are "5V tolerant". In such case the pin will output 3.3V, but will handle 5V input.
I added two commands before the "0xAA" loop,
Interresting! Can you please confirm this modification does not break compatibility with other computers? If everything is OK i will add this.
Also please take a look at #8 ... There is similar issue where we probably divert from PS2 specs i plan to fix this as well, but didn't had time yet to do the tests...
Forwarded email from @j-whitehouse:
Hi there, I hope this finds you in good health!
In these gloomy times, I have been working on an active USB HID <> PS/2 converter for an old computer without USB. The passive converters won't work with modern keyboards & wireless receivers. I found your extensions to the ps2dev library super helpful, and have been using this version. Thank you for your work on it.
If it's not too much to ask, I do have a couple quick questions. First, it looks like the LED masks are 0/1/2 for scroll, number; caps locks. Should that work with a binary comparison? Didn't see it noted, but need to catch it for the USB keyboard. Second, I'm using a basic atsamd21 MCU with the regular 3.3v logic in/out. With one PC (Dell T3600), this works great through some 220ohm resistors. With another (SGI Octane), it won't register. Now, it could be all sorts of stuff, but I was wondering if you had any resources on the hardware set up that's best for PS/2?
Also, I was wondering if you have a 'tip jar' set up through one of those online thingummers? In the spirit of buying you a beer for finding this useful.