“(SKU:RB-02S077)三軸數(shù)字羅盤 HMC5883L”的版本間的差異

來自ALSROBOT WiKi
跳轉(zhuǎn)至: 導(dǎo)航、 搜索
?產(chǎn)品相關(guān)推薦
第27行: 第27行:
 
依照程序?qū)⑷S數(shù)字羅盤與UNO連接,觀察串口輸出的X、Y、Z 三軸數(shù)據(jù)。
 
依照程序?qū)⑷S數(shù)字羅盤與UNO連接,觀察串口輸出的X、Y、Z 三軸數(shù)據(jù)。
 
===示例代碼===
 
===示例代碼===
?
<pre style='color:blue'>#include <Wire.h> //I2C Arduino Library
+
<pre style='color:blue'>
?
 
+
#include <Wire.h> //I2C Arduino Library
 
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
 
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
?
 
 
void setup(){
 
void setup(){
 
   //Initialize Serial and I2C communications
 
   //Initialize Serial and I2C communications
 
   Serial.begin(9600);
 
   Serial.begin(9600);
?
   Wire.begin();
+
   Wire.begin();
?
 
+
 
   //Put the HMC5883 IC into the correct operating mode
 
   //Put the HMC5883 IC into the correct operating mode
 
   Wire.beginTransmission(address); //open communication with HMC5883
 
   Wire.beginTransmission(address); //open communication with HMC5883
第42行: 第40行:
 
   Wire.endTransmission();
 
   Wire.endTransmission();
 
}
 
}
?
 
+
void loop()
?
void loop(){
+
{
?
 
+
 
   int x,y,z; //triple axis data
 
   int x,y,z; //triple axis data
?
 
 
   //Tell the HMC5883 where to begin reading data
 
   //Tell the HMC5883 where to begin reading data
 
   Wire.beginTransmission(address);
 
   Wire.beginTransmission(address);
第77行: 第73行:
 
打開串口監(jiān)視器可以觀察到輸出的X、Y、Z 三軸數(shù)據(jù)。
 
打開串口監(jiān)視器可以觀察到輸出的X、Y、Z 三軸數(shù)據(jù)。
 
==產(chǎn)品相關(guān)推薦==
 
==產(chǎn)品相關(guān)推薦==
?
購買地址:[http://lifestyle201.com/goods-588.html Sparkfun HMC5883L三軸數(shù)字羅盤傳感器]<br/>
+
[[文件:erweima.png|230px|無框|右]]
?
論壇地址:[http://www.makerspace.cn/portal.php 奧松機(jī)器人技術(shù)論壇]
+
===產(chǎn)品購買地址===
 +
[http://lifestyle201.com/goods-588.html Sparkfun HMC5883L三軸數(shù)字羅盤傳感器]<br/>
 +
===周邊產(chǎn)品推薦===
 +
[https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.14.QyL8Qd&id=18722272286 ADXL335模塊三軸加速度模塊]<br/>
 +
[https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.17.QyL8Qd&id=13280714814  Arduino ADXL345 三軸加速度計(jì)]<br/>
 +
[https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.20.QyL8Qd&id=522174307810 Arduino 9 Axes Motion Shield 9軸運(yùn)動(dòng)擴(kuò)展板]<br/>
 +
===相關(guān)問題解答===
 +
 
 +
===相關(guān)學(xué)習(xí)資料===
 +
[http://www.makerspace.cn/portal.php 奧松機(jī)器人技術(shù)論壇]<br/>
 +
[https://www.sparkfun.com/tutorials/301 HMC5883L Breakout Quickstart Guide]<br/>
 +
[http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/HMC5883L_Breakout-v11.pdf 電路原理圖]<br/>
 +
[http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf HMC5883L 數(shù)據(jù)手冊]<br/>

2015年9月30日 (三) 16:02的版本

3zszlp.jpg

目錄

產(chǎn)品概述

HMC5883L是奧松機(jī)器人最引進(jìn)的Sparkfun原裝進(jìn)口的三軸數(shù)字羅盤。通過I2C接口并提供2.16-3.6V的穩(wěn)定電壓就可以與HMC5883L完美連接,它可用于各種輪式機(jī)器人導(dǎo)航裝置。 此款三軸數(shù)字羅盤內(nèi)含HMC5883L測量芯片,可作為各種輪式機(jī)器人導(dǎo)航裝置,可裝在Boe-Bot Kit機(jī)器人上,從而做到方位識(shí)別定位的作用。附送PC機(jī)控制軟件,人機(jī)介面簡潔便于操作與觀測,控制器源程序開放,短暫時(shí)刻即可架設(shè)完成數(shù)字式電子羅 盤??膳c多種單片機(jī)融合,與BASIC Stamp,Javalin Stamp,以及SX 全系列完全相容。

規(guī)格參數(shù)

  1. 工作電壓 :2.16V~3.6V
  2. 工作電流:100uA(測量模式)
  3. 最大輸出頻率 :160Hz
  4. 磁場有效寬度:(+/-8 gauss)
  5. 羅盤航向精度:1~2度
  6. 通信接口:I2C
  7. 尺寸大小: 17.78x17.78mm

使用方法

引腳定義及內(nèi)部電路圖

  • GND:地(GND)
  • VIN:電源(VCC)
  • SCL:時(shí)鐘信號(hào)
  • SDA:數(shù)據(jù)信號(hào)
3zszlp1.jpg

連接圖示

SCL和SDA端口分別接到控制器的模擬5和4 I/O口。VIN和GND分別接到電源的3.3V和GND。

3zszlp2.jpg

應(yīng)用例程

依照程序?qū)⑷S數(shù)字羅盤與UNO連接,觀察串口輸出的X、Y、Z 三軸數(shù)據(jù)。

示例代碼

#include <Wire.h> //I2C Arduino Library
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
void setup(){
  //Initialize Serial and I2C communications
  Serial.begin(9600);
  Wire.begin();  
  //Put the HMC5883 IC into the correct operating mode
  Wire.beginTransmission(address); //open communication with HMC5883
  Wire.send(0x02); //select mode register
  Wire.send(0x00); //continuous measurement mode
  Wire.endTransmission();
}
void loop()
{
  int x,y,z; //triple axis data
  //Tell the HMC5883 where to begin reading data
  Wire.beginTransmission(address);
  Wire.send(0x03); //select register 3, X MSB register
  Wire.endTransmission();
  
 
 //Read data from each axis, 2 registers per axis
  Wire.requestFrom(address, 6);
  if(6<=Wire.available()){
    x = Wire.receive()<<8; //X msb
    x |= Wire.receive(); //X lsb
    z = Wire.receive()<<8; //Z msb
    z |= Wire.receive(); //Z lsb
    y = Wire.receive()<<8; //Y msb
    y |= Wire.receive(); //Y lsb
  }
  
  //Print out values of each axis
  Serial.print("x: ");
  Serial.print(x);
  Serial.print("  y: ");
  Serial.print(y);
  Serial.print("  z: ");
  Serial.println(z);
  
  delay(250);
} 

程序效果

打開串口監(jiān)視器可以觀察到輸出的X、Y、Z 三軸數(shù)據(jù)。

產(chǎn)品相關(guān)推薦

Erweima.png

產(chǎn)品購買地址

Sparkfun HMC5883L三軸數(shù)字羅盤傳感器

周邊產(chǎn)品推薦

ADXL335模塊三軸加速度模塊
Arduino ADXL345 三軸加速度計(jì)
Arduino 9 Axes Motion Shield 9軸運(yùn)動(dòng)擴(kuò)展板

相關(guān)問題解答

相關(guān)學(xué)習(xí)資料

奧松機(jī)器人技術(shù)論壇
HMC5883L Breakout Quickstart Guide
電路原理圖
HMC5883L 數(shù)據(jù)手冊