“A glove embedded with accelerometers to play a hand motion-controlled chess game”
For our ECE 4760 final project, our team designed and built a system with the ability to play the game of chess using embedded gloves. Each player wears a glove (there are two gloves for two players) and uses hand-motions to play a chess application. The chess board graphical user interface is generated using MATLAB, which receives information from the player’s gloves through a serial connection with the microcontroller, and updates the game appropriately. As such, when a player tilts his hand in a certain direction, the cursor on the computer screen moves accordingly. Since the glove also has contact sensors in the form of copper strips on both the thumb and pointer finger, pressing these two fingers together simulates picking up or dropping a piece at the location of the cursor. The goal of our project was to simulate the physical motions involved in playing chess without the need for a physical chess set.
High Level Design
Rationale and Source of Our Project Idea
Our team explored various ideas about how to revolutionize a game of computer chess. Playing chess with a simple computer mouse can simply be boring, and does not have the same feel as playing a game with a real, physical chess set. As such, we came upon the idea to make a computer chess game that more closely simulates a physical chess game and further blur the distinction between the real and the virtual. As such, our vision was to eliminate the computer mouse and replace it with in-air hand motion. As technology advances, the computer mouse is becoming less and less standard. For example, touchscreens have recently become popular because it completely eliminates the need for computer mouse. However, much like in futuristic movies like the Minority Report, the idea of being able to control mouse movement with in-air hand motion is something that is not so common in current consumer technology. We do note that past projects have had a similar idea, but our team wanted to build on this idea with our own spin, and apply this technology specifically to a game of chess.
Since we are dealing with accelerometers, we must remind ourselves of Newton’s equations of motion. Newton’s three famous equations are taught to virtually every student of elementary classical mechanics. These equations are:
- v = u + at
- s = ut + (1/2)at^2
- v^2 = u^2 + 2as
The first and second equations above are of particular interest to us. We need the first equation in order to identify the velocity at which the cursor should move based on the reading of the accelerometer from a tilt of the hand. Likewise, the second equation is needed to determine the relative displacement. In short, our hand motions/tilts result in variable a-values (acceleration), and these equations help us translate the motions/tilts to cursor speed and location on the computer screen.
At a high level, the system has three main blocks. At a high level, the system has three main blocks: the embedded gloves, the microcontroller code, and the MATLAB GUI. Each glove is embedded with a three-axis accelerometer and fitted with copper strips around the pointer finger and thumb to act as contact sensors. For each accelerometer, only the x and y axis is used. A hand-tilt forward corresponds to the positive y-direction, while a hand tilt backwards corresponds to the negative y-direction. Likewise, a tilt to the right corresponds to the positive x-direction while a tilt to the left corresponds to the negative x-direction.
The contact sensors simulate a button click, where pressing the pointer finger and thumb together creates an active-low signal that is sent to the Atmega1284 microcontroller. The x-data and y-data from the accelerometer are sent to an analog-to-digital converter in the microcontroller. The microcontroller transforms this information received from the gloves to update the cursor coordinates. The microcontroller also handles the state of the chess game, maintaining and managing a wide array of state information needed to update the game. The microcontroller continuously creates packets containing the cursor coordinates and other state data and sends them off to a MATLAB application using serial communication. MATLAB continuously requests these packets and parses them to decide how to render and update the graphical user interface that represents the chess board.
Hardware and Software Tradeoffs
A large portion of our project revolved around the software component since all the chess algorithms and serial communication were written in software. Since we only had to sample the analog-to-digital converter once every millisecond, it also was not necessary to have any additional hardware for that purpose. However, we did opt for hardware debouncing when it came to our push-buttons (used to reset the game) and contact sensors (used to simulate a button click) to avoid having to implement a software debounce state machine similar to what we dealt with in previous laboratory assignments. Within the software component, however, there was a tradeoff between what functionality was written in MATLAB and what was written in C. Since this is designated a microcontroller project, we chose to have the microcontroller, not MATLAB, maintain the entirety of the state of the game. MATLAB’s purpose was to render and redraw the GUI according to the information it received from the C portion, although this proved to be quite extensive as well.
Our initial approach to interfacing the microcontroller with the CPU involved either using the PS2 or USB HID protocol, and hence we expected to abide by the PS2 standard or USB standard and specifications. However, we found that our task would be made simpler by foregoing these standards and communicating with the PC using a serial connection instead. We thought it would be most effective to define our own packet structure (specific to our chess application) for serial communication, and hence did not use any standard in that respect.
To help create the MATLAB graphical user interface, we consulted an open source MATLAB project found on the MATLAB Central File Exchange site. The project, called Chess Master, was written by Suleman Shafqat. We modified the image files provided in his program to construct our own chess piece images.
To help create certain parts of our chess algorithms for the C portion of our code, we consulted two old ECE 4760 final projects. One of these projects was called “Touchscreen Chess,” and was designed by Samiul Nur and Caspar Valk in Spring 2012. Their team also built off an older project called “Remote Chess,” designed by Erik Jarva and William Baughman in Spring 2008. To build our website, we adapted a Cornell template used by Adam Papamarcos and Kerran Flanagan, another project team that that developed “Human Tetris” in Spring 2010. Links to these references are provided in the appendices below. Further discussions of intellectual property and copyright laws will be discussed in later sections.
The most important hardware we used are the 3-axis accelerometers. Each accelerometer has an on-chip voltage regulator which converts the 5V Vcc to about 3.3V. We built our own voltage regulator circuit to provide a 3.3V source to the analog reference on the ADC. This was to improve sensitivity to voltage changes by using the whole 0xff range on ADCH. We also connected copper strips around the thumb and index finger to be used as a switch and for picking up pieces. We opted for hardware debouncing of the contact sensors to allow the mcu more time to perform complex chess algorithms. Hardware debouncing was done using an RC circuit to smoothen the transition of a switch. We also have a switch on the board that can be used to reset the chess game. Each accelerometer has four color-coded connections to the mcu. A red wire connects to 5V Vcc, a black wire to ground, a yellow wire to x-channel of the ADC (A0 for player 1, A2 for player 2) and a green wire to the y channel (A1 for player 1, A3 for player 2) of the ADC.
|Atmega 1284||Lab Stock||$5||1||$5|
|3-axis accelerometer module||Modern Device||$10.95||2||$21.90|
|white board||Lab Stock||$6||1||$6|
|target board||Lab Stock||$10||1||$10|
|small solder board||Lab Stock||$1||1||$1|
|header pins||Lab Stock||$0.05||22||$1.10|
|power supply||Lab Stock||$5||1||$5|
|push buttons||Lab Stock||$0||2||$0|
|copper strips||Lab Stock||$0||4||$0|
|voltage regulator||Lab Stock||$0||1||$0|
For more detail: Hand-Motion Chess Using Atmega1284