Cov txheej txheem:

ADXL345 Siv Arduino Uno R3: 5 Cov Kauj Ruam
ADXL345 Siv Arduino Uno R3: 5 Cov Kauj Ruam

Video: ADXL345 Siv Arduino Uno R3: 5 Cov Kauj Ruam

Video: ADXL345 Siv Arduino Uno R3: 5 Cov Kauj Ruam
Video: Internet of Thing ตอน 2 (EMBEDDED SYSTEM AND ALGORITHMS) 2024, Kaum ib hlis
Anonim
ADXL345 Siv Arduino Uno R3
ADXL345 Siv Arduino Uno R3

Hauv zaj lus qhia no, peb yuav kawm paub siv lub ntsuas nrawm ADXL345 li cas.

Kauj Ruam 1: Cheeb Tsam

- Arduino Uno board * 1

- USB cable * 1

ADXL345 *1

- Daim phiaj * 1

- Jumper xov hlau

Kauj Ruam 2: Txoj Cai

Tus ntsuas hluav taws xob tau siv los ntsuas lub zog tsim thaum lub sijhawm nrawm. Qhov tseem ceeb tshaj plaws yog qhov paub zoo tshaj ntawm kev nrawm uas yog 1g.

Los ntawm kev ntsuas qhov nrawm los ntawm lub ntiajteb txawj nqus, koj tuaj yeem xam lub kaum sab xis ntawm lub cuab yeej mus rau theem saum npoo. Los ntawm kev txheeb xyuas qhov nrawm nrawm, koj tuaj yeem qhia txoj hauv kev tias lub cuab yeej txav mus li cas. Piv txwv, pawg tswj hwm tus kheej lossis hoverboard siv lub ntsuas nrawm thiab ntsuas lub ntsej muag rau Kalman lim thiab hloov kho lub cev.

TXL345

ADXL345 yog qhov me me, nyias, tsis muaj zog, 3-axis accelerometer nrog ntsuas siab (13-ntsis) ntsuas txog li g 16 g. Cov ntaub ntawv tso tawm digital tau muab faib ua 16-ntsis ob qho ntxiv thiab nkag mus tau los ntawm SPI (3- lossis 4-xaim) lossis I2C digital interface. Hauv qhov kev sim no, I2C digital interface tau siv.

Nws yog qhov tsim nyog txhawm rau ntsuas qhov nrawm nrawm ntawm lub ntiajteb txawj nqus hauv daim ntawv thov qaij-nkag siab, nrog rau kev nrawm nrawm los ntawm kev txav lossis poob siab. Nws qhov kev daws teeb meem siab (4 mg/LSB) ua rau lub siab hloov pauv ntsuas tsawg dua 1.0 °. Thiab qhov ua tau zoo heev (3.9mg/LSB @2g) muab qhov ua kom pom tseeb siab txog li g 16g.

ADXL345 ua haujlwm li cas

ADXL345 pom qhov ua kom nrawm nrog cov khoom pom ntawm sab xub ntiag, thiab tom qab ntawd cov hluav taws xob teeb liab pom kev hloov pauv nws mus rau hluav taws xob teeb liab, uas yog analog. Tom ntej no, AD adapter ua ke ntawm tus qauv yuav hloov pauv cov teeb liab analog mus rau digital ib qho.

X_OUT, Y_OUT thiab Z_OUT yog qhov tseem ceeb ntawm X, Y, thiab Z axis feem. Tso tus qauv lub ntsej muag: Z_OUT tuaj yeem ncav cuag +1g feem ntau, yam tsawg kawg ntawm X_OUT yog -1g mus rau Axis kev taw qhia, thiab yam tsawg kawg ntawm Y_OUT yog -1g mus rau txoj kev Ay. Ntawm qhov tod tes, tig lub module rov qab: qhov tsawg kawg ntawm Z_OUT yog -1g, qhov siab tshaj ntawm X_OUT yog +1g mus rau Axis kev taw qhia, thiab qhov siab tshaj ntawm Y_OUT yog +1g mus rau Ay txoj kev taw qhia., raws li qhia hauv qab no. Tig qhov ADXL345 module thiab koj yuav pom qhov kev hloov pauv ntawm peb qhov tseem ceeb.

thaum channel A hloov pauv los ntawm qib siab mus rau qib qis, yog tias channel B yog qib siab, nws qhia tau hais tias lub teb chaws rotator tig raws lub moos (CW); yog tias lub sijhawm ntawd channel B qib qis, nws txhais tau hais tias tig rov qab lub moos (CCW). Yog li yog tias peb nyeem tus nqi ntawm channel B thaum channel A qis qib, peb tuaj yeem paub nyob rau hauv qhov kev taw qhia qhov kev hloov pauv tus lej nkag.

Lub hauv paus ntsiab lus: Saib cov duab kos duab ntawm Rotary Encoder module hauv qab no. Los ntawm nws peb tuaj yeem pom tias tus pin 3 ntawm tus lej nkag teb chaws, uas yog CLK ntawm tus qauv, yog channel B. Pin 5, uas yog DT, yog channel A. Txhawm rau paub qhov kev taw qhia tig ntawm lub kaw lus, tsuas yog nyeem tus nqi ntawm CLK thiab DT.

Muaj 3.3v qhov ntsuas hluav taws xob hluav taws xob nti hauv Circuit Court, yog li koj tuaj yeem ua lub zog ntsuas nrog 5V lossis 3.3V.

Txij li SDO tau txuas nrog GND, I2C chaw nyob ntawm ADXL345 yog 0x53, 0xA6 rau sau, 0xA7 rau nyeem

Pin Muaj nuj nqi ntawm ADXL345 Module.

Kauj Ruam 3: Cov txheej txheem

Kauj Ruam 1. Txhim kho qhov Circuit Court.

Kauj ruam 2:

Rub tawm cov cai los ntawm

Kauj ruam 3:

Tshaj tawm cov duab kos rau Arduino Uno board

Nyem rau Upload icon txhawm rau upload cov cai rau pawg tswj hwm.

Yog tias "Ua tiav uploading" tshwm rau hauv qab ntawm lub qhov rais, nws txhais tau hais tias daim duab tau ua tiav tiav.

Tom qab rub tawm, qhib Serial Monitor, qhov twg koj tuaj yeem pom cov ntaub ntawv pom. Thaum qhov nrawm ntawm qhov hloov pauv, daim duab yuav hloov raws li ntawm lub qhov rais.

Kauj ruam 4: Code

Code
Code

// ADXL335

/********************************

TIAB SA 335

nco: vc5v, tab sis ADXL335 Vs yog 3.3V

Lub voj voog:

5v: vwm

analog 0: x-axis

analog 1: y-axis

analog 2: z-axis

Tom qab hlawv lub

program, qhib lub qhov rai saib xyuas qhov debugging qhov rai, qhov uas koj tuaj yeem pom cov ntaub ntawv kuaj pom tau tshwm sim. Thaum qhov nrawm nrawm sib txawv, daim duab yuav txawv raws qhov ntawd.

*********************************

/Email:

// Web site: www.primerobotics.in

const int xpin = np

A0; // x-axis ntawm lub ntsuas cua

const koj ypin =

A1; // y-os

const koj zpin =

A2; // z-axis (tsuas yog ntawm 3-axis qauv)

void teeb tsa ()

{

// pib qhov kev sib txuas lus txuas:

Serial.begin (9600);

}

void lub voj ()

{

int x = analogRead (xpin); // nyeem los ntawm xpin

ncua (1); //

int y = analogRead (ypin); // nyeem los ntawm ypin

ncua (1);

int z = analogRead (zpin); // nyeem los ntawm zpin

ntab zero_G = 338.0; // ADXL335 fais fab mov

los ntawm Vs 3.3V: 3.3V/5V*1024 = 676/2 = 338

//Serial.print(x);

//Serial.print("\t ");

//Serial.print(y);

//Serial.print("\t ");

//Serial.print(z);

//Serial.print("\n ");

ntab

zero_Gx = 331.5; // xoom_G tso tawm ntawm x axis: (x_max + x_min)/2

ntab

zero_Gy = 329.5; // xoom_G outgput ntawm y axis: (y_max + y_min)/2

float zero_Gz = 340.0; // cov

zero_G cov zis ntawm z axis: (z_max + z_min)/2

nplai nplai =

67.6; // fais fab tuag los ntawm Vs 3.3V: 3.3v/5v *1024/3.3v *330mv/g = 67.6g

float scale_x =

65; // teev ntawm x axis: x_max/3.3v*330mv/g

nplai scale_y =

68.5; // teev ntawm y axis: y_max/3.3v*330mv/g

nplai scale_z =

68; // teev ntawm z axis: z_max/3.3v*330mv/g

Serial.print (((ntab) x

- zero_Gx)/teev_x); // luam tawm tus nqi x tus lej saib

Serial.print ("\ t");

Serial.print (((ntab) y

- zero_Gy)/teev_y); // luam tawm tus nqi ntawm tus saib xyuas

Serial.print ("\ t");

Serial.print (((ntab) z

- zero_Gz)/nplai_z); // luam z tus nqi ntawm tus saib xyuas

Serial.print ("\ n");

ncua (1000); // tos 1 thib ob

}

Kauj Ruam 5: Txheeb Cai

Txoj cai rau ADXL345 kev sim suav nrog 3 ntu: pib txhua qhov chaw nres nkoj thiab khoom siv, tau txais thiab khaws cov ntaub ntawv xa los ntawm cov ntsuas cua, thiab hloov cov ntaub ntawv.

Pom zoo: