资源简介
找了好久的HMC5883L,霍尼韦尔常用的罗盘,指南针模块的库文件,以及中英文说明书,原来的下载链接都失效了,共享出来给需要的兄弟们。
代码片段和文件信息
/*
HMC5883L.cpp - Class file for the HMC5883L Triple Axis Magnetometer Arduino Library.
Copyright (C) 2011 Love Electronics (loveelectronics.co.uk)
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not see .
WARNING: THE HMC5883L IS NOT IDENTICAL TO THE HMC5883!
Datasheet for HMC5883L:
http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf
*/
#include
#include “HMC5883L.h“
HMC5883L::HMC5883L()
{
m_Scale = 1;
}
MagnetometerRaw HMC5883L::ReadRawAxis()
{
uint8_t* buffer = Read(DataRegisterBegin 6);
MagnetometerRaw raw = MagnetometerRaw();
raw.XAxis = (buffer[0] << 8) | buffer[1];
raw.ZAxis = (buffer[2] << 8) | buffer[3];
raw.YAxis = (buffer[4] << 8) | buffer[5];
return raw;
}
MagnetometerScaled HMC5883L::ReadScaledAxis()
{
MagnetometerRaw raw = ReadRawAxis();
MagnetometerScaled scaled = MagnetometerScaled();
scaled.XAxis = raw.XAxis * m_Scale;
scaled.ZAxis = raw.ZAxis * m_Scale;
scaled.YAxis = raw.YAxis * m_Scale;
return scaled;
}
int HMC5883L::SetScale(float gauss)
{
uint8_t regValue = 0x00;
if(gauss == 0.88)
{
regValue = 0x00;
m_Scale = 0.73;
}
else if(gauss == 1.3)
{
regValue = 0x01;
m_Scale = 0.92;
}
else if(gauss == 1.9)
{
regValue = 0x02;
m_Scale = 1.22;
}
else if(gauss == 2.5)
{
regValue = 0x03;
m_Scale = 1.52;
}
else if(gauss == 4.0)
{
regValue = 0x04;
m_Scale = 2.27;
}
else if(gauss == 4.7)
{
regValue = 0x05;
m_Scale = 2.56;
}
else if(gauss == 5.6)
{
regValue = 0x06;
m_Scale = 3.03;
}
else if(gauss == 8.1)
{
regValue = 0x07;
m_Scale = 4.35;
}
else
return ErrorCode_1_Num;
// Setting is in the top 3 bits of the register.
regValue = regValue << 5;
Write(ConfigurationRegisterB regValue);
}
int HMC5883L::SetMeasurementMode(uint8_t mode)
{
Write(ModeRegister mode);
}
void HMC5883L::Write(int address int data)
{
Wire.beginTransmission(HMC5883L_Address);
Wire.send(address);
Wire.send(data);
Wire.endTransmission();
}
uint8_t* HMC5883L::Read(int address int length)
{
Wire.beginTransmission(HMC5883L_Address);
Wire.send(address);
Wire.endTransmission();
Wire.beginTransmission(HMC5883L_Address);
Wire.requestFrom(HMC5883L_Address length);
uint8_t buffer[length];
if(Wire.available() == length)
{
for(uint8_t i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 128069 2017-04-13 18:39 QMC5883 HMC5883 寄存器对比以及参考设置.png
文件 1032 2011-09-10 20:46 HMC5883L\HHMC5883L_Example_Ansifa\HHMC5883L_Example_Ansifa.pde
文件 3259 2011-07-12 17:21 HMC5883L\HMC5883L.cpp
文件 1999 2011-07-12 17:21 HMC5883L\HMC5883L.h
文件 4217 2011-07-12 17:55 HMC5883L\HMC5883L_Example\HMC5883L_Example.pde
文件 741 2011-07-12 16:11 HMC5883L\keywords.txt
文件 448876 2011-03-20 13:45 HMC5883进口数据手册--L883\HMC5843-C.pdf
文件 1711 2011-03-20 16:00 HMC5883进口数据手册--L883\HMC5843.txt
文件 861932 2011-03-17 11:07 HMC5883进口数据手册--L883\HMC5883L.pdf
文件 3792 2011-03-23 23:57 HMC5883进口数据手册--L883\HMC5883L.txt
文件 480897 2011-03-20 13:28 HMC5883进口数据手册--L883\HMC5883L中文规格书.pdf
目录 0 2012-01-09 10:31 HMC5883L\HHMC5883L_Example_Ansifa
目录 0 2012-01-09 10:31 HMC5883L\HMC5883L_Example
目录 0 2012-01-09 10:31 HMC5883L
目录 0 2017-04-13 18:28 HMC5883进口数据手册--L883
----------- --------- ---------- ----- ----
1936525 15
- 上一篇:Finite Fields
- 下一篇:GPS在stm32单片机例程
相关资源
- arduino 小贱钟源码及教程
- Atom-TMC2208Pilot在Arduino上运行的应用程
- hmc5883l在stm32上的应用
- 写字机制作方案
- PID-增量式PID和位置式PID算法实现和
- Building Wireless Sensor Networks Using Arduin
- vc控制Arduino,实现串口通信
- Arduino入门经典
- Arduino所有库.zip
- 基于STM32和arduino的MPU9250九轴传感器代
- GY-9960模块Keil 和Arduino驱动程序
- ILI9486 3.5TFT液晶屏Arduino驱动
- [高清文字版]Arduino开发从零开始学
- 基于stm32战舰板的电子罗盘源代码
- Arduino传感器详解与应用
- 基于ESPDuino的智慧物联开发宝典电子版
- Arduino 负温度系数热敏电阻NTC测温
- Data From arduino to Excel
- arduino+App Inventor+mixly=纯图形化编程实
- 蓝桥杯大赛少儿创意编程Arduino组赛前
- Arduino的LCD12864例程包含库文件
- 米思齐第三方库
- atmega328p心型流水灯
- Arduino 常用库文件
- arduino超声波避障小车
- D1开发板学习资料例程.rar
- OLED原理图、说明、程序51、stm32、Ar
- rfid技术与Arduino开发
- arduino高级开发权威指南(第二版)
- win32控制台与arduino通信
评论
共有 条评论