24 06 2014
PS/2 Keyboard to MSX with Arduino
I made a project to connect a PS/2 keyboard on MSX.
My first project I used an Arduino UNO to this job, but it was not the best alternative because It has only two external interruption. So, I decided to use an Arduino MEGA 2560. It has 6 external interruption, more than I need.
Why did you choose an Arduino to do this? Because it is inexpensive (about US$ 15,00 on DX) , does not need an circuit programmer and it is easy to program (C++).
The MSXs in Brazil
Here in my land Brazil, there were two MSX manufactures, EPCOM was a Sharp subsidiary and Gradiente the company that registered iPhone trade mark before Apple.
Epcom made two versions of HotBit, the first with case white and the second with case black, and Gradiente made Expert in 4 versions, version 1.0, 1.1 (grey) and Plus and ddPlus (black).
An independent manufacturer made a motherboard actualization to Expert, transforming it in a MSX 2+. See this link.
My project basically works with all these computers, but in Expert Plus and ddPlus, is necessary an update, that I will not do. If someone update my code let me know.
These machines use an 8255 PPI to interfacing a matrix keyboard, as shown in the above diagram.
We need a microcontroler with 8 outputs and 4 inputs to interface with MSX, and more 2 inputs to connect a PS/2 keyboard (data pin and clock pin).
I decided to program two routines that depends on interruptions. The first routine is for PS2 data PIN and the second is for four pins from MSX PPI line selection.
Â PS/2 Read routine:
- Read keyboard buffer (11 bits).
- If is special or releasing key, read the buffer again to get the key code.
- Save the result of the PS/2 key in a matrix of 10 x 8 bits, equal MSX keyboard matrix.
MSX line selection routine:
- Read PINs 18,19, 20 and 21.
- Get the value of keyboard for line matrix and put in output PINs.
This is my MSX with Arduino interconnection.
This is a work in progress project and is not 100% functional, but it works well.
- All normal keys are ok.
- It interprets more than 1 key pressed at same time.
- CAPS Lock LED.
- Scroll Lock and Num Lock LEDs are permanently on.
What does not work?
- Some keys in numerical keypad.
Here is the Arduino code (PS2_MEGA2560)Â and if you have any issue let me know.
Watch out! This code at this time only works with Arduino MEGA.
Here is my video testing the circuit with Hotbit.
Print this PDF (Hotbit and Expert KEYS)Â to replace the keys that is missing in your ABNT keyboard.
To all. Sorry for my poor English.