首页 三轴磁阻传感器

三轴磁阻传感器

举报
开通vip

三轴磁阻传感器 This doucment outlines the implementation of User Clibration of the magnetic compass. Specifically, it describes the mathematical computations in C/C++ source code. This calibration will correct or compensate for the hard iron effects. Hard iron effects a...

三轴磁阻传感器
This doucment outlines the implementation of User Clibration of the magnetic compass. Specifically, it describes the mathematical computations in C/C++ source code. This calibration will correct or compensate for the hard iron effects. Hard iron effects are magnetic field superimpositions on the earth's magnetic field that are fixed in magnitude and which do not depend on the orientation of the compass. The compass calibration shall be initiated by a user command that put the compass into the calibrtion mode. Once in that mode the compass shall be rotated through 360 degrees abouth the Forward or Left direction followed by a 360 rotation about the Up- Down direction. That is, there are two full rotations required to complete the physical movement required. At the end of the rotations a command to end the calibration process shall be issed by the user to the compass. It is important to keep the Forward (or Left ) axis level diring the first rotation and to keep the Up-Down axis vertical during the secon calibration and until the ful calibrtion is complete. Failure to follow these process will result in less than optimal calibration and heading errors are likely. Forward Direction (+) Left Direction (+) UP Direction (+) Figure 1 First 360 Rotation 2 nd 360 Rotation #define CalThreshold 0 int Xmax, Xmin, Ymax, Ymin, Zmax, Zmin; void Initialize_Cal_Variables(int MagX, int MagY, int MagZ) void Calibrate(int MagX, int MagY, int MagZ) void Compute_and_Save(void) void Hard_Iron_Correction( int Xoff, int Yoff, int Zoff ) void Initialize_Cal_Variables(int MagX, int MagY, int MagZ) { // set Max and Min values of the mag output to the current values Xmax=MagX; Xmin=MagX; Ymax=MagY; Ymin=MagY; Zmax=MagZ; Zmin=MagZ; } void Calibrate(int MagX, int MagY, int MagZ) { // this routine will capture the max and min values of the mag X, Y, and Z data while the // compass is being rotated 360 degrees through the level plane and the upright plane. // i.e. horizontal and vertical circles. // This function should be invoked while making continuous measurements //on the magnetometers int MagXreading, MagYreading, MagZreading; MagXreading=MagX; // just for clarification... can remove these lines MagYreading=MagY; MagZreading=MagZ; if (MagXreading > Xmax ) Xmax = MagXreading; if (MagXreading < Xmin ) Xmin = MagXreading; if(MagYreading > Ymax ) Ymax = MagYreading; if(MagYreading < Ymin ) Ymin = MagYreading; if(MagZreading > Zmax ) Zmax = MagZreading; if(MagZreading < Zmin ) Zmin = MagZreading; } void Compute_and_Save(void) { if(abs(Xmax - Xmin) > CalThreshold ) { Mag_UserCal_Offset_X = (Xmax + Xmin)/2; // Save parameters in EE } if(abs(Ymax - Ymin) > CalThreshold ) { Mag_UserCal_Offset_Y= (Ymax + Ymin)/2; //Save parameters in EE } if(abs(Zmax - Zmin) > CalThreshold ) { Mag_UserCal_Offset_Z = (Zmax +Zmin)/2; // Save parameters in EE } } void Hard_Iron_Correction( int Xoff, int Yoff, int Zoff ) // call this function for correction { MagX -= Mag_UserCal_Offset_X; MagY -= Mag_UserCal_Offset_Y; MagZ -= Mag_UserCal_Offset_Z; }
本文档为【三轴磁阻传感器】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_191571
暂无简介~
格式:pdf
大小:91KB
软件:PDF阅读器
页数:3
分类:工学
上传时间:2013-08-12
浏览量:30