1.17.2013

ATmega644 Breakout Board


So I realize that it has been a while since I last posted. Lets just say life got in the way lol. Anyway I'm trying to get back to the Arduino Compatible Keyboard.

I've decided to use the ATmega644 microcontroller (the same as the Sanguino, but I plan to use the smaller TQFP package) as the brains of my keyboard. This microcontroller was chosen for a couple of reasons. First it has enough on board memory for the job. Second it has enough pins to read all the keyboard inputs, control the status LEDs on the keyboard and send all of the information over a serial link. Thirdly I have the option of loading the Sanguino bootloader onto the chip if I feel like getting fancy.

That last point about the bootloader brings me to my next topic. So far my experience with the ATmega644 has only been with the bootloader pre-installed, meaning that I have not programmed this particular chip in exclusively assembly before. Realizing this I decided that it would be a good idea to 'test-drive' the microcontroller before throwing it in a keyboard and bashing out a whole pile of assembly. Unfortunately the TQFP package is not breadboard compatible. To get two birds with one stone I decided that the first PCB I design will be a breakout board for the ATmega that would allow it to straddle a double breadboard nicely.

I used EAGLE to create the following schematic and board layout for the breakout board.




I plan to simply order this PCB from a board house (haven't decided which one yet) as I am not anywhere near equipped to make this in my apartment (yet). This board has more or less what I call the bare basics to get this chip up and running in a smooth manner. S1 is a reset button to reset the chip. There is a 10-pin programming header on the board for easy access with the Atmel programmer. A 16Mhz clock is also present. There is no voltage regulator on-board as it is meant to be plugged into a breadboard and an assumption is made that regulated 5VDC will be available through the VCC pin. The rest of the pins are simply the pins of ports A through D of the ATmega for easy breadboard access.

9.29.2012

Arduino Compatible Keyboard: Introduction

I've always wanted to be able to add keyboard input to an Arduino, or in my case a Sanguino (the Arduino's big brother). Because a keyboard is a serial (whether it be USB or otherwise) device, very few pins would be required from the Arduino to communicate with the keyboard. This would increase the number of inputs to the Arduino many times over, allow the user to enter strings, or simply add a familiar input device to your project.

So my plan is to convert an old and otherwise broken USB keyboard into a TTL serial device to easily communicate with it. This will require removing and replacing the controller in the keyboard with a TTL controller that I can program myself. I will have to make a PCB to suit the new controller. Next I will write a library to allow the Arduino to interact with the keyboard. I've never done some of these things, such as making a PCB, so this will be a learning experience for me as well.

The Keyboard
The Keyboard: Doesn't work when plugged into a computer and is missing a button.

To get the ball rolling I will take the back off of the keyboard, showing and explaining as much as I can about the workings of a keyboard for those that may be interested.

 First thing noticed after taking the back off is the array of seemingly random input contacts.
 Once the two layers of plastic containing the contacts are removed we see the rubber "springs" which allow the button to return to its normal state after pressing it. In this particular keyboard the springs are not fixed to the keyboard chassis. When I removed the contacts a couple of them decided to run across the table.
 So here is a closer look at the two sheets of contacts. The lower sheet in this picture has the contacts slightly set into the plastic. This ensures that if there is no pressure on the contacts they will be separated by the thickness of the plastic. When a button is pressed and the rubber spring touches the contacts, the plastic is flexed which allows for a connection to be made.










To explain the actual mechanism that the keyboard uses to tell which key is pressed I will use a simplified diagram of the keyboard array. Imagine only the numpad on the keyboard, specifically only the numbers, excluding zero. We have a 3x3 array of numbers:

7 - 8 - 9
|    |    |
4 - 5 - 6
|    |    |
1 - 2 - 3

If all of the columns are connected with their own wire and all of the rows connected with their own wire we get an array of connections, or contacts. Now to read this simple input pad a controller has to have at least three output and three inputs. This would be the set up: the three inputs would be attached to the columns (or rows) and the three outputs would be attached to the rows (or columns).

To read this input device and determine which button is pressed the controller would have to run through this sequence. First a row (row 0 say) would be powered by the output pin, then the controller would check each of the input pins to see if any of them were "active". Then the next row would be checked and so forth. For example say the number 6 was pressed, the controller would make its way through the sequence to row 1 (second row) and check the inputs. It would find that the third input (input 2) is active. The controller would then use the information of which output and input were active to determine which button was pressed.

For a small 3x3 grid it is hard to see the advantage of doing something complicated when there are only 9 inputs. Even with this small example though the advantage is that only 6 pins were used to access 9 inputs. Imagine for a 4x4 grid, only 8 pins needed to access 16 inputs. Not bad.

This is in fact the same mechanism used in a keyboard, just on a much larger scale and not in such a nice square arrangement. Instead the rows and columns are skewed to make the keyboard layout that we are all familiar with.

I'm not sure when but I hope to purchase the controller for the inside of the keyboard soon and start playing around with it. I will keep you all posted!

That's all I have for today. Please feel free to leave comments / suggestions.