Pages: 1 2 [3]   Go Down
 Author Topic: ADXL345 information/help/problem/guidance etc :)  (Read 1933 times) 0 Members and 1 Guest are viewing this topic.
Offline
Edison Member
Karma: 114
Posts: 2205
 « Reply #30 on: November 12, 2012, 12:38:07 pm » Bigger Smaller Reset

4 degrees are not that far off: if you look at the datasheet, it shows various drafts, typically in the 20mg - 50mg range. That means a minimum accuracy (not resolution) of 2 - 4 degrees.

Essentially, you should think of those things as tilt indicator, not tilt measurement tool and they are effectively 5 - 6 digits accuracy.
 Logged

0
Offline
Tesla Member
Karma: 81
Posts: 8188
:(){:|:&};:
 « Reply #31 on: November 12, 2012, 03:27:28 pm » Bigger Smaller Reset

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

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.

i can understand drift and other approximation/errors give you to wrong value, but i still cant' understand where this "90/256 ~= 0.4" come from, in particular the "90"
 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 #32 on: November 12, 2012, 05:20:43 pm » 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°
Okay, thanks for that. I guess I was more off the mark than I thought.

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.

That is unfortunate. I may have to look for a more accurate sensor in that case.
 Logged

Offline
Edison Member
Karma: 114
Posts: 2205
 « Reply #33 on: November 12, 2012, 05:41:41 pm » Bigger Smaller Reset

Quote

sin(x) -> x as x -> 0.

That approximation is the better when x is smaller.

Quote
i can understand drift and other approximation/errors give you to wrong value, but i still cant' understand where this "90/256 ~= 0.4" come from, in particular the "90"

In 90 degrees, the sensed gravity on the z axis goes from 1g to 0.
 Logged

Offline
Edison Member
Karma: 4
Posts: 1131
If you're not living on the Edge, you're taking up too much space!
 « Reply #34 on: November 22, 2012, 09:18:10 am » Bigger Smaller Reset

What is everyone measuring the angle of?  Hopefully not a motorcycle...
 Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

 Pages: 1 2 [3]   Go Up