Cov txheej txheem:

Motion Tracking Siv MPU-6000 thiab Arduino Nano: 4 Cov Kauj Ruam
Motion Tracking Siv MPU-6000 thiab Arduino Nano: 4 Cov Kauj Ruam

Video: Motion Tracking Siv MPU-6000 thiab Arduino Nano: 4 Cov Kauj Ruam

Video: Motion Tracking Siv MPU-6000 thiab Arduino Nano: 4 Cov Kauj Ruam
Video: Qhiab Siv AI Motion Capture for iclone 2024, Hlis ntuj nqeg
Anonim
Image
Image

MPU-6000 yog 6-Axis Motion Tracking Sensor uas muaj 3-Axis accelerometer thiab 3-Axis gyroscope kos rau hauv. Qhov ntsuas no muaj peev xwm taug qab qhov tseeb ntawm qhov chaw thiab qhov chaw ntawm ib yam khoom hauv lub dav hlau 3-dimensional. Nws tuaj yeem ua haujlwm hauv cov kab ke uas xav tau kev tshuaj xyuas txoj haujlwm mus rau qhov siab tshaj plaws.

Hauv qhov kev qhia no kev cuam tshuam ntawm MPU-6000 sensor module nrog arduino nano tau piav qhia. Txhawm rau nyeem qhov tseem ceeb ntawm kev nrawm thiab tig lub kaum ntse ntse, peb tau siv arduino nano nrog I2c adapter. Qhov I2C adapter ua rau kev txuas mus rau lub sensor module tau yooj yim thiab ntseeg tau ntau dua.

Kauj Ruam 1: Yuav Tsum Kho Vajtse:

Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse

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

1. MPU-6000

2. Arduino Nano

3. I2C Cable

4. I2C Shield rau arduino nano

Kauj ruam 2: Khoos phis tawj sib txuas:

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

Tshooj khoos phis tawj sib txuas ntu piav qhia qhov txuas txuas uas xav tau ntawm lub sensor thiab arduino nano. 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:

MPU-6000 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 3: Txoj Cai rau Tsab Ntawv Teev Npe:

Txoj Cai rau Kev Tshawb Fawb
Txoj Cai rau Kev Tshawb Fawb

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

// MPU-6000 I2C chaw nyob yog 0x68 (104)

#define Ntxiv 0x68

void teeb tsa ()

{

// Pib I2C kev sib txuas lus raws li tus Xib Hwb

Hlau.begin ();

// Initialise serial communication, teeb baud tus nqi = 9600

Serial.begin (9600);

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv lub gyroscope teeb tsa sau npe

Hlau.write (0x1B);

// Qhov ntsuas tag nrho = 2000 dps

Hlau.write (0x18);

// Nres I2C kev xa mus

Wire.endTransmission ();

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv cov ntawv teev npe kev ntsuas tus ntsuas

Hlau.write (0x1C);

// Tag nrho cov nplai ntau = +/- 16g

Hlau.write (0x18);

// Nres I2C kev xa mus

Wire.endTransmission ();

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv lub hwj chim tswj npe

Hlau.write (0x6B);

// PLL nrog xGyro siv

Hlau.write (0x01);

// Nres I2C kev xa mus

Wire.endTransmission ();

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [6];

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv cov ntaub ntawv sau npe

Hlau.write (0x3B);

// Nres I2C kev xa mus

Wire.endTransmission ();

// Thov 6 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 6);

// Nyeem 6 byte ntawm cov ntaub ntawv

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 ();

}

// Hloov cov ntaub ntawv

int xAccl = cov ntaub ntawv [0] * 256 + cov ntaub ntawv [1];

int yAccl = cov ntaub ntawv [2] * 256 + cov ntaub ntawv [3];

int zAccl = cov ntaub ntawv [4] * 256 + cov ntaub ntawv [5];

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv cov ntaub ntawv sau npe

Hlau.write (0x43);

// Nres I2C kev xa mus

Wire.endTransmission ();

// Thov 6 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 6);

// Nyeem 6 byte ntawm cov ntaub ntawv

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 ();

}

// Hloov cov ntaub ntawv

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

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

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

// Cov ntaub ntawv tso tawm rau tus saib xyuas

Serial.print ("Ua kom nrawm hauv X-Axis:");

Serial.println (xAccl);

Serial.print ("Kev nrawm hauv Y-Axis:");

Serial.println (yAccl);

Serial.print ("Ua kom nrawm hauv Z-Axis:");

Serial.println (zAccl);

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);

}

Hauv cov tsev qiv ntawv xaim Wire.write () thiab Wire.read () yog siv los sau cov lus txib thiab nyeem cov ntawv tso tawm.

Serial.print () thiab Serial.println () yog siv los tso saib cov zis ntawm lub sensor ntawm cov saib xyuas ntawm Arduino IDE.

Qhov tso tawm ntawm lub ntsuas hluav taws xob tau qhia hauv daim duab saum toj no.

Kauj Ruam 4: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

MPU-6000 yog lub suab ntsuas lub suab ntsuas, uas pom nws daim ntawv thov hauv kev sib cuam tshuam ntawm cov xov tooj ntawm tes thiab ntsiav tshuaj. Hauv cov xov tooj ntawm tes cov cuab yeej no tuaj yeem ua haujlwm hauv cov ntawv thov xws li kev hais lus taw tes rau kev siv thiab tswj lub xov tooj, txhim kho kev ua si, ua kom muaj kev muaj tiag, ua kom pom cov duab pom thiab pom, thiab taug kev thiab tsheb nqaj hlau. MotionTracking thev naus laus zis tuaj yeem hloov kho lub xov tooj thiab cov ntsiav tshuaj rau hauv cov cuab yeej ntse 3D uas tuaj yeem siv rau hauv cov ntawv thov xws li kev saib xyuas kev noj qab haus huv thiab kev tawm dag zog mus rau cov kev pabcuam raws qhov chaw.

Pom zoo: