Eranda Tennakoon
Create Your Badge
by Eranda tennakoon
Introduction
The project undertook was a motion sensing keyboard emulator and as the name suggests, motion is detected and a certain key on the keyboard is emulated. The idea is to emulate chosen keys (page up and page down) from a keyboard using motion detectors as triggers. There are various types of motion sensing equipment in the general market. Among them are video capturing motion detectors, laser detectors and PIR’s. The ST1KLA photo transistor is a versatile sensor that enables easy use and good accuracy and thus used in this project.
The PIC16F877A microcontroller was used in this project to generate bit patterns of the respective keys. The generated bit patterns are fed into the ps2 keyboard port of a PC. Any microcontroller capable of high speed signal transmission can be used.
The result of this project is a valuable device that enables easy use of the PC. With one sweep of the hand you can move through a page or a presentation slide giving you much more freedom.
High level design
This device runs on a simple mechanism which is triggered by the motion of the hand and sends a signal to the PC. The PS2 keyboard communicates bidirectionally with the PC. A unique set of codes known as the scan codes are sent to the PC when a key is pressed and also another set of scan codes are sent when the key is released. The scan codes for the keys to be emulated, should be known. The scan codes used in this device can be found at the sites provided in the references.
As mentioned before, the PC’s keyboard implements a bi-directional protocol. The keyboard can send data to the Host and the Host can send data to the Keyboard. The Host has the ultimate priority over direction. It can at anytime (although not recommended) send a command to the keyboard.
The keyboard is free to send data to the host when both the KBD Data and KBD Clock lines are high (Idle). The KBD Clock line can be used as a Clear to Send line. If the host takes the KBD Clock line low, the keyboard will buffer any data until the KBD Clock is released, ie goes high. Should the Host take the KBD Data line low, then the keyboard will prepare to accept a command from the host.
The transmission of data in the forward direction, ie Keyboard to Host is done with a frame of 11 bits. The first bit is a Start Bit (Logic 0) followed by 8 data bits (LSB First), one Parity Bit (Odd Parity) and a Stop Bit (Logic 1). Each bit should be read on the falling edge of the clock.
Additional information regarding device to host communication can be found at the site http://retired.beyondlogic.org/keyboard/keybrd.htm
The clock pulse and the data pulse were created using the delay command and sending the respective out put of the port pins to logic high and logic low as needed. Copy of the code used is given in the files below. Also the schematic would provide a better idea of the device’s functions.
The motion sensor was created using the ST1KLA photo transistor as a detector. It has an area of sensitivity that is similar to that of in LED. This was much useful since it allowed an IR LED to be placed adjacent to it without effecting it.
(image taken from http://www.datasheetcatalog.com )
When sliding the hand over the IR LED the infra red radiation reflected off the hand arrives at the photo transistor allowing it to saturate. The transistor is kept in the emitter follower configuration allowing an electrical signal to be sent to the comparator of the PIC microcontroller.
The PIC is coded to send the signal for the page up or page down keys depending on which photo transistor sent the signal.
Program / Hardware
Hardware description
Software description
Results
testing
Conclusions
Further enhancements
World of electronics holds many possibilities for the creative mind. Thus it is possible to enhance this device with many other added features. Or it could also be used for some other project as a basic component.
One idea is to enhance this to have more sensors that could detect many other hand gestures. For example you could implement it to detect the hand making a circular motion. The direction of the motion could also be used to implement other function keys of the keyboard.
A wireless hub can be used to communicate between the PC and the device. This would let the user move freely. Of course a receiver must be placed to relay the signal to PS2 port.
The theory of this can be used in other projects as well. For example a floating keyboard can be made using a laser array. Lasers are set to shoot in the fashion of square grid. Detectors are placed to constantly scan the laser signal. When a certain point of the grid is disturbed a signal is set to send through to the PS2 port with a bit pattern that resembles a certain key in the keyboard.
Appendix A
Appendix B
Appendix C
Component |
Description |
R1 | 1 K 0.5 W resistor |
R2,R3,R7,R8,R11 | 5 K 0.5 W resistor |
R4,R6 | 47 Ohms 0.5 W resistor |
R8 | 3 K 0.5 W resistor |
R5, R9 | 100 K 0.5 resistor |
R10 | 4.0 MHz Crystal oscillator |
C1,C2 | 22 pF 16 V Ceramic capacitors |
Q1,Q2 | N/A |
J1 | 6 Pin connector |
J2 | 4 Pin connector |
D1 | Green LED |
D2,D3 | ST1KLA photo transistor |
D4,D5 | IR LED |