Cov txheej txheem:

AVR Assembler Tutorial 8: 4 Cov Kauj Ruam
AVR Assembler Tutorial 8: 4 Cov Kauj Ruam

Video: AVR Assembler Tutorial 8: 4 Cov Kauj Ruam

Video: AVR Assembler Tutorial 8: 4 Cov Kauj Ruam
Video: AVR Ассемблер. Урок 1. Вводный. AVR Assembler. Lesson 1. Promo. 2024, Lub Xya hli ntuj
Anonim
AVR Assembler Tutorial 8
AVR Assembler Tutorial 8

Zoo siab Tutorial 8!

Hauv qhov kev qhia luv luv no peb yuav coj mus rau qhov sib txawv me ntsis los ntawm kev qhia txog yam tshiab ntawm cov lus sib dhos ua ke los qhia yuav ua li cas txav peb cov qauv ua qauv mus rau cais "luam tawm" pawg thawj coj saib xyuas. Qhov laj thawj yog tias, ntawm qhov no, peb lub hauv paus tseem ceeb ntawm lub khob cij tau txais nrog ntau ntau daim, xov hlau, khawm, thiab LEDs uas nws nyuaj rau sim cov khoom tshiab thiab txij li thaum kawg peb yuav tsum txav cov khoom mus rau lawv tus kheej lub rooj zaum, peb yuav zoo li pib tam sim no. Coob leej ntawm koj yog tej zaum twb paub zoo txog yam uas peb yuav hais hauv phau ntawv qhia no thiab yog li koj tuaj yeem saib ntawm Tutorial no tsuas yog so kom txaus so los ntawm coding.

Yog li niaj hnub no peb yuav txav peb cov menyuam lub duav ATmega328P thiab cov khub ntawm cov tsuav mus rau lub rooj sablaj sab nraud nrog txuas rau peb lub rooj tsavxwm tseem ceeb rau kev sib txuas lus rau nws thiab rau lub zog. Ib cag ntawm qhov ntawd, kev thaiv thiab ua haujlwm ntawm cov tsuav yuav muaj tus kheej nyob hauv qhov khoom ntawd.

Koj tuaj yeem kwv yees kwv yees los ntawm qhov no tias peb lub hom phiaj kawg yog ua qhov no nrog txhua yam ntawm cov khoom peb tsim ua raws txoj hauv kev kom thaum peb ua tiav peb tuaj yeem nkaum lawv tag nrho mus rau hauv pob zoo saib uas yuav ua haujlwm ntawm khawm nias yam tsis pom txhua ntawm cov xov hlau thiab kev ua haujlwm sab hauv.

Peb yuav siv sijhawm ntau ntawm qhov kev qhia no ua haujlwm lub cev xws li tsim lub Circuit Court, ua daim phiaj tsim qauv, thiab siv cov khoom sib dhos ua ke, tab sis muaj cov phiaj xwm me ntsis peb yuav tsum tau ua thaum kawg tom qab peb txav khoom. Qhov laj thawj yog tias peb tab tom yuav siv 2-xaim Serial Interface los sib tham ntawm peb tus tswv "tus tswv" tseem ceeb thiab txhua tus "qhev" cov tswj hwm uas tsim cov khoom ntawm peb txoj haujlwm tag nrho hauv kab lus qhia no thiab, raws li koj rov hais dua, hauv Kev Qhia 6 peb tau tsim ib hom Morse Code hom kev sib tham los sib tham peb cov dice yob los ntawm cov menyuam tsuav (Qhia 4) mus rau Tus Kws Tshuaj Ntsuam Xyuas (Tutorial 5) uas nthuav tawm qhov tshwm sim ntawm cov dice yob hauv binary ntawm 8 LEDs. Zoo uas tsuas yog "yob koj tus kheej" txoj kev sib txuas lus uas kuv txiav txim siab siv vim tias, lub sijhawm ntawd, nws ntxov dhau los nkag rau hauv 2-xaim xov tooj sib txuas. Peb tam sim no yuav luag npaj rau dhia mus rau qhov kawg ntawm kev sib tham hauv xov tooj, thiab peb yuav ua qhov ntawd hauv Tutorial 10, tab sis tam sim no peb yuav tsum cia siab tias yuav muaj kev txhim kho yav tom ntej thiab rov txuas xov tooj rau peb tsuav cov menyuam LED kom thiaj li tso tau ob pins uas peb xav tau rau kev sib txuas lus txuas.

Cov no yog SCL thiab SDA tus pin ntawm ATmega328P. Koj tuaj yeem pom los ntawm daim duab pinout uas lawv tseem hu ua ADC5 thiab ADC4 thaum siv hauv Kev Sib Hloov-rau-Digital, lawv raug hu ua PCINT13 thiab PCINT12 thaum siv ua "Pin Change Interrupt" pins, thiab thaum kawg peb feem ntau hu lawv PC5 thiab PC4 thaum yooj yim suav tias yog tus pin ntawm PortC. Txij li thaum peb siv ob tus pin no ua ib feem ntawm peb cov menyuam dice rau ntau yam laj thawj (qhov tseem ceeb yog qhov nws ua kom yooj yim dua thiab txuas mus rau LEDs ntawm lub rooj tsavxwm yooj yim dua) tam sim no peb yuav tsum hloov kho peb cov cai thiab rov xaim nws me ntsis rau pub dawb cov pins no rau kev sib tham yav tom ntej.

Yog li peb yuav pib los ntawm kev ua tus tsim, txiav, thaiv, thiab siv tshuaj txhuam. Tom qab ntawd peb yuav rov sau cov dice rau cov menyuam kom ua haujlwm nrog peb cov teeb tsa tshiab thiab thaum kawg sim nws kom ntseeg tau tias nws tseem ua haujlwm.

Txhawm rau ua kom tiav Tutorial no koj yuav xav tau cov khoom hauv qab no:

  1. Cov khoom txheem uas koj ib txwm xav tau uas kuv yuav tsum tsis txhob rov ua dua txhua lub sijhawm: koj lub rooj tsav xwm tsim qauv, koj daim ntawv theej ntawm cov ntawv teev tseg thiab cov lus qhia teeb tsa, thiab koj lub hlwb.
  2. Ib lub wireless Circuit Court prototyping PCB board zoo li qhov no: https://www.ebay.com/itm/191416297627 Kuv yuav siv Measure Explorer 103RAWD version ntawm pawg thawj coj no: https://www.ebay.com/itm/103RAT -circuit-proto-proto … txij li kuv muaj ib pawg ntawm lawv ntawm tes, tab sis 103RAW-0 version uas kuv txuas rau saum toj no yuav ua haujlwm zoo ib yam nkaus.
  3. Clippers, xov hlau, cov laug, cov hlau txuas, "pab txhais tes" lossis ib yam dab tsi los tuav cov khoom, thiab lwm yam. Thiab lwm yam ntxiv, los ntawm qhov no kuv yuav tsis tso cov khoom no ib yam. Yog tias koj tau txais qhov deb nyob hauv cov Tutorials no tej zaum koj muaj tag nrho cov khoom no lawm.

Nov yog qhov txuas mus rau kev sau tiav ntawm kuv cov AVR kev sib sau ua ke qhia:

Kauj Ruam 1: Tsim Daim Kab Xev

Tsim ib Daim Duab Hluav Taws Xob
Tsim ib Daim Duab Hluav Taws Xob
Tsim ib Daim Duab Hluav Taws Xob
Tsim ib Daim Duab Hluav Taws Xob
Tsim ib Daim Duab Hluav Taws Xob
Tsim ib Daim Duab Hluav Taws Xob

Qhov txias tshaj ntawm Measure Explorer cov laug cam yog tias yog koj siv qee lub sijhawm thiab daim duab qhia chaw thaum pib koj tuaj yeem txuag koj tus kheej ntawm ntau txoj hlua hlau thaum kawg. Yog li peb yuav pib los ntawm kev siv qee lub sijhawm tsim peb txheej txheem ua ntej peb pib siv txhua yam. Nrog cov pawg no, koj yuav tsum txiav ib pawg ntawm cov xov txuas, uas tsis yog txhua yam yooj yim, tab sis qhov tshwm sim yog lub rooj sib dhos zoo nkauj heev nrog qhov tsawg kawg nkaus ntawm cov xov tsis sib haum. Thawj qhov peb yuav tsum tau ua yog tsim peb Circuit Court kom nws haum rau ntawm lub rooj tsavxwm. Ib txoj hauv kev zoo los ua qhov no yog rub daim ntawv qhia chaw ntawm pawg thawj coj saib thiab tom qab ntawd siv nws los ua si ib puag ncig nrog cov qauv sib txawv kom txog thaum koj pom ib qho uas ua haujlwm. Nov yog txheej txheem rau ME-PB-103RAWD https://www.bluemelon.com/photo/3483513-T800600-j.webp

Kauj Ruam 2: Txiav Tawm Circuit Court ntawm Pawg Thawj Coj

Txiav tawm Circuit Court ntawm Pawg Thawj Coj
Txiav tawm Circuit Court ntawm Pawg Thawj Coj
Txiav tawm Circuit Court ntawm Pawg Thawj Coj
Txiav tawm Circuit Court ntawm Pawg Thawj Coj
Txiav tawm Circuit Court ntawm Pawg Thawj Coj
Txiav tawm Circuit Court ntawm Pawg Thawj Coj

Ua ntej tshaj tawm qhov ntse thiab, siv koj qhov kev teeb tsa uas koj tau teeb tsa hauv cov kauj ruam dhau los, kos koj lub Circuit Court ntawm lub rooj tsavxwm. I.e. kos kab los sawv cev rau cov xov hlau. Tsis txhob kos ib yam dab tsi raws li cov khoom siv, tsuas yog txuas cov xov hlau raws li qhia hauv thawj daim duab. Daim ntawv ceeb toom tias thaum koj ntsia hlau (thiab yog tias koj yog ib yam dab tsi zoo li kuv koj yuav tshem tawm ntau yam hauv cov theem no) koj tuaj yeem siv lub lwv thiab tshem kab. Ua qhov no rau ob sab ntawm pawg thawj coj.

Tom ntej no koj yuav tsum txiav cov kev sib txuas ib ncig ntawm kab. Yog tias koj saib ze ntawm lub rooj tsavxwm koj yuav pom tias txhua tus pin qhov txuas nrog 4 qhov nyob ib sab ntawm ob sab ntawm lub rooj tsavxwm kom txhua lub qhov ntawm lub rooj tsavxwm tau txuas nrog ib leeg thaum koj pib. Yog li koj yuav tsum txiav ob sab ntawm txhua qhov ntawm koj cov xov hlau kom cais lawv. Feem ntau txoj hauv kev los txiav qhov no yog nrog rab riam Exacto. Tab sis kuv nqus ntawm Exacto riam thiab tej zaum yuav txiav kuv tus kheej. Yog li kuv siv Dremel nrog cov cuab yeej txiav txiav txuas. Kuv vam tias kuv muaj qee yam kev sib tsoo txuas uas tau los rau hauv qhov ntse vim tias qhov ntawd yuav ua haujlwm zoo tshaj plaws - tab sis kuv tsis muaj ib qho zoo li ntawd yog li kuv tau siv cov ntawv txiav txuas txuas. (Nco tseg ntxiv: Tom qab ua tiav txoj haujlwm no kuv pom tias qhov me me "lub luag haujlwm hnyav txiav lub log" taub hau rau Dremels ua haujlwm zoo tshaj plaws, lawv zoo li lub voj voos me me ntawm cov ntawv xuab zeb thiab lawv ua haujlwm zoo li cov cuab yeej txiav tau qhia ntawm no tshwj tsis yog tias lawv muaj txoj kab uas hla me dua thiab nws yooj yim dua pom thiab tswj qhov twg koj tab tom txiav)

Nrog txoj kev nws yog qhov muaj txiaj ntsig los tuav lub rooj tsavxwm kom pom lub teeb thiab xyuas kom tseeb tias cov xov hlau tau raug txiav. Koj tuaj yeem thab plaub ntawm qhov tseeb tias muaj kev sib txuas ntawm ob sab ntawm lub rooj tsavxwm yog li koj yuav tsum rov txiav cov txheej txheem dua nrog rau lwm sab, tab sis kuv xav tias koj yuav pom lub ntsiab lus ntawm qhov no los ntawm lub sijhawm koj ua tiav. Kuv tau ua ntau qhov yuam kev txiav cov xov hlau uas yuav tsum tsis tau raug txiav thiab muaj lwm sab tseem txuas nrog txuas ua qhov zoo.

Nws yuav siv sijhawm me ntsis thiab ua siab ntev txhawm rau txiav lub Circuit Court rau hauv pawg thawj coj tab sis nws yog yam lom zem thaum koj ua tau zoo ntawm nws.

Kauj Ruam 3: Muab cov Cheebtsam thiab Kev Xeem

Solder Cheebtsam thiab Kev Xeem
Solder Cheebtsam thiab Kev Xeem
Solder Cheebtsam thiab Kev Xeem
Solder Cheebtsam thiab Kev Xeem
Solder Cheebtsam thiab Kev Xeem
Solder Cheebtsam thiab Kev Xeem

Tam sim no koj tau cais tag nrho cov xov hlau hauv koj lub rooj tsav xwm hauv Circuit koj tuaj yeem pib siv cov khoom sib txawv.

Thawj zaug kuv tau siv cov LEDs rau ib qho ntawm cov tsuav, tom qab ntawd kuv coj qhov zoo thiab qhov tsis zoo los ntawm kuv lub khob cij thiab kuaj cov kev sib txuas rau txhua LED kom paub tseeb tias lawv raug cais los ntawm ib leeg thiab lawv ua haujlwm.

Zoo ib yam nrog lwm tus tuag.

Tom qab ntawd xaim tus tiv thaiv rau txhua tus tuag, thiab 10K tus tiv thaiv nyob tom qab ntawm lub rooj tsavxwm.

Tom qab ntawd xa cov siv lead ua oscillator, 22pf lub kaus mom, lub pob nyem, thiab ATmega328P. Koj yuav xav siv lub qhov ntsaws ntsaws ntsaws thiab tom qab ntawd haum koj lub ATmega328P rau hauv qhov ntawd koj thiaj tuaj yeem tshem nws yog tias koj xav tau thiab rov siv nws hauv lwm yam. Kuv nyuam qhuav muab kuv tus ntiv tes tso rau ntawm lub rooj tsavxwm txij li thaum kuv paub tias peb tab tom tsim dab tsi nrog txhua qhov kev qhia no thiab kuv paub tias kuv yuav nyiam nws txaus uas kuv yuav tsis xav siv lub nti tawm.

Daim ntawv ceeb toom, los ntawm kev saib tom qab ntawm lub rooj tsavxwm, txoj kev uas peb tau txuas cov kab ntawv. Kuv siv tus pin ntev taub hau thiab khoov lawv horozontal kom lawv tsis txhob lo tawm ntawm lub rooj tsavxwm. Qhov no yog qhov kuv tuaj yeem thaum kawg npog lub rooj tsavxwm rau qib ntawm lub laub khawm thiab LEDs nrog lub ntim thiab tsis muaj lub taub hau tau txais txoj hauv kev. Peb muaj lub taub hau rau Tx, Rx yog li peb tuaj yeem teeb tsa lub nti, peb muaj lub taub hau rau SDA, SCL yog li peb tuaj yeem siv 2-xaim kev sib txuas lus tom qab. thiab peb muaj 3 tus pin header rau AVCC, AREF, GND ntawm lwm sab ntawm lub rooj tsavxwm. Kuv muaj tag nrho cov pins hauv av thiab VCC tus pin txuas ua ke ntawm lub nti yog li peb tsuas xav tau ib lub hwj chim nkag.

Thaum kawg txhua yam yog xaim, peb xaim tuag 1 tuag 2 txoj kev uas peb tau ua ntawm lub khob cij kom peb tuaj yeem tswj ob lub tsuav nrog tsuas yog 9 tus pin.

Tam sim no peb yuav tsum hloov kho peb cov cai kom nws yuav tswj hwm qhov teeb tsa tshiab no.

Kauj Ruam 4: Sib dhos Code thiab Yees Duab

Kuv tau txuas cov lej sib dhos thiab cov vis dis aus ntawm cov menyuam tsuav hauv kev ua haujlwm. Txhua yam kuv tau ua yog coj cov cai rau peb cov menyuam tsuav los ntawm Tutorial 6, hloov cov pins kom phim tus qauv tshiab, thiab tshem tawm kev sib txuas lus subroutine txij li peb yuav tau sau ib qho tshiab hauv Tutorial 10. Ntawm lub sijhawm tom ntej no peb yuav rhuav tshem peb cov keyboard dua thiab kawm paub tswj 7-ntu lus qhia saib koj li cas!

Pom zoo: