Loading...
Pages: [1]   Go Down
Author Topic: ADXL335 Converting to gs  (Read 484 times)
0 Members and 1 Guest are viewing this topic.
United States
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
Indubitably
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm working with the ADXL335 and I would like to convert the xyz values to g-force.
It is my understanding that this is done thusly:

(1) SomeAxis = Vout * Vs / 1023.0; //The analog inputs are 10 bits right?
(2) Vdelta = SomeAxis - ZeroG
(3) SomeAxis = Vdelta / Sensitivity;

Here is how I'm doing it:
Code:
double sensitivity[3] = {0.270, 0.300, 0.330}; //The ADXL335 datasheet gives 270, 300, and 330 mV/g @ 3v
Code:

    //Get raw value
    accelRead[X] = analogRead(xAxis);
    accelRead[Y] = analogRead(yAxis);
    accelRead[Z] = analogRead(zAxis);
    
    //Convert to V
    accelRead[X] = accelRead[X] * 3.3 / 1023;
    accelRead[Y] = accelRead[Y] * 3.3 / 1023;
    accelRead[Z] = accelRead[Z] * 3.3 / 1023;
    
    //Determine change in V
    deltaV[X] = accelRead[X] - (3.3 / 2.0);
    deltaV[Y] = accelRead[Y] - (3.3 / 2.0);
    deltaV[Z] = accelRead[Z] - (3.3 / 2.0);
    
    //Convert to G-Force
    accelRead[X] = deltaV[X] / sensitivity[X];
    accelRead[Y] = deltaV[Y] / sensitivity[Y];
    accelRead[Z] = deltaV[Z] / sensitivity[Z];

Unfortunately the readings are inaccurate. They correlate properly with movement, but it is certainly not gs. I know this because I'm geting readings like -0.66 when it should be 1.0 and -0.83 when it should be 0.5. I am using a voltage divider to ensure 3.3v power supply (I'm actually getting 3.31v rather than 3.29 in the 3.3v pin).

What I need to know is (1)Do I understand the conversion process correctly? (2)Does anyone know a better zero g than Vs / 2.0 for 3.3v power supply? (3)Does anyone know the sensitivity of each axis with a 3.3v power supply? (4)Does anyone have experience with the situation I'm in?

I would like to get this working properly. Any help would be greatly appreciated! (Even if you can't answer my questions.)
Here is the datasheet of the breakout I'm using if that helps: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/ADXL335_v13.pdf
« Last Edit: July 04, 2012, 02:27:06 pm by fuzzball27 » Logged

fuzzball27 >>-->

United States
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
Indubitably
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have resolved the issue by using 1.1 as the zero g voltage, and using 0.22 as the sensitivity.
Logged

fuzzball27 >>-->

Offline Offline
Edison Member
*
Karma: 9
Posts: 1000
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe you should rewrite your code.

The sensitivity is 300 mV/g for every channel.
The number of 300mV/g could actually be 270-330.
You should start with 300 for every channel.

The way you calculate the Delta is not right. Please just delete that part.
It is already an accelarator sensor, so you might not need the delta.
But if you do need to calculate the delta value, you have to remember the previous g-force value and substract that from the new g-force value.
Logged

United States
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
Indubitably
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Delta is change in voltage of power supply, not change from the last reading. As for the sensitivity, 220 was the number I was looking for. With the updated numbers the readings are excellent, and I am getting exactly what I need. Thank you for the help.
Logged

fuzzball27 >>-->

Pages: [1]   Go Up
Print
 
Jump to: