三轴指南针 HMC5883L 的角度算法公式是怎样的?如何使用C/C++编程序将数据处理并返回呢?
答案:1 悬赏:40 手机版
解决时间 2021-04-15 16:40
- 提问者网友:记得曾经
- 2021-04-15 09:08
三轴指南针 HMC5883L 的角度算法公式是怎样的?如何使用C/C++编程序将数据处理并返回呢?
最佳答案
- 五星知识达人网友:三千妖杀
- 2021-04-15 10:25
HMC HMC_count()
{
HMC count;
int x,y,z;
double angle;
Multiple_Read_HMC5883(); //连续读出数据,存储在BUF中
x=HMC_BUF[0] << 8 | HMC_BUF[1]; //Combine MSB and LSB of X Data output register
z=HMC_BUF[2] << 8 | HMC_BUF[3]; //Combine MSB and LSB of Z Data output register
y=HMC_BUF[4] << 8 | HMC_BUF[5]; //Combine MSB and LSB of Y Data output register
angle= atan2((double)y,(double)x) * (180 / 3.14159265) + 180; // angle in degrees
count.x=x;
count.y=y;
count.z=z;
count.angle=angle;
return count;
}
{
HMC count;
int x,y,z;
double angle;
Multiple_Read_HMC5883(); //连续读出数据,存储在BUF中
x=HMC_BUF[0] << 8 | HMC_BUF[1]; //Combine MSB and LSB of X Data output register
z=HMC_BUF[2] << 8 | HMC_BUF[3]; //Combine MSB and LSB of Z Data output register
y=HMC_BUF[4] << 8 | HMC_BUF[5]; //Combine MSB and LSB of Y Data output register
angle= atan2((double)y,(double)x) * (180 / 3.14159265) + 180; // angle in degrees
count.x=x;
count.y=y;
count.z=z;
count.angle=angle;
return count;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯