Cov txheej txheem:

Kev cuam tshuam ntawm 3-Axis Gyroscope Sensor BMG160 Nrog Arduino Nano: 5 Kauj Ruam
Kev cuam tshuam ntawm 3-Axis Gyroscope Sensor BMG160 Nrog Arduino Nano: 5 Kauj Ruam

Video: Kev cuam tshuam ntawm 3-Axis Gyroscope Sensor BMG160 Nrog Arduino Nano: 5 Kauj Ruam

Video: Kev cuam tshuam ntawm 3-Axis Gyroscope Sensor BMG160 Nrog Arduino Nano: 5 Kauj Ruam
Video: Nraug txuj kev hlub 2024, Hlis ntuj nqeg
Anonim
Image
Image

Hauv lub ntiaj teb niaj hnub no, ntau dua ib nrab ntawm cov tub ntxhais hluas thiab menyuam yaus nyiam ua si thiab txhua tus neeg uas nyiam nws, txaus siab los ntawm cov txuj ci ntawm kev ua si paub qhov tseem ceeb ntawm kev nkag siab zoo hauv qhov no. Peb kuj tseem xav tsis thoob los ntawm tib yam thiab tsuas yog coj nws mus rau ntawm cov laug cam, peb xav txog kev ua haujlwm ntawm lub ntsuas hluav taws xob ntsuas hluav taws xob uas tuaj yeem ntsuas tus nqi ib leeg ntawm ib yam khoom. Yog li, lub ntsuas ntsuas peb tau coj los daws cov haujlwm yog BMG160. BMG160 yog 16-ntsis, digital, triaxial, gyroscope sensor uas tuaj yeem ntsuas tus lej nyob hauv peb chav nyob ib puag ncig.

Hauv qhov kev qhia no, peb yuav los qhia txog kev ua haujlwm ntawm BMG160 nrog Arduino Nano.

Kho vajtse uas koj yuav xav tau rau lub hom phiaj no yog raws li hauv qab no:

1. BMG160

2. Arduino Nano

3. I2C Cable

4. I2C Shield Rau Arduino Nano

Kauj Ruam 1: BMG160 Txheej Txheem:

Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!

Ua ntej tshaj plaws peb xav paub koj nrog cov yam ntxwv tseem ceeb ntawm lub ntsuas qhov ntsuas uas yog BMG160 thiab cov txheej txheem kev sib txuas lus uas nws ua haujlwm.

BMG160 yog qhov tseem ceeb 16-ntsis, digital, triaxial, gyroscope sensor uas tuaj yeem ntsuas tus nqi kaum. Nws muaj peev xwm suav tus lej nyob hauv peb chav nyob ib puag ncig, x-, y- thiab z-axis, thiab muab cov cim teeb tsa sib xws. Nws tuaj yeem sib tham nrog raspberry pi board siv I2C kev sib txuas lus raws tu qauv. Cov qauv tshwj xeeb no tau tsim los kom tau raws li qhov xav tau rau cov neeg siv khoom siv nrog rau lub hom phiaj kev lag luam.

Cov txheej txheem kev sib txuas lus uas lub sensor ua haujlwm yog I2C. I2C sawv cev rau kev sib koom ua ke. Nws yog cov txheej txheem kev sib txuas lus uas kev sib txuas lus tau tshwm sim los ntawm SDA (cov ntaub ntawv xov xwm) thiab SCL (cov xov tooj). Nws tso cai txuas ntau yam khoom siv tib lub sijhawm. Nws yog ib qho ntawm cov txheej txheem kev sib txuas lus yooj yim tshaj plaws thiab muaj txiaj ntsig tshaj plaws.

Kauj Ruam 2: Yam Koj Xav Tau..

Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!

Cov ntaub ntawv uas peb xav tau kom ua tiav peb lub hom phiaj suav nrog cov khoom siv hauv qab no:

1. BMG160

2. Arduino Nano

3. I2C Cable

4. I2C Shield rau Arduino Nano

Kauj Ruam 3: Khoos Phis Tawj Hookup:

Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup

Tshooj khoos phis tawj sib txuas feem ntau piav qhia qhov txuas txuas uas xav tau ntawm lub sensor thiab Arduino. Ua kom muaj kev sib txuas raug yog qhov tseem ceeb xav tau thaum ua haujlwm ntawm ib qho system rau qhov xav tau cov zis. Yog li, qhov xav tau kev sib txuas yog raws li hauv qab no:

BMG160 yuav ua haujlwm dhau I2C. Nov yog qhov piv txwv kab hluav taws xob daim duab, qhia txog yuav ua li cas xaim txhua lub interface ntawm lub sensor.

Tawm-ntawm-lub thawv, lub rooj tsavxwm tau teeb tsa rau I2C interface, zoo li peb pom zoo siv qhov kev sib txuas no yog tias koj tsis ntseeg lwm yam.

Txhua yam koj xav tau yog plaub lub xov hlau! Tsuas yog plaub qhov kev sib txuas xav tau Vcc, Gnd, SCL thiab SDA tus pin thiab cov no txuas nrog kev pab ntawm I2C cable.

Cov kev sib txuas no tau qhia hauv cov duab saum toj no.

Kauj Ruam 4: 3-Axis Gyroscope Measurement Arduino Code:

3-Axis Gyroscope Ntsuas Arduino Code
3-Axis Gyroscope Ntsuas Arduino Code
3-Axis Gyroscope Ntsuas Arduino Code
3-Axis Gyroscope Ntsuas Arduino Code

Cia pib nrog tus lej arduino tam sim no.

Thaum siv lub ntsuas qhov ntsuas nrog arduino, peb suav nrog Wire.h lub tsev qiv ntawv. "Hlau" lub tsev qiv ntawv muaj cov haujlwm uas pab txhawb i2c kev sib txuas lus ntawm lub sensor thiab pawg thawj coj saib arduino.

Tag nrho cov cai arduino tau muab hauv qab no kom yooj yim ntawm cov neeg siv:

#suav nrog // BMG160 I2C chaw nyob yog 0x68 (104)

#define Ntxiv 0x68

void teeb tsa ()

{

// Pib I2C kev sib txuas lus li MASTER

Hlau.begin ();

// Initialise Serial Communication, teeb baud tus nqi = 9600

Serial.begin (9600);

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xaiv Range register

Hlau.write (0x0F);

// Txhim kho qhov ntsuas tag nrho 2000 dps

Hlau.write (0x80);

// Nres I2C Kev Kis

Wire.endTransmission ();

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xaiv Bandwidth sau npe

Hlau.write (0x10);

// Teeb bandwidth = 200 Hz

Hlau.write (0x04);

// Nres I2C Kev Kis

Wire.endTransmission ();

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [6];

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xaiv Gyrometer cov ntaub ntawv sau npe

Hlau.write (0x02);

// Nres I2C Kev Kis

Wire.endTransmission ();

// Thov 6 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 6);

// Nyeem 6 bytes ntawm cov ntaub ntawv

// xGyro lsb, xGyro msb, yGyro lsb, yGyro msb, zGyro lsb, zGyro msb

yog (Wire.available () == 6)

{

cov ntaub ntawv [0] = Wire.read ();

cov ntaub ntawv [1] = Wire.read ();

cov ntaub ntawv [2] = Wire.read ();

cov ntaub ntawv [3] = Wire.read ();

cov ntaub ntawv [4] = Wire.read ();

cov ntaub ntawv [5] = Wire.read ();

}

ncua (300);

// Hloov cov ntaub ntawv

int xGyro = ((cov ntaub ntawv [1] * 256) + cov ntaub ntawv [0]);

int yGyro = ((cov ntaub ntawv [3] * 256) + cov ntaub ntawv [2]);

int zGyro = ((cov ntaub ntawv [5] * 256) + cov ntaub ntawv [4]);

// Tso tawm cov ntaub ntawv rau tus saib xyuas

Serial.print ("X-Axis ntawm kev sib hloov:");

Serial.println (xGyro); Serial.print ("Y-Axis ntawm kev sib hloov:");

Serial.println (yGyro); Serial.print ("Z-Axis ntawm kev sib hloov:");

Serial.println (zGyro);

ncua (500);

}

Kauj Ruam 5: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

BMG160 muaj ntau qhov kev thov hauv cov khoom siv xws li xov tooj ntawm tes, tib neeg siv tshuab sib txuas. Qhov ntsuas qhov ntsuas no tau tsim los kom tau raws li qhov xav tau rau cov neeg siv khoom siv xws li kev ruaj ntseg duab (DSC thiab lub koob yees duab-xov tooj), kev ua si thiab taw tes. Nws kuj tseem ua haujlwm hauv cov kab ke uas xav tau kev paub piav tes piav taw thiab cov kab ke siv hauv kev qhia sab hauv tsev.

Pom zoo: