Page 1 of 1

Ps/2 Protocol for teensy?

Posted: 26 Feb 2015, 22:00
by baked_cake
Hello again. Ive been playing around with my teensy++ 2.0 for bit now, modifying some ergodox code to customize my keyboard, and now I'm ready for the next step. Has any one created ps/2 support for the teensy? As in, I can wire up a ps/2 plug to the pins, patch in some ps/2 protocol to the ergodox source, and use my keyboard as a ps/2 keyboard.

Ideally, I would like to either wire it up to have both usb and ps/2 cables, or just a use a ps/2 adapter on the usb cable.

Posted: 26 Feb 2015, 22:35
by Findecanor
I don't know if anyone has made specifically a Teensy a PS/2 client, but there are keyboards with the ATmega32A running the PS2AVR firmware which talks PS/2. I don't think it would be too difficult to make the ATmega32U4 of the Teensy 2.0 run it, as those microcontrollers are quite similar. The ATmega32U4 has USB hardware where as the other µC does not.
There are USB versions of the PS2AVR that bit-bangs the USB data lines directly instead of going through hardware - I don't know if they support both protocols or not though.

Posted: 26 Feb 2015, 23:36
by baked_cake
awesome! this might be just what i was looking for, thanks for the help.

Posted: 26 Feb 2015, 23:48
by wheybags
Why do you want a ps/2 ergodox? O.o

Posted: 26 Feb 2015, 23:59
by andrewjoy
has a PC without USB ?

Posted: 27 Feb 2015, 00:31
by Findecanor
PS/2 is faster than USB, but only in the best case. However, debouncing and other lag in the system is much longer so the extra speed is not that significant.

Posted: 27 Feb 2015, 01:38
by Muirium
PS/2 is easier to get your head around. USB HID is likely to be the most complex wired protocol ever used with keyboards. But it's USB so it won. Bluetooth may be more complex still, in the wireless realm. But I'm not going into that spooky house before you guys!

Posted: 27 Feb 2015, 20:26
by flabbergast
Here: http://dkudrow.blogspot.co.uk/2013/08/p ... o-uno.html is a code for arduino that can emulate a PS/2 device. He also writes about the PS/2 protocol a little - might be interesting to understand what's going on. Translating arduino code to pure avr-gcc code is usually not too difficult, but requires some work (generally just unwrap C++ classes to pure C functions, and replacements of pinMode, digitalWrite, delayMicroseconds by the appropriate avr-gcc code).

Posted: 27 Feb 2015, 22:45
by baked_cake
Nice flabbergast, thanks for the link. I mostly just want my keyboard to be able to work as both a ps/2 device and a usb device. I have a ps/2 kvm switch that I'm thinking about modifying to have a usb for the mouse, and ps/2 for the keyboard.

I'm not quite sure which I prefer, ps/2 has some advantages, though my keyboards debounce is set at 15ms, so that might not be such an advantage. The kvm switch at least allows me to hot swap it around a bit so that takes care of one of the major drawbacks.