how do I calibrate an accelerometer?

6 ビュー (過去 30 日間)
rafael gonzalez
rafael gonzalez 2012 年 10 月 1 日
回答済み: Jean Lambert Kubwimana 2019 年 2 月 28 日
I am trying to calibrate a sensor. could somebody please help me find the values of theta xy, yx, yz, zx. or explain how to derive it. I have converted the raw values to g. you will see in the plot that the sqrt of x^2 + y^2 +z^2 is deviating quite a bit at some points.
clc
clear all
close all
% min max value
Mx_min = 27681;
Mx_max = 38526;
My_min = 27361;
My_max = 38388;
Mz_min = 27428;
Mz_max = 38539;
% scale value
Sx = 1/((Mx_max - Mx_min)/2);
Sy = 1/((My_max - My_min)/2);
Sz = 1/((Mz_max - Mz_min)/2);
% offset value
Bx = ((Mx_min * Sx) + (Mx_max * Sx)) /2
By = ((My_min * Sy) + (My_max * Sy)) /2
Bz = ((Mz_min * Sz) + (Mz_max * Sz)) /2
% theta
xy = 0;
yx = 0;
yz = 0;
zx = 0;
xz = (Mz_max - Mz_min) / (Mx_max - Mx_min);
zy = (Mz_max - Mz_min) / (My_max - My_min);
[V]=[-Sx, 0 , 0; 0, Sy, 0; 0, 0, -Sz;];
[B]=[Bx;-By;Bz;];
A = [27681,32967,32466;28803,29427,32348;32152,27448,32091;36084,28375,31847;38375,31952,31716;37481,36112,31824;34044,38281,32093;30030,37343,32380;27790,33916,32485;31414,30822,28580;30261,30797,28707;32275,29657,28526;34751,30315,28352;35988,32417,28280;35510,34827,28373;33417,36208,28565;31008,35662,28729;29654,33615,28772;33041,33380,27479;33171,33336,27450;32839,33538,27479;32427,33469,27512;32103,33124,27532;32189,32623,27515;32606,32347,27477;33073,32474,27440;33256,32886,27428;35032,35777,29465;36054,35727,29232;33385,37146,29464;30389,36294,29679;28796,33732,29729;29296,30551,29713;31775,28755,29481;34983,29252,29241;37012,32059,29171;36392,36286,33219;37360,36478,33094;33715,38385,33367;29929,37275,33607;27804,33893,33684;28453,29919,33550;31632,27487,33217;35787,28044,32948;38466,31662,32885;34996,35487,37249;36188,34945,37140;33946,36334,37263;31298,35673,37381;29830,33456,37373;30245,30704,37223;32341,29091,37017;35116,29449,36870;36925,31813,36858;33453,32468,38511;33388,32320,38508;33618,32341,38492;33759,32530,38492;33611,32763,38517;33481,32801,38528;33356,32725,38533;33306,32609,38529;33214,32506,38527;31528,30272,36910;30466,30074,37006;32845,28810,36800;35646,29586,36661;37181,32143,36666;36524,35016,36832;33996,36569,37052;31150,35837,37206;29603,33356,37206;30650,29510,33291;28830,29357,33457;32223,27361,33172;36213,28316,32914;38526,31943,32879;37608,36153,33034;34161,38334,33230;30084,37397,33521;27806,33924,33656;27682,32965,32471;28803,29437,32315;32156,27455,32052;36094,28393,31809;38381,31998,31710;37464,36140,31845;34028,38293,32145;30013,37335,32420;27787,33896,32489;31398,30881,28546;30309,30803,28674;32306,29669,28510;34743,30320,28348;36005,32390,28294;35521,34817,28376;33410,36198,28560;30995,35647,28729;29642,33580,28781;33047,33348,27474;33179,33293,27448;32852,33502,27476;32439,33437,27506;32115,33099,27534;32200,32601,27515;32605,32306,27483;33079,32427,27446;33269,32842,27430;35105,35649,29371;36080,35711,29243;33388,37150,29473;30381,36294,29692;28779,33705,29747;29354,30565,29641;31807,28792,29427;34965,29291,29199;36952,32052,29113;36165,36416,33224;37351,36489,33081;33696,38387,33387;29918,37262,33621;27790,33820,33685;28518,29810,33531;31655,27484,33273;35807,28054,33011;38470,31666,32913;35348,35057,37134;36271,35033,37038;33970,36384,37218;31348,35736,37367;29889,33550,37406;30290,30826,37313;32365,29226,37146;35098,29574,36988;36887,31894,36919;33480,32607,38519;33392,32407,38517;33626,32442,38505;33772,32630,38499;33618,32871,38519;33487,32910,38528;33360,32836,38536;33312,32722,38539;33203,32624,38537;31652,30322,36960;30462,30160,37065;32892,28893,36892;35737,29743,36746;37152,32266,36719;36503,35102,36807;33982,36645,36989;31165,35913,37160;29632,33438,37226;30546,29501,33354;28835,29358,33480;32234,27364,33268;36219,28320,33033;38526,31952,32909;37607,36154,33005;34122,38339,33285;30050,37368,33557;27803,33903,33663;27682,32953,32460;28814,29418,32317;32162,27450,32065;36094,28388,31824;38374,31972,31708;37470,36126,31827;34036,38283,32099;30023,37338,32374;27793,33913,32476;31312,30856,28588;30282,30782,28701;32289,29654,28525;34753,30311,28356;36028,32400,28309;35530,34851,28398;33421,36226,28585;30985,35676,28755;29615,33592,28810;33050,33369,27479;33177,33294,27448;32853,33501,27477;32440,33440,27509;32109,33097,27534;32187,32591,27518;32605,32311,27482;33077,32431,27446;33258,32846,27432;35177,35623,29398;36068,35667,29203;33394,37109,29425;30399,36268,29645;28800,33710,29724;29294,30524,29738;31789,28713,29529;35004,29219,29291;37025,32038,29194;36007,36517,33238;37365,36472,33076;33720,38388,33338;29941,37284,33584;27803,33889,33692;28509,29834,33578;31661,27480,33286;35819,28059,33018;38469,31673,32921;35488,34989,37114;36241,35098,37025;33973,36412,37199;31349,35761,37354;29835,33581,37363;30244,30819,37280;32350,29196,37116;35118,29546,36956;36936,31903,36873;33462,32625,38523;33401,32467,38521;33632,32486,38506;33773,32673,38501;33624,32904,38519;33495,32948,38528;33366,32874,38538;33318,32759,38535;33228,32656,38537;]
A = transpose(A);
for i=1:225
NEW(:,i) = (V * [ A(1,i); A(2,i); A(3,i);]) + B;
end
NEW = transpose(NEW);
for i=1:225
NEW(i,4) = sqrt( NEW(i,1)^2 + NEW(i,2)^2 + NEW(i,3)^2);
ROT(i,1) = atan2(NEW(i,2),NEW(i,1));
ROT(i,2) = radtodeg(-ROT(i,1));
INC(i,1) = atan(sqrt(NEW(i,1)^2 + NEW(i,2)^2 )/NEW(i,3));
INC(i,2) = radtodeg(INC(i,1));
if INC(i,2) < 0
INC(i,2) = INC(i,2) + 180;
else
INC(i,2) = INC(i,2);
end
if ROT(i,2) < 0
ROT(i,2) = ROT(i,2) + 360;
else
ROT(i,2) = ROT(i,2);
end
end
plot(NEW,'DisplayName','NEW','YDataSource','NEW');figure(gcf);
hold on
legend('X','Y','Z','sqrt(X^2 + Y^2 + Z^2)');
  3 件のコメント
Rolfe Dlugy-Hegwer
Rolfe Dlugy-Hegwer 2012 年 10 月 1 日
編集済み: Rolfe Dlugy-Hegwer 2012 年 10 月 1 日
What is the application? For example:
  • Working with normal gravity to determine which way is up.
  • Measuring acceleration under more extreme conditions.
Do you know, based on the datasheet, if the accelerometer response is sufficiently linear for your requirements? Or, does your calibration procedure need to correct for non-linearity?
Rolfe Dlugy-Hegwer
Rolfe Dlugy-Hegwer 2012 年 10 月 2 日
Q: Rolfe: Have you seen "MEMS Accelerometer Calibration using Gauss Newton Method" on File Exchange?
A: Rafael: I have tried the program and using my measured data. I keep getting problems with the matrix saying its close to singularity. and the result does not converge.

サインインしてコメントする。

回答 (1 件)

Jean Lambert Kubwimana
Jean Lambert Kubwimana 2019 年 2 月 28 日
Did you find any answer to this question? Your code is confusing and hard to follow. For example, after you transpose NEW, your the rest of the code is not being used in the calculation of x,y, and z! If you have found the answer please update us!

カテゴリ

Help Center および File ExchangeMulticore Processor Targets についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by