Athens, Greece
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #15 on: November 10, 2012, 07:17:04 am » |
Question: To measure G forces, I'm using that code: #include "ADXL345.h" ADXL345 accel;
...
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
Offline
Tesla Member
Karma: 82
Posts: 8212
:(){:|:&};:
|
 |
« Reply #16 on: November 10, 2012, 10:22:14 am » |
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
|
|
|
|
|
Athens, Greece
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #17 on: November 10, 2012, 10:47:30 am » |
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: void ADXL345::get_Gxyz(double *xyz){ int i; int xyz_int[3]; readAccel(xyz_int); 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
Offline
Tesla Member
Karma: 82
Posts: 8212
:(){:|:&};:
|
 |
« Reply #18 on: November 10, 2012, 12:25:37 pm » |
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. (opened an issue about this  )
|
|
|
|
« Last Edit: November 10, 2012, 12:34:35 pm by lesto »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #19 on: November 10, 2012, 04:25:47 pm » |
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
Online
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #20 on: November 10, 2012, 05:08:35 pm » |
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.
|
|
|
|
0
Offline
Tesla Member
Karma: 82
Posts: 8212
:(){:|:&};:
|
 |
« Reply #21 on: November 11, 2012, 07:49:56 am » |
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
|
|
|
|
|
Athens, Greece
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #22 on: November 11, 2012, 11:27:24 am » |
Updated code: accel.setFullResBit(1); accel.setRangeSetting(8);
.. ..
int *x,*y,*z; accel.readAccel(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 » |
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: 114
Posts: 2205
|
 |
« Reply #24 on: November 11, 2012, 03:54:07 pm » |
Any pointers? Middle school geometry.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #25 on: November 12, 2012, 04:45:21 am » |
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
Offline
Tesla Member
Karma: 82
Posts: 8212
:(){:|:&};:
|
 |
« Reply #26 on: November 12, 2012, 05:47:14 am » |
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
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #27 on: November 12, 2012, 11:25:16 am » |
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
Offline
Tesla Member
Karma: 82
Posts: 8212
:(){:|:&};:
|
 |
« Reply #28 on: November 12, 2012, 11:39:51 am » |
how you come out with 4degree?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #29 on: November 12, 2012, 12:28:47 pm » |
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.
|
|
|
|
|