Yuav Ua Li Cas Txuas Cov Koob Yees Duab Digital HMC5883 Rau Arduino

Cov txheej txheem:

Yuav Ua Li Cas Txuas Cov Koob Yees Duab Digital HMC5883 Rau Arduino
Yuav Ua Li Cas Txuas Cov Koob Yees Duab Digital HMC5883 Rau Arduino

Video: Yuav Ua Li Cas Txuas Cov Koob Yees Duab Digital HMC5883 Rau Arduino

Video: Yuav Ua Li Cas Txuas Cov Koob Yees Duab Digital HMC5883 Rau Arduino
Video: Saib koosloos & Ulias lub tsev seb ua tau li cas lawm 2024, Kaum ib hlis
Anonim

Cia peb xav txog qhov txuas ntawm GY-273 module nrog Honeywell HMC5883L peb-axis digital phau duab hluav taws xob. Qhov microcircuit no tuaj yeem siv rau kev ntsuas ntsuas me me, hauv kev coj mus, yog tias qhov ntsuas qhov ntsuas siab tsis yog qhov xav tau (nrog yuam kev ntawm 1 … 2 degrees thiab tseem muaj peev xwm ntsuas). Cov cuab yeej txuas nrog ntawm I2C interface.

Digital Compass HMC5883
Digital Compass HMC5883

Tsim nyog

  • - Digital compass HMC5883;
  • - Arduino;
  • - qauv pawg thawj coj saib thiab txuas xov hlau;
  • - khoos phis tawj.

Cov Lus Qhia

Kauj ruam 1

Cov no yog cov yam ntxwv tseem ceeb ntawm lub koob taw qhia kev sib nqus:

- 3-axis magnetically rhiab rhiab;

- 12-ntsis ADC nrog daws teeb meem ntawm 2 mGs (milligauss);

- ua qhov kev ntsuas tus kheej;

- tsawg ua haujlwm voltage thiab tsawg noj;

- digital interface I2C;

- lub chaw pov npav siab - nce txog 160 zaug hauv ib ob (lub sijhawm ntsuas ib zaug yog kwv yees li 6 ms);

- qhov tseeb ntawm kev txiav txim siab qhov kev taw qhia yog 1 ° … 2 °;

- tuaj yeem siv rau hauv cov chaw muaj zog sib nqus (nce txog ± 8 Gauss).

Daim duab kos rau kev txuas nrog HMC5883L sib nqus lub ntsej muag mus rau Arduino yog muaj nyob hauv daim duab. Nws yog ib heev thiab yooj yim, vim hais tias Qhov ob-xaim I2C interface zoo heev vim nws yuav tsum muaj qee qhov kev sib txuas. Koj tuaj yeem siv lub khob cij.

Siv lub HMC5883 digital compass mus rau Arduino
Siv lub HMC5883 digital compass mus rau Arduino

Kauj ruam 2

Nws yuav tsum saib tej yam xws li duab. Kuv tseem yuav txuas cov cav laij lej sib txuas nrog rau tsheb npav SCL thiab SDA los saib xyuas cov ntaub ntawv sib pauv ntawm Arduino thiab HMC5883 module. Nws tsis yog qhov yuav tsum ua.

HMC5883 digital compass txuas nrog Arduino ntawm lub khob cij
HMC5883 digital compass txuas nrog Arduino ntawm lub khob cij

Kauj ruam 3

Raws li kev paub ua ntej, cia peb sim nyeem cov ntawv teev npe 10 (0xA), 11 (0xB) thiab 12 (0xC) ntawm cov xov hluav taws xob HMC5883 thiab sau cov duab kos zoo li hauv daim duab. Nws muaj cov ncauj lus kom ntxaws.

Kos duab nyeem cov ntawv sau npe ntawm HMC5883
Kos duab nyeem cov ntawv sau npe ntawm HMC5883

Kauj ruam 4

Cov teeb liab tau nrog lub ntsuas tus txheeb xyuas yuav ua tau raws li nyob hauv daim duab no.

Nws txhais li cas? Thawj byte yog I2C chaw nyob nrog uas peb (tus ntaus tswv, Arduino) tsim kev sib txuas lus (siab 7 npuag 0x1E), thiab sau hom (qis me ntsis - 0x0); tus xov tooj yog 0x3C. Tus thib ob yog tus lej 0xA, uas peb tau sau rau chaw nyob 0x1E thiab kev paub tseeb me ntsis los ntawm HMC5883L sensor, uas yog tus qhev. Nov yog tus lej rau npe uas peb yuav pib nyeem cov ntaub ntawv. Qhov no xaus qhov kev pauv thawj zaug. Tom ntej no yuav pib. Lub cim thib peb yog kev thov nyeem los ntawm tus qhev (qhov tseem ceeb tshaj plaws 7 yog qhov chaw nyob 0x1E, 8 tus lej yog tus lej ua haujlwm 0x1; tus lej tshwm sim yog 0x3D). Qhov kawg 3 peb bytes yog cov lus teb los ntawm HMC5883L qhev los ntawm kev sau npe 0xA, 0xB, thiab 0xC, ua raws.

Lub koob yees duab digital digital HMC5883L txav los ntawm cov ntawv sau npe tus kheej thaum lub sijhawm txuas ntxiv kev nyeem ntawv. Cov. nws tsis yog qhov tsim nyog (tab sis tsis txwv) kom qhia qhov teeb meem txhua lub sijhawm. Piv txwv li, yog tias tsis hloov 0xA peb yuav sau 0x3 thiab nyeem 10 zaug, peb yuav tau txais qhov tseem ceeb rau 10 tus sau npe, pib txij hnub tim 3 txog 12.

Thiab peb peb tus lej no yog li cas - 0x48, 0x34, 0x33? Kev siv cov ntaub ntawv cov ntaub ntawv rau HMC5883L digital compass dua, peb yuav pom tias cov no yog qhov txiaj ntsig rau peb tus ntawv sau npe.

Sijhawm daim duab ntawm I2C pauv nrog HMC5883 digital compass
Sijhawm daim duab ntawm I2C pauv nrog HMC5883 digital compass

Kauj ruam 5

Txhawm rau kom tau txais cov ntaub ntawv digital digital ntawm cov chaw sib nqus, koj yuav tsum nyeem cov ntawv sau npe 3 txog 8, ib yam li peb nyeem cov npe sau npe. Qhov txawv tsuas yog tias cov ntaub ntawv rau txhua ntawm peb leeg axes X, Y thiab Z yog nthuav tawm ua ob-byte tus lej. Hloov lawv rau cov lej zauv, peb tau txais kev qhia ua ke nrog txhua ntawm peb txoj kab ke.

Pom zoo: