DE-ACCM5G Application Note
G Meter

The DE-ACCM's buffered outputs are ideal for connection to a microcontroller's analog input pins. In this project I used this functionality to make a simple G meter suitable for mounting into a car. It displayed the amount of acceleration in units of g whenever the car was accelerating or braking. This project is suitable for anyone experienced in developing for an analog enabled microcontroller.

Choosing the display - 7 Seg or LCD?
Using an LCD as a display would allow you to show many things at once, such as forward, lateral, maximum and average acceleration. However cheap parallel LCDs can be a pain to interface with, and are hard to read if you are driving. Alternatively, $26 will buy you an easy to use Serial LCD with backlight.
My personal favorite choice was a $2.16 triple digit 7 segment display (Digikey part #160-1544-5-ND). The digits are large and bright and therefore can easily be seen if you are driving. With the 3 digits I had at my disposal, I chose to display acceleration in the form of X.XXg. I could have displayed it as ±X.Xg, but it is pretty obvious when you are in a car whether you are accelerating or braking isn't it? So may as well display extra precision instead.

Schematic
Lite-On's diagrams for the 7 seg display are quite hard to decipher at first, so I have photoshopped them slightly to make them a little bit easier to read. I also cleaned up the PIC pinout to make it specific for this project. For the originals, see the datasheets linked below.


Microcontroller
The 7 seg display requires 11 output pins to drive, and at least 1 analog input to read in acceleration. The most suitable micro I had in my parts box was a PIC16F818. PIC16F818 datasheet

Power
To fit the voltage requirements of the DE-ACCM5G and the PIC, I used a garden variety 7805 regulator. Since many LEDs in the display were being switched on and off very quickly, I used a 22uF capacitor on the 7805's output to keep the power supply stable.

7 seg display
The way I have things hooked up, the 7 segment display only actually ever displays one digit at a time. The displayed digit is chosen by making one of pins A0, A6, A7 high. The actual number to be displayed is then determined by portB, which allows the segments to turn on when a pin goes low. The individual digits are cycled very fast, and persistence of vision creates the illusion of all 3 digits being displayed at once. LTC-4624JR 7 seg display datasheet

Measuring acceleration
The PIC's ADC was set to 10bit resolution, with 5V as the reference voltage. To get a rough estimate, I knew that the 0g on the accelerometer output would be close to 5V / 2 = 2.5V. In 10bit mode, this would correspond to (2.5V / 5V)*(2^10)= 512. At 1g, the voltage would be ~2.812V, which would correspond to (2.812V / 5V)*(2^10)=576. Knowing this helped me write some initial code snippets to display non-calibrated acceleration values.

Calibration
Since this project was designed to display accelerations as small as 10mg, I had to calibrate the microcontroller during development. For example, using a perfect 5.000V reference for the microcontroller's 10 bit ADC with an input of 2.500V would give a 0g value of 512. However, since a 7805's voltage reference is only accurate to within 2%, and no accelerometer is perfect, I found the 0g point to be 510. (See source code).

Source code
The project was written and compiled with CCS PCWH. It is a pricey compiler, but it makes PIC development much easier. Source code and hex file.zip

Video
Hard brake.avi (2.4Mb DivX 5.1.1)
Hard brake.mpg (3.8Mb Mpeg2)
To show the G meter in action, John drove around while I tried (and failed) to keep the camera steady on the display. Accelerating in first gear read about 0.25g, then as the clutch was pressed down acceleration dropped to 0 for a split second. Once second gear was engaged acceleration was about 0.15g. After a few seconds a constant speed had been reached, and acceleration was back to 0 again. Finally, we reached an unexpected traffic light and the harsh braking registered 0.52g.

More ideas
I only spent about 4 hours on the whole project, so there are still lots of things that one could do to improve on it. In its current state, the display data refreshes very fast. It would be easy enough to artificially slow things down in software if you only wanted the screen to update twice a second. Using the microcontroller's other pins and some push switches, it would be easy to expand this project to add support for displaying maximum recorded acceleration or toggling between X and Y acceleration. If you have any artistic talent, you could build an attractive case to fit everything inside, then use a suction cup to mount it to your windshield. You could also mount the display inside your dashboard.

Back to Dimension Engineering