Pages: 1 [2] 3   Go Down
 Author Topic: ADXL345 information/help/problem/guidance etc :)  (Read 3385 times) 0 Members and 1 Guest are viewing this topic.
Athens, Greece
Offline
Newbie
Karma: 0
Posts: 18
 « Reply #15 on: November 10, 2012, 07:17:04 am » Bigger Smaller Reset

Question:

To measure G forces, I'm using that code:

Code:

...

accel.powerOn();
accel.setFullResBit(1);
accel.setRangeSetting(8);
accel.get_Gxyz(xyz);

Is it correct? When I'm changing from 8 to 2 or to 4 for example, I get different readings. I just want the upper limit to be more than 4 Gs.
 Logged

0
Online
Shannon Member
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
 « Reply #16 on: November 10, 2012, 10:22:14 am » Bigger Smaller Reset

with setRangeSetting you are setting the upper (and lowest) limit. because the value are 10bit (form 0 to 1024), changing the limit also change the precision of the reading...

with limit of 2, a read of 512 (zero)+(512/2=256) is 1G. BUT at limit 8, 1G it is 512+(512/8=64)

(value are just example, they can be wrong. for example, al 16G the sensor can use 16bit precision.
 « Last Edit: November 10, 2012, 10:24:47 am by lesto » Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Athens, Greece
Offline
Newbie
Karma: 0
Posts: 18
 « Reply #17 on: November 10, 2012, 10:47:30 am » Bigger Smaller Reset

with setRangeSetting you are setting the upper (and lowest) limit. because the value are 10bit (form 0 to 1024), changing the limit also change the precision of the reading...

with limit of 2, a read of 512 (zero)+(512/2=256) is 1G. BUT at limit 8, 1G it is 512+(512/8=64)

(value are just example, they can be wrong. for example, al 16G the sensor can use 16bit precision.

That means after reading the values (I'm using this library) I have to convert them?

Here is reading procedure of the library:

Code:
int i;
int xyz_int[3];
for(i=0; i<3; i++){
xyz[i] = xyz_int[i] * gains[i];
}
}

It looks like it multiplies the result with gains (for the 3 axis). I need to do further calculations, like the ones you suggest?
 Logged

0
Online
Shannon Member
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
 « Reply #18 on: November 10, 2012, 12:25:37 pm » Bigger Smaller Reset

yes, but technically the library is wrong.
every time you change the range, the array gains should change accordingly..

but it is not implemented, so you can make the gain calculation by yourself and use the setGain function.

 « Last Edit: November 10, 2012, 12:34:35 pm by lesto » Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline
Newbie
Karma: 0
Posts: 4
 « Reply #19 on: November 10, 2012, 04:25:47 pm » Bigger Smaller Reset

How sensitive is this sensor in recording tilt.
I've had a look at the data sheets, and it just says less than 1 degree.
Does anyone know if there's anything more specific than this. Like 0.5 degrees.
Or would 1 degree be enough to go with.
The reason I'm asking is because I need to choose a motor for a self leveling platform, and the sensitivity of the sensor will dictate the motor I choose.

Thanks
 « Last Edit: November 10, 2012, 04:28:01 pm by ocelotrevs » Logged

Global Moderator
UK
Offline
Brattain Member
Karma: 238
Posts: 24352
I don't think you connected the grounds, Dave.
 « Reply #20 on: November 10, 2012, 05:08:35 pm » Bigger Smaller Reset

Quote
How sensitive is this sensor
The datasheet says 4mg / LSB, which I make to be a bit less than 0.04 ms-2 on the most sensitive +/- 2g range. (4 / 1024 = 0.00390625)
 Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Online
Shannon Member
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
 « Reply #21 on: November 11, 2012, 07:49:56 am » Bigger Smaller Reset

I've had a look at the data sheets, and it just says less than 1 degree.

the datasheet talk about gravity, not about degree. you have to do the math
 Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Athens, Greece
Offline
Newbie
Karma: 0
Posts: 18
 « Reply #22 on: November 11, 2012, 11:27:24 am » Bigger Smaller Reset

Updated code:

Code:
accel.setFullResBit(1);
accel.setRangeSetting(8);

..
..

int *x,*y,*z;
xyz[0]=(*x*0.0078);
xyz[1]=(*y*0.0078);
xyz[2]=(*z*0.0078);

(0.0078 = 8/(2^10) - I guess that's correct for scaling 8Gs ? Is it?
 « Last Edit: November 11, 2012, 04:11:20 pm by vegos » Logged

Offline
Newbie
Karma: 0
Posts: 4
 « Reply #23 on: November 11, 2012, 01:13:43 pm » Bigger Smaller Reset

I've had a look at the data sheets, and it just says less than 1 degree.

the datasheet talk about gravity, not about degree. you have to do the math
Unfortunately, I have no idea where to even start with trying to work that out.
Any pointers?
All the terminology is new to me.
 « Last Edit: November 11, 2012, 01:17:38 pm by ocelotrevs » Logged

Offline
Edison Member
Karma: 116
Posts: 2205
 « Reply #24 on: November 11, 2012, 03:54:07 pm » Bigger Smaller Reset

Quote
Any pointers?

Middle school geometry.
 Logged

Offline
Newbie
Karma: 0
Posts: 4
 « Reply #25 on: November 12, 2012, 04:45:21 am » Bigger Smaller Reset

Quote
Any pointers?

Middle school geometry.

That was never my strong point.
Do we need to relate the bit resolution in terms of a g unit, then relate that to a degree value. So a 10 bit resolution gives a sensitivity of 0.1 degree of sensitivity.
Or does it relate to the mg/LSB value. So if a value of 4mg/LSB is given, then the sensitivity is 0.25 degrees?
 Logged

0
Online
Shannon Member
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
 « Reply #26 on: November 12, 2012, 05:47:14 am » Bigger Smaller Reset

we can calculate orientation (from -90° to 90°) on one axes by

asin(val);

where val HAVE to be from -1 to 1, so

maxValue = 1024
half=maxValue/2; //because we have value from 0 to 1024, 0 is -G, 1024is +G and 512 is 0G
val = (rawRead-half)/half; //the /zero assure that we will have a result in range of -1, +1

(notice you have to use acos if this axis is parallel to gravity vector, so asin for x and y, acos for Z)

now we have to set our precision. with a precision of +-4g, 1g = 512/4 = 128LSB so 1LSB = 1/128 G
precision now is asin(0) - asin(1/128)
asin of 0 is 0 (how convenient!)
asin of (1/128) is 0.44°, so 0.44° is your precision

but we don't need 4g, because any value above 1G is just noise from acceleration, so we can use the lowest resolution witch is +-2G, 1G= 512/2=256LSB, so 1LSB=1/256
asin(1/256) = 0.22°
 Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline
Edison Member
Karma: 116
Posts: 2205
 « Reply #27 on: November 12, 2012, 11:25:16 am » Bigger Smaller Reset

The number to look for is the sensitivity figure. This particular chip has the max sensitivity ratings of 256lsb/g, so each "bit" corresponds to 1/256g. or 90/256 ~= 0.4 degree, in theory.

In reality, you would be lucky to get to within 2-3 degrees.
 Logged

0
Online
Shannon Member
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
 « Reply #28 on: November 12, 2012, 11:39:51 am » Bigger Smaller Reset

how you come out with 4degree?
 Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Global Moderator
UK
Offline
Brattain Member
Karma: 238
Posts: 24352
I don't think you connected the grounds, Dave.
 « Reply #29 on: November 12, 2012, 12:28:47 pm » Bigger Smaller Reset

Small angle sine approximation doesn't work that well for angles in degrees.
 Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

 Pages: 1 [2] 3   Go Up