女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何制作數字指南針

454398 ? 來源:wv ? 2019-10-12 14:19 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

第1步:所需零件

對于此項目,您將只需要一個Arduino開發板和一個MEMS磁力計即可測量地磁場。我將使用包含MC5883L 3軸磁力計的GY – 80分支板。

在繼續執行該項目的源代碼之前,如果您需要更多詳細信息,請參見MEMS磁力計如何工作以及如何通過I2C通信連接和使用GY-80接線板,

第2步:Arduino源代碼

我們首先需要做的是將草圖上傳到Arduino板,該板將讀取來自磁力計的數據,并將其發送到Processing IDE。這是Arduino源代碼:

/* Arduino Compass

*

* by Dejan Nedelkovski,

* www.HowToMechatronics.com

*

*/

#include //I2C Arduino Library

#define Magnetometer_mX0 0x03

#define Magnetometer_mX1 0x04

#define Magnetometer_mZ0 0x05

#define Magnetometer_mZ1 0x06

#define Magnetometer_mY0 0x07

#define Magnetometer_mY1 0x08

int mX0, mX1, mX_out;

int mY0, mY1, mY_out;

int mZ0, mZ1, mZ_out;

float heading, headingDegrees, headingFiltered, declination;

float Xm,Ym,Zm;

#define Magnetometer 0x1E //I2C 7bit address of HMC5883

void setup(){

//Initialize Serial and I2C communications

Serial.begin(115200);

Wire.begin();

delay(100);

Wire.beginTransmission(Magnetometer);

Wire.write(0x02); // Select mode register

Wire.write(0x00); // Continuous measurement mode

Wire.endTransmission();

}

void loop(){

//---- X-Axis

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mX1);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mX0 = Wire.read();

}

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mX0);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mX1 = Wire.read();

}

//---- Y-Axis

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mY1);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mY0 = Wire.read();

}

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mY0);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mY1 = Wire.read();

}

//---- Z-Axis

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mZ1);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mZ0 = Wire.read();

}

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mZ0);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mZ1 = Wire.read();

}

//---- X-Axis

mX1=mX1《《8;

mX_out =mX0+mX1; // Raw data

// From the datasheet: 0.92 mG/digit

Xm = mX_out*0.00092; // Gauss unit

//* Earth magnetic field ranges from 0.25 to 0.65 Gauss, so these are the values that we need to get approximately.

//---- Y-Axis

mY1=mY1《《8;

mY_out =mY0+mY1;

Ym = mY_out*0.00092;

//---- Z-Axis

mZ1=mZ1《《8;

mZ_out =mZ0+mZ1;

Zm = mZ_out*0.00092;

// ==============================

//Calculating Heading

heading = atan2(Ym, Xm);

// Correcting the heading with the declination angle depending on your location

// You can find your declination angle at: http://www.ngdc.noaa.gov/geomag-web/

// At my location it‘s 4.2 degrees =》 0.073 rad

declination = 0.073;

heading += declination;

// Correcting when signs are reveresed

if(heading 《0) heading += 2*PI;

// Correcting due to the addition of the declination angle

if(heading 》 2*PI)heading -= 2*PI;

headingDegrees = heading * 180/PI; // The heading in Degrees unit

// Smoothing the output angle / Low pass filter

headingFiltered = headingFiltered*0.85 + headingDegrees*0.15;

//Sending the heading value through the Serial Port to Processing IDE

Serial.println(headingFiltered);

delay(50);

}

步驟3:處理IDE源代碼

在我們上傳了之前的Arduino草圖之后,我們需要將數據接收到Processing IDE中并繪制Digital Compass。指南針由背景圖像,箭頭的固定圖像和指南針主體的旋轉圖像組成。因此,使用Arduino計算出的耳磁場的值將用來旋轉羅盤。

以下是Processing IDE的源代碼:

/* Arduino Compass

*

* by Dejan Nedelkovski,

* www.HowToMechatronics.com

*

*/

import processing.serial.*;

import java.awt.event.KeyEvent;

import java.io.IOException;

Serial myPort;

PImage imgCompass;

PImage imgCompassArrow;

PImage background;

String data=“”;

float heading;

void setup() {

size (1920, 1080, P3D);

smooth();

imgCompass = loadImage(“Compass.png”);

imgCompassArrow = loadImage(“CompassArrow.png”);

background = loadImage(“Background.png”);

myPort = new Serial(this, “COM4”, 115200); // starts the serial communication

myPort.bufferUntil(’ ‘);

}

void draw() {

image(background,0, 0); // Loads the Background image

pushMatrix();

translate(width/2, height/2, 0); // Translates the coordinate system into the center of the screen, so that the rotation happen right in the center

rotateZ(radians(-heading)); // Rotates the Compass around Z - Axis

image(imgCompass, -960, -540); // Loads the Compass image and as the coordinate system is relocated we need need to set the image at -960x, -540y (half the screen size)

popMatrix(); // Brings coordinate system is back to the original position 0,0,0

image(imgCompassArrow,0, 0); // Loads the CompassArrow image which is not affected by the rotateZ() function because of the popMatrix() function

textSize(30);

text(“Heading: ” + heading,40,40); // Prints the value of the heading on the screen

delay(40);

}

// starts reading data from the Serial Port

void serialEvent (Serial myPort) {

data = myPort.readStringUntil(’ ‘);// reads the data from the Serial Port and puts it into the String variable “data”。

heading = float(data); // Convering the the String value into Float value

}

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 指南針
    +關注

    關注

    2

    文章

    17

    瀏覽量

    11022
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    東映攜手奧拓刷新日本影視制作數字化標桿

    近日,由奧拓電子全程深度參與打造的“東映虛擬影棚”已正式發布啟用。這座凝聚前沿科技的虛擬影棚,不僅以640㎡的規模成為日本之最,更憑借頂尖技術配置,刷新了日本影視制作數字化標桿。作為日本首個由電影
    的頭像 發表于 06-04 15:21 ?377次閱讀

    不到千元體驗最新數字人技術!華為云 Flexus 數字人效果領先更超值

    當下,數字人的應用已經非常廣泛,徹底走進了我們的日常生活。在教育領域,可以看到數字人被用于制作教學視頻,通過模擬真實的教師講解,為學生提供生動、直觀的學習材料;在政府服務大廳,有數字
    的頭像 發表于 03-10 11:04 ?338次閱讀
    不到千元體驗最新<b class='flag-5'>數字</b>人技術!華為云 Flexus <b class='flag-5'>數字</b>人效果領先更超值

    多種傳感器集成,IMU助力無人機穩定飛行

    常見的傳感器包括陀螺儀、加速度計、磁力計(指南針)、氣壓計(高度計)和GPS模塊,大多數IMU只集成陀螺儀和加速度計。
    的頭像 發表于 12-18 14:34 ?1064次閱讀
    多種傳感器集成,IMU助力無人機穩定飛行

    3D掃描與數字拓片:打造文化遺產的數字復本

    拓片作為一種記錄和傳承傳統石刻文化的方式,承載了厚重的歷史文化信息。然而,傳統的拓片手段在文物保存和展示方面存在許多局限。隨著科技的進步,通過3D掃描制作數字拓片,不僅能夠精準采集石刻的每一處細節
    的頭像 發表于 10-31 17:22 ?553次閱讀
    3D掃描與<b class='flag-5'>數字</b>拓片:打造文化遺產的<b class='flag-5'>數字</b>復本

    用AIC3254來作數字拾音器,遇到的幾個疑問求解

    我是用AIC3254來作數字拾音器,當中遇到了一點問題 1,ADC DAC不能使用預置處理模式,也就是說我在p0_r60,p_r61只能設置為0(minidsp used for signal
    發表于 10-31 07:53

    電流傳感器的主要參數與選型

    和控制等要求。電流傳感器廣泛應用于家用電器、智能電網、電動車、風力發電等領域,如電腦硬盤、指南針等設備中都含有電流傳感器。
    的頭像 發表于 10-22 18:18 ?3515次閱讀

    使用PCM5242連接到TMS320C5517上作數字量與模擬量的轉換,如何配置寄存器參數?

    現在使用PCM5242連接到TMS320C5517上作數字量與模擬量的轉換,控制線是I2C,數據線是I2S3,應該如何配置寄存器參數
    發表于 10-16 06:32

    現代海上的電子指南針——艦艇慣導系統

    艦艇慣導系統通過慣性測量裝置獲取艦艇運動參數,實現自主、連續、隱蔽的導航,提供航向、速度等關鍵信息。未來趨勢包括高精度化、多傳感器融合和自主導航能力提升,為船舶航行帶來更多便利和安全。
    的頭像 發表于 09-30 15:46 ?859次閱讀

    索尼DMX-R100數字音頻混音器使用手冊

    DMX-R100是一款緊湊型數字音頻混音器,適用于制作數字媒體或數字廣播的制作公司。
    發表于 09-29 11:49 ?2次下載

    數字隔離器的設計指南

    電子發燒友網站提供《數字隔離器的設計指南.pdf》資料免費下載
    發表于 08-31 09:43 ?2次下載
    <b class='flag-5'>數字</b>隔離器的設計<b class='flag-5'>指南</b>

    數字隔離器設計指南

    電子發燒友網站提供《數字隔離器設計指南.pdf》資料免費下載
    發表于 08-30 11:36 ?0次下載
    <b class='flag-5'>數字</b>隔離器設計<b class='flag-5'>指南</b>

    醫療機器人的“指南針”:MT6701磁編碼IC實現精確導航

    ,MT6701 磁編碼 IC 憑借其卓越的性能,成為了實現精密導航的核心力量。 MT6701 磁編碼 IC 究竟有何獨特之處?它就像是醫療機器人的“指南針”,能夠在復雜的醫療環境中為機器人提供精確無誤的位置和方向信息。想象一下,在一臺精密的
    的頭像 發表于 08-23 17:23 ?846次閱讀

    e2studio開發磁力計LIS2MDL(1)----輪詢獲取磁力計數據

    為適當的單位并通過串行通信輸出。 這個傳感器常用于多種電子設備中,以提供精確的磁場強度數據,從而用于指南針應用、位置追蹤或者動作檢測等功能。
    的頭像 發表于 08-09 15:14 ?2396次閱讀
    e2studio開發磁力計LIS2MDL(1)----輪詢獲取磁力計數據

    關鍵指南針-NXP USB CDC_VCOM虛擬串口例程

    最近有小伙伴反應USB中的 usb_examples/usb_device_cdc_vcom 例程(USB虛擬串口VCOM)中的一些使用問題,今天集中來說說使用example的必知要點~ 實驗平臺和軟件版本說明 本篇文章的實驗平臺為:SDK_2_5_0_LPC54605J512oardslpcxpresso54608usb_examplesusb_device_cdc_vcom?但實際上本篇文章適用于NXP大部分的硬件平臺,因為usb_device_cdc_vcom(以下簡稱vcom)這部分例程代碼和硬件關系并不大,屬于USB Stack之上的應用部分,另外這部分代碼在SDK的各個版本上變化也不是很大,所以如果您使用的新
    的頭像 發表于 07-25 09:17 ?2852次閱讀
    關鍵<b class='flag-5'>指南針</b>-NXP USB CDC_VCOM虛擬串口例程

    深度揭秘!觀測云產品核心理念

    一個產品的強大生命力和競爭力,源自于其內在的哲學和理念。作為團隊的領航者,我帶領著每一位成員,堅守著這些核心理念。它們是我們設計和實現產品的基石,是我們在技術發展道路上的指南針
    的頭像 發表于 07-23 10:15 ?426次閱讀