Hardware

Hardware Components
AT90s8515    (mcu)
G321D           (LCD)
SED1330F     (controller built into G321D)

Accelerometer
The accelerometer has an output pin each for reporting accelerations in the x- and y-axis. We tied each pin to one of the external interrupt pins on PORTD of the AT90s8515.

The duty cycle of zero acceleration on an axis is 50% (that is – T1/T2 is ½). As acceleration increases in the positive x-axis, T1 increases while T2 remains constant. If we have negative acceleration (in the negative x direction, for example), T1 decreases. We can calculate the acceleration on the axis using the following equation:
A = (T1/T2 – 0.5)/ 0.125

So if T2 is set to be 10 ms, and T1 is 6 ms, the calculated acceleration is 0.8 g. A tilt of zero degrees (chip held horizontally) is an acceleration of 0 g. The maximum acceleration due to simply tilting the chip is 1 g, corresponding to a 90o tilt. Other tilt angles are calculated from the acceleration as:
Tilt = ArcSin( A )

The period of the pulse, which stays constant, is determined by the value of the resistance used, RSET. It can vary from 0.5 ms to about 12 ms. The period T2 is given to be:
T2 = RSET/125MW

Though it did not matter what the exact value for T2 was, a larger value was better to reduce the relative error (being off by 0.25 ms is an error of 50% if T2 is 0.5ms, but only 2.5% if T2 is 10 ms). We chose RSET to be 1.33 MW, so that T2 was 10.65 ms.

For noise reduction, two capacitors must be added to the ADXL202 chip. We used capacitors of 0.05 mF, which is the correct value for a bandwidth of 100MHz (period of 10 ms). These can be seen on the accelerometer picture (here).

Liquid Crystal Display (with controller built in)
The G312D is a 320x200 pixel graphics display. It has got multiple layers, some of which are text, some graphics, and the rest configurable for either text or graphics display. There are 20 pad connections on the module; 5 connections are control lines, 8 form a data bus, and the other connections are for ground and power supply voltages (-24V for the LCD, 5V  for contrroller). We used PORTC as our control line, and PORTB for data. For contrast, we placed a trimport wiper, in series with a 22 KW resistor, between -24V and ground.

The SED1330F documentation defines the command set comprehensively. However, we had to write our own driver routines. Most of the timing issues we had to be aware of were minimum times, and in the nanosecond scale. Since the AT90s8515 is a 4MHz processor, we did not have to worry much about sending commands too fast. The generic command format for the controller is as follows:

[8 bit opcode], [Pararmeter 1], [Parameter 2], ....

A particular requirement we had to pay attention to was that a write can only occur during the negative phase of a full strobe cycle (the strobe is simply the write enable/read disable signal). To deal with this, we followed the scheme described by Froemming and Waterston, which is to:

• Write a '1' to WRITE-ENABLE
• Write a '0' to WRITE-ENABLE
• Write to the data bus
• Write a '1' to WRITE-ENABLE (completes the cycle)
For details on the device drivers, please see software.