Using PC PS/2 keyboards (5V) with 3.3V FPGAs and microcontrollers

546 views
Skip to first unread message

Nigel Kendrick

unread,
Oct 1, 2019, 11:36:04 PM10/1/19
to retro-comp
Hi folks,

I am working on a circuit based on a 3.3V FPGA (not 5V tolerant) with a PS/2 keyboard, which officially runs on 5V. Various designs (eg: Grant's Multicomp) just hook the keyboard up to 3.3V, and I have read that this works sometimes (mostly?), depending on the keyboard.

Since the keyboard is (supposed?) to have open collector data and clock pins, I was thinking about powering it from 5V and putting external pullups to 3.3V, but my experiments with the only PS/2 keyboard I have to hand right now suggest that it has internal pullups - so that option is a no-go unless the keyboard is modified, which is doable but not ideal, especially if keyboards could be swapped around.

There's always the option of using bi-directional level shifters or some form of clamping. While I gather the main parts, and some more keyboards (including ones with USB-PS/2 adapters), to do further testing, I'd appreciate any insight from people who've 'been there, done that'.

Thanks

Nigel Kendrick

Alan Cox

unread,
Oct 2, 2019, 8:46:10 AM10/2/19
to retro-comp
Since the keyboard is (supposed?) to have open collector data and clock pins, I was thinking about powering it from 5V and putting external pullups to 3.3V, but my experiments with the only PS/2 keyboard I have to hand right now suggest that it has internal pullups - so that option is a no-go unless the keyboard is modified, which is doable but not ideal, especially if keyboards could be swapped around.

PS/2 keyboards are supposed to have the pull-ups internally. Some even have it in the keyboard IC.

Have you tried simply running a PS/2 keyboard at 3.3v ?

Alan

Duncan Reed

unread,
Oct 2, 2019, 9:57:59 AM10/2/19
to retro-comp

I am also running a keyboard off 3.3v. To be precise it is a USB keyboard, into a ps/2 adaptor, plugged into a PS2 FPGA PMOD supplying 3.3v. And it works fine with a Spartan 6 FPGA.

Nigel Kendrick

unread,
Oct 2, 2019, 10:18:22 AM10/2/19
to retro-comp
Hi Alan,

Thanks for the reply.

it's early days - I don't have the FPGA boards yet hence the info gathering and basic testing.

Nigel

Nigel Kendrick

unread,
Oct 2, 2019, 10:19:42 AM10/2/19
to retro-comp
Thanks Duncan,

Sounds like the 5V Vs 3.3V thing may be a non-issue with most keyboards.

Nigel

Mark T

unread,
Oct 2, 2019, 10:26:01 AM10/2/19
to retro-comp
I think one thing to watch out for is that not all usb keyboards include the ps/2 interface so maybe check the spec of the keyboard you plan to use.

Mark

Richard Lewis

unread,
Oct 2, 2019, 2:17:21 PM10/2/19
to retro-comp
A while back I interfaced a PS/2 keyboard with ZYNQ FPGA board. The PS/2 interface is essentially an open-collector I2C interface so needed to provide pull-ups on the data and clk lines as well as series resistors as line terminators. The keyboard I was using was a cheap one I got off of Amazon and was able to drive it at 3.3V. 

There are plenty of adapters available that will convert the PS2 I2C into TTL serial such as this one: PS2 Keyboard Driver Module which will power the keyboard at 5V and provide a UART output. 

-Richards

Mark T

unread,
Oct 2, 2019, 5:09:19 PM10/2/19
to retro-comp
I was thinking it might be possible to interface a ps2 keyboard to appear as an 8 by 8 matrix to a micro that could be mapped to the original matrix of a Sord M5, ZX81 etc, This could then allow a ps2 keyboard to be used with original software of the target machine.

I have seen similar interface using a micro and analog switch matrix, but using a cpld would avoid the use of a modern micro and puts it in a single chip.

I mapped the pins of the EPM7128S and found it just about fits, at 98% usage of the macrocells. This required adjusting the pinouts of my CPLD SD card board to avoid more than 3 data lines in any one LAB.

Changes to the key matrix map could possibly result in the design failing to compile.

Quartus project and vhdl on github if anyone is interested in playing with this. I may get around to testing it one day.

Mark
Reply all
Reply to author
Forward
0 new messages