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

來自ALSROBOT WiKi
跳轉(zhuǎn)至: 導(dǎo)航、 搜索
?產(chǎn)品相關(guān)推薦
 
(未顯示1個(gè)用戶的6個(gè)中間版本)
第11行: 第11行:
 
#通信接口:I2C
 
#通信接口:I2C
 
#尺寸大小: 17.78x17.78mm
 
#尺寸大?。?17.78x17.78mm
?
==使用方法==
+
==接口定義==
?
===引腳定義及內(nèi)部電路圖===
+
 
*GND:地(GND)
 
*GND:地(GND)
 
*VIN:電源(VCC)
 
*VIN:電源(VCC)
第19行: 第18行:
 
[[文件:3zszlp1.jpg|700px|縮略圖|居中]]
 
[[文件:3zszlp1.jpg|700px|縮略圖|居中]]
  
?
===連接圖示===
+
==使用方法==
 +
===接線方法===
 
SCL和SDA端口分別接到控制器的模擬5和4 I/O口。VIN和GND分別接到電源的3.3V和GND。
 
SCL和SDA端口分別接到控制器的模擬5和4 I/O口。VIN和GND分別接到電源的3.3V和GND。
 +
[[文件:RB02S07701.png|500px|縮略圖|居中]]
  
?
[[文件:3zszlp2.jpg|700px|縮略圖|居中]]
+
===例子程序===
?
 
+
?
==應(yīng)用例程==
+
 
依照程序?qū)⑷S數(shù)字羅盤與UNO連接,觀察串口輸出的X、Y、Z 三軸數(shù)據(jù)。
 
依照程序?qū)⑷S數(shù)字羅盤與UNO連接,觀察串口輸出的X、Y、Z 三軸數(shù)據(jù)。
?
===示例代碼===
+
<pre style='color:blue'>
?
<pre style='color:blue'>#include <Wire.h> //I2C Arduino Library
+
/*
?
 
+
An Arduino code example for interfacing with the HMC5883
 +
Analog input 4 I2C SDA
 +
Analog input 5 I2C SCL
 +
*/
 +
#include <Wire.h> //I2C Arduino Library
 
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
 
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
  
第34行: 第37行:
 
   //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
?
   Wire.send(0x02); //select mode register
+
   Wire.write(0x02); //select mode register
?
   Wire.send(0x00); //continuous measurement mode
+
   Wire.write(0x00); //continuous measurement mode
 
   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);
?
   Wire.send(0x03); //select register 3, X MSB register
+
   Wire.write(0x03); //select register 3, X MSB register
?
   Wire.endTransmission();
+
   Wire.endTransmission();   
?
    
+
?
+
 
  //Read data from each axis, 2 registers per axis
 
  //Read data from each axis, 2 registers per axis
 
   Wire.requestFrom(address, 6);
 
   Wire.requestFrom(address, 6);
 
   if(6<=Wire.available()){
 
   if(6<=Wire.available()){
?
     x = Wire.receive()<<8; //X msb
+
     x = Wire.read()<<8; //X msb
?
     x |= Wire.receive(); //X lsb
+
     x |= Wire.read(); //X lsb
?
     z = Wire.receive()<<8; //Z msb
+
     z = Wire.read()<<8; //Z msb
?
     z |= Wire.receive(); //Z lsb
+
     z |= Wire.read(); //Z lsb
?
     y = Wire.receive()<<8; //Y msb
+
     y = Wire.read()<<8; //Y msb
?
     y |= Wire.receive(); //Y lsb
+
     y |= Wire.read(); //Y lsb
?
   }
+
   }
?
 
+
 
   //Print out values of each axis
 
   //Print out values of each axis
 
   Serial.print("x: ");
 
   Serial.print("x: ");
第70行: 第66行:
 
   Serial.print(y);
 
   Serial.print(y);
 
   Serial.print("  z: ");
 
   Serial.print("  z: ");
?
   Serial.println(z);
+
   Serial.println(z);
?
 
+
 
   delay(250);
 
   delay(250);
?
} </pre>
+
}
 +
</pre>
 
===程序效果===
 
===程序效果===
 
打開串口監(jiān)視器可以觀察到輸出的X、Y、Z 三軸數(shù)據(jù)。
 
打開串口監(jiān)視器可以觀察到輸出的X、Y、Z 三軸數(shù)據(jù)。
 +
[[文件:RB02S07710.png|300px|縮略圖|居中]]
 
==產(chǎn)品相關(guān)推薦==
 
==產(chǎn)品相關(guān)推薦==
?
購買地址:[http://lifestyle201.com/goods-588.html Sparkfun HMC5883L三軸數(shù)字羅盤傳感器]
+
[[文件: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)動擴(kuò)展板]<br/>
 +
===相關(guān)問題解答===
 +
 
 +
===相關(guān)學(xué)習(xí)資料===
 +
[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/>
 +
[http://pan.baidu.com/s/1ntD14VZ 三軸數(shù)字羅盤 HMC5883L 設(shè)計(jì)參考 Eagle 文件下載]<br/>
 +
[http://www.makerspace.cn/portal.php 奧松機(jī)器人技術(shù)論壇]<br/>

2015年10月23日 (五) 15:41的最后版本

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ī)器人上,從而做到方位識別定位的作用。附送PC機(jī)控制軟件,人機(jī)介面簡潔便于操作與觀測,控制器源程序開放,短暫時(shí)刻即可架設(shè)完成數(shù)字式電子羅 盤。可與多種單片機(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

接口定義

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

使用方法

接線方法

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

RB02S07701.png

例子程序

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

/*
An Arduino code example for interfacing with the HMC5883
Analog input 4 I2C SDA
Analog input 5 I2C SCL
*/
#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.write(0x02); //select mode register
  Wire.write(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.write(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.read()<<8; //X msb
    x |= Wire.read(); //X lsb
    z = Wire.read()<<8; //Z msb
    z |= Wire.read(); //Z lsb
    y = Wire.read()<<8; //Y msb
    y |= Wire.read(); //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ù)。

RB02S07710.png

產(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)動擴(kuò)展板

相關(guān)問題解答

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

HMC5883L Breakout Quickstart Guide
電路原理圖
HMC5883L 數(shù)據(jù)手冊
三軸數(shù)字羅盤 HMC5883L 設(shè)計(jì)參考 Eagle 文件下載
奧松機(jī)器人技術(shù)論壇