Cov txheej txheem:

AVR/Arduino Flashing Nrog Raspberry Pi: 3 Kauj Ruam (nrog Duab)
AVR/Arduino Flashing Nrog Raspberry Pi: 3 Kauj Ruam (nrog Duab)

Video: AVR/Arduino Flashing Nrog Raspberry Pi: 3 Kauj Ruam (nrog Duab)

Video: AVR/Arduino Flashing Nrog Raspberry Pi: 3 Kauj Ruam (nrog Duab)
Video: Amazing arduino project 2024, Hlis ntuj nqeg
Anonim
AVR/Arduino Flashing Nrog Raspberry Pi
AVR/Arduino Flashing Nrog Raspberry Pi

Ib tus programmer hauv-system (ISP) yog lub cuab yeej uas koj tuaj yeem siv los tsim ntau lub microcontrollers, piv txwv li ATMega328p uas yog lub hlwb ntawm Arduino Uno. Koj tuaj yeem yuav qee yam xws li USBtinyISP, lossis koj tseem tuaj yeem siv Arduino. Cov lus qhia no yuav qhia koj yuav siv Raspberry Pi li ISP li cas.

Qhov kev pab cuam avrdude, uas yog Arduino IDE siv li cas hauv qab lub hood kom nyem cov chips, tuaj yeem siv nrog ntau tus programmer. Ib qho ntawm nws cov kev xaiv yog siv SPI pins ntawm Pi qhov chaw nres nkoj nthuav dav. Kuv yuav piav qhia yuav ua li cas thiaj tsim kev sib txuas tsim nyog, tso ua ke ib qho yooj yim Circuit Court ntawm perfboard yog li koj tsis tas yuav rov ua cov kab hluav taws xob txhua lub sijhawm koj xav nyem lub nti, thiab yuav teeb tsa thiab siv avrdude li cas. Kuv tseem yuav qhia koj yuav ua li cas kom tau txais cov kev pab cuam suav nrog siv Arduino IDE mus rau AVR nti xws li ATmega lossis ATtiny siv txoj hauv kev no.

Yam Yuav Tsum Tau:

  • Raspberry Pi nrog qhov tseeb Raspbian ntsia
  • 40-pin txiv neej lub taub hau ntsaws (lossis 26-pin yog tias koj muaj Pi loj dua)
  • IDE cable txuas rau koj Pi
  • 16 MHz siv lead ua resonator
  • 22 pF capacitors (2)
  • LED (1) qhia qhov xwm txheej ntawm tus programmer
  • 8, 14, thiab/lossis 28 tus pin IC nyob, nyob ntawm seb cov duab zoo li cas koj xav tau nyem
  • Qee qhov perfboard, xov hlau, kab laug sab

Kauj Ruam 1: Tsim Cobbler Attachment

Tsev Cobbler Attachment
Tsev Cobbler Attachment
Tsev Cobbler Attachment
Tsev Cobbler Attachment
Tsev Cobbler Attachment
Tsev Cobbler Attachment

Serial Peripheral Interface (SPI), tseem hu ua plaub-xaim xov tooj, yog ib txoj hauv kev sib txuas lus ntawm ib tus tswv cuab yeej nkaus xwb thiab ib lossis ntau yam khoom siv qhev. Peb yuav siv qhov no los nyem cov chips, nrog Pi ua tus tswv thiab nti ua tus qhev. Koj yuav ua cov kev sib txuas hauv qab no ntawm Pi thiab koj cov nti (saib cov pinouts saum toj no rau ntau yam AVRs thiab Pi nthuav cov chaw nres nkoj kom paub tias tus pin yog leej twg):

  • Txuas MOSI (tus tswv-tawm-qhev-hauv) tus pin ua ke
  • Txuas SCLK (sib koom ua ke moos) pins ua ke
  • Txuas MISO (tus tswv-hauv-qhev-tawm) pins ua ke nrog 220 Ohm resistor, los tiv thaiv Pi los ntawm ib qho kev cia siab siab qhov hluav taws xob los ntawm cov nti
  • Txuas GPIO 25 ntawm Pi ncaj qha rau RESET tus pin ntawm lub nti. Tus Pi rub tus lej no qis thaum ua haujlwm, yog li peb siv 10K tus tiv thaiv kom nws siab thaum tsis ua haujlwm, thiab LED nrog 1K tiv thaiv tus tiv thaiv khiav mus rau qhov hluav taws xob zoo los muab rau peb qee qhov pom tau zoo thaum nws tau ua haujlwm.

Peb txuas hauv av thiab lub zog (3.3V) tus pin ntawm Pi thiab cov chips peb xav kom ua haujlwm. Yog tias koj tsis tau paub dua, Raspberry Pi tus pin tsis yog 5V zam - lawv yuav raug puas tsuaj yog ntau dua 3.3V tshwm rau lawv. Yog tias cov chips tau xav tau 5V lub zog rau qee qhov laj thawj, peb tuaj yeem siv qib hloov pauv nti los tiv thaiv Pi tus pin, tab sis kuv tsis tau ntsib teeb meem siv 3.3V - yog li kuv pom zoo ua si kom nyab xeeb thiab txuag ntawm cov khoom.

Thaum kawg, peb txuas 16MHz siv lead ua oscillator hla XTAL pins ntawm lub nti, uas peb kuj txuas rau hauv av ntawm ob peb 22pF capacitors. AVR chips tuaj yeem teeb tsa kom khiav ntawm ntau zaus, thiab tseem tuaj yeem teeb tsa los siv sab hauv lossis sab nraud los txiav txim qhov zaus ntawd. Yog tias koj lub nti tau teeb tsa siv cov siv lead ua sab nraud raws li nws qhov peev txheej ntau, koj yuav tsis tuaj yeem rov tsim dua yam tsis muaj nws. Txwv tsis pub nws tsis muaj teeb meem yog tias nws nyob ntawd.

Koj tuaj yeem siv cov phiaj xwm hluav taws xob hauv daim duab kawg los ua cov lus qhia rau kev sib dhos koj cov cobbler txuas rau ntawm perfboard. Koj tuaj yeem muaj ntau lossis tsawg ob peb qhov sib txawv ntawm IC qhov nyob raws li koj xav tau, tsuas yog txuas tus pin tsim nyog ua ke nrog Pi thiab siv lead ua. N. B. yog tias koj siv daim duab ntawm kuv tus qauv ua tus qhia, nco ntsoov tias kuv tau ntxiv qee lub taub hau ntxiv thiab qhov ntsaws kom kuv tuaj yeem nkag mus rau tus pin ntawm Pi vim li cas tsis cuam tshuam.

Kauj Ruam 2: Txhim Kho thiab Siv Avrdude

Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude
Txhim Kho thiab Siv Avrdude

Txhawm rau nruab avrdude ntawm koj Pi, tsuas yog ntaus

sudo apt-tau nruab avrdude

Tom qab ntawd koj yuav tsum tau qhib lub SPI interface, yog tias nws tseem tsis tau qhib. Muaj txoj hauv kev hais kom ua qhov no, tab sis nws yooj yim dua siv Raspberry Pi cov cuab yeej teeb tsa. Hom

sudo raspi-teeb tsa

thiab mus rau Interface Options kom qhib rau SPI.

Txhawm rau nyem koj lub nti, ntsaws cov kab xov txuas los ntawm koj tus Pi rau hauv qhov txuas ntawm kab hluav taws xob perfboard thiab ntxig lub nti rau hauv qhov tsim nyog IC qhov (kom ntseeg tau tias nws tau ntsib txoj kev yog).

Thaum ua kom pom qhov program, koj yuav tsum nco ntsoov teeb lub fuses hauv lub nti kom raug. Cov no tsuas yog cov khoom me me hauv cov nti uas koj teeb tsa los qhia nws tias lub moos khiav nrawm npaum li cas, txawm tias yuav lwv EEPROM thaum sau cov nti, thiab lwm yam. nws yooj yim dua los siv lub tshuab xam zauv fuse muab ntawm engbedded.com/fusecalc. Xaiv lub npe AVR uas koj tab tom siv thiab xaiv cov kev xaiv uas koj xav tau hauv thaj chaw "Xaiv Xaiv". Kuv ib txwm tsuas yog ua kom lub moos teeb tsa raug thiab tso lwm yam ntawm qhov tsis raug. Koj yuav luag ib txwm xav tawm "Cov phiaj xwm phiaj xwm tau qhib" CHECKED thiab "Reset Disabled" UNCHECKED - txwv tsis pub koj yuav tsis tuaj yeem rov tsim dua lub nti. Thaum koj tau teeb tsa raug, koj tuaj yeem nqes mus rau thaj chaw "Chaw Tam Sim No" thiab luam tawm AVRDUDE cov lus sib cav raws li qhia hauv daim duab.

Txhawm rau teeb tsa fuses, nkag mus rau cov lus txib

sudo avrdude -c linuxspi -P /dev/spidev0.0 -p

qhov twg lub npe sib xws rau lub nti koj siv. Koj tuaj yeem pom cov npe ntawm cov npe los ntawm kev nkag mus sudo ardude -c linuxspi -p? Type. Txhawm rau nyem koj cov haujlwm, xyuas kom nws nyob hauv koj phau ntawv teev npe tam sim no thiab nkag mus

sudo avrdude -c linuxspi -P /dev/spidev0.0 -p -U nyem: w:: i

Tom qab ob qho lus txib, LED yuav ci thaum lub nti raug hloov pauv.

Kauj Ruam 3: Tau Txais Cov Kev Kawm Arduino rau AVRs

Tau Txais Cov Kev Kawm Arduino rau AVRs
Tau Txais Cov Kev Kawm Arduino rau AVRs
Tau Txais Cov Kev Kawm Arduino rau AVRs
Tau Txais Cov Kev Kawm Arduino rau AVRs
Tau Txais Cov Kev Kawm Arduino rau AVRs
Tau Txais Cov Kev Kawm Arduino rau AVRs

Lub hom phiaj tseem ceeb ntawm cov lus qhia no yog ua kom pom cov program uas twb tau sau ua ke mus rau cov chips, tsis yog yuav sau lossis sau lawv li cas. Txawm li cas los xij, Kuv xav piav qhia yuav ua li cas koj tuaj yeem suav sau binaries siv Arduino IDE thiab coj lawv mus rau qhov khoob AVR chips siv txoj hauv kev no, txij li Arduino yog qhov yooj yim kawm thiab muaj ntau yam kev qhia thiab piv txwv.

Ua ntej, koj yuav tsum tau ntxiv cov ntaub ntawv hais txog AVR chips koj yuav tau nyem kom IDE paub yuav ua li cas sau rau lawv. James Sleeman tau pab ua ke ua ke qee cov ntaub ntawv teeb tsa, uas muaj nyob ntawm github. Txhawm rau siv lawv, qhib "Cov Ntawv Nyiam" ntawv qhia zaub mov hauv Arduino IDE thiab nyem lub npov nyob ib sab ntawm "Tus Thawj Saib Xyuas Ntxiv URLs" teb. Luam thiab muab tshuaj txhuam cov URL hauv qab no hauv cov lus sib tham uas tshwm:

Tom qab ntawd, mus rau "Cov Cuab Yeej" ntawv qhia zaub mov thiab nrhiav "Tus Thawj Saib Xyuas Haujlwm …" kev xaiv hauv ntu "Pawg Thawj Coj". Xaub mus rau hauv qab ntawm cov npe hauv Tus Thawj Saib Xyuas lub npov lus sib tham thiab teeb tsa DIY ATmega thiab DIY ATtiny laug cam.

Txhawm rau suav koj cov haujlwm, ua ntej ua ntej kom ntseeg tau tias koj tau xaiv cov nti raug hauv "Cov Txheej Txheem" ntawv qhia zaub mov, nrog rau cov txheej txheem ua kom raug. Xaiv qhov "Siv Bootloader: Tsis" xaiv, vim peb yuav tso ncaj qha nrog Pi thiab yog li tuaj yeem siv qhov chaw ntxiv uas ib txwm yuav tsum tau nqa los ntawm Arduino bootloader. Tam sim no, nyem lub pob "Txheeb Xyuas" (kos cim). Qhov no yuav suav koj cov haujlwm yam tsis tau sim rub nws (txij li koj tau ua cov kauj ruam koj tus kheej).

Piv txwv tias txhua yam mus tau zoo, tam sim no koj yuav tsum tau muab cov phiaj xwm tso ua ke rau koj Pi. IDE zais lawv nyob hauv qhov chaw ib ntus, vim nws tau tsim los tso cov program nws tus kheej. Ntawm Windows, nws nyob hauv AppData/Local/Temp hauv koj cov npe neeg siv, hauv daim nplaub tshev uas pib nrog 'arduino_build'. Nrhiav rau.hex cov ntaub ntawv - qhov ntawd yog koj qhov haujlwm! Xa nws mus rau koj tus Pi ntawm FTP lossis nrog USB stick, thiab koj tab tom ua lag luam.

Ua qhov no xav kom koj muaj Windows PC lossis Mac los sau koj cov haujlwm, uas koj tom qab ntawd xa mus rau Pi. Nws yuav yog qhov yooj yim heev kom tuaj yeem ua qhov no ntawm Pi nws tus kheej, tab sis hmoov tsis qhov ua haujlwm raug cai ntawm Arduino IDE muaj nyob hauv Raspbian chaw cia khoom yog qhov qub thiab tsis muaj Tus Thawj Saib Xyuas Haujlwm. Tsis muaj qhov no, ntxiv cov chaw tsim nyog los suav sau rau AVRs liab qab yog qhov nyuaj me ntsis. Muaj cov kev qhia tawm rau kev suav ua qhov hloov tshiab ntawm Arduino ntawm koj Pi - yog tias koj xav ua, mus nrhiav lawv! Kuv kuj xav zoo li nws yuav tsum ua tau kom tau IDE los siv linuxspi programmer txhawm rau nyem lub nti los ntawm IDE nws tus kheej (piv txwv li siv "rub tawm" khawm), tab sis qhov no dhau ntawm kuv lub siab ntev thiab qib txuj ci - yog tias koj paub ib txoj kev, tshaj tawm nws hauv cov lus! Thaum kawg, koj tuaj yeem tsuas yog sau cov program ncaj qha hauv AVR-C thiab sau lawv ntawm Pi nrog avr-gcc, muab rau koj ua tiav AVR kev txhim kho platform hauv Raspberry Pi. Kuv tau ua qhov me me ntawm qhov ntawd, thiab yog tias koj xav mus rau txoj kev ntawd, Kuv thov qhuas koj. Tau flashing!

Pom zoo: