欧美性猛交xxxx免费看_牛牛在线视频国产免费_天堂草原电视剧在线观看免费_国产粉嫩高清在线观看_国产欧美日本亚洲精品一5区

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

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

3天內(nèi)不再提示

如何制作數(shù)字指南針

454398 ? 來源:wv ? 2019-10-12 14:19 ? 次閱讀

第1步:所需零件

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

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

第2步:Arduino源代碼

我們首先需要做的是將草圖上傳到Arduino板,該板將讀取來自磁力計的數(shù)據(jù),并將其發(fā)送到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草圖之后,我們需要將數(shù)據(jù)接收到Processing IDE中并繪制Digital Compass。指南針由背景圖像,箭頭的固定圖像和指南針主體的旋轉(zhuǎn)圖像組成。因此,使用Arduino計算出的耳磁場的值將用來旋轉(zhuǎn)羅盤。

以下是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

}

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

    關(guān)注

    2

    文章

    17

    瀏覽量

    10902
收藏 人收藏

    評論

    相關(guān)推薦

    多種傳感器集成,IMU助力無人機穩(wěn)定飛行

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

    3D掃描與數(shù)字拓片:打造文化遺產(chǎn)的數(shù)字復本

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

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

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

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

    現(xiàn)在使用PCM5242連接到TMS320C5517上作數(shù)字量與模擬量的轉(zhuǎn)換,控制線是I2C,數(shù)據(jù)線是I2S3,應(yīng)該如何配置寄存器參數(shù)
    發(fā)表于 10-16 06:32

    現(xiàn)代海上的電子指南針——艦艇慣導系統(tǒng)

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

    索尼DMX-R100數(shù)字音頻混音器使用手冊

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

    數(shù)字隔離器的設(shè)計指南

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

    數(shù)字隔離器設(shè)計指南

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

    醫(yī)療機器人的“指南針”:MT6701磁編碼IC實現(xiàn)精確導航

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

    e2studio開發(fā)磁力計LIS2MDL(1)----輪詢獲取磁力計數(shù)據(jù)

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

    關(guān)鍵指南針-NXP USB CDC_VCOM虛擬串口例程

    最近有小伙伴反應(yīng)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)這部分例程代碼和硬件關(guān)系并不大,屬于USB Stack之上的應(yīng)用部分,另外這部分代碼在SDK的各個版本上變化也不是很大,所以如果您使用的新
    的頭像 發(fā)表于 07-25 09:17 ?2266次閱讀
    關(guān)鍵<b class='flag-5'>指南針</b>-NXP USB CDC_VCOM虛擬串口例程

    深度揭秘!觀測云產(chǎn)品核心理念

    一個產(chǎn)品的強大生命力和競爭力,源自于其內(nèi)在的哲學和理念。作為團隊的領(lǐng)航者,我?guī)ьI(lǐng)著每一位成員,堅守著這些核心理念。它們是我們設(shè)計和實現(xiàn)產(chǎn)品的基石,是我們在技術(shù)發(fā)展道路上的指南針。
    的頭像 發(fā)表于 07-23 10:15 ?275次閱讀

    感謝浙江理工大學對我司導熱系數(shù)測試儀認可

    在現(xiàn)代工業(yè)與科技的浪潮中,測量技術(shù)如同航海者的指南針,引領(lǐng)著產(chǎn)品質(zhì)量與性能的不斷提升。在這樣的背景下,浙江理工大學的科研團隊對我司HS-DR-5導熱系數(shù)測試儀的認可,不僅是對該儀器性能的一次權(quán)威驗證
    的頭像 發(fā)表于 06-13 10:11 ?351次閱讀
    感謝浙江理工大學對我司導熱系數(shù)測試儀認可

    科學指南針&amp;華東理工大學XPS表面分析技術(shù)課程圓滿落幕

    在科學探索的道路上,不斷學習和掌握先進的科研技術(shù)對于推動學術(shù)創(chuàng)新至關(guān)重要。近日,科學指南針與華東理工大學聯(lián)合舉辦的XPS表面分析技術(shù)課程在華東理工大學奉賢校區(qū)圓滿結(jié)束。本次課程吸引了眾多
    的頭像 發(fā)表于 05-18 15:01 ?601次閱讀

    傳感器的應(yīng)用前景分析

    時期,因人們對于物體磁性的不斷探索,進而發(fā)明能夠感受磁場的最早傳感器——指南針。 三、傳感器的前景 ? ? ? 傳感器作為一種能夠監(jiān)測、測量和定位物理量,并將其轉(zhuǎn)化為可讀的電信號或數(shù)字信號的技術(shù)術(shù)語,是實現(xiàn)智能化和自動化的
    的頭像 發(fā)表于 03-11 16:34 ?986次閱讀