Cov txheej txheem:

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

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

Video: Kev cuam tshuam ntawm 3-Axis Gyroscope Sensor BMG160 Nrog Particle: 5 Kauj Ruam
Video: Nraug txuj kev hlub 2024, Kaum ib hlis
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 Particle Photon.

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

1. BMG160

2. Particle photon

3. I2C Cable

4. I2C Shield rau Particle Photon

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. Particle Photon

3. I2C Cable

4. I2C Shield Rau Particle Photon

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 ntu piav qhia qhov txuas txuas txuas uas xav tau ntawm lub sensor thiab Particle. 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 Particle Code:

3-Axis Gyroscope Measurement Particle Code
3-Axis Gyroscope Measurement Particle Code
3-Axis Gyroscope Measurement Particle Code
3-Axis Gyroscope Measurement Particle Code

Cia peb pib nrog cov lej me me tam sim no.

Thaum siv lub ntsuas qhov ntsuas nrog arduino, peb suav nrog application.h thiab lub tsev qiv ntawv spark_wiring_i2c.h. "application.h" thiab lub tsev qiv ntawv spark_wiring_i2c.h muaj cov haujlwm uas pab txhawb kev sib txuas lus i2c ntawm lub sensor thiab cov khoom me me.

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

#suav nrog

#suav nrog

// BMG160 I2C chaw nyob yog 0x68 (104)

#define Ntxiv 0x68

int xGyro = 0, yGyro = 0, zGyro = 0;

void teeb tsa ()

{

// Teem sib txawv

Particle.variable ("i2cdevice", "BMG160");

Particle.variable ("xGyro", xGyro);

Particle.variable ("yGyro", yGyro);

Particle.variable ("zGyro", zGyro);

// Pib I2C kev sib txuas lus li MASTER

Hlau.begin ();

// Initialise Serial Communication

Serial.begin (9600);

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xaiv Range register

Hlau.write (0x0F);

// Kho qhov ntsuas puv 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 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

xGyro = ((data [1] * 256) + data [0]);

yog (xGyro> 32767)

{

xGyro -= 65536;

}

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

yog (yGyro> 32767)

{

yGyro -= 65536;

}

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

yog (zGyro> 32767)

{

zGyro -= 65536;

}

// Tso tawm cov ntaub ntawv rau dashboard

Particle.publish ("X-Axis ntawm kev sib hloov:", Txoj hlua (xGyro));

Particle.publish ("Y-Axis ntawm kev sib hloov:", Txoj hlua (yGyro));

Particle.publish ("Z-Axis ntawm kev sib hloov:", Txoj hlua (zGyro));

ncua (1000);

}

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: