Cov txheej txheem:

DC Tsav Tswj Arduino Uno R3: 6 Cov Kauj Ruam
DC Tsav Tswj Arduino Uno R3: 6 Cov Kauj Ruam

Video: DC Tsav Tswj Arduino Uno R3: 6 Cov Kauj Ruam

Video: DC Tsav Tswj Arduino Uno R3: 6 Cov Kauj Ruam
Video: Tswj Tus Kheej - Koomtes Lis (Official Audio) 2024, Hlis ntuj nqeg
Anonim
DC Tsav Tswj Arduino Uno R3
DC Tsav Tswj Arduino Uno R3

Hauv qhov kev sim no, peb yuav kawm paub tswj hwm kev taw qhia thiab nrawm ntawm lub zog me me DC lub cav los ntawm tus tsav tsav L293D. Ua qhov kev sim yooj yim, peb tsuas yog ua kom lub cev muaj zog tig mus rau sab laug thiab sab xis, thiab ua kom nrawm lossis nrawm dua.

Kauj Ruam 1: Cheeb Tsam

- Arduino Uno board * 1

- USB cable * 1

L293D *1

- DC lub cav me me * 1

- Daim phiaj * 1

- Jumper xov hlau

Kauj Ruam 2: Txoj Cai

Qhov siab tshaj tam sim no ntawm Arduino I/O chaw nres nkoj yog 20mA tab sis qhov tsav tam sim no ntawm lub cav yog tsawg kawg 70mA. Yog li ntawd, peb tsis tuaj yeem siv qhov chaw nres nkoj I/O ncaj qha rau tsav tam sim no; Hloov chaw, peb tuaj yeem siv L293D los tsav lub cav. L293D L293D yog tsim los muab cov kev sib tw tsav mus txog 600mA ntawm qhov hluav taws xob los ntawm 4.5V txog 36V. Nws tau siv los tsav cov khoom siv hluav taws xob xws li kev xa tawm, solenoids, DC thiab bipolar stepping motors, ntxiv rau lwm cov khoom siv hluav taws xob tam sim no/siab-siab hauv kev thov zoo.

Saib daim duab ntawm tus pin hauv qab no. L293D muaj ob tus pin (Vcc1 thiab Vcc2) rau lub hwj chim. Vcc2 yog siv los muab lub zog rau lub cav, thaum Vcc1, rau lub nti. Txij li lub tshuab me me DC tau siv ntawm no, txuas ob tus pin rau +5V. Yog tias koj siv lub zog muaj zog ntau dua, koj yuav tsum txuas Vcc2 mus rau lub zog hluav taws xob sab nraud.

Kauj Ruam 3: Daim Duab Schematic

Schematic Daim duab
Schematic Daim duab

Kauj ruam 4: Cov txheej txheem

Cov txheej txheem
Cov txheej txheem
Cov txheej txheem
Cov txheej txheem

Pab kom tus pin 1, 2EN ntawm L293D txuas nrog 5V twb, yog li L293D ib txwm nyob hauv lub xeev ua haujlwm. Txuas tus pin 1A thiab 2A rau tus pin 9 thiab 10 ntawm pawg tswj hwm feem. Ob tus pin ntawm lub cev muaj zog txuas nrog tus pin 1Y thiab 2Y feem. Thaum tus pin 10 tau teeb tsa qib siab thiab tus pin 9 li qis, lub cav yuav pib tig mus rau ib qho kev taw qhia. Thaum tus pin 10 Tsawg thiab tus pin 9 yog Siab, nws tig rau hauv qhov kev coj rov qab.

Kauj ruam 1:

Tsim lub voj voog.

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.

Tam sim no, cov hniav ntawm DC lub cav yuav pib tig sab laug thiab sab xis, hauv qhov nrawm uas txawv raws li qhov tsim nyog.

Kauj ruam 5: Code

Code
Code

// DC Tsav Tswj

// DC tsav

yuav pib tig sab laug thiab sab xis, thiab nws qhov nrawm yuav txawv raws qhov ntawd.

// Web site: www.primerobotics.in

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

const koj motorIn1

= 9; // txuas rau ib tus pin ntawm lub cav

const koj motorIn2

= 10; // txuas rau lwm tus pin ntawm lub cav

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

void teeb tsa ()

{

pinMode (motorIn1, OUTPUT); // initialize motorIn1 tus pin raws li cov zis

pinMode (motorIn2, OUTPUT); // initialize motorIn2 tus pin raws li cov zis

}

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

void lub voj ()

{

clockwise (200); // tig clockwise

ncua (1000);

// tos ib pliag

tig rov qab (200); // tig rov qab

ncua (1000);

// tos ib pliag

}

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

/Cov haujlwm rau

tsav lub cev muaj zog tig clockwise

tsis muaj dab tsi clockwise (int

Ceev)

{

analogWrite (motorIn1, Ceev); // teeb tsa qhov ceev ntawm lub cev muaj zog

analogWrite (motorIn2, 0); // nres lub cav In2 tus pin ntawm lub cev muaj zog

}

// Lub luag haujlwm tsav

lub cev muaj zog tig rov qab

tsis muaj dab tsi

counterclockwise (int ceev)

{

analogWrite (motorIn1, 0); // nres lub cav In1 tus pin ntawm lub cev muaj zog

analogWrite (motorIn2, Ceev); // teeb tsa qhov ceev ntawm lub cev muaj zog

}

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

Pom zoo: