Hello everybody,
recently I bought my first Accelerometer sensor from local (ADXL335) I connected it to 3.3V, I am reading Raw Analog values from the sensor (X,Y,Z) and printing it on Arduino Serial Monitor.
I want to calculate G-Force from it, How to I do it.? Is there any formula to convert these analog values to G-Force.?
Thank you for replying and sending me this tutorial, I have now used the code provided and also assigned relevant pins of ADXL335 sensor to the Arduino Mega as per the instructions, Right now I am getting the values perfectly! ,I know these are the acceleration values - How do I convert this acceleration to G-Force.?
Do I need to convert these values to DECIMALS.?
and
read all steds
What do you mean there.? You mean to study that instructions and do it.?
steds = steps (my typo)
...........
from the datasheet you can see that the sensor will give you ca. 1.5 V out when powered @ 3V.
I guess this value is 1.65V since you use 3.3V to Ucc and Aref.
More to be noticed is the sensivity: 300mV/g => which is 0.3*1023/3.3 =93 steps/g.
practical:
Note theese 6 values and make them integer constants in your code Xmin,Xmax,Ymin,Ymax,Zmin,Zmax
You find them by reading each axis min/max when sensor is steady in different positions.
Now you know all values for -1g and +1g. (0g will most often be close to middel value)
Make formulas (linear) to interpolate/extrapolate your reading to find actual acceleration in any direction.
Total acc. can be computed as sqroot(x^2 + y^2 + z^2) This number will include acc og gravity
thank you very much for the explanation @knut_ny ,I understood your excellent explanation.
I am actually trying to build a device which can measure human impacts (typically used in Rugby match) - according to the datasheet this sensor provides upto 3g's , so it will cover upto 3 times the human weight.
from the datasheet you can see that the sensor will give you ca. 1.5 V out when powered @ 3V.
I guess this value is 1.65V since you use 3.3V to Ucc and Aref.
More to be noticed is the sensivity: 300mV/g => which is 0.3*1023/3.3 =93 steps/g.
1.65V is the max voltage I will get on output pins (Xout,Yout,Zout).? if yes, 1.65V is +3g ,0V is the 0g, -1.65V is the -3g.?
I want to know - is that value enough for human impacts.?
when I keep the device on the flat surface keeping Z-axis vertically and monitoring the values on Serial monitor, it will give some value ,assuming a value like 300, which means 300 is 1g right ?, because 1 g is equal to the force of gravity at the Earth's surface, which is 9.8 meters per second square.
Hello @knut_ny
thank you for your replies and explanation again, I made a simple code where I am getting 512 analog value at Z-Axis when placed it vertically towards ground.
Now, this 512 is the 0 g right? as you said, but I am little bit of confused here: that the acceleration due to gravity pulling at the Z-Axis which is 9.8m/s^2, in our case the sensor is at rest( not accelerating )so now it will be constant which is 9.8m/s and which is "1 g".
Acceleration due to gravity is always pulling with the rate of 1 g, so it should be 607 in resting position of the sensor rather than 512.? Please shred some light on this please.
Try this formula: float gforce=0.0108*analogRead(An) - 5.5;
do you mean this.? while A2 is connected to Z-Axis
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float gforce=0.0108*analogRead(A2) - 5.5;
Serial.println(gforce);
}
By the way I made a code for total acc
const int xpin = A0; // x-axis
const int ypin = A1; // y-axis
const int zpin = A2; // z-axis
int x, y, z;
int total = 0;
void setup() {
// initialize the serial communications:
Serial.begin(9600);
}
void loop() {
analogReference(EXTERNAL);
x = analogRead(xpin);
y = analogRead(ypin);
z = analogRead(zpin);
total = sqrt(x * x + y * y + z * z);
Serial.println(total);
}
If you want to consider things using general relativity, then the surface of the earth is accelerating, upwards,
at 9.8m/s^2, but is not moving because spacetime is curved.
That's why the Z direction (upwards) component of an accelerometer measures +1g, not -1g. In free-fall
or in orbit (non-accelerating inertial frame) the accelerometer will read all zeroes.
In general relativity there is no difference between inertial and gravitational acceleration, they are identical,
but spacetime is curved (which makes for interesting tensor maths to describe stuff). I lowly MEMS accelerometer chip cannot distinquish inertial and gravitation acceleration, since that's a human conception.
My sensor measures 512 on the Z-Axis so that means 512/9.8 = 52.24G's .?
If you want to consider things using general relativity, then the surface of the earth is accelerating, upwards,
at 9.8m/s^2, but is not moving because spacetime is curved.
That's why the Z direction (upwards) component of an accelerometer measures +1g, not -1g. In free-fall
or in orbit (non-accelerating inertial frame) the accelerometer will read all zeroes.
In general relativity there is no difference between inertial and gravitational acceleration, they are identical,
but spacetime is curved (which makes for interesting tensor maths to describe stuff). I lowly MEMS accelerometer chip cannot distinquish inertial and gravitation acceleration, since that's a human conception.