ADXL335 normalization and calibration

In addition to my previous post about the ADXL335 accelerometer, I’ve now added some basic calibration!

The datasheet for the ADXL335 (http://goo.gl/LAslK) does actually state the voltages that the accelerometer should produce with respect to the actual level of acceleration though as some may know, the value of gravity varies dependent on where about you are on earth and decreases with amplitude above ground! Fortunately, by getting minimum and maximum readings for a given area, one can calibrate their accelerometer relatively well and produce normalized values that are dependent on these minimum and maximum readings. Its a really simple equation and looks like:

(CurrentVal – MinVal)/(MaxVal – MinVal).

If you think about it, this is logical. If the CurrentVal is equal to the MaxVal ever read, the output will be 1 as (MaxVal-MinVal)/(MaxVal-MinVal) has to be equal to 1 as the denominator and numerator are equal. On the other hand, if the CurrentVal is equal to the MinVal, the output will be zero as (MinVal-MinVal) = 0, and 0 divided by anything is 0! This therefore normalizes the values given. One needs to remember however that when collecting the data on the minimum and maximum values, moving the accelerometer too fast will produce erroneous results. If the accelerometer is moved at 3g in one direction, the maximum read value for that direction will be larger than what would naturally be produced by gravity itself! This method is only for a quick normalization of values and much more complex methods are available for good calibration of your accelerometer (See: http://goo.gl/ynP6UV). Bare in mind also, in my simple example, the microcontroller is forever collecting data on the minimum and maximum values! An additional piece of code could be added so that the microcontroller only collects data when a button is pressed or in a defined time period.

Regardless! The updated test program now looks like:

P1020496
Displaying the minimum, maximum, raw and normalized values from the accelerometer reads!

The newly updated code can be found at my github!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s