A Project by:
Ran Postar & Yosi Turevich
This is a project in Prof. Sivan Toledo's Embedded course in Tel-Aviv University. Our Project goal is to make a wireless connector for a ps2 keyboard.
To achieve our goal we used two Tmote Sky boards running Contiki os. One of them has a ps2 keyboard connect to it, through a ps2 connector welded to it's expansion ports, And the other is connected to the PC.
You can type on the keyboard, and it will be written on the PC screen(need to login to the other Tmote Sky).
The first step was to connect a keyboard to a Tmote Sky board and see if we can power the keyboard through the Tmote Sky. The first expected problem was that the Tmote Sky board run on 3v (2 AA batteries) and ps2 keyboard uses 5v (the standard volt of a ps2 connector). As expected the keyboard didn't work with 3v.
So, our next step was to build a voltage doubler. We decided to use Dickson charge pump, this voltage doubler requires a clock signal. There for, we programmed the mps430 to output TimerA to GIO1 and from there to expansion pin 7. Our design was base on a 3v clock signal, however, the TimerA clock signal was 1v to our surprise. We managed to amplify the voltage to 4v(we checked before that the keyboard works with 4v), however, the keyboard didn't work - it started for a second and then shutdown. We guess that there were too much Fluctuation in the voltage for the keyboard micro controller.
In the end we decided to power the keyboard and the Tmote Sky with the PC USB port. Another solution is just to add one more AA battery.
Now that we powered up the keyboard we needed to connect the data and the clock signals to the Tmote Sky.
As can be seen in the picture we connected the clock signal to expansion U26 pin 2(GPIO2) which is pin2.3, And the data signal to expansion U2 pin 2 (UART0RX) which is pin3.5.
The second step was to generate interrupt when the clocks signal change, so we can sample the data signal in each interrupt. In contiki there is a package of sensors (like the button_sensor) and we added our sensor for the keyboard (keyboard_sensor). Another problem that we encountered is that our keyboard_sensor irq function was running in a slow rate. After some debug we understood that contiki run all the sensors irq function one after the other in each interrupt, And in the button_sensor irq was a wait function which delayed the keyboard interrupts.
Our solution was to remove the button_sensor from the loaded sensors (it is loaded by default).
The next step was to read the data signal in each interrupt and translate it.
At first our translation code was in the irq function, however, after some debugging we realized that it took too much time and we were missing interrupts. To fix this we changed the irq function to only save the data bit to a buffer, And added another process to translate the signal. After we succeeded to read the keyboard we sent the data to the second Tmote Sky using the unicast of the Rime package.
The last part was to receive and translate the data sent from the first Tmote Sky and print it to the screen.
A nice addition to our project is to add a component to the second Tmote Sky that can identify as a keyboard to the PC.