Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:examples:setup:linux [2010/02/04 10:49] – external edit 127.0.0.1en:examples:setup:linux [2020/07/20 09:00] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
-====== Tarkvara Linuxi keskkonnas ======+====== The software environment for Linux ======
  
-Järgnev juhend kirjeldab AVR arenduskeskkonna installeerimist ja kasutamist Ubuntu 9.10 operatsioonisüsteemis.+The following guide describes the installation and use of the AVR toolkit 9:10 Ubuntu operating system.
  
-===== Tarkvara paigaldamine =====+===== Software Installation =====
  
-Installeerida järgnev tarkvara:+Install the following software:
  
-**1. Linuxi tarkvarapaketid**+**1. Linux software packages**
  
-  * gcc-avr – GNU C-keele kompilaator AVR platvormile +  * gcc-avr – GNU C-language compiler for AVR 
-  * avrdude – programm hex-faili laadimiseks mikrokontrollerisse +  * avrdude – Program for uploading hex-files to microcontroller 
-  * avr-libc – C-keele teegid koodi kirjutamiseks AVR platvormile+  * avr-libc – C language libraries to write code for AVR platform
  
-Installeerimiseks kasutada terminali käsurida:+To install the packages, use the terminal command:
  
   sudo apt-get install gcc-avr avrdude avr-libc   sudo apt-get install gcc-avr avrdude avr-libc
  
-või graafilist paketihaldustarkvara (näiteks Ubuntu tarkvarakeskus või Synaptic pakihaldur).+or graphical installation software (such as Ubuntu software center or Synaptic packet manager).
  
-**2. Kodulabori teek**+**2. HomeLab library**
  
-Teek lihtsustab programmikoodi kirjutamistkuna madalama taseme funktsioonid on selles juba valmis kirjutatudTeegi installeerimiseks salvestada arvutisse kodulabori kodulehelt fail nimega //Homelab library vX.X.run//, kus X.X asemel on versiooni number, ning käivitada see järgmise käsuga:+The library simplifies the writing of program codesince lower-level functions are ready-madeVisit the HomeLab website and download the file named //Homelab library vX.X.run//, where XX represents the version numberRun the following command to install the library:
  
   sudo sh homelab_library_vX.X.run   sudo sh homelab_library_vX.X.run
  
-Veendu, et kodulabori teegi allalaadimine ja installeerimine õnnestus+Make sure that your library installation is successful.
  
 **3. KontrollerLab** **3. KontrollerLab**
  
-KontrollerLab on IDE (inglise keeles //integrated development environment//ehk integreeritud arenduskeskkond tarkvara kirjutamisekskompileerimisekspealelaadimiseks jmsSalvestada KontrollerLab tarkvarapakett kausta (näiteks //~/Dokumendid/AVR/KontrollerLab///) ning terminali aknas käivitada käsk selles kaustas:+KontrollerLab is an IDE (//integrated development environment//for writingcompilingloading and debugging AVR softwareDownload the KontrollerLab software and save it to some folder (for example, //~/Documents/AVR/KontrollerLab//). Run the following command in this folder:
  
   sudo dpkg -i kontrollerlab*.deb   sudo dpkg -i kontrollerlab*.deb
  
-Kui tekib probleeme paketisõltuvusessiis käivitada järgnev käsk, mis installeerib puuduvad paketid:+If you have problems with packet dependenciesrun the command which installs the missing packages:
  
   apt-get install –f   apt-get install –f
Line 39: Line 39:
 {{  :kit:001_kontrollerlab_installer.png?500  |}} {{  :kit:001_kontrollerlab_installer.png?500  |}}
  
-===== Programmaatori ühendamine =====+===== Connecting the programmer =====
  
-Ühendada programmaator arvutiga ning kontrollida, kas arvuti tunneb seadme äraTerminali aknasse kirjutada käsk //lsusb//, mis näitab nimekirja ühendatud USB seadmetestProgrammaatori nimi on "Future Technology Devices International, Ltd FT 232 USB-Serial (UART) IC".+Connect to programmer with computer and see if the computer recognizes itWrite the command "lsusb" in the terminal window which should show the list of connected USB devicesProgrammers name is "Future Technology Devices International, Ltd FT 232 USB-Serial (UART) IC".
  
 {{  :kit:002_lsbusb.png?500  |}} {{  :kit:002_lsbusb.png?500  |}}
  
-Saamaks teadamillise pordi taha on programmaator ühendatud, kontrollida ///dev// kataloogi, kasutades käske //cd /dev// (määrab ///dev// kui aktiivse kataloogija //dir// (kuvab kataloogi sisu). Kuna tegu on USB-Serial liidesegasiis on ta märgitud //ttyUSBx//-na, kus märgib liidese numbritKui eelnevalt ei ole mingeid teisi USB-serial seadmeid ühendatud, siis on see number 0 +To get the port to which the programmer is connected tocheck the ///dev// folder using the commands //cd /dev// (sets ///dev// as a current folderand //dir// (displays the content of the folder). As the programmer is USB-serial interfaceit is named as a "ttyUSBx" where "x" marks the index of the intefaceIf there are no other USB-serial devices this number is zero.
  
 {{  :kit:003_ttyusb0.png?500  |}} {{  :kit:003_ttyusb0.png?500  |}}
  
-===== Projekti loomine =====+===== Creating a new project =====
  
-AVR programmi kirjutamiseks tuleb luua uus projektmis tüüpiliselt sisaldab endas mitmeid erinevaid faileprogrammikoodi(e)päisefailekompileeritud programmi jneSelleks, et projektid oleks korrektselt eristatavadtuleks iga projekti jaoks luua uus kataloog (seda võimalust pakub ka uue projekti loomise abimees).+To write an AVR programa project must be created which contains all the necessary filessource codesheader filescompiled program, etcTo clearly seperate projectsa folder for each project should be made (this option is also given by the project wizard).
  
-Uue projekti loomiseks järgi järgmisi samme:+To create a project follow the steps:
  
-**1.** Avada KontrollerLab (//Rakendused -> Programmeerimine -> KontrollerLab//ning valida ülevalt menüüst //File -> New -> New project//Avaneb aken, kus tuleb määrata projekti asukoht ning //Location//-väljale kirjutada projektifaili nimiToodud näites on loodud eraldi kataloog //../Homelab/blinkingLED///, kus hoitakse kõik näiteprogrammi (vilkuva LED) jaoks loodavad failid eraldi.+**1.** Open KontrollerLab (//Applications -> Programming -> KontrollerLab//and start a new project from the //File -> New -> New project// menu A window opens where the project location must be specifiedIn this example the locations is //../Homelab/blinkingLED///.
  
 {{  :kit:004_new_project_kontrollerlab.png?500  |}} {{  :kit:004_new_project_kontrollerlab.png?500  |}}
  
-**2.** Kuna projekt on esialgu tühi, siis tuleb sellele juurde lisada C-fail, kuhu koodi saaks kirjutadaValida menüü //File -> New -> New//Avaneb faili lisamise akenkus valida //C source// ja määrata faili nimi.+**2.** The project must have at least one file where to write the program codeFiles can be added from the //File -> New -> New// menuIn the opening windowselect //C source// as a file type and specify the name of the file.
  
 {{  :kit:005_new_file_kontrollerlab.png?500  |}} {{  :kit:005_new_file_kontrollerlab.png?500  |}}
  
-**3.** Seadistada KontrollerLabi projekt vastavalt kodulabori riistvaraleValida menüü //Project -> Configure Project//, mispeale kuvatakse projekti seadistamise aken avatuna //Common//-kaardilMäärata protsessoriks (CPUATmega128, taktsageduseks (clock14745600,0 Hz ning loodavate HEX ja MAP failide nimedVajutades nuppu //Set as default//, määrab see hetkeseadistused KontrollerLabis ka kõikide edaspidi loodavate projektide seadistusteksKuna sõltumata projektist jääb kodulabori riistvara  samaks, siis on mõttekas määratagi sisestatud parameetrid vaikimisi parameetriteksSamas jäävad ka KontrollerLabi poolt loodavate väljundfailide (HEX, MAP) nimed samaks. Siinkohal on kaks võimalust: igas projektis muuta HEX faili nime või panna mingi universaalsem nimi (nt out.hex), mis sobiks kõikidele projektidele. Hetkel on võetud teine variant, nii et projekti vahetamisel ei pea väljundfailide nimesid muutma.+**3.** Next, the project must be configured for HomeLab kitFrom the //Project -> Configure Project// menu open the configurations window and select //Common// tab. CPU type should be ATmega128 and the clock should be 14745600,0 Hz. Also the names of the HEX and MAP files should be specifiedPressing a //Set as default// button makes these configurations as a default for new projectsThis is reasonable when working only with HomeLab AVR microcontrollerAs the HEX and MAP files are also stored as a default it is recommended to use some general name for themfor example "out.hex".
  
-NB! Kuna KontrollerLab programmis ei saa korrektselt teeki lisada // Linker // kaardilsiis tuleb Kodulabori teegi lisamine seadistada siin, kirjutades map faili nime taha // -lhomelab //.+NB! As the HomeLab library can not be added on the //Linker// configuration tabthe command "-lhomelab" must be added behind the name of the MAP file.
  
 {{  :kit:006_project_conf_common.png?500  |}} {{  :kit:006_project_conf_common.png?500  |}}
  
-//Compiler// kaardil seadistada kompilaatori sätted, nagu näidatud juuresoleval pildilEnne //OK// vajutamist määrata ka siin sisestatud parameetrid vaikimisi säteteks.+Apply settings on the //Compiler// tab as shown on the following screenshotBefore pressing //OK// set compiler configurations also as a default.
  
 {{  :kit:007_project_conf_compiler.png?500  |}} {{  :kit:007_project_conf_compiler.png?500  |}}
  
-**4.** Seadistada programmaatori sätted, valides menüü //Project -> Configure Programmer////Choose Programmer//-kaardil valida AVRDUDE ning AVR DUDE kaardil määrata programmaatori tüübiks //jtagmkI// ja ühendusliideseks eelnevalt leitud port ///dev/ttyUSBx// (vt programmaatori peatükki). Määrata ka siin seadistatud parameetrid vaikimisi säteteks.+**4.** Configure the programmer by opening the configurations window from the //Project -> Configure Programmer// menu. Choose "AVRDUDE" as a programmer. On the "AVRDUDE" tab set the programmer type to //jtagmkI// and connection port to ///dev/ttyUSBx// (where "x" is the port index). Set these configuration settings also as a default.
  
 {{  :kit:008_programmer_conf.png?500  |}} {{  :kit:008_programmer_conf.png?500  |}}
  
-**5.** Seadistada tekstiredaktori sätted niiet tabulaatorit tõlgendataks 4 tühikuna. See on vajalik, kui juhtutakse lähtefaili avama mõne muu tekstiredaktoriga, mis tõlgendab tabulaatorit teisiti kui KontrollerLab. Sel juhul võib koodi liigendus muutuda, nii et inimese jaoks on kood raskesti jälgitav. Selleks, et seda ei juhtu, valida menüü //Settings -> Configure Editor// ja avanenud aknas vasakult Editing.  Märgi linnuke kasti "Insert spaces instead of tabulators" sisse. Samuti määra tabulaatori laiuseks 4 tühikut.  +**5.** At lastplace the windows in the KontrollerLab as it is more convenient and get ready to write your first program.
- +
-{{  :kit:009_editor_conf.png?500  |}} +
- +
-**6.** Seadista avanenud alamaknad KontrollerLabis oma käe järgi ning kirjuta mingi lihtne programm keskkonna testimiseks. Järgnevas alampeatükis on näitena toodud vilkuva LED programm.+
  
 {{  :kit:010_kontrollerlab.png?500  |}} {{  :kit:010_kontrollerlab.png?500  |}}
  
-===== Seadistuste testimine =====+===== Writing and testing a program =====
  
-Kui arenduskeskkond on esimest korda paigaldatud ja seadistatudon mõistlik testida, kas kõik sai tehtud õigesti. Selleks on lihtsaim viis teha üks väike programm, see ära kompileerida ja laadida kontrollerisse.+After the configurations steps are doneit is time to programm.
  
-**1.** Ühendada programmaator ATMega128 Kontrollerimooduli plaadigaKontrollida, et programmaator saab ühendatud õigesse pistikusse (JTAG) ja õigetpidi (kaabel on suunatud kontrolleri plaadist eemale - vaata järgmist pilti). Pärast programmaatori ühendamist ühendada kontrolleri toide (kontrolleri plaadil peab süttima väike roheline LED).+**1.** Connect the programmer with Controller moduleDouble-check if the programmer is correctly connected with a JTAG socket. The cable must head away from the board (look at the picture). Now connect the power supply and check if the green LED lights on the Controller board.
  
 {{  :kit:kit_test.jpg?500  |}} {{  :kit:kit_test.jpg?500  |}}
  
-**2.** Sisestada lihtne C-kood ja kompileerida see (//compile//). +**2.** Write the following program in the Kontrollerlab file editor window and compile it:
  
 <code c> <code c>
Line 101: Line 97:
 int main(void) int main(void)
 { {
- // Viigu PB7 seadmine väljundiks+ // Set pin PB7 as an output
  DDRB = 0x80;  DDRB = 0x80;
    
Line 107: Line 103:
  while (true)  while (true)
  {  {
- // Viigu PB7 inverteerimine+ // Inverting pin PB7
  PORTB ^= 0x80;  PORTB ^= 0x80;
  hw_delay_ms(500);  hw_delay_ms(500);
Line 114: Line 110:
 </code> </code>
  
-[{{  :kit:011_compile_ignite.png?408  |Tööriistariba}}]+[{{  :kit:011_compile_ignite.png?408  |Toolbar}}]
  
-Veendu, et väljundaknasse tuleb teade "File compiled successfully"Kui annab teate "Error(s) occurred: ", siis kontrollida, et koodi sisestamisel ei ole tehtud mõnd kirjaviga.+Make sure that the output window shows "File compiled successfully" messageIf the "Error(s) occurred: " message is showncheck the program code for mistakes.
  
-**3.** Koodi pealelaadimiseks valida //ignite// käskKui kõik õnnestubsiis väljundaknas viimase reana annab KontrollerLab teate "Project built and uploaded successfully". Kontrolli, et punane LED hakkaks perioodiliselt vilkuma (500 ms põleb, 500 ms on kustund).+**3.** To download the program into the Controller press the //Ignite// buttonAfter the succeful downloadthe "Project built and uploaded successfully" message should be shown.
  
-Kui LED vilgubnii nagu eespool kirjeldatud, on tarkvara paigaldatud edukalt ja esimene labor läbitudPalju õnne!+If everything was done correctly the red LED on the Controller board should blink periodicallywith 1 second interval.
  
-===== Ujukoma-arvude kasutamine =====+===== Using floating-point numbers =====
  
-Mõnikord tekib vajadus AVR programmis kasutada ujukoma-arveNendega arvutamiseks ja nende esitamiseks //printf//-tüüpi funktsioonidega tuleb projekti seadistustes teha järgmised muudatused:+Sometimes it is neccessary to use floating-point numbers in programTo calculate with them and use them with //printf//-typed functions, some modifications in project configuration must be done:
  
-**1.** Avada projekti seaded menüüst //Project -> Configure Project// ning valida //Linker// kaartMärgistada //Linker flags// sektsioonis esimene linnuke (vaata ka juuresolevat pilti).+**1.** Open the //Project Configurations// window and the //Linker// tabCheck the first line in the //Linker flags// list (look at the picture).
  
 {{  :kit:012_linker_fprintf.png?500  |}} {{  :kit:012_linker_fprintf.png?500  |}}
  
-**2.** Vajutada //OK// ja sulgeda seadete aken.+**2.** Press //OK// and close the window.
  
en/examples/setup/linux.1265280572.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0