IntroductionAt the time of writing this article I cannot really recall why I started out on this project in the first place. Maybe, because some time ago I was experimenting with the built-in analogue-digital converters of some PIC micros and was thinking that they could be used easily to interface the analogue output of an accelerometer… Maybe I saw something similar on a web site and thought I could make a better one… I don’t know. What I do know is that I like projects that involve LEDs (especially blue ones, preferably flashing most of the time :) ), interfacing with real world, and projects that teach me something new. So… one day I decided to make a 3 axis accelerometer – to see if I can make it – that could be used (as is or with slight modifications) in real life applications. I tried it in a car - it works great there, but at the moment I just have it sitting on my desk to entertain visitors.
|The assembled 3-axis accelerometer|
If you like this project and would like to build it yourself all the necessary information on it is below. If you don’t feel adventurous enough to build it yourself but still would like to have it I can prepare you a kit or a fully built unit – drop me a line for more info.
HardwareThe direction-sensing is accomplished by Freescale’s MMA7361L, which is a three axis low-g micromachined accelerometer in a tiny (14 pin LGA) package. The advantage of this chip is that it’s super simple to use: just connect the three directional output pins to an analog-digital converter input of a microcontroller and you’re ready to go. With a few more pins connected straight to some further microcontroller IO pins you can enhance its operation with functions like SLEEP, 0g detection, sensitivity selection, etc. The disadvantage of this chip is that it’s in a tiny package that’s a bit difficult to solder at home. In fact, I tried to make a breakout board for it, but it doesn’t seem to work. I think I made the solder pads too small for the IC and this is why it doesn’t work, but I still have to find out why. In the meantime, I got a breakout board complete with the sensor on eBay for a few euros to keep me going. That worked like a charm for the very first try.
|MMA7361 breakout board from eBay|
The MMA7361L has a g-select input. This can be used to select the sensitivity of the device (±1.5g or ±6g). I decided to put a jumper on the PCB to allow easy selection. I could have used an actual switch for even easier selection :-) but I didn’t want to overcomplicate it. It’s not like I need to change it all the time…
The processing is done in Microchip’s PIC16F887. I chose this micro for this project because I had worked with it in the past and I could get my hands on a few of them in a 44 pin TQFP packaging – another challenge for me. I had never soldered this small pitch ICs before and wanted to try my hands at them. It turned out it was not difficult at all – I used the some-solder-and-a-lot-of-flux method with superb results.
|Control module PCB "naked"...|
|... and with components soldered in place|
|Bottom side - it containd a socket that is aligned with the display module's connector.|
Coming up with a nice way of displaying the directional data was not an easy task. I came up with several different layouts – all had pros and contras. Finally I decided having a cross (showing up/down and left/right data) and line (showing forward/backward data) combo made up of blue SMT LEDs. (I just love blue…) The resolution of the displayed data is 8 LED in every direction which adds up to 48 LEDs total. The resolution of the measured data is much higher, but it is not necessary in my application, so in firmware I simply discard the extra information. Since I made my design modular I can later design a new display module for the same “CPU board” without redesigning the whole board or changing the firmware. If you can think of any layout that would look better please let me know in the comments section.
|Only the 48 LEDs and the realted resistors (all SMD) on this side of the board.|
The 48 LEDs in the current formation are driven by 6 daisy-chained serial-in-parallel-out shift registers (one for each segment) using only 3 pins of the microcontroller. This is a very efficient use of microcontroller IO lines and easy to program since it doesn’t need constant refreshing.
|Schematics of the display module|
I also added a buzzer (recycled from an old motherboard) to the design – its sole purpose is to beep when the device is in 0g, or free fall. I really don’t expect to hear it very often when this circuit is mounted in a car… but in other applications this might get useful. Anyway, I put it in the design because I could :-).
|Schematics of the micro controller module|
The circuit doesn’t contain any stabilization for input voltage – I planned on using a 12V DC -> 5V DC converter. I put a standard USB micro socket on my board, so any USB car charger for mobile phones or GPSs would be OK to power this device.
Finally, the mandatory ICSP header is also aboard for easy development.
SoftwareAs I consider myself a beginner with PICs, programming was done in assembly so that I learn the most about the microcontroller. The source and/or the hex file is available upon request.
EnclosureAs usual, making a nice and useful enclosure for the circuit was the most difficult part of the project. Originally, I wanted a dark plastic panel for the front so that the circuit is not visible only the lit up LEDs. After an extensive search on the internet as well as local stores I realized this is not going to happen. I still don’t understand what is so special about this material – it is used in millions of common everyday items, such as car dashboards, TV/video/dvd player displays etc. If you can recommend a place to me that sells these dark, semi-transparent pieces of plastic sheets in small quantities (and ship to Greece) please let me know.
|Back of the display module - all parts soldered in.|
|From bottom to top: Display module, control module, MMA7361 breakout board - all sandwiched together.|