SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By weboide
#182956
I put together my redbot shadow chassis kit and everything is working great except the accelerometer.

AngleXY (which I'm guessing should give me the "direction" of the bot) is not giving sensible values. I checked AngleXZ and angleYZ which gave accurate results. Now when I rotate the bot along XZ, angleXZ increases normally, but angleXY also increases, which I find odd.

I'm using the redbot library and the code from experiment 8-1 Accelerometer Read.

Here's some samples:

Laying still on table ([xz, yz, xy]):
Code: Select all
(-560, -272, 16304) -- [-1.97, -0.96, -115.91]
(-496, -224, 16368) -- [-1.74, -0.78, -114.30]
(-480, -240, 16304) -- [-1.69, -0.84, -116.57]
(-400, -208, 16336) -- [-1.40, -0.73, -117.47]
(-448, -224, 16368) -- [-1.57, -0.78, -116.57]
(-464, -240, 16352) -- [-1.63, -0.84, -117.35]
(-640, -208, 16256) -- [-2.25, -0.73, -108.00]
(-592, -176, 16304) -- [-2.08, -0.62, -106.56]
(-560, -176, 16256) -- [-1.97, -0.62, -107.45]
(-576, -160, 16272) -- [-2.03, -0.56, -105.52]
(-608, -112, 16224) -- [-2.15, -0.40, -100.44]
(-528, -240, 16320) -- [-1.85, -0.84, -114.44]
(-576, -192, 16304) -- [-2.02, -0.67, -108.43]
(-512, -112, 16352) -- [-1.79, -0.39, -102.34]
(-496, -208, 16352) -- [-1.74, -0.73, -112.75]
(-544, -112, 16320) -- [-1.91, -0.39, -101.63]
(-432, -160, 16368) -- [-1.51, -0.56, -110.32]
(-432, -256, 16336) -- [-1.51, -0.90, -120.65]
(-416, -240, 16368) -- [-1.46, -0.84, -119.98]
(-480, -208, 16320) -- [-1.68, -0.73, -113.43]
(-464, -128, 16336) -- [-1.63, -0.45, -105.42]
(-544, 0, 16432) -- [-1.90, 0.00, -90.00]
(-592, -384, 16336) -- [-2.08, -1.35, -122.97]
(-496, -256, 16304) -- [-1.74, -0.90, -117.30]
(-512, -240, 16320) -- [-1.80, -0.84, -115.11]
(-528, -208, 16240) -- [-1.86, -0.73, -111.50]
(-272, -224, 16304) -- [-0.96, -0.79, -129.47]
Moving 0-90 degres along XY ([xz, yz, xy]):
Code: Select all
(-144, -384, 16224) -- [-0.51, -1.36, -159.44]
(-16, -432, 16336) -- [-0.06, -1.51, -177.88]
(-256, -416, 16384) -- [-0.90, -1.45, -148.39]
(-16, -432, 16368) -- [-0.06, -1.51, -177.88]
(-128, -848, 16320) -- [-0.45, -2.97, -171.42]
(352, -1472, 16144) -- [1.25, -5.21, 166.55]
(1408, -2512, 15840) -- [5.08, -9.01, 150.73]
(-2064, -1696, 17488) -- [-6.73, -5.54, -129.41]
(80, 5200, 25392) -- [0.18, 11.57, 0.88]
(-2080, 2432, 21792) -- [-5.45, 6.37, -40.54]
(-128, -1328, 18000) -- [-0.41, -4.22, -174.49]
(1680, -496, 19424) -- [4.94, -1.46, 106.45]
(-1472, -2624, 14528) -- [-5.79, -10.24, -150.71]
(-2160, -1168, 16160) -- [-7.61, -4.13, -118.40]
(-1168, -2944, 15616) -- [-4.28, -10.68, -158.36]
(624, -896, 16240) -- [2.20, -3.16, 145.15]
(-384, -176, 16160) -- [-1.36, -0.62, -114.62]
(-1920, 64, 16944) -- [-6.46, 0.22, -88.09]
(-192, -960, 16800) -- [-0.65, -3.27, -168.69]
Moving 0-90 and 90-0 degres along XZ ([xz, yz, xy]). Notice that XY changes similar to XZ.
Code: Select all
(-1952, -48, 16656) -- [-6.68, -0.17, -91.41]
(1168, 1488, 15072) -- [4.43, 5.64, 38.13]
(-240, 11424, 22624) -- [-0.61, 26.79, -1.20]
(9200, -1856, 5888) -- [57.38, -17.50, 101.41]
(12400, -208, 11360) -- [47.51, -1.05, 90.96]
(13616, -2608, 5376) -- [68.45, -25.88, 100.84]
(31312, -7488, -13216) -- [112.88, -150.46, 103.45]
(15904, 432, 4480) -- [74.27, 5.51, 88.44]
(15952, -1024, 3888) -- [76.30, -14.76, 93.67]
(16064, -1040, 3392) -- [78.08, -17.05, 93.70]
(16144, -896, 3520) -- [77.70, -14.28, 93.18]
(17936, 16, 4032) -- [77.33, 0.23, 89.95]
(15136, 1488, 6496) -- [66.77, 12.90, 84.39]
(10048, -384, 9648) -- [46.16, -2.28, 92.19]
(6256, 224, 15456) -- [22.04, 0.83, 87.95]
(4368, -2016, 14512) -- [16.75, -7.91, 114.78]
(656, -4080, 15616) -- [2.41, -14.64, 170.87]
(-2080, -1952, 15120) -- [-7.83, -7.36, -133.18]
(96, 208, 16064) -- [0.34, 0.74, 24.78]
(-400, -1168, 15632) -- [-1.47, -4.27, -161.10]
By jremington
#182971
An accelerometer alone cannot detect which way the robot is "pointing" in the horizontal plane, unless it is accelerating. You need a magnetometer for that.

With an accelerometer, you can detect the tilt with respect to vertical, but this is accurate only if the robot is motionless or not accelerating. For more on the theory, see this application note: http://cache.freescale.com/files/sensor ... AN3461.pdf
By weboide
#182978
jremington wrote:An accelerometer alone cannot detect which way the robot is "pointing" in the horizontal plane, unless it is accelerating. You need a magnetometer for that.

With an accelerometer, you can detect the tilt with respect to vertical, but this is accurate only if the robot is motionless or not accelerating. For more on the theory, see this application note: http://cache.freescale.com/files/sensor ... AN3461.pdf
Thank you for clarifying this! I was wondering if it was a "limitation" of the accelerometer, but since I had zero knowledge with those, I thought I'd post a question here.
Well, thanks a lot for the quick reply and the helpful documentation!