Cov txheej txheem:

INFRA RED REMOTE CONTROLLED ROBOCAR SIV AVR (ATMEGA32) MCU: 5 Kauj Ruam
INFRA RED REMOTE CONTROLLED ROBOCAR SIV AVR (ATMEGA32) MCU: 5 Kauj Ruam

Video: INFRA RED REMOTE CONTROLLED ROBOCAR SIV AVR (ATMEGA32) MCU: 5 Kauj Ruam

Video: INFRA RED REMOTE CONTROLLED ROBOCAR SIV AVR (ATMEGA32) MCU: 5 Kauj Ruam
Video: Arduino Auto Controlled Robo-Car v0.3 with Infrared 2024, Hlis ntuj nqeg
Anonim
INFRA RED REMOTE CONTROLLED ROBOCAR SIV AVR (ATMEGA32) MCU
INFRA RED REMOTE CONTROLLED ROBOCAR SIV AVR (ATMEGA32) MCU

PROJECT tam sim no piav qhia kev tsim qauv thiab kev siv lub infrared (IR) chaw taws teeb tswj RoboCar uas tuaj yeem siv rau ntau yam kev siv tsis siv neeg tswj tsis siv neeg. Kuv tau tsim cov chaw taws teeb tswj RoboCar (sab laug-sab xis/pem hauv ntej-nraub qaum). Tag nrho cov kab ke yog ua raws microcontroller (Atmega32) uas ua rau cov kev tswj hwm ntse dua thiab yooj yim hloov kho rau lwm daim ntawv thov. Nws ua rau tus neeg siv ua haujlwm lossis tswj hwm RoboCar thiab ua haujlwm lub zog hloov hluav taws xob los ntawm kwv yees li 5 metres deb.

Cov lus tseem ceeb: IR Decoder, AVR (Atmega32) Microcontroller, TV remote Controller, Kev sib txuas lus wireless

_

Kauj ruam 1: IntraRed Kev Sib Tham

IntraRed Kev Sib Txuas Lus
IntraRed Kev Sib Txuas Lus

IR txoj kev sib txuas lus:

a) IR kis

Tus xa tawm ntawm IR LED sab hauv nws lub Circuit Court, uas tawm lub teeb infrared rau txhua qhov hluav taws xob mem tes muab rau nws. Qhov mem tes no tau tsim los ua lub khawm ntawm cov chaw taws teeb tau raug nias, yog li ua tiav qhov Circuit Court, muab kev tsis ncaj ncees rau LED. LED ntawm kev tsis ncaj ncees tso lub teeb ntawm lub nthwv dej ntawm 940nm ua ntu ntu ntawm cov mem tes, sib thooj rau lub pob nyem. Txawm li cas los xij txij li nrog IR LED ntau lwm qhov chaw ntawm lub teeb pom kev zoo xws li peb tib neeg, teeb pom kev, hnub ci, thiab lwm yam, cov ntaub ntawv xa tuaj yeem cuam tshuam. Kev daws teeb meem no yog los ntawm kev hloov kho. Lub teeb liab kis tau hloov pauv siv tus neeg nqa khoom zaus ntawm 38 KHz (lossis lwm qhov zaus ntawm 36 txog 46 KHz). IR LED tau ua kom oscillate ntawm qhov zaus no rau lub sijhawm ntawm lub plawv dhia. Cov ntaub ntawv lossis lub teeb pom kev zoo yog ntsuas qhov dav dav thiab muaj nyob hauv 38 KHz zaus. Kev xa xov hluav taws xob hais txog lub zog hauv cheeb tsam ntawm cov hluav taws xob hluav taws xob hluav taws xob nyob ntawm qhov ntev ntev dua li qhov pom kev, tab sis luv dua li ntawm cov xov tooj cua yoj. Raws li qhov tshwm sim, infrared zaus ntau dua li ntawm microwaves, tab sis qis dua qhov pom kev. Cov kws tshawb fawb tau faib cov duab hluav taws xob infrared (IR) rau hauv peb cheeb tsam. Cov wavelengths tau teev tseg hauv micron (cim cim µ, qhov twg 1 µ = 10-6 meter) lossis hauv nanometers (sau luv nm, qhov twg 1 nm = 10-9 meter = 0.001 5). Cov nyob ze IR band muaj lub zog nyob hauv thaj tsam ntawm cov nthwv dej ze tshaj rau qhov pom, los ntawm kwv yees li 0.750 txog 1.300 5 (750 txog 1300 nm). Cov qhab nia nruab nrab IR (tseem hu ua IR qib nruab nrab) suav nrog lub zog hauv thaj tsam 1.300 txog 3.000 5 (1300 txog 3000 nm). Qhov deb IR qhab txuas los ntawm 2.000 txog 14.000 5 (3000 nm txog 1.4000 x 104nm).

b) Txais tos IR

Tus neeg txais khoom suav nrog lub ntsuas duab uas tsim cov teeb liab hluav taws xob tawm thaum lub teeb pom kev tshwm sim ntawm nws. Qhov tso tawm ntawm lub ntsuas hluav taws xob tau siv lub lim lim nqaim uas muab pov tseg txhua qhov hauv qab no lossis siab dua tus neeg nqa khoom zaus (38 KHz hauv qhov no). Cov txiaj ntsig lim tawm yog muab rau cov cuab yeej tsim nyog xws li Microcontroller lossis Microprocessor uas tswj cov cuab yeej zoo li PC lossis Robot. Cov zis los ntawm cov ntxaij lim dej kuj tseem tuaj yeem txuas nrog Oscilloscope los nyeem cov mem tes.

Cov ntawv thov IR:

Infrared tau siv ntau yam kev sib txuas lus wireless, saib xyuas, thiab tswj kev siv. Nov yog qee qhov piv txwv:

· Lub thawv lom zem hauv tsev-tswj chaw taws teeb

· Wireless (network hauv cheeb tsam)

· Kev sib txuas ntawm cov khoos phis tawj laptop thiab khoos phis tawj desktop

· Cordless modem

· Tshawb xyuas kev nkag mus

· Tsab ntawv tsa suab

· Cov ntsuas hluav taws

· Kev pom kev hmo ntuj

· Cov cuab yeej kuaj mob

· Cov txheej txheem cuaj luaj

· Cov cuab yeej saib xyuas thaj tsam

Kev xa cov ntaub ntawv IR los ntawm ib lub cuab yeej mus rau lwm lub sijhawm qee zaum hu ua beaming.

Kauj Ruam 2: IR Sensor & NEC Raws Cai Raws Cai

IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai
IR Sensor & NEC Raws Cai Raws Cai

IR sensors (Daim duab 1)

TSOP1738, SFH-5110-38 (38kHz)

TSOP sensors Nta:

  • Lub preamplifier thiab lub ntsuas duab ob leeg nyob hauv ib pob
  • Sab hauv lim rau PCM zaus
  • Txhim kho kev tiv thaiv tiv thaiv kev cuam tshuam hluav taws xob
  • TTL thiab CMOS sib xws
  • Cov zis muaj zog tsawg Tsawg zog siv
  • Kev tiv thaiv siab tiv thaiv lub teeb ib puag ncig
  • Cov ntaub ntawv txuas mus txuas ntxiv tau

NEC raws tu qauv:

NEC IR kev sib kis raws tu qauv siv mem tes nrug deb ntawm cov lus xov. Txhua qhov mem tes tawg yog 562.5µs ntev, ntawm tus neeg nqa khoom zaus ntawm 38kHz (26.3µs). Cov cuab yeej cuab yeej raug xa raws li hauv qab no (Daim duab 2):

  • Logical '0' - 562.5µs mem tes tawg tom qab 562.5µs chaw, nrog rau tag nrho lub sijhawm xa tawm ntawm 1.125ms
  • Logical '1' - 562.5µs mem tes tawg tom qab qhov chaw 1.6875ms, nrog rau tag nrho lub sijhawm xa tawm ntawm 2.25ms

Tus neeg nqa khoom pulse muaj 21 mus ntawm 38kHz. Cov noob taum feem ntau muaj lub cim/qhov chaw sib piv ntawm 1: 4, txhawm rau txo kev siv tam sim no:

(Daim duab 3)

Txhua tus lej sib law liag pib nrog 9ms mem tes, hu ua AGC mem tes. Qhov no tau ua raws los ntawm 4.5ms ntsiag to:

(Daim duab 4)

Cov ntaub ntawv ntawd suav nrog 32 cov khoom, chaw nyob 16-ntsis ua raws los ntawm 16-ntsis hais kom ua, qhia hauv qhov kev txiav txim uas lawv tau xa mus (sab laug mus rau sab xis):

(Daim duab 5)

Plaub bytes ntawm cov ntaub ntawv me me yog txhua qhov xa tsawg kawg qhov tseem ceeb me ntsis ua ntej. Daim duab 1 qhia txog hom ntawv ntawm NEC IR kis kab mob, rau qhov chaw nyob ntawm 00h (00000000b) thiab kev hais kom ua ntawm ADh (10101101b).

Tag nrho ntawm 67.5ms yuav tsum tau xa cov kab lus. Nws xav tau 27ms kom xa 16 qhov chaw nyob (chaw nyob + thim rov qab) thiab 16 cov lus txib (hais kom ua + thim rov qab).

(Daim duab 6)

Lub sij hawm xav tau los xa tus ncej:

16 khoom rau qhov chaw nyob (chaw nyob + thim rov qab) xav tau 27ms kom xa sijhawm. vim hais tias (chaw nyob + chaw nyob hloov pauv) lossis (hais kom ua + rov ua dua) yuav ib txwm muaj 8 '0's thiab 8' 1's li (8 * 1.125ms) + (8 * 2.25ms) == 27 ms. raws li tag nrho lub sijhawm xav tau los xa tus ncej yog (9ms +4.5ms +27ms +27ms) = 67.5 ms.

NYEEM CODES: Yog tias tus yuam sij ntawm lub chaw taws teeb tswj hwm kev nyuaj siab, yuav rov ua dua tus lej, feem ntau nyob ib puag ncig 40ms tom qab lub plawv dhia tawg uas qhia qhov kawg ntawm cov lus. Ib txoj cai rov ua haujlwm tseem yuav raug xa tawm ntawm 108ms sib nrug, kom txog thaum tus yuam sij raug tso tawm thaum kawg. Txoj cai rov ua dua muaj cov hauv qab no, nyob rau hauv kev txiav txim:

  • 9ms ua rau lub plawv dhia tawg
  • ib 2.25ms
  • a 562.5µs mem tes tawg kom cim qhov kawg ntawm qhov chaw (thiab yog li qhov kawg ntawm kev rov ua dua cov cai).

(Daim duab 7)

Ncua Kev Suav (1ms):

Clock Freq = 11.0592 Mhz

Lub voj voog tshuab = 12

Ncua = 1ms

TimerValue = 65536 - ((qeeb * ClockFreq)/Machine Cycle) = 65536 - ((1ms * 11.0592Mhz)/12)

= 65536 - 921 = 0xFC67

Kauj Ruam 3: DC Tsav Tswj Kev Siv L293D

DC Tsav Tswj Kev Siv L293D
DC Tsav Tswj Kev Siv L293D

DC Tsav

Lub tshuab hluav taws xob DC hloov hluav taws xob hluav taws xob mus rau lub zog kho tshuab uas tuaj yeem siv los ua ntau yam haujlwm muaj txiaj ntsig. Nws tuaj yeem tsim cov khoom siv txav mus zoo li Mus Tom Ntej/Backword ntawm kuv RoboCar. DC motors los hauv ntau qhov kev ntsuas xws li 6V thiab 12V. Nws muaj ob txoj hlua los yog tus pin. Peb tuaj yeem thim rov qab qhov kev taw qhia los ntawm kev thim rov qab qhov polarity ntawm cov tswv yim.

Ntawm no peb nyiam L293D raws li qhov ntsuas ntawm 600mA yog qhov zoo rau kev tsav DC lub cav me me thiab kev tiv thaiv diodes suav nrog hauv IC nws tus kheej. Cov lus piav qhia ntawm txhua tus pin yog raws li hauv qab no: Pab kom pins: Cov no yog tus lej tsis yog. 1 e pin nr. 9. Pin nr. 1 tau siv los pab Ib nrab-H tus tsav tsheb 1 thiab 2. (H choj ntawm sab laug). Tus pin no. 9 tau siv los pab H-tus tsav tsheb 3 thiab 4. (H choj ntawm sab xis).

Lub tswv yim yog qhov yooj yim, yog tias koj xav siv tshwj xeeb H choj koj yuav tsum muab lub laj thawj siab rau qhov sib thooj pab tau tus pin nrog rau lub zog xa mus rau IC. Tus pin no tseem tuaj yeem siv los tswj kev nrawm ntawm lub cav siv PWM txheej txheem. VCC1 (Pin 16): Tus pin fais fab. Txuas nws mus rau 5V cov khoom siv. VCC2 (Pin 8): Lub hwj chim rau lub cav. Thov +ve voltage rau nws raws li qhov ntsuas lub cev muaj zog. Yog tias koj xav tsav koj lub cav ntawm 12V, thov 12V ntawm tus pin no.

Nws kuj tseem tuaj yeem tsav lub cav ncaj qha ntawm lub roj teeb, tsis yog qhov siv los muab lub zog rau hauv Circuit Court, Tsuas yog txuas +lub davhlau ya nyob twg ntawm lub roj teeb rau VCC2 tus pin thiab ua GND ntawm ob lub roj teeb ntau. (MAX qhov hluav taws xob ntawm tus pin no yog 36V raws li nws cov ntawv teev tseg). GND (Pins 4, 5, 12, 13): Txuas lawv mus rau GND ib txwm muaj ntawm cov khoom siv hluav taws xob. Inputs (Pins 2, 7, 10, 15):

Cov no yog cov pins nkag los ntawm kev tswj cov cim qhia los ntawm microcontrollers lossis lwm yam kev sib txuas/ICs. Piv txwv li, yog tias ntawm tus pin 2 (Cov tswv yim ntawm 1st ib nrab H tus tsav tsheb) peb muab Logic 1 (5V), peb yuav tau txais qhov hluav taws xob sib npaug rau VCC2 ntawm cov zis sib xws tus pin ntawm 1st ib nrab H tus tsav tsheb piv txwv li tus lej tsis. 3. Zoo ib yam rau Logic 0 (0V) ntawm Pin 2, 0V ntawm Pin 3 tshwm. Raws li cov lus tawm tswv yim tso tawm cov teeb liab los.

Kev Tsav Tsheb A B.

-----------------------------------------------------------------------------------------

…………… Nres: Tsawg: Tsawg

…… Clockwise: Tsawg: Siab

Anticlockwise: Siab: Tsawg

……………. Stop: Siab: Siab

Kauj Ruam 4: Daim Duab Circuit Court rau Tsav Tsav Tsheb thiab IR Sensor

Daim duab qhia chaw rau Tsav Tsav Tsheb thiab IR Sensor
Daim duab qhia chaw rau Tsav Tsav Tsheb thiab IR Sensor
Daim duab qhia chaw rau Tsav Tsav Tsheb thiab IR Sensor
Daim duab qhia chaw rau Tsav Tsav Tsheb thiab IR Sensor
Daim duab qhia chaw rau Tsav Tsav Tsheb thiab IR Sensor
Daim duab qhia chaw rau Tsav Tsav Tsheb thiab IR Sensor

ATmega32 yog lub zog qis CMOS 8-ntsis microcontroller raws li AVR txhim kho RISCarchitecture. Los ntawm kev ua tiav cov lus qhia muaj zog hauv ib teev moos, ATmega32 ua tiav cov txiaj ntsig tau los txog ze li 1 MIPS ib MHz tso cai rau tus tsim qauv kom ua kom muaj zog siv zog piv rau kev ua haujlwm nrawm.

Cov tub ntxhais AVR sib koom ua ke cov lus qhia nplua nuj nrog 32 lub hom phiaj ua haujlwm rau npe. Txhua qhov kev sau npe 32 tau txuas ncaj qha mus rau Arithmetic Logic Unit (ALU), tso cai rau ob qho kev sau npe ywj pheej kom nkag tau rau hauv ib qho kev qhia ua tiav hauv ib teev. Cov txiaj ntsig tsim tau zoo dua qhov ua tau zoo thaum ua tiav kev nkag mus txog kaum zaug sai dua li CISC microcontrollers ib txwm muaj.

ATmega32 muab cov yam ntxwv hauv qab no:

  • 32 Kbytes ntawm In-System Programmable Flash Program nco nrog Nyeem-Thaum-Sau peev xwm,
  • 1024 bytes EEPROM, 2K byte SRAM,
  • 32 hom phiaj dav dav I/O kab,
  • 32 lub hom phiaj ua haujlwm rau npe,
  • JTAG interface rau Boundaryscan,
  • On-chip Debugging kev txhawb nqa thiab kev ua haujlwm, peb hloov pauv Timer/Counters nrog kev sib piv hom, Sab hauv thiab Sab Nraud cuam tshuam, ib qho program tuaj yeem siv tau USART, ib byte taw qhia Ob-hlau Serial Interface, 8-channel,
  • 10-ntsis ADC nrog rau kev xaiv sib txawv cov tswv yim theem nrog programmable nce (TQFP pob nkaus xwb),
  • programmable Watchdog Timer nrog Internal Oscillator,
  • ib qho chaw nres nkoj SPI, thiab
  • rau software xaiv lub zog txuag hom.

    • Hom tsis ua haujlwm nres CPU thaum tso cai rau USART,
    • Ob-xaim interface, A/D Converter,
    • SRAM,
    • Timer/Suav,
    • Chaw nres nkoj SPI, thiab
    • cuam tshuam qhov system kom ua haujlwm txuas ntxiv.
    • Lub Hwjchim-down hom khaws cov ntawv sau npe tab sis khov lub Oscillator, ua haujlwm tag nrho lwm cov haujlwm ua haujlwm kom txog thaum cuam tshuam sab nraud lossis kho vajtse rov pib dua.
    • Hauv Hwj chim-txuag hom, Asynchronous Timer txuas ntxiv ua haujlwm, tso cai rau tus neeg siv tswj hwm lub sijhawm pib thaum lub cuab yeej tseem tsaug zog.
    • Lub ADC Noise Reduction mode nres CPU thiab txhua I/O modules tshwj tsis yog Asynchronous Timer thiab ADC, txhawm rau txo qis suab nrov thaum hloov pauv ADC
    • Hauv Standby hom, siv lead ua/resonator Oscillator tab tom khiav thaum lub cuab yeej tas li tsaug zog. Qhov no tso cai pib sai heev ua ke nrog kev siv hluav taws xob tsawg.
    • Hauv Kev Txuas Ntxiv Hom, ob lub ntsiab Oscillator thiab Asynchronous Timer txuas ntxiv mus.

Txhua qhov kev sib txuas uas cuam tshuam tau muab rau ntawm no thiab lub ntsiab tseem ceeb (atmega32) kuj tseem muab.

Kauj ruam 5: Avr Cov Haujlwm

Avr Kev Kawm
Avr Kev Kawm
Avr Kev Kawm
Avr Kev Kawm

1. Rau "chaw taws teeb sensor":

#ncig #ncig

#suav nrog "remote.h"

// Lub ntiaj teb hloov pauv tsis tau kos npe rau Lub Sijhawm; // Lub sijhawm tseem ceeb, khaws sijhawm hauv 10us, // Hloov kho tshiab los ntawm ISR (TIMER0_COMP) qhov hloov pauv tsis tau kos npe BitNo; // Txoj haujlwm ntawm tom ntej BIT hloov pauv tsis tau kos npe ByteNo; // Pos ntawm tam sim no Byte

qhov hloov pauv tsis tau kos npe IrData [4]; // Plaub cov ntaub ntawv Bytes ntawm Ir Pob Ntawv // 2-Byte Chaw Nyob 2-Byte Cov ntaub ntawv hloov pauv tsis tau kos npe IrCmdQ [QMAX]; // Qhov Kev Hais Kom Kawg Tau Txais (Tsis)

tsis hloov pauv tsis tau kos npe PrevCmd; // Siv rov ua dua

// Variables siv los pib rov ua haujlwm tsuas yog tom qab tus yuam sij raug nias rau qee lub sijhawm

volatile unsigned char Rov ua dua; // 1 = yog 0 = tsis muaj qhov hloov pauv tsis tau kos npe RCount; // Rov suav dua

volatile char QFront = -1, QEnd = -1;

lub xeev tsis hloov pauv uas tsis tau kos npe Xeev; // Xeev tus txais

hloov pauv tsis tau kos npe ntug Ntug; // Ntug kev cuam tshuam [RISING = 1 LOS YOG FALLING = 0]

volatile unsigned int nres;

/********************************************************** ********************************************** /*FUNCTIONSSTARTS* / / ******************************************************** ****************************************************/

void RemoteInit () {

char kuv; rau (i = 0; i <4; i ++) IrData = 0;

nres = 0; Xeev = IR_VALIDATE_LEAD_HIGH; Ntug = 0; Rov ua dua = 0;

// Teeb tsa Timer1 // ------------ TCCR0 | = ((1 <

TIMSK | = (1 <

OCR0 = TIMER_COMP_VAL; // Teeb Sib Piv Tus Nqi

unsigned char GetRemoteCmd (tos tos) {tsis kos npe cmd;

yog (tos) thaum (QFront ==-1); lwm yog (QFront ==-1) rov qab (RC_NONE);

cmd = IrCmdQ [QFront];

yog (QFront == QEnd) QFront = QEnd = -1; else {if (QFront == (QMAX-1)) QFront = 0; lwm QFront ++; }

rov cmd;

}

2. lub ntsiab ():

int lub ntsiab (tsis muaj dab tsi) {

uint8_t cmd = 0; DDRB = 0x08;

DDRD = 0x80;

DDRC = 0x0f; PORTC = 0x00;

thaum (1) // Infinite Loop kom nquag IR-sensor {

cmd = GetRemoteCmd (1);

hloov (cmd) {

rooj plaub xx: {// BOT txav mus tom ntej // Ch+ btn forwardmotor ();

tawg; // Ob qho Motors hauv Kev Taw Qhia Mus Ntxiv

}

………………………………………………….

………………………………………………….

………………………………………………….

default: PORTC = 0x00; tawg; // Ob sab laug thiab sab xis motors nres}

}

}/*Xaus qhov tseem ceeb*/

……………………………………………………………………………………………………………………

// Nws yog tus qauv yooj yim, tab sis kuv tuaj yeem siv nws hauv PWM hom.

// ………………………………………………………….. Muaj Kev Zoo Siab ………………………………………………………… //

Pom zoo: