Get Acceleration from Accelerometer

Hey all,
I am not sure if this the right place to post this
But I consider this to be more of a mathematical issue rather than programming

I am getting The XYZ analog values from the acclerometer.

How can you derive acceleration from this data.

Thanx in advance

Nikhil

You need to check the documentation for the accelerometer.
It will give a sensitivity value, expressed in "mV/g" (for an analogue device) or "counts/g" (for a digital device).

You then simply do the arithmetic for the value you are seeing.
Don't forget the 0g offset.

Hey
I thought there is some mathematical formulate that allows you tp derive the acceleration.
I read it some where.

thought there is some mathematical formulate that allows you tp derive the acceleration.

And there probably is, but without knowing what real-world values to plug into it, a formula isn't much use.
Because you still haven't told us what device the accelerometer is, we can't even begin to guess what the formula might be.

Sorry I forgot to mention.

I am using a

Triple Axis Accelerometer Breakout - ADXL335

that can be found here:http://www.sparkfun.com/products/9269

I am looking in to the sensitivity thing.Will need help to figure it out.

Page 3: 300mV/g at Vs of 3V.

Hey thanx fo all your time n help.
I am still stuck

I am using this code that i found somewhere on this forum to get Acceleration

const int analogInPin0 = A0;  
const int analogInPin1 = A1;  
const int analogInPin2 = A2;  
const int analogInPin3 = A3;  
int last_Val = 0;
int new_Val = 0;

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
}

void loop() {
  // read the analog in value:
 int _piezo = analogRead(analogInPin0);
 int _x = analogRead(analogInPin1);
 int _y = analogRead(analogInPin2);
 int _z = analogRead(analogInPin3);
 
 float _Acc = sqrt(_x^2+_y^2+_z^2);
 
 
 
 last_Val = new_Val;
 new_Val = _Acc;
 float diff = new_Val-last_Val;
// new_Val = (0.95 * last_Val) + (0.05 * new_Val); //This was some code I got for smoothing the values
 

   Serial.println(diff);
   delay(100);  



}

I am making a ball that when hits a wall or a surface sends data about the hit and the force.I think accelerometer can give me this data .

Nikhil

I am still stuck

Stuck where?

What does that code do that you don't want? What does it not do that you want? We can't help you fix the code if we have no idea what needs to be fixed.

int _x = analogRead(analogInPin1);
 int _y = analogRead(analogInPin2);
 int _z = analogRead(analogInPin3);
 
 float _Acc = sqrt(_x^2+_y^2+_z^2);

Ordinarily, you only square and take a root if there is a negative value you want to ignore, but analogRead cannot return a negative value, so I think that's a fairly expensive operation for little gain.
You've forgotten to offset the analogue reading by half the supply voltage.

You've forgotten to offset the analogue reading by half the supply voltage.

Could that then result in negative numbers?

Sorry for being unclear

I Dun understand when you say

You've forgotten to offset the analogue reading by half the supply voltage.

About what I want is

I am not good at maths but I thought If the code gives me a value that tells me the difference in acceleration because of some motion .So if i shake my accelerometer it shows a good deflection in the diff variable.

I might seem to be stupid but I am trying to understand how accelerometer work.

Thanx for helping me

nikhil

The accelerometer measures acceleration, but the rest (zero acceleration) reading for each axis is offset by half the supply voltage to ensure only positive output voltages.

If we assume that the supply for the accelerometer is 3.3V, and the analogue reference is 5V, then you need to subtract about (3.3/5 * 1024) / 2 = 338 from each reading.

Thnx.I corrected it.

But the change in acceleration remains the same.
Also when I rotate my acclerometer slowly then the diff value I am printing shoots up

0.00
0.00
0.00
7.00
9.00
11.00
10.00
0.00
0.00

Where I was expecting them to shoot when I give my acclerometer a jerk.

Am I retrieving the acceleration the right way.

nikhil

If you're only printing results every tenth of a second, you may very well miss the reading of your "jerk".

this document provides a good explanation of what you need to do.
http://www.freescale.com/files/sensors/doc/app_note/AN3107.pdf