Differences

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

Link to this comparison view

de:book [2011/07/21 07:54] – angelegt seilerde:book [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Preface ======+====== Einleitung ======
  
-The book you are about to read is a microcontroller and practical robotics handbook which according to the authors hope will help to build intelligent microcontroller based solution and popularize the engineering profession amongst the young peopleThe book is oriented to the schools and universitiesbut can also be used for hobbyist and companies who are planning to use AVR microcontrollers in their projectsThe target group is as well teachers as learners by helping to get fast results for both of themfor learner to get new knowledge and for teachers to make their life easier when trying to bring new subject for the learners :)+Dieses Buch wurde als praktisches Handbuch für Mikorcontroller und Robotik konzipiert, in der Hoffnung, dem Leser bei der Entwicklung von „smarten“ Lösungen zu helfenDarüber hinaus soll es auch dazu beitragendie Begeisterung für den Ingenieurberuf bei jungen Menschen zu wecken. In erster Linie richtet sich das Buch an Schulen sowie Universitäten, aber auch an Bastler und Unternehmen, die im Rahmen von Projekten mit AVR Mikrocontrollern arbeiten möchten. 
 +  
 +Ziel ist es, sowohl Lehrende als auch Lernende dabei zu unterstützen, rasch Ergebnisse zu erzielenso soll Schülern und Studenten neues Wissen vermittelt und das Leben der Lehrenden erleichtert werden.
  
-**Platform** 
  
-The selected base platform for the practical examples is AVR ATmega128 microcontroller based Robotic HomeLab Kit. AVR is one of the most widely used microcontroller besides Microchip PIC amongst the hobby robotic community and is very good for educational purpose. +**Plattform**
  
 +Für die praktischen Beispiele in diesem Buch wird ein AVR ATmega128 Mikrocontrollersystem,das sogenannte HomeLab Kit, als grundlegende Plattform genutzt. Die AVR Mikrocontroller sind, neben Microchip PIC, die am weitesten verbreiteten in der Hobby-Robotik-Community. Darüber hinaus sind siebesonders gut für Lehrzwecke geeignet.
  
-The book is logically divided into five sections: 
  
-**1.** section is giving a fast introduction to the most simple electronic fundamentals and calculations. These formulas are very useful for several practical exercises. Also the C-language is briefly covered and some simple examples are given.+Das Buch ist systematisch in fünf Kapitel unterteilt:
  
-**2.** section gives an overview of 8-bit AVR microcontroller by using the ATmega128 as an example. The section relays basically on the ATmega datasheet but simplifies and presents the information in more friendly wayThis is a general microcontroller basic function description.+**1.** Das erste Kapitel gibt eine kurze Einführung in die grundlegenden elektronischen Prinzipien und Berechnungen. Die vorgestellten Beispiele und Formeln sind sehr nützlich für viele folgende AufgabenAußerdem wird die Programmiersprache „C“ kurz vorgestellt und ein paar grundlegende Anwendungsbeispiele werden diskutiert.
  
-**3.** section introduces the hardware and software platform which is developed for the educational use and is a base platform of the next chapter examplesSpecial software library is developed for most common functionsThe user can concentrate on the program logic instead of working with the registers in deep. Both Windows and Linux operation systems are supported.+**2.** Im zweiten Kapitel wird am Beispiel des ATmega 128 ein Überblick über 8-bit AVR Mikrocontroller gegebenDieses Kapitel basiert weitgehend auf dem Datenblatt des ATmega Mikrocontrollers, stellt die benötigten Informationen jedoch vereinfacht und übersichtlicher darHier werden allgemein die Grundfunktionen eines Mikrocontrollers erörtert.
  
-**4.** section consists of practical examples together with exercises. Examples are divided into labs by covering the most common electromechanical devices and functions. Every chapter has short theory background description and practical example which enables to run the function immediately by coping the program into the controller. Every exercise group (lab) has exercises in the end of sub-chapter together with questions. Exercises are divided for beginners and for advanced users, in a way giving the selection according to the learners skillsFor better understanding the chapters are provided by the references to the theoretical section.+**3.** Dieses Kapitel führt die Hardwareund Softwareplattform einwelche für Lehrzwecke entwickelt wurde und als Grundgerüst für weitere Beispiele in den folgenden Kapiteln dientFerner wird an dieser Stelle auch die „HomeLab Library“, eine für das Kit entwickelte Softwarebibliothek, welche vereinfachte Methodenaufrufe für häufig genutzte Funktionalitäten bietet, vorgestellt. Dies bietet dem Benutzer den Vorteil, dass er sich auf die Logik seiner Software konzentrieren kann, anstatt den Fokus auf das Programmieren von Registern legen zu müssen. Dabei berücksichtigt dieses Buch sowohl Windows- als auch Linux-Betriebssysteme.
  
 +**4.** Im vierten Kapitel werden schließlich praktische Beispiele sowie Übungen vorgestellt. Die Beispiele sind unterteilt in „Labs“ (Übungsabschnitte) und decken die meisten elektro-mechanischen Bauteile und Funktionen ab. Jeder Abschnitt enthält zunächst eine kurze Beschreibung des theoretischen Hintergrunds sowie praktische Beispiele. Durch einfaches Kopieren der Beispielprogramme in den Controller hat der Nutzer direkt die Möglichkeit, die Funktionen zu nutzen.  Am Ende jedes Unterkapitels finden sich Beispielaufgaben sowie Verständnisfragen zum jeweiligen Übungsabschnitt. Sämtliche Übungen sind nach ihrem Schwierigkeitsgrad gegliedert, damit sowohl Anfänger als auch Fortgeschrittene die für sie geeigneten Übungsaufgaben auswählen können. Darüber hinaus werden zum besseren Verständnis der Aufgaben Bezüge zu den betreffenden theoretischen Abschnitten dargestellt.
  
-**5.** section is giving tips for doing the teamworkThe section illustrates how to present the solution developed as a teamwork and how to write the reportThe topics are highlighted and commented which should be included into the team reportThe example project is also introduced to give a pattern for compiling the concise report+**5.** Im fünften Kapitel finden sich Tipps für die gemeinsame Arbeit an ProblemstellungenHier wird illustriert wie man gemeinsam entwickelte Konzepte implementiert sowie präsentiert und wie Berichte verfasst werdenDabei sind jene Themen, welche in einem Teambericht enthalten sein sollen, besonders hervorgehobenWeiterhin wird an dieser Stelle auch ein Beispielprojekt vorgestellt, welches als Muster zum Erstellen eines präzisen Berichts für eigene Projekte dienen soll.
  
-We hope that the book is a assistant for young and senior microcontroller and robotic enthusiast and will bring more people closer to the technology.+Wir hoffen, dass das Buch eine gute Hilfe sowohl für neue als auch für erfahrene Mikrocontroller- und Robotik-Enthusiasten darstellt und vielen Menschen diese Technologie näher bringt.
  
-Snowy and cold TallinnJanuary 2010+Bochumim Sommer 2013
  
-Raivo Sell +Sven Seiler 
-====== Microcontrollers and robotics ======+====== Mikrocontroller und Robotik======
  
-=== Microcontrollers ===+=== Mikrocontroller ===
  
 [{{  :images:general:intel_p8048h.jpg?250|The first microcontroller in the world: Intel 8048}}] [{{  :images:general:intel_p8048h.jpg?250|The first microcontroller in the world: Intel 8048}}]
  
-Microcontroller is basically a computer which is placed on a single integrated circuit chip. It consists of memoryprocessor as well as input-output interfacesMicrocontroller is programmed to run a certain taskwhich meansif there is a need to change or enhance its functionalityone must install a new program on the chipAspects which differentiate microcontrollers from other computers (PC, laptopserver, etc.) are:+Mikrocontroller sind im Wesentlichen Computerwelche auf einen einzelnen Chip mit integriertem Schaltkreis positioniert werden und aus einer Speichereinheiteinem Prozessor sowie Input-Output Schnittstellen bestehenSie werden für eine bestimmte Aufgabe programmiertwas bedeutetdass sobald eine Änderung oder Verbesserung der Aufgabe nötig istein neues Programm auf dem Chip installiert werden mussEigenschaften, welche den Mikrocontroller von anderen Computern (PC, LaptopServer, etc.) unterscheiden sind:
  
-  * All functions are placed on a single chip on a smaller and more compact scale+  * Sämtliche Funktionen sind auf einem einzelnen, kleineren und kompakteren Chip gespeichert
-  * It is programmed to perform certain taskin order to change its functionality new  software must be installed+  * Er wird zur Durchführung einer bestimmte Aufgabe programmiertum die Funktionalität zu ändern muss neue Software installiert werden
-  * It consumes less powerbecause all physical characteristics are smaller and less energy demanding than in PC, laptop or serverUsually the developers of microcontrollers are concentrating on low energy demandso that mobile applications which use batteries can work longer+  * Er verbraucht weniger Stromda alle physischen Komponenten kleiner und energiesparender sind als die eines PC, Laptops oder ServersEntwickler von Mikrocontrollern fokussieren einen geringen Energieverbrauchsodass mobile Anwendungen länger betrieben werden können
-  * Single purpose inputs and outputsMicrocontrollers have so called peripheralswhich establish connection between microcontroller and other microcontrollers or computers (e.g. USB, CAN, UART), helping to understand the processes in the real physical world (e.gswitching actionstemperature measuring, etc. ) and helping to control surroundings (e.gcontrol motortrigger alert etc.)  +  * In- und Outputs, die auf einen bestimmten Zweck ausgelegt sindMikrocontroller besitzen so genannte Peripherie-Schnittstellenwelche Verbindungen zwischen mehreren Mikrocontrollern oder zwischen einem Mikrocontroller und einem Computer (zB. USB, CAN, UART)  ermöglichen sowie dabei helfenreale physikalische Prozesse nachzuvollziehen (zBSchaltvorgängeTemperaturmessungen, etc.) und nicht zuletzt auch die Steuerung von Umgebungen unterstützen (zBMotoren steuern, Alarme auslösen, etc.) 
  
-Microcontrollers can be found in a variety of everyday itemshousehold appliances (e.gmicrowave ovenTV-set), toys (Lego NXT, talking dolls), vehicles (carshoists), etc. Microcontrollers’ wide usage has been possible because they are easy to program and have wide range of functionalityhence is very easy to add new features and upgrade the level of intelligence of the appliance they are in.+Mikrocontroller finden sich in diversen Gegenständen des täglichen Gebrauchsin Haushaltsgeräten (zBMikrowelleFernsehgerät), Spielzeugen (Lego NXT, sprechende Puppen), Beförderungsmitteln (AutoAufzug), etc. Der umfassende Einsatz von Mikrocontrollern ist möglichda sie leicht zu programmieren sind und eine Vielzahl von Funktionen besitzen; folglich können sehr leicht neue Funktionen hinzugefügt sowie das Anwendungsniveau erhöht werden.
  
-=== Robotics === 
  
-Robotics is science which combines technology and knowledge necessary to build robots. Due to fast development of technology the term robot, as an automatic machine that replaces human, is not so clear anymore. Robot is not anymore just humanoid robot, robotic hand at automotive industry’s assembly line, autopilot in aircraft, artificial intelligence built of living neurons or simple cleaning robot, it is also computer software witch completes tasks meant for humans(for example complies reports). It is known that robots are built to replace humans at certain tasks. There are many reasons for this: dangerous working conditions, cheaper production, monotonous work may cause humans to err, new systems are so complex and time critical, that automatic system makes better decisions than human.         +=== Robotik ===
  
-=== Microcontrollers in robotics ===+Robotik ist die Wissenschaft, welche die Technologie und das notwendige Wissen zum Bau von Robotern miteinander kombiniert. Aufgrund des rasanten technologischen Fortschritts ist der Begriff „Roboter“, der als automatisierte Maschine den Menschen ersetzt, nicht mehr klar definiert. Roboter sind nicht länger nur humanoide Roboter, Roboterhände in Fertigunggstraßen, Autopiloten in Flugzeugen, aus lebenden Neuronen bestehende künstliche Intelligenz oder einfache Reinigungsroboter; der Begriff „Roboter“ bezeichnet vielmehr auch Computersoftware, welche für den Menschen gedachte Aufgaben ausführt (z. B. Berichte erstellen). Es ist allseits bekannt, dass Roboter gebaut werden, um den Menschen bei bestimmten Aufgaben zu ersetzen. Eine Vielzahl von Gründen rechtfertigt dieses: gefährliche Arbeitsbedingungen, günstigere Produktion, monotone Arbeit bei der Menschen zu Fehlern neigen, neue Systeme, die so komplex und zeitkritisch sind, dass automatisierte Maschinen diese besser erledigen können als Menschen. 
 +         
  
-Because of the wideness of the robotics, we determinate it as hobby robotics, the systems are not too complex and it is possible to build them alone. Common microcontrollers in hobby robotics are:+=== Mikrocontroller in der Robotik===
  
-  * Atmel AVR microcontrollers (ATmegaATtiny, etc.) +Aufgrund der Weitläufigkeit der Robotikkonzentrieren wir uns in diesem Buch auf die Hobby-RobotikDiese Systeme sind nicht allzu komplex und es ist möglich sie eigenständig zu implementierenHäufig genutzte Mikrocontroller in der Robotik sind:
-  * Microchip Technology PIC microcontrollers (PIC16, PIC24, etc.+
-  * Microcontrollers based on ARM technology.+
  
  
-Quite often third parties have created development boards and environments based on microcontrollers mentioned herein beforeFor example: Arduino (AVR), BASIC Stamp (PIC) and Lego NXT (ARM). Necessaries for developing HomeLab witch are described in this book hereinafter are based on AVR ATmega128 microcontroller. +  * Atmel AVR Mikrocontroller (ATmega, ATtiny, etc.) 
-Question arises from the large amount of microcontrollers and development boards available: how to find the most appropriate? Generally we can classify following four properties: price, physical characteristics, development environment and customer supportNotable physical characteristics are: +  * Microchip Technology PIC Mikrocontroller (PIC16, PIC24, etc.
 +  * Mikrocontroller, die auf der ARM-Technologie basieren.
  
-  * processor operating frequency  - determines chip operating speed + 
-  * program memory capacity – determines the size of the program that can be installed on the chip +Drittanbieter haben sehr häufig Entwicklungsplatinen und Umgebungen gebaut, die auf den zuvor genannten Mikrocontrollern basieren. Zum Beispiel: Arduino (VAR), BASICStamp (PIC) und Lego NXT (ARM). Die zur Entwicklung von HomeLab notwendigen Grundvoraussetzungen, welche in diesem Buch beschrieben werden, basieren auf dem AVR ATmega127 Mikrocontroller. 
-  * data memory capacity – how much data can be processed in the program +Aus der Vielzahl der zur Verfügung stehenden Mikrocontroller und Entwicklungsplatinen gilt es nun, das für den jeweiligen Bedarf am besten geeignete Produkt auszuwählen. Allgemein lassen sich die folgenden 4 Eigenschaften unterscheiden: Preis, technische Merkmale, Entwicklungsumgebung und Kundenbetreuung. Bemerkenswerte technische Merkmale sind: 
-  * number of input/output pins and their function – different pins have different possibilities + 
-  * number of timers – important for pursue time criteria +  * Arbeitsgeschwindigkeit des Prozessors – legt die Arbeitsgeschwindigtkeit des Chips fest 
-  * energy consumption – important for mobile applications+  * Speicherkapazität des Programms – bestimmt die Größe des Programms, das auf dem Chip installiert werden kann 
 +  * Datenspeicherkapazität – gibt die mögliche Datenverarbeitungsmenge des Programms an 
 +  * Anzahl der Input- Output-Schnittstellen sowie deren Funktionen – unterschiedliche Schnittstellen bieten differenzierte Möglichkeiten 
 +  * Anzahl der Timer – wichtig für das Zeitverhalten der Anwendung  
 +  * Energieverbrauch – von großer Bedeutung für mobile Anwendungen
   
  
-Here development environment is PC softwarewitch allows creating and compiling programsuploading programs to the microcontrollers and bridging in the programs during work in order to detect possible faultsHow easy and comfortable it is to do all that becomes decisivebecause during development period of the program it will be the primary working areaAll this leads to the fourth characteristicwitch is customer supportIt is important that receiving help and support for solving possible issues is made as easy as possibleBy considering all four mentioned propertiesit should be possible to find the development board needed   +In diesem Buch verwenden wir PC-Software als Entwicklungsumgebungmit der Programme erstellt und kompiliert und auf die Mikrocontroller geladen werden können sowie Zugriff auf die laufenden Programme hergestellt werden kannum so mögliche Fehler zu entdecken. Da diese Software während der Entwicklungsphase des Programms als primäre Entwicklungsumgebung dient, wird die  einfache und angenehme Arbeitsweise während der Nutzung deutlich. Dies führt schließlich zur vierten Eigenschaft, der Kundenbetreuung. Hier ist es wichtig, dass auf Hilfe und Unterstützung bezüglich diverser Problemstellungen so einfach wie möglich zugegriffen werden kann. Unter Berücksichtigung der vier genannten Merkmale, sollte es schließlich möglich sein, die geeignete Entwicklungsplatine zu finden. 
-====== AVR microcontroller ======+====== Elektronik ====== 
 + 
 +{{:images:book:ohms_law.png?580|}} 
 + 
 +Verschiedene elektronische Schaltkreise werden so häufig in praktischen Beispielen verwendet, dass sie in den folgenden Kapiteln separat beschrieben werdenDa sie das Verständnis der Beispiele sowie den Bau eigener Schaltkreise erleichternist es wichtig sie zu kennen. 
 + 
 +===== Ohm'sches Gesetz ===== 
 + 
 +Das Ohm’sche Gesetz besagt, dass die Stromstärke eines elektrischen Leiters direkt proportional zu der potenziellen Differenz oder Spannung zwischen zwei Punkten sowie umgekehrt proportional zu dem Widerstand zwischen diesen ist, unter der Voraussetzung, dass die Temperatur konstant bleibt. 
 + 
 +Die Gleichung lautet wie folgt: 
 +[{{  :images:electronics:ohms_law:resistor_circuit.png?180|Resistance of the conductor, applied voltage and current through the resistance}}] 
 + 
 +I = U / R 
 + 
 +mit: 
 + 
 +  * I für die Stromstärke [in A] 
 +  * U für die Spannung [in V] 
 +  * R für den elektrische Widerstand [in Ω] 
 + 
 + 
 +Viele weitere, in der Elektronik häufig verwendete Gleichungen sind vom Ohm’schen Gesetz abgeleitet. 
 +===== Spannungsteiler ===== 
 + 
 +Ein Spannungsteiler ist ein elektrischer Schaltkreisder die Eingangsspannung teiltDie Ausgangsspannung ist ein Teil der Eingangsspannung und der Wert ist abhängig vom Verhältnis der Widerstände im SchaltkreisDie Abbildung rechts zeigt ein Beispiel mit zwei Widerständen.   
 + 
 +Die Ausgangsspannung des Schaltkreises wird mit folgender Gleichung berechnet: 
 + 
 + 
 +[{{  :images:electronics:voltage_divider:voltage_divider_schematics.png?180|Schaltplan eines Spannungsteilers}}] 
 + 
 +U<sub>2</sub> = U<sub>1</sub> ⋅ (R<sub>2</sub> / (R<sub>1</sub> + R<sub>2</sub>)) 
 + 
 +mit: 
 + 
 +  * U<sub>1</sub> für die Eingangsspannung 
 +  * U<sub>2</sub> für die Ausgangsspannung 
 +  * R<sub>1</sub> und R<sub>2</sub> für die Widerstände 
 + 
 +Die Gleichung ist vom Ohm'schen Gesetz abgeleitet.  
 + 
 +mit: 
 + 
 +I = U<sub>1</sub> / (R<sub>1</sub> + R<sub>2</sub>
 + 
 +und: 
 + 
 +U<sub>2</sub> = I ⋅ R<sub>2</sub> 
 + 
 +Spannungsteiler werden häufig im Zusammenhang mit Widerstandssensoren (Fotowiderstandtemperaturgesteuerter Widerstand etc.) verwendet, wobei einer der Widerstände durch einen Widerstandssensor ersetzt wird. Dadurch wird die Widerstandsänderung des Sensors einfach in eine Spannungsänderung transformiert, welche kompatibel zu dem analogen Input des Mikrocontrollers ist.  
 +===== Berechnung des LED-Widerstands ===== 
 + 
 +Für den Fall, dass die Betriebsspannung höher ist als die Spannung der LED, muss der Widerstand in Reihe in den Stromkreislauf geschaltet werden. Er begrenzt die Spannung und erzeugt dadurch den notwendigen Spannungsabfall. Um den korrekten Widerstand auszuwählen, wird folgende, vom Ohm’schen Gesetz abgeleitete, Gleichung angewandt: 
 + 
 + 
 +[{{  :images:electronics:led_resistor:led_resistor_schematics.png?180|LED mit in Serie geschaltetem Widerstand}}] 
 + 
 +R = (U<sub>in</sub> - U<sub>f</sub>) / I<sub>f</sub>\\ 
 +U<sub>r</sub> = U<sub>in</sub> - U<sub>f</sub>\\ 
 +P<sub>r</sub> = U<sub>r</sub> ⋅ I<sub>f</sub>\\ 
 + 
 +mit: 
 + 
 +  * R für den Widerstand. 
 +  * U<sub>in</sub> für die Betriebsspannung. 
 +  * U<sub>f</sub> für die LED Spannung. 
 +  * I<sub>f</sub> für die LED Stromstärke. 
 +  * U<sub>r</sub> für den Spannungsabfall am Widerstand. 
 +  * P<sub>r</sub> für die Leistung des Widerstands, welche in Wärme umgewandelt wird. 
 + 
 +Der spannungsbegrenzende Widerstand einer LED darf nicht geringer sein als R und muss mindestens die Leistung von P<sub>r</sub> haben. 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +====== AVR Mikrocontroller ======
  
 {{:images:book:avr.jpg?580|}} {{:images:book:avr.jpg?580|}}
  
-The following chapters introduce the AVR microcontrollerwhich this book is based onIn spite of being so smalla microcontroller is full of features that have been documented by Atmel in a manual almost 400 pages longBesides thatthere are a lot of additional specific documentsAll that information has been compressed to a fast and simple overview of the subjectwhich helps a beginner to understand better the AVR and learn to read its datasheet.+Das folgende Kapitel stellt den AVR Mikrocontroller vorauf welchem dieses Buch basiertTrotz seiner geringen Größe besitzt der Mikrocontroller eine Vielzahl von Funktionenwelche von Atmel in einem fast 400 Seiten umfassenden Handbuch dokumentiert wurdenDarüber hinaus gibt es noch einige weitere Dokumentedie sich mit der Thematik befassenSämtliche Informationen werden in dem folgenden Abschnitt in komprimierter Form dargestelltum dem Leser so einen schnellen und einfachen Überblick über das Thema zu geben. Zugleich dient diese Übersicht dazu, ungeübten Nutzern das Verständnis des AVR Mikrocontrollers näher zu bringen und zeigt ihnen, wie das Datenblatt zu lesen ist
  
-===== Introduction =====+===== Einführung =====
  
 [{{  :images:avr:avr_atmega128_smd.jpg?182|ATmega128 in SMT package (TQFP64, to be precise)}}] [{{  :images:avr:avr_atmega128_smd.jpg?182|ATmega128 in SMT package (TQFP64, to be precise)}}]
  
-AVR is a series of 8-bit RISC microcontrollers produced by Atmel. AVR follows Harcard architecture and therefore has separate program and data memoryFor the program it has an internally overwriteable flash memoryfor data there are static (SRAM) and EEPROM memoryController's frequency is usually up to 16 MHz and performance is almost 1 MIPS per a 1-megahertz cycle.+AVR ist eine Serie aus 8-bit RISC Microcontroller produziert von Atmel. AVR folgt der Harcard-Architektur und hat daher separate Programm- und DatenspeicherFür das Programm hat er einen internen überschreibbaren Flash-Speicherfür statische Daten (SRAM) und EEPROM-SpeicherDie Taktfrequenz des Controllers liegt normalerweise bei 16MHz und schafft fast 1 MIPS pro 1MHz-Zyklus.
  
-The production of AVR microcontrollers began in 1997 and by now AVR is one of the most popular controller with freelance electronic engineersThanks to cheap developing toolsthe diversity of peripherals in a single package and low power consumption came the initial successToday, there is another reason for choosing AVR: the massive amount of information and tutorials built up over the yearsThe AVR technology is inevitably agingbut to stay in the competition Atmel is also making new AVR microcontrollers with more up-to-date peripherals and 16- and 32-bit busesfirst of which are from the 8-bit compatible XMega series and the latter from the brand new AVR32 series.+Die Produktion des AVR Microcontroller begann 1997 und heute ist AVR einer der am beliebtesten Controller der freischaffenden Elektronik-IngenieureDank der günstigen Entwicklungstoolsder diversen Peripherals in einem Paket und des niedrigen Energiebedarfs kam der anfängliche ErfolgHeute gibt es noch einen anderen Grund sich für den AVR zu entscheidendie Masse an Information und an Tutorials die sich über die Jahre angesammelt habenDie AVR Technologie altert natürlichaber um konkurrenzfähig zu bleiben stellt Atmel neue AVR Microcontroller her, mit up-to-date peripherals und 16- und 32-bit BusErste aus der 8-bit kompatiblem XMega Serie und Letztere aus der neuen AVR32 Serie.
  
-Based on the type of the applicationthere are several types of AVR microcontrollerseach with a different configurationMost of the AVRs belong to the megaAVR serieswhich have a large program memoryTo balance the megaAVR series, there is also the tinyAVR serieswhich have smaller packages and less featuresIn addition to those, there are also different series of microcontrollers designed specifically for controlling USB, CAN, LCD, ZigBee, automatics, lighting and battery-powered devices.+Basierend auf den Typ der Anwendunggibt es unterschiedliche Typen von AVR Microcontrollerjeder mit einer unterschiedlichen KonfigurationDie meisten der AVRs gehören zur megaAVR Seriesie haben einen großen Programm-SpeicherAls Gegenstück gibt es die tinyAVR Seriemit weniger FunktionenZusätzlich gibt es noch unterschiedliche Microcontroller Serien  speziell zum Kontrollieren von USB, CAN, LCD, ZigBee, automatics, Beleuchtung und batteriebetriebene Geräte
  
-The following text describes the main features of megaAVR series microcontrollersusing one of the most popular controllers in this series, ATmega128 as an exampleThis controller is also in the HomeLab kitGenerally, all the AVR series microcontrollers' register namesmeanings and usage is reglemented in a way which able the examples also to be used with other controllers by making only slight changesThe main differences are in the peripheralsThe code samples of this introduction are written in assembler and C, using AVR LibC.+Der folgende Text beschreibt die Hauptfeatures der megaAVR Serie Microcontrolleram Beispiel des beliebtesten Controller dieser Seriedes ATmega128. Dieser Controller ist auch im HomeLab-Kit enthaltenGenerell alle AVR Microcontroller RegisternamenBedeutungen und Benutzungen sind in einer Weise geregelt , welche es möglich macht Beispiele auch mit anderen Controller zu nutzen, in dem man nur kleine Änderungen durchführt. 
 +Der Hautunterschied liegt in den Peripherals. 
 +Die Codebeispiele dieser Einführung sind mit AVR LibC in Assembler und geschrieben 
  
-=== Physical appearance ===+ 
 +=== äußerer Aufbau ===
  
 [{{:images:avr:avr_atmega32_dip.jpg?200  |ATmega32 in 40-pin DIP casing}}] [{{:images:avr:avr_atmega32_dip.jpg?200  |ATmega32 in 40-pin DIP casing}}]
  
-Like all other controllers, the AVR is also packaged in some standard shellThe traditional casing is DIP (also called DIL). DIP is a so-called casing on legs all the pins extrude as legsabout 5 mm in lengthfrom the black plastic casing. DIP casing is a sensible choice for hobby applications and prototypesbecause there are cheap sockets available for it, so the microcontroller can easily be replaced, should it happen to malfunction or dieThe legs are also the down-side of the DIP casingbecause it requires holes to be drilled in the circuit board.+Wie alle anderen Controller ist der AVR in einer Standarthülle gepacktDas traditionelle Gehäuse ist DIP (bzw. DIL). DIP ist eine so genannte Casing-On-Legs. Alle Pins treten wie Beine ca 5mm in Längeaus dem schwarzen Plastikgehäuse hervor. 
 +DIP Gehäuse sind eine gute Wahl für Hobbyanwendungen und Prototypenweil es dafür günstige Sockets gibtDaher kann der Microcontroller einfach ersetzt werden sollte er Ausfallen. Die Beine sind aber auch der Nachteil des DIP Gehäusesda man dafür Löcher in die Platine bohren muss.
  
-The surface mount casings (SMT, also called SMD) are much more compactbecause their pins are designed to be soldered straight to the board without the need to penetrate it. SMT microchips are in thincoin-sized rectangular casings with pins about mm longA more precise hand and better tools are required for soldering SMT chips.+Die Surface-Mount-Casings (SMT, bzw. SMD) sind viel kompakterweil die Pins dafür gedacht sind direkt auf die Platine gelötet zu werden ohne zu BohrenAMT Microchips sind dünne münzen-große rechteckige Gehäuse mit Pins von ca. 1mm Länge.  
 +Eine ruhigere Hand und präzisere Werkzeuge werden zum löten von SMT Chips benötigt. 
 + 
 + 
 +AVRs gibt es als DIP und SMT Gehäuse. Das Layout der Pins ist vom Design her so logisch und elektronisch ausgeglichen wie es nur möglich ist. Zum Beispiel sind bei größeren Chips die Ground- und Supply-Pins auf mehreren Seiten des Microcontrollersdie Pins für einen Externen Oszillator sind nahe des Ground-Pins, die Bus-Pins sind durchnummeriert, die Communication-Pins sind nebeneinander etc. AVRs digitale Pins sind kompatibel mit TTL/CMOS Voltwerten. Bei 5V Supply-Spannung, 0 bis V sind Logische Null (Zero), auch  Zero, Null,  0 Low, Ground oder GND genanntBei Gleicher Supply-Spannung, 2 bis 5.5V sind die logische Eins, auch one, 1, high, genannt. Dieses Typ von weiten Spannungsunterschieden gibt es nur im Input, die Outputspannung an einem Pin mit keinem Load ist immer noch 0 V oder nahe der Supply-Spannung, je nach Status des Pins. 
 +Die erlaubte Analogspannung an den ADC Kanälen ist 0-5.5V
  
-AVRs are available in both DIP and SMT casings. The layout of the pins is designed as logical and electrically even as possible. For example, on larger chips, the ground and supply pins are located on several sides of the microcontroller, the pins for an external oscillator are near the ground pin, the bus pins are in numerical order, the communication pins are next to each other etc. AVRs digital pins are compatible with TTL/CMOS standard voltage levels. At 5 V supply voltage, 0 to 1 V means logical zero, which is also called zero, null, 0, low, ground, or GND. At the same supply voltage, 3 to 5.5 V means logical one, also called one, 1, high. This type of wide voltage ranges only apply to the inputs - the output voltage on a pin with no load is still 0 V or near supply voltage, depending on the state of the pin. The allowed analog voltage level on the ADC channels is 0 to 5.5 V. 
  
 == ATmega128 == == ATmega128 ==
  
-To better understand the following examples on ATmega128there is a pinout schematic of ATmega128 (SMT packagebelowNext to each pinis a text with its number, primary function and secondary (alternatefunction in brackets. Supply pins are GND and VCC. AVCC and AREF are analog-to-digital converter's supply and reference voltage pins. XTAL1 and XTAL2 are for connecting an external crystal oscillatorresonator or clock generator. Pins PB0 to PG4 mark the bits of input-output busesThe secondary functions of pins are discussed in the corresponding chapters.+Um die folgenden Beispiele am ATmega 128 besser zu verstehengibt es am Ende des Textes ein Pinout-Schema des ATmega128 (SMT Package). 
 +An jedem Pin ist ein Text mit der Nummerprimären Funktion und sekundären (alternativenFunktion in Klammen. Supply Pins sind GND und VCC. 
 +AVCC und AREG sind die analog zu digital Konverter Supplyund ReferenceVoltage-Pins. 
 +XTAL1 und XTAL2 sind für den Anschluss einen externen SchwingquarzesResonator oder TaktgebersDie Pins PB0 bis PG4 markieren die Bits der Input-Output BusesDie sekundären Funktionen werden in dem entsprechenden Kapitel besprochen. 
  
 [{{  :images:avr:avr_atmega128_pinout.png?420  |ATmega128 pinout}}] [{{  :images:avr:avr_atmega128_pinout.png?420  |ATmega128 pinout}}]
-===== Registers =====+===== Register =====
  
-One of the toughest things for beginners to understand in a microcontroller is typically a register. When dealing with microcontrollersit is impossible to get by without knowing what it isThis book is in no way differentas the reader is also expected to familiarize him/herself with the concept of a register and therefore the following text will try to explain it in simple enough termsso that even a beginner can grasp the idea of a register.+Typischerweise ist das Register eines der Bestandteile eines Mikrocontrollersdie ein Anfänger nur mühsam verstehtIm  Umgang mit Mikrocontrollern ist es jedoch unumgänglich diese Komponente zu kennen. Auch für die weitere Arbeit mit diesem Buch ist der Leser dazu angehaltensich das Konzept des Registers anzueignen. Daher wird es im nun folgenden Text auf eine möglichst verständliche Weise erklärtsodass auch ein Anfänger ein Gespür für das Register bekommt
  
 === Essence === === Essence ===
  
-[{{  :images:logic:tape_buttons.jpg?240|Tape player's buttons}}]+[{{  :images:logic:tape_buttons.jpg?240|Tasten eines Kassettenrekorders}}]
  
-A register is like a panel of buttons on a home applianceIt has switcheswhich can be turned on or offOne of the best examples is a simple tape playerFor thosewho don't remember, the tape player has (had) buttons, left to right:+Ein Register ähnelt einem Panel von Tasten eines HaushaltsgerätesEs verfügt über Schalterdie ein- und ausgeschaltet werden könnenDas beste Beispiel hierfür ist ein KassettenrekorderZur Erinnerungein Kassettenrekorder verfügt über Tasten von links nach rechts:
  
-  Record + 
-  * Rewind +  Aufnahme 
-  * Play +  * Zurückspulen 
-  * Fast forward +  * Abspielen 
-  * Stop+  * Vorspulen 
 +  * Stopp
   * Pause   * Pause
  
-Each button does somethingbut only when it is used correctlyFor examplethe stop button does nothing unless a tape is playing only then will it do something apparent and stop the playbackForward and rewind buttonson the other handcan be pressed at any timebecause the tape can be wound in both directionsno matter if it is playing or stoppedThe recording begins only when the play and record buttons are pressed down simultaneously. Some may have tried to depress several or all buttons at once - in this casethe tape player might have done something unexpected or break altogether.+Jede Taste führt eine Funktion ausjedoch nur wenn sie auch korrekt verwendet wirdSo macht die Stopp-Taste solange nichtsbis die Kassette abgespielt wird. Erst dann kann die Funktion ausgeführt werden und die Wiedergabe wird gestoppt. Dagegen können Vorlaufund Rückspultasten zu jeder Zeit betätigt werden, denn die Kassette kann in beide Richtungen gespult werden, unabhängig davon ob sie gerade abgespielt wird oder nichtDie Aufnahmetaste startet nur dann eine Aufnahmewenn sowohl die Abspielen- als auch die Aufnahmetaste zeitgleich gedrückt werden. Eventuell hat mancher einmal versuchtmehrere oder alle Tasten auf einmal zu betätigen. Dieses hat vermutlich eine unerwartete Funktion des Kassettenrekorders ausgelöst oder ihn sogar beschädigt.   
 + 
 +Die Register von Mikrocontrollern verhalten sich wie Tasten eines Kassettenrekorders – jede Taste führt eine Funktion auswenn sie korrekt verwendet wird. Werden die falschen Tasten betätigt, wird der Mikrocontroller in der Regel nicht direkt beschädigtaber er wird nicht funktionierenTatsächlich gibt es keine Tasten im Register sondern stattdessen eine Vielzahl von Transistoren, welche die Stromversorgung einund ausschalten. Einfachere Mikrocontroller haben 8 transistorbasierte Schalter in einem einzigen Register. Unter einem Register kann man sich eine 8-Bit Zahlenfolge vorstellen, wobei jedes Bit durch den Status eines dieser Schalter gekennzeichnet wird. Zum Beispiel kann ein Bit-Wert von 1 bedeuten, dass der Schalter an ist, ein Wert von 0 hieße danndass er aus ist.
  
-Microcontroller registers behave like buttons on a tape player - each button does something, when used correctly. By pressing the wrong buttons, a microcontroller usually won't break, but it won't work either. In reality, there are no buttons in the registers, instead there are a whole lot of transistors, which turn the electricity on and off. Simpler microcontrollers have 8 transistor-based switches in a single register. A register can be thought of as an 8-bit number, where every bit is marked by the state of one of those switches. For example, a bit value of 1 can mean that the switch is on and 0 that the switch is off.+[{{  :images:logic:register_buttons_and_bits.png?240|"Tasten" des Registers und Bitwerte}}]
  
-[{{  :images:logic:register_buttons_and_bits.png?240|Register's "buttons" and bit values}}]+Da der Status eines Registerschalters einfach durch eine Nummer abgebildet werden kann, lässt sich ein Register mit einem Speicher vergleichen, der Daten in Form genau einer Zahl speichern kannDurch diesen Vergleich wird deutlich, dass Register tatsächlich Speicherslots sind. Der Unterschied zwischen einem Register und einem Speicherslot besteht darin, dass letzterer lediglich Informationen speichert, während die Informationen in einem Register tatsächlich etwas steuern. So sorgt zum Beispiel der Binärwert 01100001 in einem Register dafür, dass drei imaginäre Tasten betätigt werden wodurch eine Funktion ausgelöst wird.
  
-Since the state of a register's switches can easily be displayed as a number and vice versa, a register can be compared to a memory, which can hold data in the size of one number. By this comparison, we see that registers actually are memory slots. The difference between a register and a memory slot is that a memory slot only stores the information, but in a register this information actually controls something. For example, if a binary value of 01100001 is written to a register, then three imaginary buttons are pressed down and something happens. 
  
-On a tape player it is possible to press each button separatelybut in a register it is more difficult to change the value of one "switch" or bitTypically it is necessary to change the entire content of the registerBefore moving on to bit changingone should know that there are a lot of registers in a microcontrollerSome parts of the microcontroller use tens of registers to control them. The variety of registers means that there has to be a way to distinguish between different registers and that is done by naming the registers. One registerfor exampleis called PORTB. Actuallythese names are just to make things easier for the developer and each name corresponds to a numeric address.+Während es bei einem Kassettenrekorder möglich istjeden Knopf einzeln zu betätigen, ergeben sich bei einem Register Schwierigkeiten, wenn nur der Wert eines Schalters oder Bits geändert werden sollHier ist es gewöhnlich notwendig, den gesamten Inhalt der Registers zu ändernBevor jedoch detaillierter auf die Thematik der Bit-Veränderung eingegangen wirdmuss zunächst klargestellt werden, dass ein Mikrocontroller mehrere Register enthältDie Vielzahl der Register führt dazu, dass diese voneinander unterscheidbar gemacht werden müssenwas durch Kennzeichnung mit einem Namen geschiehtwie zum Beispiel „PORTBHierdurch wird dem Entwickler die Arbeit erleichtertda jedem Namen auch eine eigene numerische Adresse zugewiesen wird.
  
-=== Usage ===+=== Gebrauch ===
  
-To write to a register or read a value from itit has to be addressed as a variable in C. The following example demonstrates writing a binary value to an imaginary register REG and then reading it to variable //reg//Binary values are distinguished by 0b (leading zero), so that the compiler understands the numeric system.+Zur Programmierung eines Registers oder auch dazuum Werte aus diesem abzulesen muss er als Variable in C deklariert werdenDas folgende Beispiel veranschaulicht, wie ein Binärwert einem imaginären Register REG zugewiesen wird und dann in der Variable //reg// abgelegt wirdBinärwerte werden an einem vorangestellten 0b (leading zero) erkanntsodass der Compiler das binäre Zahlensystem erkennt.
  
 <code c> <code c>
Line 135: Line 232:
 </code> </code>
  
-There is nothing difficult in writing and reading register valuesbut it gets a little tricky if only a single bit needs to be changed. To change bitsone needs to know how to do binary math and use different numeric systemsIt isn't forbidden to deal only with binary numbersbut they can be a bit troublesome, because binary numbers are quite longand this is why most people use shorter hexadecimal numbers.+Die Schwierigkeit liegt nicht darinRegisterwerte zu schreiben und auszulesensondern vielmehr darin, ein einzelnes Bit zu verändernHierzu sind Kenntnisse der Binärmathematik sowie im Gebrauch diverser Zahlensysteme notwendig. Es ist auch möglichnur mit Binärzahlen zu arbeiten. Da diese aufgrund ihrer Länge die Programmierarbeit jedoch erschweren könnenverwenden die meisten Programmierer die kürzeren Hexadezimalzahlen.
  
-[{{  :images:logic:logic_hexadecimal.png?209|Hexadecimal numbers}}]+[{{  :images:logic:logic_hexadecimal.png?209|Hexadezimalzahlen}}]
  
-In hexadecimal, the numbers are not only and as in binary or to as in decimalbut instead to F. A hexadecimal number consists of four bitsThe table on the right shows the binary numbers and their hexadecimal counterpartsBinary numbers are converted to hexadecimal by reading bits four at a timestarting from the lowest rankRanks are read from right to left and their numbers start from 0. For example, the lowest ranked (rank 0) bit is and the highest (rank 3) is 1. In the previous example, the register's binary value is 01100001, which is 61 in hexadecimal and is written as 0x61 (leading zero) in C.+Im Hexadezimalsystem gibt es nicht nur die Ziffern und wie im binären System oder bis gemäß dem Dezimalsystemsondern stattdessen bis F. Eine Hexadezimalzahl besteht aus vier BitsDie Abbildung auf der rechten Seite veranschaulicht die Binärzahlen und deren zugehörige HexadezimalwerteBinärzahlen werden in Hexadezimalzahlen umgewandelt indem vier Bits zugleich, beginnend bei dem niedrigstengelesen werdenDie Bitfolge wird von links nach rechts gelesen und startet bei 0. So ist zum Beispiel das niederwertigste Bit (an Stelle 0) 0 und das mit dem höchsten Wert (an Stelle 3) 1. Im vorangehenden Beispiel ist der Binärwert der Registers 01100001, der im Hexadezimalsystem 61 entspricht und in C als 0x61 (leading zero) geschrieben wird.
  
-To change single bits in a number (registervariable or anywhere else for that matterit is necessary to use binary operationsBinary operation is an operation between two binary numberswhere each bit of the numbers is subject to its own logical operationTypically a microcontroller supports four binary operations, each having several namesThe following section describes the logical operation behind each of these four binary operations with a single bit or multpile bits.+Um einzelne Bits innerhalb einer Zahl zu verändern (RegisterVariable oder ähnlichesmüssen Binäroperationen angewandt werdenBinäroperationen sind Vorgänge zwischen zwei Binärzahlenwobei jedes Bit der Zahlen durch eine eigene logische Operation abgebildet wirdMikrocontroller unterstützen generell vier unterschiedliche BinäroperationenDer folgende Abschnitt beschreibt die logische Operation hinter diesen vier Binäroperationen mit einzelnen sowie mehreren Bits
  
-[{{  :images:logic:logic_all_4.png?550  |Negation, logical multiplicationlogical addition and exclusive disjunction }}]+[{{  :images:logic:logic_all_4.png?550  |Negation, logische Multiplikationlogische Addition und exklusive Disjunktion }}]
  
-~~PB~~+<pagebreak>
  
-  * **Negation / Inversion** \\ Negation changes the bit's value to its opposite, a becomes a and vice versa. In C, negation is marked with "~"+  * **Negation / Inversion** \\ Eine Negation kehrt den Wert eines Bits in das jeweilige Gegenteil um. So wird aus einer eine und umgekehrt. In C wird eine Negation durch "~" vorgenommen
-  * **Logical multiplication Conjunction** \\ When multiplying two bitsthe answer is if both bits are 1 and in any other case 0. In C, logical multiplication is marked with "&"+  * **Logische Multiplikation Konjunktion** \\ Bei der Multiplikation zweier Bits ist das Ergebnis 1 für den Falldass beide Bits den Wert besitzen, ansonsten 0. Eine Logische Multiplikation wird in durch "&" dargestellt
-  * **Logical addition Disjunction** \\ When adding two bits, the answer is if at least one of the bits is and if both bits are 0. In C, logical addition is marked with "|"+  * **Logische Addition Disjunktion** \\ Eine Addition von zwei Bits ergibt wenn zumindest eines der Bits den Wert hat und wenn beide Bits den Wert haben. In C kennzeichnet "|" die Logische Addition
-  * **Exclusive disjunction Exclusive OR / XOR** \\ Exclusive OR operation will return if the two bits differ from each other (one is and the other 0), otherwise the answer is 0. In C, exclusive disjunction is marked with "^".+  * **Exklusive Disjunktion Exklusives ODER / XOR** \\ Das Ergebnis einer Exklusiven ODER Operation ist bei zwei unterschiedlichen Bits (also wenn ein Bit den Wert besitzt, das andere den Wert 0), ansonsten 0. Eine Exklusive Disjunktion wird in durch "^" dargestellt.
  
-This is all one needs to know to change single bits. The theory alone is probably not enoughthoughand that is why there are some typical examples with registers in the next few paragraphs.+Man benötigt nicht mehr als diese vier Operationenum einzelne Bits zu ändern. Da die Theorie allein vermutlich nicht ausreichen magenthalten die folgenden Abschnitte einige Anwendungsbeispiele.
  
 ~~CL~~ ~~CL~~
  
-== Setting a single bit high ==+== Ein einzelnes Bit "high" setzen ==
  
-[{{  :images:logic:op_bit_set.png?230|Setting a single bit high}}]+[{{  :images:logic:op_bit_set.png?230|Ein einzelnes Bit "high" setzen}}]
  
-To set one or more bits in a register high (1) a logical addition operation is neededOne of the operands of the operation must be the register and the other a binary numberwhere the only high bit is the one that needs to be set high in the registerThis binary number is called a bitmaskBelow is the code for the operation shown on the right:+Um einzelne oder mehrere Bits in einem Register “high” zu setzen (1) muss eine logische Addition durchgeführt werdenHierfür muss ein Operand das Register sein und ein anderer die Binärzahlwobei das einzige „high“ Bit jenes ist, was ein einem Register „high“ gesetzt werden mussDiese Binärzahl wird Bitmaske genanntNachfolgend ist der C-Code für diese Operation abgebildet:
  
 ~~CL~~ ~~CL~~
  
 <code c> <code c>
-  // Let's suppose REG = 0x0F +  // Annahme REG = 0x0F 
-  REG = REG | 0x11; // First method +  REG = REG | 0x11; // Erste Methode 
-  REG |= 0x11;      // Second method +  REG |= 0x11;      // Zweite Methode 
-  // Now REG = 0x1F+  // Ergebnis REG = 0x1F
 </code> </code>
  
-== Setting a single bit low ==+== Ein einzelnes Bit “low” setzen ==
  
-[{{  :images:logic:op_bit_clear.png?229|Setting a single bit low}}]+[{{  :images:logic:op_bit_clear.png?229|Ein einzelnes Bit “low” setzen}}]
  
-To set one or more bits in a register low (0) a logical multiplication operation is neededOne operand of the operation must be the register and the other a bitmask, in which the only low bit is the one that needs to be set low in the registerBelow is the C code for the operation shown on the right:+Um einzelne oder mehrere Bits in einem Register “low“ zu setzen (0) ist eine logische Multiplikation nötigDabei muss ein Operand das Register und ein weiterer eine Bitmaske sein, in welcher das einzige low-Bit jenes ist, welches im Register „low“ gesetzt werden soll.
  
 ~~CL~~ ~~CL~~
  
 <code c> <code c>
-  // Let's suppose REG = 0x0F +  // Annahme REG = 0x0F 
-  REG = REG & 0xFE; // First method +  REG = REG & 0xFE; // Erste Methode 
-  REG &= 0xFE;      // Second method +  REG &= 0xFE;      // Zweite Methode 
-  // Now REG = 0x0E+  // Ergebnis REG = 0x0E
 </code> </code>
  
-~~PB~~+<pagebreak>
  
-== Inverting a single bit ==+== Ein einzelnes Bit invertieren / umkehren ==
  
-[{{  :images:logic:op_bit_invert.png?229|Inverting a single bit}}]+[{{  :images:logic:op_bit_invert.png?229|in einzelnes Bit invertieren}}]
  
-To invert one or more bits in a register an exclusive disjunction operation is requiredOne of the operands of the operation must be the register and the other a bitmaskwhere the only high bit is the one that needs to be inverted in the registerBelow is the code for the operation shown on the right:+Zum Invertieren einzelner oder mehrerer Bits eines Registers muss eine Exklusive Disjunktion angewandt werdenHierzu ist ein Operand das Register, der andere muss eine Bitmaske sein, in der das einzige high Bit jenes ist, welches invertiert werden sollDer C-Code für diese Operation ist unten abgebildet:
  
 ~~CL~~ ~~CL~~
  
 <code c> <code c>
-  // Let's suppose REG = 0x0F +  // Annahme REG = 0x0F 
-  REG = REG ^ 0x11; // First method +  REG = REG ^ 0x11; // Erste Methode 
-  REG ^= 0x11;      // Second method (use only one per inversion+  REG ^= 0x11;      // Zweite Methode (nur eine pro Inversion verwenden
-  // Now REG = 0x1E+  // Ergebnis REG = 0x1E
 </code> </code>
  
-== Inverting the whole register ==+== Das gesamte Register invertieren ==
  
-[{{  :images:logic:op_reg_invert.png?229|Inverting all bits}}]+[{{  :images:logic:op_reg_invert.png?229|Invertieren aller Bits}}] 
 + 
 +Durch die Negationsoperation werden sämtliche Bits eines Register invertiert. Diese Operation besteht aus nur einen Operanden und ist daher unär. Der hierfür benötigte C-Code ist unten abgebildet:
  
-To invert all bits in a register a negation operation is used. This operation is unary, which means it has only one operand. Below is the C code for the operation shown on the right: 
  
 ~~CL~~ ~~CL~~
  
 <code c> <code c>
-  // Let's suppose REG = 0x0F+  // Annahme REG = 0x0F
   REG = ~REG;   REG = ~REG;
-  // Now REG = 0xF0+  // Ergebnis REG = 0xF0
 </code> </code>
  
-== Reading the value of a single bit ==+== Den Wert eines einzelnen Bits auslesen == 
 + 
 +[{{  :images:logic:op_bit_get.png?229|Den Wert eines Bits auslesen}}]
  
-[{{  :images:logic:op_bit_get.png?229|Reading the value of a bit}}]+Sollen ein oder mehrere Bits aus einem Register gelesen werden muss ebenfalls die logische Multiplikation angewandt werden. Einer der Operanden ist das Register, der zweite eine Bitmaske, in welcher das einzige high-Bit jenes ist, welches aus dem Register gelesen werden soll. Unten ist der C-Code für diesen Vorgang dargestellt.
  
-To read one or more bits from a register the same operation is required as was used for setting a bit low - logical multiplication. One of the operands of the operation must be the register and the other a bitmask, where the only high bit is the one that needs to be read from the register. Below is the C code for the operation shown on the right: 
  
 ~~CL~~ ~~CL~~
  
 <code c> <code c>
-  // Let's suppose REG = 0x0F+  // Annahme REG = 0x0F
   unsigned char x = REG & 0x01;   unsigned char x = REG & 0x01;
-  // Now x = 0x01+  // Ergebnis x = 0x01
 </code> </code>
  
-~~PB~~+<pagebreak>
  
-== Shifting a bit ==+== Ein Bit verschieben ==
  
-Many programming languages actually have a few additional bitwise operationswhich make it easier for the programmersThese are bit shifting operations that shift bits left or right in a binary numberThe main value of shift operations in dealing with registers is their ability to convert bit ranks to bitmasks and vice versa.+Viele Programmiersprachen verfügen mittlerweile über einige zusätzliche Bitoperationenwas die Programmierarbeit erleichtertHierzu gehören die Operationen, welche die Bits einer Binärzahl nach rechts oder links verschiebenIm Umgang mit Registern liegt der größte Vorteil dieser Operationen darin, dass Bitfolgen zu Bitmasken konvertiert werden können und umgekehrt.
  
-[{{  :images:logic:op_bit_shift_left.png?241|Shift left}}]+[{{  :images:logic:op_bit_shift_left.png?241|Linksshift}}]
  
-The image on the right shows a shift left operationAlthough bit shifting is not a logical operation and has no corresponding symbol, in C it is marked as "<<"Shift left is used to transform a bit rank to a bitmaskFor example, to get the mask for the 6th bit (NB! rank 5), number 1 has to be shifted left 5 timesThe example operation looks like this in C:+Das Bild auf der rechten Seite zeigt einen LinksshiftAuch wenn ein Bitshift keine logische Operation darstellt und kein zugehöriges Symbol hatwird diese Operation in C mit "<<" gekennzeichnetEine Linksshiftoperation wird genutzt, um eine Bitfolge in eine Bitmaske umzuwandelnUm beispielsweise die Maske für das sechste Bit (Rang 5) zu erhaltenmuss das erste Bit um fünf Stellen nach links verschoben werdenIn wird diese Operation wie folgt geschrieben:
  
 ~~CL~~ ~~CL~~
Line 245: Line 344:
 <code c> <code c>
 REG = 0x01 << 5; REG = 0x01 << 5;
-// Now REG = 0x20+// Ergebnis REG = 0x20
 </code> </code>
  
-[{{  :images:logic:op_bit_shift_right.png?241|Shift right}}]+[{{  :images:logic:op_bit_shift_right.png?241|Rechtsshift}}]
  
-Shift right operation works similarly to shift left operation. It is marked as ">>" in CRight shift is used to get the logical value of a bit from a bitmaskA leading example showed how to read the value of a single bitLet's suppose the bit to read is not of the lowest rankbut for example of rank 5. In this casethe result would be either 0x20 or 0x00, but sometimes a result of or is needed and that is when the right shift comes to the rescueThe example operation on the right looks like this in C:+Der Rechtsshift funktioniert auf die gleiche Weise und wird in C durch  ">>" dargestelltRechtsshiftoperationen dienen dazu, den logischen Wert eines Bits aus der Bitmaske zu erhaltenAn einem vorherigen Beispiel wurde bereits gezeigt, wie der Wert eines einzelnen Bits gelesen werden konnteIst dieses Bit nun nicht das niederwertigstesondern zum Beispiel eines mit dem Rang 5, wäre das Ergebnis entweder 0x20 oder 0x00. Allerdings wird manchmal ein Ergebnis von oder benötigt und genau hier kommt die Rechtsshiftoperation zur AnwendungDer Rechtsshift aus dem Beispiel rechts sieht in C folgendermaßen aus:
  
 ~~CL~~ ~~CL~~
  
 <code c> <code c>
-// Let's suppose REG = 0x20+// Annahme REG = 0x20
 unsigned char x = REG >> 5; unsigned char x = REG >> 5;
-// Now x = 0x01 (or simply 1)+// Ergebnis x = 0x01 (or simply 1)
 </code> </code>
  
-If a bit is shifted right from the lowest rank or left from the highest rank by the bit shifting operationit disappearsSome programming languages also have rotating bit shift operationswhere the bit doesn't disappearbut moves from the lowest rank to the highest or vice versa. C doesn't have that kind of bit shift operationsbut they can be written by the programmer if needed.+Wird durch diese Operationen ein Bit vom niedrigsten Rang nach rechts oder vom höchsten Rang nach links verschobenverschwindet esEinige Programmiersprachen verfügen jedoch über rotierende Bitshiftoperationenbei denen ein Bit nicht verschwindetsondern vom niedrigsten zum höchsten Rang wandert oder umgekehrtIn gibt es diese Operationen nichtsie können jedoch bei Bedarf vom Programmierer selbst geschrieben werden.
  
-All bit operations work with not only registersbut with variables and constants as wellThe latter can of course only be used as operands and not the result.+Sämtliche Bitoperationen sind nicht nur mit Registern durchführbarsondern auch mit Variablen und KonstantenLetztere können jedoch ausschließlich als Operanden, nicht als Ergebnis genutzt werden.
  
-=== AVR registers ===+=== AVR Register ===
  
-To do anything actual with the microcontroller's registersone needs to know how to use that particular microcontrollerEach microcontroller comes with one or several datasheetswhich describe the whole structure and functionality or the microcontrollerThe datasheet also describes the registersThe following will help understand the register descriptions in AVR datasheets.+Um tatsächlich mit dem Register eines Mikrocontrollers zu arbeitenist es notwendig zu wissen, wie dieser spezielle Mikrocontroller verwendet wirdZu jedem Mikrocontroller gibt es ein oder mehrere Datenblätterwelche seine Struktur und Funktionalität beschreibenDieses Datenblatt enthält auch Informationen über die RegisterDer folgende Abschnitt dient dazu, die Registerbeschreibungen der AVR Datenblätter zu verstehen.
  
-[{{  :images:logic:avr_example_register.png?580  |One of AVRs registers from its datasheet}}]+[{{  :images:logic:avr_example_register.png?580  |Eines der AVR Register, Datenblattansicht}}]
  
-The image shows ATmega128 microcontroller'UCSRnA register, which stands for "USART Control and Status Register A"This register is used to configure AVR's USART module and read its statesAll AVR register names are written in capital lettersbut as the reader might noticethe register name contains also a lower case n. A lower n is used to mark some module's indexSince ATmega128 has 2 almost identical USART modulesthey are not described twicebut only once and the must be read as or by the userTherefore ATmega128 has registers UCSR0A and UCSR1A.+Die Abbildung zeigt das UCSRnA Register des ATmega128UCSRnA bezeichnet „USART Control and Status Register ADieses Register wird verwendet um das USART Modul der AVR Mikrocontroller zu konfigurieren und deren Status auszulesenSämtliche AVR Registernamen werden in Großbuchstaben geschriebenjedoch enthält der Name auch ein kleines nwelches den Index des Moduls kennzeichnetDer ATmega128 verfügt über zwei nahezu identische USCART Moduledie jedoch nicht getrennt beschrieben werdensodass der Nutzer das als oder lesen mussAus diesem Grund hat der ATmega128 die Register USCR0A und UCSR1A.
  
-The content of the register is marked by an 8-slot box with a bold line around itEach slot marks one bitBit ranks are marked above the box - increasing from right to leftSince AVR is an 8-bit microcontrollermost of the registers are 8-bit as wellThere are some exceptionsa few registers are 16-bitbut they actually consist of two 8-bit registersLike each register has a nameeach bit in the register has also a name - just like the buttons on a tape playerEach bit is described in the datasheetBit names are abbreviations as well and the lower must be substituted with the module's index, just like with register namesSome registers don't use all bits, in this case the bit's slot is marked with a hyphen.+Der Inhalt des Registers wird durch eine Box mit Feldern und einem dicken schwarzen Rahmen dargestelltJedes Feld steht hier für ein BitDie Bitränge sind oberhalb der Box abgebildet – von links nach rechts ansteigendDa der AVR ein 8-Bit Mikrocontroller isthaben auch die meisten seiner Register 8-Bit Es gibt auch Ausnahmenso sind einige Register 16-Bit großaber tatsächlich bestehen sie aus zwei 8-Bit RegisternSo wie jedes Register einen Namen hathat auch jedes Bit innerhalb des Registers einen Namen – so wie die Tasten an einem KassettenrekorderJedes Bit wird im Datenblatt beschriebenWie Registernamen sind Bitnamen ebenfalls Abkürzungen und das kleine entspricht jeweils dem ModulindexEinige Register nutzen weniger als Bit, in diesem Fall ist das Feld eines solchen Bits mit einem Trennstrich markiert.
  
-Below the register's bits are two lineswhich state whether the bit is readable (R), writable (W) or both (R/W). For examplethe status bits can't be overwritten and even if it's attempted in the programthe bit will remain unchangedIf the bit is marked as writablereading it will always result in one specific value stated in the datasheetThe second line specifies the default value of the bitwhich it has after the reset of the microcontroller.+Unterhalb der Bits des Registers finden sich im Datenblatt zwei Zeilen. Die erste gibt anob das Bit lesbar (R), beschreibbar (W) oder beides (R/W) istKann beispielsweise der Status eines Bits nicht überschrieben werdenso bleibt das Bit unverändertauch wenn das mit dem Programm versucht wurdeDurch Auslesen eines beschreibbaren Bits wird stets ein spezifischer Wert ausgegebender im Datenblatt angegeben istIn der zweiten Zeile wird der Standardwert dargestelltden das Bit nach dem Reset des Mikrocontrollers hat.
  
-While AVR register names point to an actual memory slot addressthe bit names hold the rank number of the corresponding bitTherefore it is necessary to transform the names to bitmasks using a shift operation, in order to manipulate with bits in a registerThe following code contains a few example lines for using the USART 0 module's register.+Während die AVR Registernamen auf eine tatsächliche Adresse im Speicher verweistenthalten Bitnamen den Rang und das zugehörige BitDaher ist eine Transformation der Namen zu Bitmasken mit einer Shiftoperation notwendigwenn man mit Bits in einem Register arbeiten willDer folgende Code zeit einige Beispielzeilen für die Nutzung des USART 0 Modul Registers.
  
 <code c> <code c>
-  // Set TXC0 bit high+  // Setze TXC0 Bit high
   UCSR0A |= (1 << TXC0);   UCSR0A |= (1 << TXC0);
  
-  // Set U2X0 bit low+  // Setze U2X0 Bit low
   UCSR0A &= ~(1 << U2X0);   UCSR0A &= ~(1 << U2X0);
  
-  // Read the value of UDRE0 bit(mask)+  // Lies den Wert aus UDRE0 Bit(Maske)
   unsigned char u = (UCSR0A & (1 << UDRE0));   unsigned char u = (UCSR0A & (1 << UDRE0));
  
-  // At this point u value is either or 32, +  // An dieser Stelle ist der Wert entweder oder 32, 
-  // which enables using it in a logical operation+  // wodurch die Nutzung in einer logischen Operation aktiviert wird
   if (u)   if (u)
   {   {
-     // Invert MPCM0 bit+     // Invertiere MPCM0 Bit
      UCSR0A ^= (1 << MPCM0);      UCSR0A ^= (1 << MPCM0);
   }   }
  
-  // Sometimes it is necessary to acquire a specific 0 or value, +  // Manchmal ist es notwendig einen spezifischen oder 0 Wert zu erhalten 
-  // so the read bit needs to be shifted right+  // Dazu muss das Bit nach rechts verschoben werden
   u >>= UDRE0;   u >>= UDRE0;
  
-  // Now the value of u is either or 1+  // Nun ist der Wert entweder oder 1
 </code> </code>
  
-===== Architecture =====+===== Architektur =====
  
-AVR has an internal 8-bit data busthrough which is moved the data between arithmetic logic unit (ALU), status register (SREG), program counter (PC), random access memory (SRAM) and peripheralsThe program, an array of commandsthat get executed in the ALU comes from an address in the flash memoryspecified by the program counterThe ALU has 32 8-bit general purpose registerswhich are used as operands when carrying out instructions.+Der AVR hat einen internen 8-Bit Daten-Busdurch den Daten zwischen der arithmetisch-logischen Einheit (ALU), dem Status Register (SREG), dem Befehlszähler (PC), dem Random-Access-Memory (SRAM), und den Peripherieschnittstellen bewegt werden könnenDas Programmeine Reihe an Befehlendie in der ALU ausgeführt werden, resultiert aus einer Adresse im Flash-Speicherspezifiziert vom BefehlszählerDer ALU hat 32 8-bit Mehrzweckregister, welche als Operanden genutzt werdenwenn Befehle ausgeführt werden.
  
 [{{  :images:avr:avr_atmega128_block_diagram.png?580  |Block diagram of ATmega128}}] [{{  :images:avr:avr_atmega128_block_diagram.png?580  |Block diagram of ATmega128}}]
  
-=== Instruction pipeline ===+=== Befehls-Pipeline ===
  
-AVR has a two-stage instruction pipelineWhile one instruction is executedthe next is fetched from the program memoryThis is why carrying out jump instructions takes 2 cycles on fulfillment of the jump conditionSince the new instruction is always fetched from the next memory addressit is necessary to discard the previously fetched instruction and fetch a new one when jumping to another addressbecause it was fetched from an old, wrong location.+Der AVR hat eine zweistufige Befehls-PipelineWährend ein Befehl ausgeführt wirdwird der nächste aus dem Programmspeicher geholtDarum sind beim Ausführen einer „Jump-Instruction“ zwei Takte notwendig, um die Bedingungen des Jumps zu erfüllenNeue Befehle werden immer von der nächsten Speicheradresse geholt. Dadurch ist es notwendig die vorherigen Befehle zu löschen und neue zu ladenwenn man zu einer neuen Adresse springtda der Ort an dem der Befehl geholt wurde nun nicht mehr stimmt.
  
-=== General purpose registers ===+=== Mehrzweckregister ===
  
-General purpose registers R0-R31 are like buffers for storing and operating with memory and peripheral dataThey simplify the architecture of the processorbecause they are quickly accessible by the ALU and the use of the data bus to read operands from the memory is not necessary for every operationGeneral purpose registers are used for performing all data-related arithmetical and logical operations.+Mehrzweckregister R0-R31 sind wie Buffer, um mit Speicher- und Peripheriedaten zu arbeiten und sie zu speichernSie vereinfachen die Architektur des Prozessorsweil sie schnellen Zugang der ALU erlauben und der Datenbus nicht immer benutzt werden muss um Operanden aus dem Speicher zu lesenMehrzweckregister werden für alle datenbezogenen arithmetischen und logischen Abläufe benutzt. 
 + 
 +Wenn man in Assembler programmiert, ist es möglich die benötigten Daten im Mehrzweckregister zu speichern. Programmiert man in C und muss eine Variable im Mehrzweckregister speichern, wird die Variable zusätzlich als „Register“ definiertZum Beispiel:
  
-While programming in assembler, it is possible to store the urgent data in general purpose registers. While programming in C and a need to store a variable in a general purpose register arises, the variable is additionally defined as "register". 
-For example: 
  
 <code c> <code c>
Line 324: Line 423:
 </code> </code>
  
-=== Instruction set === +=== Befehlssatz ===
- +
-The instruction set of most AVRs consists of 90-133 different instructions. ATmega128 has 133 instructions. Instructions have either one, two or no operands. Most instructions take only one cycle to complete, but the more complex ones can use up to 5 cycles. For XMega, the successor of AVR, several instructions have been modified to use less cycles. Most instructions in AVR are used for jumps, moving and comparing data and executing arithmetic calculations. A status register is used for performing calculations and comparisons. It stores the output status of the ALU - whether the result was negative, positive, zero, exceeded the maximum allowed value (8 bits), needed to transfer a bit to the next operation etc (there are a few more complex cases).+
  
 +Der Befehlssatz der meisten AVRs besteht aus 90-133 verschiedenen Befehlen. Der ATmega128 hat 133 Befehle. Befehle haben entweder ein, zwei, oder keine Operanden. Die meisten Befehle benötigen nur einen Takt zur Ausführung, komplexere Befehle können jedoch bis zu fünf Taktzyklen benötigen. Für den XMega, den Nachfolger des AVR, wurden viele Befehle modifiziert, damit weniger Taktzyklen genutzt werden. Die meisten Befehle im AVR werden benutzt für Jumps, um Daten zu bewegen und zu vergleichen und um arithmetische Berechnungen auszuführen. Ein Status-Register wird genutzt um Berechnungen und Vergleiche auszuführen. Es speichert den Output-Status der ALU - ob das Ergebnis negativ, positiv, null, den maximal erlaubten Wert (8 Bits) überschreitet, oder einen Bit in die nächste Operation transferieren muss, usw. (Es gibt noch ein paar kompliziertere Fälle).
 <box 100% round #EEEEEE|Example> <box 100% round #EEEEEE|Example>
  
-This is a piece of code written in Assembler and consists of pure instructionswhich adds to the byte at random access memory address $100 (decimal 256). These instructions exist in all AVRs.+Die ist ein Teil eines in Assembler geschrieben Codesder bloße Befehle beinhaltet, welcher eine zum Byte in der RAM-Adresse $100 (dezimal 256) hinzufügtDiese Befehle gibt es alle im AVR.
  
 <code asm> <code asm>
-ldi  r1, 5       ; Load the constant to general purpose register r1 +ldi  r1, 5       ; Lädt die Konstante in das Mehrzweckregister r1 
-lds  r2, $100    ; Load the byte from the memory to register r2 +lds  r2, $100    ; Lädt das Byte aus dem Speicher in das Register r2 
-add  r2, r1      ; Add the value of r1 to r2 +add  r2, r1      ; Fügt den Wert von r1 zu r2 hinzu 
-sts  $100, r2    ; Write the value of r2 back to the memory+sts  $100, r2    ; Schreibt den Wert von r2 zurück in den Speicher
 </code> </code>
  
 </box> </box>
  
-=== Program stack ===+=== Programmstapelspeicher (stack===
  
-Stack is a data structurewhere the last data written to the memory is read out first. AVR's stack can be used while operating with subroutinesinterrupts and temporary dataBefore executing a subroutine or interruptthe address in the program counter where the program was interrupted is stored in the stackWhen the subroutine or interrupt has finished its executionthis address is read back from the stack and the program continues from the address it left off beforeStoring temporary data in the stack is usually used when dealing with shorter chunks of codewhich do not require reserved memory throughout the execution of the programSimpler assembler programs are usually written so that it is not necessary to use the stackbut if the program contains a lot of variables and functionsthe compilers automatically make use of it.+Ein Stapelspeicher (stack) ist eine Datenstruktur, bei der der letzte in den Speicher geschriebene Wertals erstes ausgelesen wirdDie Stacks im AVR können genutzt werdenwenn man mit Subroutinen, Interrupts und temporären Daten arbeitetBevor eine Subroutine oder ein Interrupt ausgeführt wird speichert der Stack die Adresse im Befehlszähler, bei welcher das Programm unterbrochen wurdeWenn die Subroutine oder der Interrupt ausgeführt wurdewird die Adresse wieder aus dem Stack gelesen, und das Programm fährt von der Adresse vor der Unterbrechung wieder fortDas Speichern temporärer Daten im Stack wird normalerweise dann genutztwenn man mit kleineren Stücken Code arbeitet, welche keinen reservierten Speicher während ihrer Ausführung benötigenEinfache Assembler Programme werden normalerweise so geschriebendass es nicht notwendig istden Stack zu nutzen, aber wenn das Programm viele Variablen und Funktionen enthählt, verwendet der Compiler den Stack automatisch.
  
-The stack of MegaAVR series microcontrollers is physically located in the random access memorySome tinyAVR series devices do not have a random access memory at all and the stack is realized as a separatequite limited memory unitTypically there are no compilers for devices with no random access memory.+Der Stack der MegaAVR-Serie ist physikalisch im Random-Access-Memory zu findenEinige Modelle der tinyAVR-Serie besitzen jedoch keinen Random-Access-Memory sodass der Stack hier durch eine kleineseparate und begrenzte Speichereinheit realisiertNormalerweise gibt es keinen Compiler für Modelle ohne Random-Access-Memory.
  
-To program in a high level language (Pascal, C, C++), it is not necessary to be familiar with the inner workings of the microcontrollerbecause the compiler is capable of selecting general purpose registers and instructions by itselfbut knowing what goes on in the controller is certainly beneficialIt is necessary to know the instructions of the microcontroller when developing time-critical applicationswhere the operations have to be completed in a limited amount of cycles+Um in einer hochleveligen Sprache zu programmieren (Pascal, C, C++), ist es nicht notwendigsich mit der inneren Arbeitsweise eine Mikrocontrollers zu beschäftigenda der Compiler in diesem Fall Mehrzweckregister und Befehle selbst auswählen kannEs kann jedoch nur von Vorteil seinzu wissen was in einem Mikrocontroller abläuft. Es ist notwendig die Befehle des Mikrocontrollers genau zu kennen, wenn man zeitkritische Applikationen entwickelt, bei denen die Operationen in einer begrenzten Anzahl an Taktzyklen beendet sein müssen
-===== Clock =====+===== Taktgeber =====
  
-As it is with most digital electronicsan AVR also works at a constant frequencyA constant frequency assures the reliability of data exchange throughout the deviceThere are several methods for generating a clock signal for an AVR.+Wie die meiste digitale Elektronikarbeitet auch der AVR in einer konstanten FrequenzEine konstante Frequenz versichert die Zuverlässigkeit von Datenaustausch im GerätEs gibt unterschiedliche Methoden um ein Taktsignal für den AVR zu generieren
  
-**Internal RC oscillator**+**Interner RC Oszillator**
  
 [{{  :images:avr:avr_clock_ext_rc.png?150|Using an RC oscillator}}] [{{  :images:avr:avr_clock_ext_rc.png?150|Using an RC oscillator}}]
  
-This is a internal clock generatorwhich does not need any external componentsIts main cons are low frequency and inaccuracy.+Dies ist ein interner Taktgeberwelcher keine externen Komponenten benötigtSeine größten Nachteile sind niedrige Taktfrequenz und Ungenauigkeit.
  
-**External RC oscillator**+**Externer RC Oszillator**
  
-Works on the same principal as an internal RC oscillator and has no significant advantage over the internal one.+Funktioniert nach dem gleichen Prinzip wie ein interner Taktgeber und hat keine signifikanten Vorteile gegenüber diesem
  
-**Crystal oscillator**+**Schwingquarz**
  
 [{{  :images:avr:avr_clock_ext_crystal.png?150|Using a crystal oscillator}}] [{{  :images:avr:avr_clock_ext_crystal.png?150|Using a crystal oscillator}}]
  
-Crystal oscillators use a crystal (usually quartzthat vibrates at its resonant frequency in the electric field and has a piezoelectic quality to produce an electric field on mechanical deformation (vibration). Crystal oscillators enable a precision of nearly 0.001%, which does not depend on the temperature.+Schwingquarze nutzen einen Kristall (gewöhnlich einen Quarz), welcher in einem elektrischen Feld in seiner Resonanzfrequenz vibriert. Er hat die piezoelektrische Eigenschaft bei mechanischer Deformation (Vibrationein elektrisches Feld zu produzieren. Schwingquarze haben eine Präzision von ca. 0.001%, welche temperaturunabhängig ist.
  
-**Ceramic resonator**+**Keramische Resonatoren**
  
-Ceramic resonators are similar to crystal oscillatorsbut are made from cheaper piezoelectric materialsCeramic resonators are typically smaller than crystal oscillatorsbut are also less precise (~0.5%) and more sensitive to temperature changes.+Keramische Resonatoren ähneln den Schwingquarzensind aber aus günstigeren piezoelektrischen Materialien gemachtKeramische Resonatoren sind in der Regel kleiner als Schwingquarzeaber weniger genau (~0.5%) und weniger stark temperaturabhängig.
  
-**External clock signal**+**Externes Taktsignal**
  
 [{{  :images:avr:avr_clock_ext_clock.png?150|Using an external clock signal}}] [{{  :images:avr:avr_clock_ext_clock.png?150|Using an external clock signal}}]
  
-External clock signal can be generated with any deviceprovided that the frequency and amplitude (voltageare in the correct rangeFor example, an external clock signal generator can be used to provide a clock signal to several microcontrollers at once.+Ein Externes Taktsignal kann mit jedem Gerät erzeugt werdensolange die Frequenz und die Amplitude (Spannungim richtigen Bereich liegenZum Beispiel kann ein externer Taktgeber benutzt werden um ein Taktsignal gleichzeitig an mehrere Microcontroller weiterzugeben.
  
 ===== Interrupts ===== ===== Interrupts =====
  
-Interrupts in AVR can be caused by counterscommunication interfacesanalog-to-digital convertercomparatorspecial input-output pins and several other functionsdepending on the controllerAny interrupt can be allowed or disallowed from the unit that generates it. Regardless of the interrupt being allowed or disallowedthere is a 1-bit field (interrupt flag) in the corresponding unit of the controllerwhich is marked as true when the interrupt condition is fulfilledIf the interrupt flag is changed to true and the interrupt is allowedthe controller starts to execute the code specified for this interrupt.+Interrupts können im AVR – je nach Controller - durch ZählerKommunikations-InterfacesAnalog-zu-Digital KonverterKomparatorspezielle Input-Output Pins und verschiedene andere Funktionen hervorgerufen werden. Jeder Interrupt kann von der Einheit die ihn generiertentweder zugelassen werden oder nichtUnabhängig davon, ob der Interrupt zugelassen ist oder nichtgibt es ein 1-Bit Feld (Interrupt Flag) in der dazugehörigen Einheit im Controllerwelches mit „true“ markiert wird, wenn die Interrupt-Bedingung erfüllt istWurde die Interrupt-Flag auf „true“ geändert wird und der Interrupt zugelassendann wird der Controller den für den Interrupt gedachten Code ausführen.
  
-Every interrupt in the AVR microcontroller is tied to a specific eventEach event has a flag bit in the status registerwhich marks the occurring of the eventEvents are also tied to interrupt mask registers and the corresponding bits. If the event's interrupt bit is left unmasked and an event occursthe processor halts executing the current program for a few duty-cycles and begins executing the interrupt programAfter the interrupt program has been executedthe processor resumes executing the paused main program.+Jeder Interrupt des AVR Microcontrollers ist an ein bestimmtes Ereignis gebundenJedes Ereignis hat einen Flag-Bit im Status-Registerwelcher den Eintritt des Ereignisses markiertEreignisse sind ebenfalls an die Register der Interrupt-Masken sowie die dazugehörigen Bits gebunden. Wenn das Interrupt-Bit des Ereignisses unmaskiert ist und ein Ereigniss stattfindetstoppt der Prozessor die Ausführung des laufenden Programms für einige Arbeitszyklen und führt das Interrupt-Programm ausNachdem das Interrupt-Programm ausgeführt wurdefährt der Prozessor mit seinem pausierten Hauptprogramm fort.
  
 <box 100% round #EEEEEE|Example> <box 100% round #EEEEEE|Example>
  
-To use interrupts with the AVR LibC libraryit is necessary to include //interrupt.h//The code that gets executed upon interrupt is written after the "ISR" keywordThe text between the brackets after "ISR" is the name of the interrupt. C language example:+Um Interrupts mit der AVR LibC Bibliothek zu nutzenist es notwendig interrupt.h einzubindenDer Code der ausgeführt wird, wenn der Interrupt stattfindet, wird nach einem „ISR“-Keyword geschriebenDer Text innerhalb der Klammern nach „ISR“ kennzeichnet den Namen des InterruptsEin Beispiel in C:
  
 <code c> <code c>
Line 393: Line 491:
 ISR(XXX_vect) ISR(XXX_vect)
 { {
- // Do something+ // Anweisungen
 } }
 </code> </code>
Line 399: Line 497:
 </box> </box>
  
-Global allowing of all interrupts is configured from the control and status register SREG. The option to allow or disallow all interrupts at once is there to help protect dataSince interrupts disrupt the execution of the main programsome data used by the main program may be disturbed or corrupted in the processSituations like this can be avoided by simply disallowing all interrupts before dealing with such delicate dataDisallowing interrupts globally is easyif it can be done by changing only one register (SREG). After the critical part of the program has been executedthe interrupts can easily be allowed again and all the interrupts that would have fired in the meanwhile will get executed.+Die generelle Erlaubnis sämtlicher Interrupts wird vom Control- und Statusregister SREG konfiguriertDie Option, alle Interrupts sofort zu erlauben oder zu verbieten existiert zum Schutz von DatenDa Interrupts das Ausführen eines Programms unterbrechenkönnten einige Daten im Hauptprogramm dabei zerstört oder beschädigt werdenSolche Situationen können einfach vermieden werden, wenn man alle Interrupts verbietet, bevor man mit empfindlichen Daten arbeitetDas generelle Verbot von Interrupts ist einfachda hierzu lediglich ein Register (SREG) geändert werden mussNachdem der kritische Teil des Programms ausgeführt wurde, können Interrupts einfach wieder zugelassen werden wodurch dann sämtliche Interrupts die zurückgehalten wurdenausgeführt werden.
  
-~~PB~~+<pagebreak>
  
 <box 100% round #EEEEEE|Example> <box 100% round #EEEEEE|Example>
  
-Let's suppose there is a 16-bit variable in use in the programwhich is changed by both the main program and the interrupt program and the value of this variable is later given to another variable:+Angenommen, in diesem Programm wird eine 16-Bit Variable verwendet, welche sowohl von dem Hauptprogrammals auch vom Interrupt geändert wird und der Wert dieser Variable wird später einer anderen Variable gegeben.
  
 <code c> <code c>
 #include <avr/interrupt.h> #include <avr/interrupt.h>
  
-// Global 16-bit variables and y+// Globale 16-Bit Variable und y
 unsigned short x, y; unsigned short x, y;
  
-// A random interrupt that changes the value of x+// Ein zufälliger Interrupt der den Wert von ändert.
 ISR(XXX_vect) ISR(XXX_vect)
 { {
Line 421: Line 519:
 int main() int main()
 { {
- // Give a value to x+ // x einen Wert geben
  x = 0x1111;  x = 0x1111;
  
- // Allow interrupts globally+ // Interrupts generell erlauben
  sei();  sei();
  
- // Give the value of x to y+ // y erhält Wert von x
  y = x;   y = x;
 } }
 </code> </code>
  
-The program itself is very simple - first, variable x is given a value of 0x1111 and later, its value is given to variable y. If an interrupt fires between those two operations, x gets a value of 0x3333. By logic, variable y can have two possible values by the end of the program, but on an 8-bit AVR there is also a third option. This is because 8-bit architecture needs 2 cycles to move 16-bit data and therefore a badly-timed interrupt can corrupt the integrity of the data. Consequently, y can have a value of 0x1111 or 0x3333, but it can also have a value of 0x3311 at the end of the program. To avoid getting the third, unwanted value, all interrupts should be temporarily disallowed before performing operations that take more than 1 cycle. 
  
-In the following examplethe value of is given to using a safe method:+Das Programm selbst ist sehr einfach - zuerst bekommt die Variable x den Wert 0x1111 und später wird dieser an y weitergegeben. Wenn ein Interrupt zwischen diesen beiden Operationen auftrittbekommt einen Wert von 0x3333. Logisch gesehen kann somit zwei mögliche Werte am Ende des Programms haben, allerdings existiert bei einem 8-Bit AVR noch eine dritte Möglichkeit. Hierzu kommt es, da die 8-Bit Architektur zur Verarbeitung von 16-Bit Daten 2 Taktzyklen braucht. Daher kann ein Interrupt durch schlechtes Timing die Integrität dieser Daten beschädigen. Dadurch kann y am Ende des Programms den Wert 0x1111 oder 0x3333, aber auch 0x3311 haben Um den dritten und ungewollten Wert zu verhindern, sollten alle Interrupts temporär verboten werden wenn eine Operation mehr als einen Taktzyklus umfasst. 
 + 
 +Im folgenden Beispiel wird eine sichere Methode benutzt um y den Wert von x zu geben: 
  
 <code c> <code c>
- // Disallow interrupts globally+ // Interrupts generell verbieten
  cli();  cli();
  
- // Give the value of x to y+ // y erhält Wert von x
  y = x;  y = x;
  
- // Re-allow all interrupts again+ // Sämtliche Interrupts wieder zulassen
  sei();  sei();
 </code> </code>
  
 </box> </box>
-===== Digital inputs/outputs =====+===== Digitale Inputs/Outputs =====
  
-All the buses on AVR are both readable and writableif they are used in the default logical input/output (I/O) mode. AVR buses are named as letters from the beginning of the Latin alphabet: A, B, C etcSome AVRs might not have bus A, though, if bus existsEach bus is 8-bit and each bit usually has its own pin on the controller. Pins are counted with numbers starting from zero. For both directions on the busthere are two separate registersIn addition, there is a register to decide the real direction of the buswhere a bit value of marks the bus as output and as inputAltogether, each bus has three registers:+Sämtliche Busse des AVR sind sowohl lesbar als auch beschreibbarwenn sie im normalen logischen Input/Output (I/O) Modus verwendet werden. AVR Busse werden nacheinander mit lateinischen Buchstaben (A, B, C usw.) benannt. Allerdings können einige AVR zwar einen Bus B, jedoch keinen Bus A besitzenJeder Bus ist ein 8-Bit Bus und jedes Bit hat normalerweise seinen eigenen Pin am Controller. Pins werden mit Ziffern, beginnend bei NullversehenFür beide Richtungen im Bus gibt es ein separates Register. Zusätzlich gibt es noch ein weiteres Register welches die tatsächliche Richtung des Bus festlegtein Bitwert von markiert den Bus als Output und ein Wert von als InputDamit hat der Bus drei Register:
  
-  * PORT - for setting the output value of the bus. +  * PORT - Zur Festsetzung des Outputwertes 
-  * PIN - for reading the input on the bus. +  * PIN - Zum Auslesen des Inputs am Bus 
-  * DDR - for setting the direction of the bus.+  * DDR - Zur Festlegung der Richtung des Busses.
  
-<box 100% round #EEEEEE|Example>+<box 100% round #EEEEEE|Beispiel>
  
-Taskmake pins 0-3 on bus inputspins 4-7 outputsset pin 5 high and read the values of pins 0-3 to a variableThe code for it looks like this:+AufgabeDie Pins 0-3 von Bus sollen Input seindie Pins 4-7  Outputsetzen Sie Pin high“ und lesen Sie die Werte der Pins 0-3 in einer Variable ausDer C-Code sieht wie folgt aus:
  
 <code c> <code c>
Line 467: Line 567:
  unsigned char x;  unsigned char x;
  
- // Pins 0-3 as inputs, 4-7 as outputs+ // Pins 0-3 als Input, 4-7 als Output
  DDRB = 0xF0;  DDRB = 0xF0;
  
- // Set pin five as high+ // Setzt Pin 5 "high"
  PORTB |= (1 << PIN5);  PORTB |= (1 << PIN5);
  
- // Read the values from inputs 0-3+ // Liest den Wert der Pins 0-3
  x = PINB & 0x0F;  x = PINB & 0x0F;
 } }
Line 480: Line 580:
 </box> </box>
  
-In this examplethe inputs are used in Hi-Z (high impedancemodeIn essencethe input does not put virtually any load on the source of the signalThis mode might be necessaryif the pin is used as a data bus. It is wise to use a pull-up resistor on the inputif the pin is used for a buttona switch or any other solution, where the input is connected to groundFor that, the output bit of the corresponding pin must be set high in the input mode - as a resulta resistor is placed between the supply voltage and the inputwhich keeps the input voltage high unless it is being pulled down by somethingThe goal of a pull-up resistor is to prevent floating of the input due to statical electricity and other interferencesAfter booting the controllerall IO buses are in the high impedance input mode by default.+In diesem Beispielwird der Input im Hi-Z (hochohmigModus verwendet. Im Wesentlichen liegt an diesem Input keine Ladung anDiese Betriebsart könnte hilfreich seinwenn der Pin als Datenbus genutzt wirdEs ist sinnvolleinen Pull-Up-Widerstand für den Input zu nutzenwenn der Pin als TasteSchalter oder anderes verwendet wird wobei er mit der Masse verbunden istHierfür muss das korrespondierende Output-Bit im Inputmodus „high“ gesetzt werden. Als Folge daraus muss zwischen Stromversorgung und Input ein Widerstand eingefügt werdenwelcher die Inputspannung hoch hältbis irgendetwas sie heruntersetztEin solcher Pull-Up-Widerstand dient dazu, ein Floaten des Inputs aufgrund von Reibungselektrizität oder anderen Einwirkungen zu verhindernNachdem der Controller gebootet wurdebefinden sich sämtliche IO Busse standardmäßig im hochohmigen Inputmodus.
  
-Usually, the pins on the IO bus are also used for other peripheralsaside from the logical connectionsIf there is a need to use the alternate function of the pinthe appropriate IO pin mode can be found in the AVR's datasheetFor example to use an ADC channel as an inputthe pin should be in input mode and to generate PWM signalit should be in output modeOn the other handsome peripheral modules select the IO pin mode by themselves+Normalerweise werden die Pins am IO Busneben den logischen Anschlüssen, auch für andere Peripherieschnittstellen genutztSoll eine alternative Funktion des Pins genutzt werdenkann der zugehörige IO Pin-Modus im AVR Datenblatt abgelesen werdenWenn beispielsweise ein ADC Kanal als Input dienen sollsollte der Pin im Input Modus sein. Um jedoch ein ein PWM Signal zu generierensollte er im Output Modus betrieben werdenEs gibt jedoch auch Peripheriemoduledie den IO Pin-Modus eigenständig auswählen
-===== External interrupts =====+===== Externe Interrupts =====
  
-External interrups are one of the most simple peripheral functionsTypically AVRs have to special pinswhich are used to cause interrupts in the program when their logical value changes or they are at a certain stateSince this function is usually used to monitor external logical signalsthese pins are called external interrupt pins.+Externe Interrupts sind eine der einfachsten Funktionen der PeripheriegeräteNormalerweise haben AVR'bis spezielle Pinswelche benutzt werden um Interrupts im Programm auszulösen, wenn sich entweder ihr logischer Wert ändert oder sie einen bestimmten Status erreichenDa diese Funktion normalerweise gebraucht wird um externe logische Signale zu überwachenwerden diese Pins auch externe Interrupt-Pins genannt.
  
-To use an external interruptthe pin has to be configured as standard IO input (it can also be used as an outputbut in this case the interrupt can only be created by the controller itself). It is necessary to allow receiving interrupts and specify the condition that causes the interrupt to fire in the external interrupt configuration registerThere are four possible conditions:+Um einen externen Interrupt zu nutzenmuss der Pins als Standard IO Input (er kann auch als Output genutzt werdenjedoch kann der Interrupt dann nur vom Controller selbst ausgelöst werdenkonfiguriert werdenAußerdem muss der Empfang von Interrupts zugelassen sein und die Bedingung, welche den Interrupt auslöst, muss im externen Konfigurationsregister des Interrupts spezifiziert werden
  
-  * Logical zero (voltage of 0V) +Es existieren vier mögliche Bedingungen:
-  * Change in the logical value +
-  * Descending front - logical change from one to zero. +
-  * Rising front - logical change from zero to one.+
  
 +  * Logische Null (Spannung von 0 V)
 +  * Änderung des logischen Werts
 +  * Fallende Flanke – logische Änderung von 1 zu 0
 +  * Steigende Flanke – logische Änderung von 0 zu 1
  
-When the mode is set to logical zero, the interrupt will fire continuously as long as the pin has a value of zero. During this period the execution of the main program is stopped. 
  
-Grouped by principalthere are two types of interrupts: synchronized to the controller's clock and asynchronous. Synchronized interrupts work by remembering the values of the inputswhich means that the changes in logical values are found by comparing values read during two different clock cycles. If the logical changes in the signal happen faster than the controller's duty-cycle, the interrupts either fire incorrectly or are skipped altogether. Asynchronous interrupts do not depend on the controller's clock and enable detecting faster changes in the external signal as well - the logical level must still be constant for at least 50 nsATmega128 has 4 synchronized and 4 asynchronous external interrupts.+Der Modus „logische Null“ bewirktdass der Interrupt durchgehend ausgelöst wirdsolange der Pin den Wert Null hatWährend dieser Periode wird die Ausführung des Hauptprogramms gestoppt.
  
-~~PB~~+Prinzipiell gibt es zwei Typen von Interrupts: Mit dem Taktgeber des Controllers synchrone und asynchrone Interrupts. Synchrone Interrupts funktionieren indem sie den Wert des Inputs behalten. Auf diese Weise können Änderungen der logischen Werte aufgedeckt werden, indem die Werte zwischen zwei Taktzyklen verglichen werden. Erfolgen die Änderungen des Signals schneller als der Tastzyklus des Controllers, können Interrupts falsch oder gar nicht ausgelöst werden. Asynchrone Interrupts sind unabhängig vom Taktgeber des Controllers und können so schnellere Änderungen im externen Signal erfassen - das logische Level muss jedoch immer noch für mind. 50 ns konstant sein. Der ATmega128 hat 4 synchrone und 4 asynchrone externe Interrupts.
  
-<box 100% round #EEEEEE|Example> 
  
-TaskMake ATmega128 pin number 9 (pin on bus E) fire an interrupt if its value is changedThis pin corresponds to the INT7 external interruptwhich is synchronous.+<pagebreak> 
 + 
 +<box 100% round #EEEEEE|Beispiel> 
 + 
 +AufgabeLassen Sie ATmega128 Pin Nummer 9 (Pin an Bus E) einen Interrupt auslösen, wenn sich sein Wert ändertDer Pin gehört zum externensynchronen INT7 Interrupt.
  
 <code c> <code c>
 #include <avr/interrupt.h> #include <avr/interrupt.h>
  
-// The code of the external interrupt+// Der Code des externen Interrupts
 ISR(INT7_vect) ISR(INT7_vect)
 { {
- // Do something+ // mache irgendetwas
 } }
  
 int main() int main()
 { {
- // Change pin on bus E to an input by changing bit to zero+ // Ändere Pin 7 an Bus E zu einem Inputpin, indem Bit auf 0 gesetzt wird
  DDRE &= ~(1 << PIN7);  DDRE &= ~(1 << PIN7);
  
- // Defining a pull-up resistor to to pin on bus + // Definiere einen Pull-Up Widerstand für Pin an Bus E  
-        // to prevent input floating+        // um Input Floating zu verhindern.
  PORTE |= (1 << PIN7);  PORTE |= (1 << PIN7);
  
- // Set the interrupt mode to logical change for interrupt + // Setzt den Interruptmodus auf “Logische Änderung” für den Interrupt 
-        // in the external interrupt configuration register+        // im externen Interruptkonfigurationsregister.
  EICRB = (1 << ISC70);  EICRB = (1 << ISC70);
  
- // Allow external interrupt 7+ // Erlaube externen Interrupt 7
  EIMSK |= (1 << INT7);  EIMSK |= (1 << INT7);
  
- // Allow global interrupts+ // Erlaube globale Interrupts
  sei();  sei();
  
- // Endless loop+ // Endlosschleife
  while (1) continue;  while (1) continue;
 } }
Line 540: Line 643:
 </box> </box>
  
-In addition to interrupts fired by single pins, if the AVR has enough pins it is possible to use entire groups of pins to fire logical value change interruptsThese interrupts are simply called pin change interruptsThey fire when the value of at least one pin in the group is changed+Verfügt der AVR über ausreichend Pins, ist es möglich, zusätzlich zu einem Interrupt der von einem einzelnen Pin ausgelöst wird, eine ganze Gruppe an Pins zu nutzen, um Interrupts durch logische Wertänderungen auszulösenDiese Interrupts werden einfach „Pin change Interrupts“ genanntSie lösen aus, sobald mindestens der Wert von einem Pin in der Gruppe sich ändert
-===== Analog-to-digital converter =====+===== Analog-zu-Digital Konverter =====
  
-Analog-to-digital converter (ADC) transforms an analog voltage value to a digital valueThe allowed voltage range on an ADC input of an AVR microcontroller is to 5.5 VThe size of the digital value is 10 bits, but its precision is ±2 unitsThe error may be even largerif the microcontroller's supply voltage is not protected from interference. AVR has a separate voltage supply and comparison voltage pin for ADC. The separate supply voltage helps to cut down the interference and it may not differ more than 0.3 V from the main supply voltageComparison voltage defines the maximum digital valueFor exampleif the comparison voltage is 3 V then an input with the same voltage will read as 2<sup>10</sup> - 1 (1023).+Analog-zu-Digital Konverter (ADC) transformieren einen analogen Spannungswert in einen digitalen WertDie erlaubte Spannungsreichweite am ADC-Input eines AVR Microcontrollers liegt bei 0-5.5VDer digitale Wert ist 10 Bit groß und bis auf ± 2 Einheiten genauDer Fehler kann jedoch auch noch größer seinwenn die Betriebsspannung nicht vor Störungen geschützt istDer AVR hat separate Betriebs- und Vergleichsspannungs-Pins für den ADC. Die separate Betriebsspannung trägt dazu bei, Störungen möglichst klein zu halten wobei sie sich nicht mehr als 0.3V von der Hauptbetriebsspannung unterscheiden darfDie Vergleichsspannung definiert den maximalen digitalen WertBeträgt sie zum Beispiel 3V beträgtdann wird ein Input mit der gleichen Spannung mit 210 - 1 (1023) ausgelesen.
  
-AVR ADC works on the principal of successive approximationIn shortthe measured voltage is compared to specific voltage levels and the results are reported as a bit arrayThis method is relatively slowas each bit in the final result is calculated separately. AVR spends 13 clock cycles for each measuringexcept the first (on start-up), which takes 25 cyclesThese cycles are not the controller's duty cycles thoughbut instead special cycles allocated to the ADC unit by the frequency dividerThe ADC frequency should be 50-200 kHz to achieve maximum precisionon higher frequencies the precision fadesIn some cases it is more important to get a large number of readings instead of maximum precisionin which case using a larger frequency is totally justifiedAccording to AVR documentation, one measuring takes 13-260 µs.+Der AVR ADC arbeitet nach dem Prinzip der schrittweisen AnnäherungKurz gesagtdie gemessene Spannung wird mit bestimmten Spannungslevels verglichen und die Ergebnisse werden als Bit-Array ausgegebenDiese Methode ist relativ langsamda jedes Bit im Endergebnis einzeln berechnet wirdDer AVR benötigt 13 Taktzyklen für jede Messungfür die Erste jedoch (beim Start-up ) werden, 25 Taktzyklen benötigtDiese Taktzyklen entsprechen jedoch nicht den Arbeitstakten des Controllerssondern sind spezielle Taktzyklen die der ADC-Einheit durch den Frequenzteiler zugewiesen wurdenUm die maximale Präzision zu erreichen, sollte die ADC-Frequenz sollte 50-200 kHz betragenbei höheren Frequenzen sinkt die GenauigkeitEine höhere Frequenz ist dann sinnvollwenn viele Daten ausgelesen werden sollen wobei die Genauigkeit dieser vernachlässigt wirdGemäß dem AVR-Handbuch dauert eine Messung 13-260 µs.
  
-The measured value can be read as an 8- or 10-bit valueSince AVR itself is an 8-bit deviceit has two 8-bit registers for storing the ADC valuesIt is possible to specify in the settings whether the first two or the last two bits go to a separate registerIf the two younger bitswhich characterize the result lessare separatedthe result can be read as an 8-bit value - a combination like that is called a left aligned result. The other combinationwhere both registers are read and the value is in 10-bit format, is called a right aligned result.+Der gemessene Wert kann als 8- oder 10-Bit Wert gelesen werdenDa der AVR ein 8-Bit Mikrocontroller istverfügt er über zwei 8-Bit Register um ADC-Werte zu speichernIn den Einstellungen kann festgelegt werden, ob die ersten oder letzten zwei Bits in ein seperates Register sollenFalls die zwei zuletzt ausgelesenen Bitswelche das Ergebnis weniger widergebensepariert werdenkann das Ergebnis als 8-Bit Wert ausgelesen werden. Eine solche Kombination nennt man „left aligned resultDarüber hinaus kennzeichnet „right aligned result“  jene Kombination, bei der beide Register gelesen werdenund der Wert ein 10-Bit Format hat.
  
-A typical AVR has analog voltage input channels, ATtiny series have only a fewsome ATmega devices have 16, but there is always only one converterTo make it possible to use different inputs, the device has a built-in multiplexerThe input of the multiplexer is definable using a special registerThe ADC unit has a few more propertiesusing the processor's sleep mode for converting to reduce the interference and the option to use an internal fixed comparison voltage (usually 2.65 V, in some models 1 V).+Ein normaler AVR verfügt über analoge Spannungs-Input-Kanäle. Die Mikrocontroller der ATtiny Serie besitzen wenigereinige ATmega haben 16, allerdings existiert immer nur ein ADCUm verschiedene Inputs nutzen zu können hat das Gerät einen eingebauten MultiplexerDer Input des Multiplexer kann durch Nutzung eines speziellen Registers definiert werdenDie ADC Einheit weist darüber hinaus noch weitere Eigenschaften aufDer Sleepmodus des Prozessors wird für die Umwandlung genutzt, um  Störungen zu verringern. Außerdem gibt es die Option zur Nutzung einer internen festen Vergleichsspannung (gewöhnlich 2.65 V, bei manchen Modellen aber 1 V)
  
-~~PB~~ 
  
-<box 100% round #EEEEEE|Example>+<pagebreak> 
 + 
 +<box 100% round #EEEEEE|Beispiel>
  
-Taskmeasure the voltage in ADC channel of an ATmega128. The voltage is in range of 0-5 V and the result should be at 8-bit precision.+AufgabeMessen Sie die Spannung des ADC Kanals eines ATmega128. Der Spannungsbereich liegt bei 0-5 V und das Ergebnis sollte 8-Bit präzise sein.
  
 <code c> <code c>
Line 564: Line 668:
  unsigned char result;  unsigned char result;
  
- // Choose AREF pin for the comparison voltage + // Wähle den AREF Pin zum Vergleich der Spannung 
- //   (it is assumed AREF is connected to the +5V supply+ // (es wird angenommen, dass AREF mit der +5V Stromversorgung verbunden ist)
- // Choose channel in the multiplexer + // Wähle Kanal im Multiplexer r 
- // Left align the result+ // ordne das Ergebnis links an
  ADMUX = (1 << REFS0) | (1 << ADLAR) | (3);  ADMUX = (1 << REFS0) | (1 << ADLAR) | (3);
  
- // Start the ADC unit+ // Starte den ADC, 
- // set the conversion cycle 16 times slower than the duty cycle+ // setze den Umwandlungszyklus 16 mal langsamer als das Tastverhältnis
  ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADSC);  ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADSC);
  
- // Wait for the measuring process to finish+ // Warte auf Beendigung des Messvorganges
  while (ADCSRA & (1 << ADSC)) continue;  while (ADCSRA & (1 << ADSC)) continue;
  
- // Read the 8-bit value+ // Lies den 8-Bit Wert aus
  result = ADCH;  result = ADCH;
 } }
Line 585: Line 689:
 ===== Counters/Timers ===== ===== Counters/Timers =====
  
-Counterswhich in some sense can be called timersare one of the most important sub-functions of a microcontrollerThese enable to precisely time processesgenerate signals and count eventsA counter converts the number of input cycles to a binary value using an array of triggersThe maximum number of counted cycles depends on the length of this array and this is marked by the length of the binary code. AVR has 8- and 16-bit countersIf a timer has reached its maximum value (255 in 8-bit and 65535 in 16-bit counters), the next cycle will generate an overflow and the counter resets back to 0. A counter's clock signal can come from the clock signal of the microcontroller and in this case it is possible to decrease its value using a prescalerSome AVRs have an internal independent clock signal generatorwhich can be modified to run faster using a frequency multiplierCounters also differ in application cases and work modes.+Counterwelche man auch in einigen Fällen Taktgeber nennen kannsind einer der wichtigsten Unterfunktionen eines MicrocontrollersDiese ermöglichen es Prozesse exakt zu timenSignale zu generieren und Ereignisse zu zählenEin Zähler konvertiert die Nummer der Inputzyklen in einen binären Wert mit Hilfe eines Arrays an TriggernDie maximale Nummer der gezählten Zyklen hängt von der Länge des Arrays ab und diese ist markiert von der Länge des binären CodesDer AVR hat 8- und 16- Bit CounterWenn ein Timer seinen  maximalen Wert erreicht hat(255 bei 8-Bit und 65535 bei 16-Bit), generiert der nächste Zyklus ein Overflow und der Zähler macht ein Reset auf 0. Das Taktsignal eines Counters kann vom Taktsignal des Microcontrollers kommen und in diesem Fall ist es möglich den Wert mit einem Prescaler herunter zusetzenEinige AVRs haben einen internen unabhängigen Taktgeberwelcher mit einem Frequenzmultiplikator modifiziert werden kann, um schneller zu laufen. 
 +Counter unterscheiden sich auch in Applikationsfällen und Arbeitsmodi.
  
 === Counter's default mode === === Counter's default mode ===
  
-In the default modea counter does nothing more than count sequential numbers all the timeIts value canof course, be read and changed from the program at any timeThe only additional function in the default mode is to cause an interrupt on counter overflow. The default mode is typically used to execute a section of the program at certain intervals.+Im Default-Modus macht ein Counter nichts anderesals fortlaufend Nummer zu zählen 
 +Sein wert kann natürlich jederzeit ausgelesen, und von einem Programm verändert werden. 
 +Die einzige zusätzliche Funktion im Default-Modus istdass er ein Interrupt beim Counter-Overflow verursachtDer Default-Modus wird normalerweise benutzt, um eine Sektion eines Programms in bestimmten Intervallen laufen zulassen.
  
 <box 100% round #EEEEEE|Example> <box 100% round #EEEEEE|Example>
  
-TaskMake an 8 MHz ATmega128 fire an interrupt every 10 ms (frequency 100 Hz). For this task, the 8-bit counter is suitable.+AufgabeEin 8 MHz ATmega128 soll einen Interrupt alle 10ms (100 Hz) auslösenDafür ist der 8-Bit Counter brauchbar.
  
 <code c> <code c>
Line 600: Line 707:
 ISR(TIMER0_OVF_vect) ISR(TIMER0_OVF_vect)
 { {
- // Give the counter such a value + // Gibt den Counter einen Wert, 
- // that the next overflow occurs in 10 ms+ // dass der nächste Overflow in 10Hz passiert
- // Formula: 256 - 8 MHz / 1024 / 100 Hz = 177,785 = ~178+ // Formel: 256 - 8 MHz / 1024 / 100 Hz = 177,785 = ~178
  TCNT0 = 178;  TCNT0 = 178;
 } }
Line 608: Line 715:
 int main() int main()
 { {
- // To make the first overflow interrupt fire in 10 ms as well+ // Um den ersten Interrupt in 10ms auszulösen
- // the counter needs to be initialized here.+ // muss der Counter initialisiert werden.
  TCNT0 = 178;  TCNT0 = 178;
  
- // Prescaler value 1024+ // Prescaler Wert 1024
  TCCR0 = 0x07;  TCCR0 = 0x07;
  
- // Allow overflow interrupts+ // Erlaubt Overflow Interrupts
  TIMSK |= (1 << TOIE0);  TIMSK |= (1 << TOIE0);
  
- // Allow interrupts globally+ // Erlaubt global Interrupts
  sei();  sei();
  
- // Endless loop+ // Endlosschleife
  while (1) continue;  while (1) continue;
 } }
 </code> </code>
  
-The counter in this example will not generate the interrupt in exactly 10 ms thoughin order    to do that it would require giving the counter a decimal value and this is not possibleTo achieve a precise interval between the interruptsboth the prescaler value and the initial value of the counter have to be chosen so that their division results in an exact numberThis is not always possibleespecially with 8-bit counters as their value range is quite smallTo achieve a more precise or larger interval16-bit counter can be used.+Der Counter in diesem Beispiel wird den Interrupt nicht in exakt 10 ms generierendafür müsste man dem Counter einen Dezimalwert geben, das ist aber nicht möglich. 
 +Um einen präzisen Intervall zwischen den Interrupts zu verwirklichenwird sowohl der Prescaler Wert, als auch der Wert des Counter müssen so ausgesucht werden, dass ihre Division in einer exakten Nummer endetDas ist nicht immer möglichvor allem mit 8-Bit Countern, da ihr Wertebereich sehr klein istUm einen präziseren oder größeren Intervall zu bekommenkann ein 16-Bit Counter gewählt werden. 
  
 </box> </box>
  
-== External clock counter ==+== Externer Taktgeber ==
  
-It is also possible to use an external clock source as a counter's clock signal. AVR has a pin called Tn for this purpose, marking the number of the counterExternal clock signal and the polarity can be selected using the prescaler register.+Es ist auch möglich einen externen Taktgeber als das Taktsignals eines Counters zu nutzen. 
 +Der AVR hat einen Pin "Tn" dafür. Das ist Platzhalter für die Nummer des Counters. 
 +Das Externe Taktsignal und die Polarität kann man im Prescaler Register auswählen.
  
 == Timing events == == Timing events ==
  
-Since the counters allow timing operationsmore complex AVR microcontrollers have an option to time specific events on a hardware levelThis part of the counter is called an input capture unitThere is a choice between two events: the logical change in the value of a special input pin or in the value of the analog comparator result. If the selected event occurs, the counter's value is written to a special registerfrom where it can be read at any timeIf the event is longer than the overflow time of the counterthe program has to count the overflows as well and take them into account when calculating the final result.+Da die Counter zeitlich abgestimmte Operationen ermöglichenhaben komplexe AVR Microcontroller eine Option auf Hardware-Level für zeit spezifische Ereignisse. 
 +Der Teil des Counter heißt "Input Capture Unit". Es gibt eine Auswahl zwischen zwei Ereignissen: Die logische Änderung eines Werts an einem speziellen Input Pins oder im Wert des analogen Komparator ErgebnissesWenn das gewählte Ereignis eintritt wird der Wert des Counters in ein spezielles Register geschriebenwelches man jederzeit auslesen kannWenn das Event länger ist als die Overflowzeit des Countermuss das Programm die Overflow mit zählen und beim Endergebnis mitberechnen.
  
 <box 100% round #EEEEEE|Example> <box 100% round #EEEEEE|Example>
  
-TaskMeasure the frequency of an external 122 Hz 100 kHz logical square signal using an 8 MHz ATmega128. The measurement has to be at 1 Hz precisionThe program uses a 16-bit counter with 1 input capture unit.+AufgabeMiss die Frequenz eines Externen 122Hz 100kHz logischen Rechtecksignals mit einem 8MHz ATmega128. Die Messung soll mit einer 1 Hz-Präzision erfolgenDas Programm nutzt einen 16-Bit Counter mit einer Input Capture Unit.
  
 <code c> <code c>
Line 647: Line 759:
 unsigned long frequency; unsigned long frequency;
  
-// Interrupt for the event+// Interrupt für das Ereignis
 ISR(TIMER1_CAPT_vect) ISR(TIMER1_CAPT_vect)
 { {
Line 653: Line 765:
  TCNT1 = 0;  TCNT1 = 0;
  
- // The result is valid only if the counter + // Das Ergebnis ist nur gültig wenn der Counter 
- // has not overflown yet+ // noch kein Overflow hatte.
  if (!(TIFR & (1 << TOV1)))  if (!(TIFR & (1 << TOV1)))
  {  {
- // Calculating the frequency from the period+ // Berechnen der Frequenz von der Periode
  frequency = (unsigned long)8000000 /  frequency = (unsigned long)8000000 /
              (unsigned long)ICR1;              (unsigned long)ICR1;
Line 663: Line 775:
  else  else
  {  {
- // Frequency is less than 122 Hz+ // Frequenz ist weniger als 122Hz
  frequency = 0;  frequency = 0;
  
- // Set the counter's overflow flag to 0+ // Setzt die Counter Overflow Flagge auf 0
  TIFR &= ~(1 << TOV1);  TIFR &= ~(1 << TOV1);
  }  }
Line 673: Line 785:
 int main() int main()
 { {
- // Register a rising front, prescaler value 1+ // Registriert eine "rising front"Prescaler Wert auf 1
  TCCR1B = (1 << ICES1) | (1 << CS10);  TCCR1B = (1 << ICES1) | (1 << CS10);
  
- // Allow event interrupts+ // Erlaubt Ereignis-Interrupts
  TIMSK = (1 << TICIE1);  TIMSK = (1 << TICIE1);
  
- // Allow interrupts globally+ // Erlaubt global Interrupts
  sei();  sei();
  
- // Endless loop+ // Endlosschleife
  while (1) continue;  while (1) continue;
 } }
 </code> </code>
  
-The program fires an interrupt each time a rising front occurs in the external signalDuring the interruptthe counter is checked for overflows this can happen if the frequency of the signal is below 122 Hz (8 MHz / 2<sup>16</sup>and in this case the value of the counter doesn't reflect a real period any moreThe frequency is calculated using 32-bit numbers to get the inverse of the periodFirst thing is to set the counter to 0, because the timer works on the same clock signal as the processor and each instruction execution occurring after the external event shortens the measured period corrupting the resultThe maximum measured frequency is limited by the time spent in the interrupt program.+Das Programm löst jedes mal bei einer "Rising Front" im externen Signal einen Interrupt aus. 
 +Während des Interruptsüberprüft das Programm den Counter auf einen Overflow dass kann passieren wenn die Frequenz des Signals unter 122Hz (8 MHz / 2<sup>16</sup>ist und in so einem Fall spiegelt der Wert des Counters die echte Periode nicht mehr wiederDie Frequenz wird berechnent indem man mit 32-Bit Nummern die Inverse der Periode bekommtAls erstes setzt man den Counter auf 0, weil der Timer mit dem gleichen Taktsignal wie der Prozessors arbeitet und jede Befehlsausführung nach dem externen Event die zu messende Periode verkürzt und damit das Ergebnis verfälschtDie maixmale gemessene Frequenz wird durch die Zeit die das Interrupt benötigt limitiert. 
 +</box>
  
-</box>+Events erfassen und die Zeit registrieren die es brauchte damit das Event auftrat kann auf Software Level abgehandelt werden. Es ist möglich einen externen oder andere Interrupts zu nutzen und den Wert des Counters während des Events auszulesen. Das Erfassen auf Hardwarelevel wird genutzt um unabhängig vom Hauptprogramm zu arbeiten und sehr kurze (oder häufige) Events zu timen.
  
-Catching events and registering the time it took for them to occur can also be resolved at the software level. It is possible to use external or other interrupts and read the value of the counter during these events. The hardware-level event catching is meant to run independently form the main program and time relatively short (or frequent) events. 
  
-=== Signal generating ===+=== Taktsignal generieren ===
  
-More complex counters can generate a signalin addition to timing the length of oneFor this purpose the counter has an output compare unit and a compare match output unitThe output compare unit has registers with the same bit-width as the counter and the values of these registers are compared to the value of the counter while it is runningAn interrupt can be generated and special pins' values can be changed each time the counter's value is equal to the value in the compare unit registerAt this moment a pin can either be set high or low or inversedThe signal is generated by changes in the value of the output pin.+Komplexere Counter können ein Taktsignal generierenzusätzlich zum Timen eines SignalsDafür hat der Counter eine "Output Compare Unit" und eine "Compare Match Output Unit"Die Output-Compare-Unit hat Register mit der gleichen Bit-Weite wie der Counter und die Werte dieser Register werden mit den Werten des Counters verglichen während dieser läuft. 
 +Ein Interrupt kann generiert werden und spezielle Pin Werte können geändert werden wenn der Counter Wert gleich der des Compare Unit Registers istIn diesem Moment kann ein Pin entweder High oder low gesetzt oder invertiert werdenDas Signal wird durch Änderungen im Wert des Output-Pins generiert.
  
-In some signal generating modesthe counter's maximum value can be alteredThe counter's physical size will remain the samebut a comparison register is used to reset the counter at a specific countThe previous examples could also be solved by using this methodbut the function is rather for changing the period of the signalIn addition to thata counter can be configured to a mode where it works with both incrementing and decrementing.+In einigen Signal-generierenden Modikann der maximale Wert des Counters verändert werden. 
 +Die physikalische Größe bleibt die gleicheaber ein Vergleichsregister wird benutzt um den Counter bei einem bestimmten Wert zu resetten. 
 +Das vorherige Beispiel kann auch mit dieser Methode gelöst werdenaber die Funktion ist eher für das Ändern der Periode des Signals gedachtZusätzlich kann ein Counter so eingestellt werdendass er mit auf- oder absteigenden Werten arbeitet.
  
-The counters and the signal generating modes using them are one of the most complex peripheral modules in an AVR. Writing about all of them here would be a huge waste of time and typically there is no need to know everything in order to use themThe following describes one of the most common PWM signals in roboticsThe rest can be read from the AVR documentation.+Der Counter und die Signal-generierenden Modi die diese nutzten sind einer der komplexesten Peripheriemodule in einem AVR. Über jeden hier zu schreiben würde eine große Zeitverschwendung sein, normalerweise gibt es keinen Grund alles zu wissen, um sie zu nutzenDer folgende Absatz beschreibt einer der üblichen PWM Signale in den RoboticsDer Rest kann den AVR Dokumentationen entnommen werden.
  
 == Pulse Width Modulation == == Pulse Width Modulation ==
  
-Pulse width modulation (PWM) is a type of signalwhere the frequency and period (typicallyare both constantbut the length of the half-periods changes. PWM signals are used for controlling electromechanicaloptical and other devicesFor examplethe servo motors known from modeling use a PWM signal of 50 Hz and have a high half-period of to 2 ms.+Pulsweitenmodulation (PWM) ist ein Typ eines Signalswo die Frequenz und die Periode(normalerweisekonstant sindaber die Länge der Halb-Periode ändert sich. PWM Signale werden benutzt um elektromechanischeoptische und andere Geräte zu kontrollieren. 
 +Zum Beispielein Servomotor nutzt ein ein 50Hz PWM Signal und haben einen hohe Halbperiode von 2 ms.
  
 <box 100% round #EEEEEE|Example> <box 100% round #EEEEEE|Example>
  
-Taskusing an 8MHz ATmega128, generate two speed regulating servo motor signalsUse pin PB5 (OC1A) to generate a pulse width of 1 ms and pin PB6 (OC1B) to generate pulse width of 2 ms.+AufgabeGeneriere mit einem 8Mhz ATmega128, zwei Geschwindigkeits-regulierende Servomotor SignaleNutze Pin PB5 (OC1A) um eine Pulsweite von 1ms zu generieren und Pin PB6 (OC1B) um eine Pulsweite von 2ms zu generieren.
  
 <code c> <code c>
Line 738: Line 855:
 ===== USART ===== ===== USART =====
  
-USART is a universal synchronous serial interface, UART its simplified version universal asynchronous serial interfaceThe difference is, USART uses also a clock signal line to synchronize databut UART only uses data lines. AVR's USART allows the use of full duplex communication, 5- to 9-bit data words (8-bit word byte), 1 or stop bitsthree parity modes and a wide variety of baud rates. AVR microcontrollers typically have up to 2 USART interfacesalthough some may have no USART. Data transmission is performed one word at a time - AVR converts the word it got from the user to bits on the hardware level and transmits it independently and vice versaThe user controls USART by reading and writing configuration, status and data registers.+USART ist ein Universal Synchrones Serielles Interface, UART ist die vereinfachte Version Universelles Asynchrones InterfaceDer Unterschied zwischen beiden liegt darindass das USART auch eine Taktsignalleitung nutzt um Daten zu synchronisierenwährend das UART nur Datenleitungen benutztDas UART des AVR Mikrocontrollers Duplexverkehr, 5- bis 9-Bit Datenworte (8-Bit Wort 1 Byte), 1 oder Stop Bits3 Paritätsmodi und eine Vielzahl an Baud-Raten zulässt. AVR Mikrocontroller verfügen normalerweise über bis zu 2 USART Interfacesjedoch gibt es auch einige ohne USART. Datenübertragungen werden mit einen Wort für Wort ausgeführt der AVR konvertiert das Wort, welches er vom Benutzer bekommt in Bits auf Hardwareeinheiten und übermittelt es unabhängig und andersherumDer Benutzer kann das USART mit Schreib- und Lesekonfigurationen sowie Status- und Datenregistern kontrollieren.
  
-Every configuration option has corresponding registerswhich are quite easy to configure using the datasheetThe baud rate, though, is a bit more difficult to setClock signal for data transmission is generated from the controller's own clock and the user can specify a number from to 4096, by which the controller's clock cycle is dividedThe result is additionally divided by 2, 8 or 16, depending on the modeThe problem isnot all clock frequencies can be divided so that the result is a standard baud rate. With some frequenciesthe baud rate can differ from the standard by up to 10%. AVR datasheets contain tables with typical clock frequenciesbaud ratesthe needed multiplier to reach that baud rate and the possible calculation error.+Jede Einstellungsoption hat ein eigenes Registerwelches recht einfach anhand des Datenblatts konfiguriert werden kannDie Baud-Rate ist allerdings etwas schwieriger einzustellenDas Taktsignal für die Datenübertragung wird vom Taktgeber des Controllers generiert und der Nutzer kann eine Zahl von bis 4096 eingebendurch welche die Taktrate dividiert wirdDas Ergebnis wird darüber hinaus, je nach Modus, durch 2, 8 oder 16 dividiertDas Problem istdass nicht alle Taktfrequenzen so dividiert werden könnendass das Ergebnis eine Standard-Baud-Rate ergibt. Bei einigen Frequenzen kann die Baud-Rate bis zu 10% vom Standardwert abweichenDie Datenblätter des AVR beinhalten Tabellen mit Angaben zu den typischen TaktfrequenzenBaud-Ratenden nötigen Multiplikatoren um die Baud-Raten zu erreichen sowie den möglichen Rechenfehlern.
  
-Since data transmission takes place independently of the processor and much slowerit is necessary to confirm that the interface is ready for the next word before transmittingThis can be done by keeping an eye on the transmit buffer's ready bitwhich signifies if the buffer is ready to accept a new word or notThe controller starts with the ready bit enabledAs soon as a word is transmitted and the buffer is emptythe ready bit is brought high.+Da die Datenübertragung unabhängig vom Prozessor und viel langsamer geschiehtist es nötig zu bestätigen, dass das Interface für das nächste Wort bereit ist, bevor eine weitere Übertragung stattfindetDas kann gewährleistet werden, indem das Ready Bit des Sendepuffers beachtet wird, welches anzeigt ob der Puffer bereit istein neues Wort zu empfangen oder nichtDer Controller startet mit einen aktivierten Ready BitSobald ein Wort übertragen wird und der Puffer leer istwird das Ready Bit „high“ gesetzt.
  
-The arrival of a word is signified also by a special status bitIn addition to thatthere are status bits to signify framing errorsparity errors and receive buffer overflowsBuffer overflow can occurwhen the last word is yet to be read from the buffer while a new one arrives - this is why it is always important to read the incoming words to the program as soon as possiblefor example by using an interrupt for thatThere are three possible interrupt reasonstransmit buffer readytransmit successful and receive successful.+Der Empfang eines Wortes ist wird durch ein spezielles Status-Bit gekennzeichnetZusätzlich gibt es Status-Bitswelche RahmenfehlerParitätsfehler und Pufferüberläufe anzeigenEin Pufferüberlauf tritt aufwenn das letzte Wort noch aus dem Puffer gelesen werden musswährend ein neues ankommtAus diesem Grund ist es wichtig, die empfangenen Datenwörter stets so schnell wie möglich ins Programm zu lesen, z.B. mit Hilfe eines Interrupts. Es gibt drei mögliche Gründe für InterruptsSendepuffer bereit, Übertragung erfolgreichEmpfang erfolgreich.
  
-The transmit and receive buffers are physically separate registersbut share the same memory address and nameWhen writing to the shared register, the data is stored in the transmit buffer and when reading from itthe data is read from the receive bufferWhen using 9-bit wordsthe 9th bit is transmitted and read using one of the configuration registers.+Der Sende- und Empfangspuffer sind physikalisch getrennte Registeraber sie nutzen die gleiche Speicheradresse und den gleichen NamenWährend des Schreibens in ein gemeinsam benutztes Registerwerden die Daten im Sendepuffer gespeichert, beim Auslesen werden sie aus dem Empfangspuffer gelesenWerden 9-Bit Worte benutztwird das 9. Bit mit Hilfe eines Einstellungsregister übertragen und ausgelesen.
  
-~~PB~~ 
  
-<box 100% round #EEEEEE|Example>+<pagebreak> 
 + 
 +<box 100% round #EEEEEE|Beispiel>
  
-TaskConfigure an 8 MHz ATmega128's USART0 interface to transmit 8-bit words asynchronously using 9600 bps baud rate, 1 stop bit and no parity bitsSend the symbol "X".+AufgabeKonfigurieren Sie die USART0 Schnittstelle eines 8 MHz ATmega128 so, dass sie ein 8-Bit-Wort asynchron überträgt, wobei die Baudrate 9600 bps beträgt, 1 Stoppbit und kein Paritätsbit genutzt werden sollSenden Sie das Symbol “X.
  
 <code c> <code c>
Line 759: Line 877:
 int main() int main()
 { {
- // Set baud rate to 9600 bps. Formula+ // Setzt die Baud-Rate auf 9600 bps. Formel
- //   multiplier clock frequency / 16 / baud rate - 1+ //   Faktor Frequenz / 16 / Baudrate -1
  //   UBRR = 8000000 / 16 / 9600 - 1 = ~51  //   UBRR = 8000000 / 16 / 9600 - 1 = ~51
  UBRR0H = 0;  UBRR0H = 0;
  UBRR0L = 51;  UBRR0L = 51;
  
- // Allow transmitting+ // Erlaube Senden
  UCSR0B = (1 << TXEN0);  UCSR0B = (1 << TXEN0);
  
- // Configure asynchronous modeset the word size to bits + // Konfiguriere den asynchronen Modussetze die Wortgröße auf Bit, 
- // 1 stop bitno parity bits.+ // 1 Stoppbitkein Paritätsbit.
  UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);  UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
  
- // Wait for the data buffer to empty (previous word to transmit+ // Warte solange, bis der Datenpuffer leer ist (das vorherige Wort wurde gesendet
- // In this example there is no need to waitas the first symbol is yet + // In diesem Beispiel ist es jedoch nicht nötig zu wartenda nur das erste Symbol  
-        // to be sentbut it should be done when transmitting more symbols.+        // gesendet wird. Es sollte jedoch beachtet werdenwenn mehr als ein Symbol gesendet wird.
  while (!(UCSR0A & (1 << UDRE))) continue;  while (!(UCSR0A & (1 << UDRE))) continue;
  
- // Write the symbol to the buffer for transmitting+ // Schreibe das Symbol in den Sendepuffer.
  UDR0 = 'X';  UDR0 = 'X';
   
- // Endless loop+ // Endlosschleife
  while (1) continue;  while (1) continue;
 } }
Line 786: Line 904:
  
 </box> </box>
-====== Electronics ======+====== Robotic HomeLab Kit ======
  
-{{:images:book:ohms_law.png?580|}}+{{:kit:kodulaboridjarobotid.jpg?580|}} 
 +     
 +Das auf dem ATmega128 Mikrocontroller basierende Mechatronik und Robotik HomeLab ist eine Zusammenstellung von Modulen in einem tragbaren Koffer. Es ermöglicht die Durchführung diverser Mechatronik- und Robotikexperimente und –übungen, angefangen bei einem Blinklicht bis hin zur Erstellung komplexer Geräte. In erster Linie richtet sich das HomeLab an Schulen, da es zusätzlich zur Hardware methodologisches Material sowie Übungen mit Musterlösungen enthält. Das HomeLab wurde in eine Web-Umgebung integriert, welche Schülern und Lehrern die gegenseitige Interaktion ermöglichen soll. Kurz gefasst ist das HomeLab kit eine Sammlung mobiler Werkzeuge mit dem Zweck zu Hause, in der Schule oder am Arbeitsplatz lernen und üben zu können.
  
-Some electronic circuits in practical examples are so commonthat they are separately described in the following chaptersIt's important to learn them as they ease understanding the examplesThey will most probably help building your own circuits too.+Das HomeLab kit wurde von der Tallinn University of Technology sowie estnischen Unternehmen in Kooperation mit europäischen Partneruniversitäten und der Unterstützung des Leonardo da Vinci Programms entwickelt. Die HomeLab Module sind zu verschiedenen Bausätzen zusammengestellt. Die Grundausstattungwelche zum Erlernen einfacher digitaler In- und Output-Operationen dient, nennt sich HomeLab Basic kitDer Sensoren und Bedienteil Ergänzungsbausatz besteht aus einer Zusammenstellung von Sensoren, Motoren sowie deren TreibernDas Advanced kit enthält sowohl das HomeLab Basic kit sowie das Sensors and Actuators Add-on kit und darüber hinaus zusätzliche Module.
  
-===== Ohm's law =====+Die HomeLab Basic und Advanced kits eignen sich zur Durchführung von Experimenten, als Basisplattform für Roboter sowie andere mechatronische Regeltechniken. Das HomeLab wird ständig weiterentwickelt, daher lohnt es sich, regelmäßig nachzuschauen, ob neue Übungsaufgaben oder Modul-Updates veröffentlicht wurden. Darüber hinaus ist es lohnenswert, die Versionsnummern der Module zu überprüfen, da einige Übungsaufgaben und Beispiele in neueren Versionen verfügbar sind. Die Nutzung von DistanceLab erhöht den Nuten von HomeLab maßgeblich. DistanceLab ermöglicht es, die HomeLab Hardware über das Internet zu betreiben.
  
-Ohm's law states that the current through a conductor between two points is directly proportional to the potential difference  or voltage  across the two points, and inversely proportional to the resistance between them, provided that the temperature remains constant.+HomeLab Webseite\\ 
 +http://home.roboticlab.eu
  
-The equation is as follows: +DistanceLab Webseite\\ 
-[{{  :images:electronics:ohms_law:resistor_circuit.png?180|Resistance of the conductor, applied voltage and current through the resistance}}]+http://distance.roboticlab.eu
  
-I = U / R 
  
-where: 
  
-  * I is current +===== Ganzheitliches Konzept der Robotik =====
-  * U is voltage +
-  * R is resistance+
  
 +Die Ingenieurausbildung kann sich heutzutage nicht mehr auf einer bestimmten Lehrmethode aufbauen, wie zum Beispiel klassische universitäre Vorlesungen und Übungen. Lernende sind heute nicht mehr mit zeitlich festgelegten Vorlesungen und Übungen zufrieden. Viele junge Leute, aber auch Erwachsene, leben ein Leben in einer modernen Informationsgesellschaft, in welchem Sie viel Zeit im Internet verbringen. Daher bestätigen die klassischen Lernmethoden die Lernenden und ihre Art zu Lernen heute nicht mehr. Aufgrund dessen müssen die Ingenieursausbildungen in eine Internetumgebung gebracht und dadurch attraktiver werden, ohne jedoch die Qualität und die praktische Erfahrung zu verlieren.
 +The integrated concept of robotic and mechatronic study incorporates the standard teaching and studying aids and novel approaches, which are integrated into one methodical unit.
  
-Several other equations are derived from Ohm's law which are used most often in electronics. +Das ganzheitliche Konzept der Robotik und Mechatronik beinhaltet sowohl standardisierte Lehrmethoden und Lernhilfen, als auch neue Ansätze, welche in einer systematischen Einheit untergebracht sind.
-===== LED resistor calculation =====+
  
-If the supply voltage is higher than LEDs voltage the resistor have to be included into the circuit in series.  The resistor limits the current and produces the required voltage drop. To find the correct value for the resistor the following equation is derived from Ohm's law: +Das folgende Beispiel kann Schulen helfen Kurse zur Robotik zu starten oder einen Denkanstoß zu gebenwie man verschiedene Lernkonzepte in einer praktische Lerneinheit in diesem technologischen Feld anwendet.
- +
-[{{  :images:electronics:led_resistor:led_resistor_schematics.png?180|LED with series resistor}}] +
- +
-R = (U<sub>in</sub> - U<sub>f</sub>) / I<sub>f</sub>\\ +
-U<sub>r</sub> = U<sub>in</sub> - U<sub>f</sub>\\ +
-P<sub>r</sub> = U<sub>r</sub> ⋅ I<sub>f</sub>\\ +
- +
-where: +
- +
-  * R is resistor. +
-  * U<sub>in</sub> is supply voltage. +
-  * U<sub>f</sub> is LED voltage. +
-  * I<sub>f</sub> is LED current. +
-  * U<sub>r</sub> is voltage drop on the resistor. +
-  * P<sub>r</sub> is power of the resistor that is transformed to the heat. +
- +
-The current limiting resistor of a LED has to be not smaller than R and at least with the power of P<sub>r</sub>+
-===== Voltage divider ===== +
- +
-Voltage divider is an electrical circuit which divides the input voltage. The output voltage is a portion of an input voltage and the value of the output is dependent of the resistors ratio in the circuit. The schematics on the right includes two resistor. +
- +
-The output of the circuit is calculated by the following equation: +
- +
-[{{  :images:electronics:voltage_divider:voltage_divider_schematics.png?180|Electrical schematics of the voltage divider}}] +
- +
-U<sub>2</sub> = U<sub>1</sub> ⋅ (R<sub>2</sub> / (R<sub>1</sub> + R<sub>2</sub>)) +
- +
-where: +
- +
-  * U<sub>1</sub> is input voltage +
-  * U<sub>2</sub> is output voltage +
-  * R<sub>1</sub> and R<sub>2</sub> are resistors +
- +
-The equation is derived from Ohm's law  +
- +
-where: +
- +
-I = U<sub>1</sub> / (R<sub>1</sub> + R<sub>2</sub>+
- +
-and: +
- +
-U<sub>2</sub> = I ⋅ R<sub>2</sub> +
- +
-Voltage divider is very often used together with resistive sensors (photo resistorthermistor etc.) where one of the resistors is replaced by the resistive sensor. In this way the change of the resistance of the sensor is easily transformed to the voltage change which is compatible with microcontrollers analogous input. +
-====== Robotic & Mechatronic HomeLab ====== +
- +
-{{:kit:kodulaboridjarobotid.jpg?580|}} +
- +
-Mechatronics and Robotics HomeLab is ATmega128 microcontroller based inter-related set of modules that are completed to a portable case. Various mechatronic and robotic experiments and exercises can be carried out with HomeLab kit, ranging from a simple flashing light to a complex device construction. HomeLab is primarily intended for schools, as it includes methodological materials and exercises with solutions in addition to hardware. HomeLab has been integrated into web environment, which is aimed for students and teachers to boost interaction between each other. In short, the HomeLab kit is a mobile tools suite with the purpose of learning and practicing at home, school or workplace. +
- +
-HomeLab kit has been developed by Tallinn University of Technology and the Estonian company's cooperation with the European partner universities and Leonardo da Vinci program support. HomeLab modules are bundled into different kits. The basic suite, which teaches simple digital input and output operations, is called the HomeLab Basic kit. Sensors and Actuators Add-on kit contains set of sensors and motors and its drivers. Advanced kit includes both HomeLab Basic kit, Sensors and Actuators Add-on kit, as well as additional modules. +
- +
-HomeLab Advanced and Basic kit can be successfully used in experiments, as robot base platform and other mechatronics control systems. HomeLab versions are constantly evolving and,therefore every now and then please check whether new exercises have been published or module updates have been released. It is also worthwhile to check the version numbers of modules, some of the exercises and examples can be drawn up in the newer versions. Significant value to HomeLab is added by DistanceLab. DistanceLab allows HomeLab hardware platform to be used through the web. +
- +
-HomeLab webpage\\ +
-http://home.roboticlab.eu +
- +
-DistanceLab webpage\\ +
-http://distance.roboticlab.eu +
-===== Integrated Concept of Robotic Studies ===== +
- +
-Today's engineering studies cannot rely only on one specific teaching method any more - such as classical university lecture-practicum. Today's learner is not satisfay with fixed time lectures and labs. Most young people (and also grown-ups) are living solid information society era life, by spending much of the time on Internet. This means that classical study methods do not confirm the learners way of studing any more. Based on that, the engineering studies needs to be brought into Internet environment and made more attractive, but without losing the quality and practical hands-on experience. +
- +
-The integrated concept of robotic and mechatronic study incorporates the standard teaching and studying aids and novel approaches, which are integrated into one methodical unit.+
  
-The following example can help schools to initiate the robotic studies or give an idea how to apply different studying concepts into practical learning in the technology field.+Das Konzept beinhaltet die folgenden Lehr- und Lernhilfsmittel:
  
-The concept includes the following teaching and studying aids: +  Koventionelles Lehrbuchz.BIntegrated Systems & Design“ ISBN: 978-9985-59-850-4. 
-  Conventional textbooke.g"Integrated Systems & DesignISBN:978-9985-59-850-4. +  * Praktisches Übungsbuch 
-  * Practical Hands-On Exercise book. +  * Robotic HomeLab 
-  * Robotic HomeLab. +  * DistanceLab 
-  * DistanceLab. +  * Das Kompetenznetzwerk der Robotik- und Mechatronikgemeinschaft http://www.roboticlab.eu.
-  * The Network of Excellence of Robotic and Mechatronic community http://www.roboticlab.eu.+
  
-Theoretical study aids are conventional textbooks and exercise books which can be accessed in addition to paper version also electronically.+Theoretische Lernhilfsmittel sind das konventionelle Lehrbuch und das Übungsbuch, welches zusätzlich zur Papierversion auf elektronisch erhältlich ist.
  
-Practical part consists of Robotic HomeLab and DistanceLab - over the Internet robot programming environment. HomeLab, combined with DistanceLab forms a solid solutionmeaning that the learner can practice the single functions of robotics (i.esensor readingsmotor control etc.) from home and at the same time apply his/her acquired knowledge on the robotic systemThe robotic system can be accessed over the DistanceLab solution which consists of real equipmentThe system is built up from the same components included in the HomeLab mobile case. This way the user can test each single learned skill immediately on the bigger system. The feedback of the robotic system is provided over the video stream.+Der praktische Teil besteht aus dem Robotic HomeLab und dem DistanceLab, einer internetbasierten Programmierumgebung für RoboterDas HomeLab bildet zusammen mit dem DistanceLab eine kompakte Lösungwas bedeutet, dass der Lernende auch einzelne Funtionen der Robotik (z.BSensormesswerte, Motorsteuerung, etc.) von zuhause aus ausprobieren und gleichzeitig sein erlerntes Wissen im Robotersystem anwenden kannDas Robotersystem kann über das DistanceLab erreicht werden, welches aus realen Geräten bestehtDas System selbst ist aus denselben Komponenten zusammengestellt, wie sie auch im mobilen HomeLab-Koffer enthalten sind.
  
-The sequence of one study process/labwork is described on the next picture.+Der Ablauf von einem Lernprozess bzw. der Arbeit mit dem Lab ist auf dem nächsten Bild beschrieben.
  
 {{  :method:metoodika_en.png?580  |}} {{  :method:metoodika_en.png?580  |}}
  
-The topic begins with introduction which can be a classical lecturedistance online lecture or video lectureThe recorded video lecture is important also on the conventional lecture case as this enables to re-watch the lecture in case of something left unclear or in case the student wasn't able to participate in the lecture. The introduction lecture gives an overview of the problem and along with the teacher the practical example can be gone through supported by teachers commentsThe theoretical part is supported by the textbook and hand-on exercise book.+Das Thema beginnt mit einer Einführungwelche eine klassische Vorlesung, eine Onlinevorlesung oder eine Videovorlesung sein kannDie Videovorlesungen sind auch für die klassischen Vorlesungen wichtig, da sie die Möglichkeit bieten eine Vorlesung erneut zu sehen, sollte etwas unklar geblieben oder der Studierende nicht in der Lage gewesen sein, an der Vorlesung teil zu nehmen. Die Einführungsvorlesung gibt eine Übersicht über das jeweilige Problem und mit Hilfe eines Lehrers kann dann ein praktisches Beispiel durchgegangen werdenDer theoretische Teil wird durch das Lehrbuch und das praktische Übungsbuch unterstützt.
  
-After the introduction lecture the individual practical work is carried outPractical work is about running the example code solution in the beginning and later modifying the example case according to the first "Warm-up" exerciseThis is followed by the more complex exercise which is assigned by the teacher for every person or team individually from "Exercise" pages of each topic. The practical work is carried out with the HomeLab or other robotic kit which is supported by the exercises and DistanceLab. An important role is played here by the Network of Excellence environment which supports individual studies providing the communication environment and help for the learners and teachers.+Nach der Einführungsvorlesung wird der praktische Arbeitsteil realisiertDie Praktische Arbeit besteht anfangs darin, die Codebeispiele auszuführen und später darin, die Beispiele entsprechend der Übung zu verändernDaraufhin folgen komplexere Übungen, welche durch einen Lehrer jeder Person oder jedem Team individuell aus dem Übungsbuch zugeteilt werden.
  
-The results of practical work are concluded in the report and this is sent to the supervisorIf the e-environment supports automatic report uploadingit can be used instead of sending e-mailIn addition to text report the working machine code HEX file is also includedThe report includes typically the description of the work and full, clearly commented source code of the solution+Die Ergebnisse der praktischen Arbeit werden in einem Bericht zusammengefasst und dem Betreuer zugeschicktFalls die Entwicklungsumgebung eine automatische Berichterstattung unterstütztso kann diese anstatt dem Senden einer Email genutzt werdenZusätzlich zu den Textberichten wird außerdem die HEX-Datei für die Arbeitsmaschine eingebundenDer Bericht umfasst typischerweise die Beschreibung der Arbeit und einen vollständig kommentierten Quellcode der Lösung
-===== Teaching the robotics =====+===== Robotik unterrichten =====
  
-It is well-known that ICT has entered into everyday life for many people and changed the way of studying and communication channelsFor many young people it is very likely to get most of the information about the course material from different communication channels on the internetBefore trying to solve a problemfirstly a quick search is done to find possible solution, examples or background information As the everyday communication is partly moved into several social networks on the Internet it is quite natural that the methodology performed by the schools have to follow the same trend and find the way to reach the students in their everyday environmentOf course it is not the total replacement for the traditional teaching methodsbut relying only on those is not enough any more.+Es ist allseits bekannt, dass die Informationsund Telekommunikationstechnologie (ICT) in das tägliche Leben von vielen Menschen eingetreten ist und die Art und Weise des Lernens und der Kommunikation verändert hatViele junge Leute sind es gewohnt Informationen über das Kursmaterial über verschiedene Kommunikationswege aus dem Internet zu bekommenBevor versucht wird ein Problem zu lösen wird erst eine schnelle Suche nach möglichen LösungenBeispielen oder Hintergrundinformationen durchgeführtDa die tägliche Kommunikation teilweise in soziale Netzwerke verlagert wurde, ist es nur natürlich, dass die Methodik, welche von den Schulen angewandt wird auch diesem Trend folgen muss, um die Studierenden in ihrem täglichen Umfeld zu erreichenNatürlich wird die traditionelle Lehrmethodik nicht komplett ersetztaber sich nur auf diese zu verlassen ist heutzutage nicht mehr genug.
  
-Robotics and Mechatronics are fields of the futurewhere following the newest trends and technologies are especially importantAt the same time the fields are very practical and lots of hands-on experience is needed to acquire the skills and knowledgeEven several virtual simulations can be performed for studying the system behaviorHowever the virtual simulations do not replace the hands-on experience of using the real hardware.  +Robotik und Mechatronik sind sehr zukunftsreiche Gebietein denen es sehr wichtig ist den neuesten Trends und Technologien zu folgenGleichzeitig sind diese Gebiete sehr praktisch veranlagt und es verlangt viel manuelle Erfahrung Fähigkeiten und Wissen zu erlangenSelbst verschiedene virtuelle Simulationen können durchgeführt werden um das Systemverhalten zu verstehenTrotzdem ersetzten die virtuellen Simulationen nicht die praktische Erfahrung mit echter Hardware
-The following is a practical guide how to implement a robotic course where different studying approached are appliedThe methodology expect that the teacher can use practical HomeLab kit.+Das Folgende ist eine praktische Anleitung wie ein Robotikkurs eingeführt werden kann, in dem verschiedene Lehransätze genutzt werdenDie Methodik erwartet, dass der Lehrer das HomeLab kit benutzen kann.
  
-Issues to conciser, when starting a new course .....+Aspekte die bei der Erstellung eines neuen Kursen berücksichtigt werden müssen:
  
-  - **Team size** \\ +  - **Gruppengröße** \\ 
-    Optimal number of team members is largely set by limits of using a computer workplaceThis means that usually no more than persons fits to work together with one computer workplaceIf more persons have to work with the same place they might not be able to participate actively and will lose the focus on the work.  +    Die optimale Anzahl der Teammitglieder ist weitgehend durch die Anzahl der Computer Arbeitsplätze begrenztDas bedeutet, dass normalerweise nicht mehr als Personen zusammen an einem Arbeitsplatz arbeiten könnenWenn mehr Personen an einem Arbeitsplatz arbeiten müssen könnte es sein, dass sie nicht in der Lage sind aktiv an der Arbeit teilzunehmen und somit die Konzentration auf die Arbeit verloren geht.  
-  - **Practical work and reporting** \\ +  - **Praktische Arbeit und Berichterstattung** \\ 
-    Practical work is divided into labs where every lab has similar structure but different skills are trained. Every lab ends with a report. It is also possible to divide the work within the groupe.g one is responsible for creating the source code another is responsible for writing the report or connecting the hardware. In addition to commented source code the report should also include the algorithmdescription of the work, answers to the questions, hardware connection schemapros and cons of the labThe last one is a good feedback for the teacher to investigate the level of difficulty of the labhow interesting the lab waswhat was learned etc.  \\ It is important to start the example coding together with a teacher who can comment the background of the functions and solve the example on the screenWhole process should be written down step-by-step to ensure that all learners are able to follow the process even if they proceed at different speedOne possible lab process structure is described as followsbut can vary according to the specific situation and needs: +    Die Praktische Arbeit ist unterteilt in Übungseinheiten, wobei jede Übung eine ähnliche Struktur besitzt und mit einem Bericht endetjedoch unterschiedliche Fähigkeiten trainiertEs ist außerdem möglich die Arbeit innerhalb der Gruppe aufzuteilenso dass zum Beispiel ein Mitglied für die Erstellung des Quellcodesein anderes Mitglied für die Erstellung des Berichts und ein Mitglied für das Anschließen der Hardware verantwortlich istZusätzlich zu dem kommentierten Quellcode sollte der Bericht auch AlgorithmenBeschreibungen der ArbeitAntworten auf die gestellten Fragen, ein Schema der Hardwareverbindungen und Vor- und Nachteilbeurteilungen der Übung enthalten. Der letzte Punkt ist ein gutes Feedback für den Lehrenden um den Schwierigkeitsgrad der Übung einzuschätzen und wie interessant die Übung für die Lernenden war.  \\ Es ist wichtig, dass man die Beispiele zusammen mit einem Betreuer implementiert, da dieser Hintergrundinformationen zu den Funktionen bieten und die Beispiele lösen kannDie ganze Vorgehensweise sollte schriftlich Schritt für Schritt festgehalten werden, damit jeder Lernende folgen kann und so sicher gegangen werden kann, dass alle Teilnehmer den Ablauf verstanden haben, auch wenn sie in unterschiedlichen Geschwindigkeiten voran kommenEine mögliche Übungsablaufstruktur ist im Folgenden beschriebenkann jedoch je nach Situation und Bedürfnissen angepasst werden. 
-    * Lab introduction +    * Einführung in die Übung 
-      * The teacher explains the new labgoing through the all necessary theoretical material and the example program is performed together.  +      * Der Lehrer erklärt die neue Übunggeht alle nötigen theoretischen Inhalte durch und führt zusammen mit dem Teilnehmern ein Beispielprogramm aus
-      * The lab is divided into small stages so that every stage consists of theoretical part and source code developmentIt means that the source code is developed together with theoretical explanations+      * Die Übungseinheit ist in kleinere Teile unterteilt, wobei jeder Teil aus einem theoretischen und einem praktischen Teil besteht, in welchem dann Quellcode entwickelt werden sollDas bedeutet, dass der Quellcode anhand von theoretischen Erklärungen entwickelt wird
-    * Individual workThis is performed according to the lab working guide where the aimwork processrequirements and reporting are definedLearners are working individually (personally or as a small teamand can get the support from the teacher if neededThe aim of the individual work is that the learners will find the solution by themselvesIf possible it is recommended that learners can take the HomeLab kit home to perform the individual workIn that case they are not fixed with the lab time frame and place.  +    * Individuelle ArbeitDie individuelle Arbeit erfolgt gemäß den Arbeitsanweisungen der Übungseinheit. Hier sind ZieleArbeitsprozesseAnforderungen und die Berichterstattung definiertDie Schüler lernen selbstständig (entweder alleine oder in einer kleinen Gruppeund erhalten, wenn nötig, Unterstützung von ihren LehrernZiel des eigenständigen Arbeitns ist jedoch, die Lösung selbstständig zu findenWenn möglich, sollten die Schüler das HomeLab kit mit nach Hause nehmen können, um so auch dort arbeiten zu könnenSo sind sie nicht an den Zeitrahmen und Ort der Übung gebunden.  
-    * ReportingLearners have to compile a report where they can describe the work according to reporting requirements and as well as answer to team-specific questions assigned by the teacherReport together with a working solution (HEX filehave to be sent to the teacher by e-mail or uploaded to e-learning system+    * BerichteLernende müssen einen Bericht verfassen, in welchem sie ihre Arbeit gemä´den Anforderungen an einen Bericht beschreiben und welcher Antworten auf Fragen des Lehrers an die Gruppe gibtDer Bericht sowie die Lösung der Aufgabe (HEX-Dateisollen dem Lehrer per E-Mail zugeschickt oder in den E-Learning Bereich hochgeladen werden
-    * Inspection +    * Überprüfung 
-      * The teacher checks the report and the working file sent by the team. The result evaluation is made according to the quality of the report and working solution.  +      * Der Lehrer überprüft und bewertet den Bericht sowie die erarbeitete Lösung jeder Gruppe qualitativ.  
-      * The teacher can check whether the solution works according to the lab requirements and can also ask to comment the program orally where each team member has to explain one part of the report+      * Er kann überprüfen, ob die Lösung entsprechend der Übungsvoraussetzungen funktioniert und darüber hinaus von den Schülern verlangen, das Programm mündlich zu erläutern. In diesem Fall sollte jedes Gruppenmitglied einen Teil des Berichtes erklären
-  - ** Group management ** \\ +  - ** Gruppenmanagement ** \\ 
-    While doing lab work in a classroom it often happens that one team is performing slower from the others and thus taking up most of the teachers efforts in follow-up the lessonSimilar case is when one team is getting things done faster from others and gets bored while waiting for a new exerciseBoth problems can be minimized if the working process is well defined and the lab guide is provided to the team membersThis way the team can perform the work without waiting for the next step from teacher but can simply follow the guideIn addition different levels of exercises are provided in the end of every lab and the teacher can assign the exercises according to the team skills and progress+    Bei der Durchführung von Übungen in einem Klassenraum kommt es häufig vor, dass eine GRuppe langsamer arbeitet als die anderen und somit stärker vom Lehrer unterstützt werden muss, um nicht hinterherzuhängenÄhnlich ist es, wenn eine Gruppe schneller arbeitet als alle anderen und somit auf die nächste Aufgabe warten mussBeide Probleme können minimiert werden, wenn der Arbeitsprozess für alle offensichtlich dargestellt ist und jeder einzelne die vollständigen Übungsanweisungen zu Beginn der Übung erhältSo kann die Gruppe arbeiten, ohne auf die nächstesn Anweisungen des Lehrers warten zu müssen, indem sie einfach den Anweisungen folgtDarüber hinaus enthält jeder Übungsabschnitt am Ende Aufgaben in verschiedenen Schwierigkeitsgraden, die der Lehrer je nach Fortschritt und Fähigkeiten der Gruppe verteilen kann.  
-  - **Evaluation** \\ +  - **Bewertung** \\ 
-    If the the ultimate target is to ensure that all team members have acquired the programming skillsthe teacher can arrange the team work in a way that all members can perform the programming work and the explanationAnother possibility is for the teacher to pick randomly the member who has to comment the codeeven if it is not directly written by this particular memberThe final result is assigned for the whole team according to the result of the weakest memberIf this kind of evaluation seems unfair an individual reporting inside the team can also be done.  +    Soll letztendlich sicher gestellt werdendass alle Teilnehmer die vorgestellten Programmierfähigkeiten erlernt haben, so kann der Leherer die Gruppenarbeit derart gestalten, dass jedes Gruppenmitglied selbst programmieren und dieses auch präsentieren mussEine andere Möglichkeit wäredass der Lehrer zufällig ein Mitglied der Gruppe auswählt, welches dann das Programm vorstellen mussAuch wenn diese Person den Code vielleicht nicht persönlich geschrieben hatDas Endergebnis wird dann für die gesamte Gruppe gezählt, ausgehend vom Schwächsten Mitglied. Sollte diese Art der Bewertung ungerecht wirken, kann auch innerhalb der Gruppe eine individuelle Berichterstattung durchgeführt werden
-  - **Debugging** \\ +  - **Fehlerbehebung** \\ 
-    Quite often similar mistakes are done by the learners when handling the hardware or doing the programming workIt is very reasonable to compose the so called frequently asked question FAQ section into the webpage to prevent waisting the learners time in solving some common mistakes and problemsThe FAQ along with solutions should be maintained by the HomeLab support website+    Die Schüler machen im Umgang mit der Hardware oder beim Programmieren häufig ähnliche FehlerDaher ist es sinnvoll, auf der Webseite einen Bereich für häufig gestellte Fragen (FAQ - Frequently Asked Questions) einzurichtenSo können die Lernenden Zeit sparen, da sie bei häufig auftretenden Fragen oder Problemen schnell Hilfe finden. Der FAQ-Bereich sollte zusammen mit den Lösungen im Support-Bereich der HomeLab Webseite verfügbar sein.  
-  - **Competition** \\ +  - **Wettbewerb** \\ 
-    One common way to rise the motivation in a robotics studies is to connect the practical work with some sort of competitionwhere teams have to develop a solution to a given problem which in the end is evaluated together It is important to publish the measurable criteria (timespeeddistance etc.) to evaluate the final solutionAlso secondary criteria can be proposed to evaluate the outlookinventivenesscost efficiency etcof the solutionthe task can be also connected to some real-life problem e.g. battery sorter projectsecurity system. Most often the hobby robotic tasks such as mobile robotic for following the linesumo robotsball games etc. are taken.+    Zur Steigerung der Begeisterung für Robotik-Studien kann die praktische Arbeit mit einer Art Wettbewerb verbunden werden. Die Gruppen müssen zu einem gegebenen Problem eine Lösung erarbeitenwelche anschließend gemeinsam bewertet wirdDie Beurteilungskriterien (ZeitGeschwindigkeit, Entfernung, etc.) müssen klar definiert und bekannt gegeben werdenDarüber hinaus können weitere Kriterien herangezogen werden um die Ansichtden Erfindungsreichtungdie Kosteneffizenz und weitere Aspekte der Lösung zu bewertenDie Aufgabe kann darüber hinaus auch mit Problemstellungen des täglichen Lebens verbunden werden wie zum Beispiel ein Projekt zu Batteriesortierern oder SicherheitssystemenMeistens werden Aufgaben aus der Hobbyrobotk oder der mobilen Robotik gestelltwie beispielsweise ein Roboterder einer Linie folgen sollSumoroboter, Ballspiele etc. 
  
-~~PB~~+<pagebreak>
  
-The following example is a typical lab guide which can be used for practical labs.+Das folgende Beispiel veranschaulicht eine typische Übungsanweisung, die für praktische Übungen verwendet werden kann.
  
-<box 100% round #EEEEFF|Lab Nr 3. Sensors and analog-digital converter+<box 100% round #EEEEFF|Lab Nr 3. Sensoren und Analog-Digital Konverter
  
-**Supervisor**: Raivo Sell+**Leiter**: Sven Seiler
  
-**The Aim**+**Das Ziel**
  
-To get familiar with analog-digital converter basics and converting the analog signals by using the AVR ATmega128 8-bit microcontrollerTo study different sensors with analog output. To perform a simple analog sensor lab.+  Grundlagen über Analog-Digital-Konverter und das Konvertieren analoger Signale mit dem AVR ATmega128 8-Bit Mikrocontroller. 
 +  - Verschiedenen Sensoren mit analogem Output kennenlernen 
 +  - Eine einfache Übung mit einem analogen Sensor durchführen.
  
-**Needed equipment**+**Benötigte Ausrüstung**
  
-HomeLab Basic kit, Sensor and Motor Add-On kit, AVR programming software.+HomeLab Basic kit, Sensor and Motor Add-On kit, AVR Programmiersoftware.
  
-**Working guide**+**Arbeitsanweisungem**
  
-  - Perform the example exercise with the potentiometer. \\ http://home.roboticlab.eu/en/examples/sensor/potentiometer +  - Führen Sie die Übung mit dem Potentiometer durch. \\ http://home.roboticlab.eu/en/examples/sensor/potentiometer 
-  - Perform the common "Warm-up" exercise. \\ http://home.roboticlab.eu/en/exercises/sensor +  - Führen Sie die allgemeine Aufwärmübung durch. \\ http://home.roboticlab.eu/en/exercises/sensor 
-  - Perform the team specific exercise. (the exercise will be assigned by the supervisor right before the work+  - Absolvieren Sie die gruppenspezifische Aufgabe. (diese wird rechtzeitig vom Übungsleiter bekannt gegeben
-  - answer the questions (team specific questions are assigned by the supervisor right before the work)+  - Beantworten Sie die Fragen (gruppenspezifische Fragen werden rechtzeitig vom Übungsleiter bekannt gegeben)
  
-**Report**+**Bericht**
  
-The electronic report has to be submitted after the individual work and needs to consist the following structure. +Der elektronische Bericht muss nach der eigenständigen Arbeit eingereicht werden und folgende Struktur aufweisen: 
-  * Report of the work +  * Arbeitsbericht 
-    * The aim +    * Das Ziel 
-    * Short description of performed work +    * Kurze Beschreibung der durchgeführten Arbeit 
-    * The algorithm and commented source code out print for steps and 3. \\  NBsource code has to be commented and color coded ("Programmer's Notepad" may be used to get the color code to MS Word or OpenOffice writer). +    * Ausdruck des Algorithmus und Quellcodes für die Schritte und 3. \\  AchtungDer Quellcode muss kommentiert und farbig gekennzeichnet sein(um das Farbsystem korrekt in MS Word oder einem OpenOffice Programm darzustellen könnte das "Programmer's Notepad" genutzt werden
-    * Answer to the question (step 4+    * Anworten auf die Fragen (Schritt4
-    * Results and Comments +    * Ergebnisse und Kommentare 
-  * Working solutions (HEX filesof steps and 3+  * Lösungen (HEX-Dateienvon Schritt und 3
  
-The report has to contain the namelab numberdate and team members (if it is teamwork). The report has to be short but conciseThe quality is evaluatednot the quantity! Be ready to demonstrate the solution or comment the source codeThe report has to be uploaded into e-learning systems assignment sectionThe deadline of the report is one week after starting the lab.+Der Bericht muss den eigenen Namendie Nummer des Übungsabschnittsdas Datum sowie die Namen der Gruppenmitglieder (bei einer GruppenarbeitenthaltenEr sollte kurz und präzise verfasst sein wobei die Qualität wichtig ist, nicht die QuantitätSie sollten darauf vorbereitet seindie Lösung zu präsentieren oder den Quellcode zu kommentierenDer Bereicht muss in den Bereich für Hausarbeiten des E-Learning Systems hochgeladen werdenDer letzte Abgabetermin für den Bericht ist eine Woche nach Beginn der Übung.
  
-**Readings** +**Lektüren** 
-  - HomeLab support center: http://home.roboticlab.eu +  - HomeLab Support-Center: http://home.roboticlab.eu 
-  - ATmega128 datasheet +  - ATmega128 Datenblatt 
-  - Sharp infrared sensor datasheet+  - Sharp Infrarotsensor Datenblatt
   - http://www.avrfreaks.net   - http://www.avrfreaks.net
 </box> </box>
-===== HomeLab hardware =====+===== HomeLab Hardware =====
  
-The modules of Robotic HomeLab are divided into different kits, allowing to select the best option for the needs of a student or a schoolThe simplest set is HomeLab Basic Kit including the base components to carry out the basic microcontroller experimentIn addition to microcontroller the kit consists of Digital i/o module with LCD displayTogether with Basic Kit the Motor and Sensor Add-on Kit can be used, which includes different types of motors and sensors together with accessories. Sensor and motor Add-On Kit cannot be used separately from Basic Kit as microcontroller is not included in the Add-On kitHomeLab Advanced Kit includes all modules and components from Basic Kit and Add-On Kit and in addition the RFID, Communication and Machine Vision modulesHomeLab Advanced Kit is more targeted to teachers. For the students Basic Kit together with Add-On Kit is much more convenient to use and carry on to home or working place.+Die Module des Robotik HomeLab sind in unterschiedliche Bausätze („kits“) eingeteiltum so die am besten geeignete Ausstattung für die Bedürfnisse eines Studenten oder einer Schule auswählen zu könnenDas einfachste Set ist das HomeLab Basic kit, welches die für grundlegende Mikrocontrollerexperimente notwendigen Komponenten enthältDarüber hinaus verfügt es über eine Anwendungsoberfläche mit LCD DisplayDas Basic kit kann zusammen mit dem Motor and Sensor Add-On kit verwendet werdenLetzteres beinhaltet verschiedene Arten von Motoren und Sensoren sowie zusätzliches Zubehör und Kommunikationsmodule. Das Sensor and Motor Add-On kit kann nicht ohne das Basic kit verwendet werden, da der Mikrocontroller nicht in dem Add-On enthalten istAußerdem enthält das Add-On kit RFID sowie Machine Vision Module. Basic und Add-On kit sind komfortabel im Gebrauch und können bequem transportiert werden, um die Robotikexperimente zu Hause oder am Arbeitsplatz durchzuführen.
  
-=== HomeLab Basic Kit ===+=== HomeLab Basic kit ===
  
-[{{  :kit:basic_kit.jpg?200|HomeLab Basic Kit}}]+[{{  :kit:basic_kit.jpg?200|HomeLab Basic kit}}]
  
-    * AVR ATmega128 development board +    * AVR ATmega2561 Entwicklungsplatine, inklusive Ethernet, SD Kartenlesen und integriertem JTAG Programmiergerät 
-    * Digital i/o board (buttons, LEDs, 2 x LCD output, 7-segment indicator+    * Benutzerschnittstellenplatine (Schalter, LEDs, graphisches LCD, 7-Segment Anzeige
-    * 2 x 16 alphanumeric LCD display with back-light +    * USB Kabel 
-    * JTAG programmer and debugger (USB) + cable +    * Beispielaufgaben mit C-Quellcode  
-    * Example exercises with C-source code (examples) +    * Softwarebibliothek 
-    * Power supply+    * Stromversorgung
     * Multimeter     * Multimeter
-    * Software for programming in Assembler and language +    * Software zur Programmierung in Assembler und 
-    * Portable case+    * Tragbarer Koffer
  
-=== Sensor and Motor Add-On Kit ===+=== Sensor and Motor Add-On kit ===
  
-== Motor module == 
  
-[{{  :kit:sensor_motor_kit.jpg?200|Sensor and Motor Add-On Kit}}]+== Sensormodul ==
  
-  * DC motor (w/ gear+  * Analoge Sensoren- und Tiefpassplatine mit on-board Sensoren (Temperatursensor, Lichtsensor, Potentiometer und Mikrofon
-  * RC servo motor +  * Ultraschallentfernungssensor SRF05 mit Kabel  
-  * Stepper motor (bipolar or unipolar stepper) +  * Infrarotentfernungssensor mit Kabel
-  * motor driver board +
-  * Supply divider +
-  * Ribbon cable+
  
-== Sensor module ==+== Motormodul ==
  
-  * analogous sensor and low-pass filter combined board with on-board sensors (temperature sensor, light intensity sensor, potentiometer) +[{{  :kit:sensor_motor_kit.jpg?200|Sensor and Motor Add-On kit}}]
-  * Ultrasonic distance sensor SRF05 with cable +
-  * Infrared distance sensor with cable +
-  * Ribbon cable+
  
-=== HomeLab Advanced Kit ===+  * DC Motor (mit Getriebe und Kodierer) 
 +  * RC Servomotor 
 +  * Schrittmotor (uni- oder bipolarer Schrittbetrieb) 
 +  * Motorentreiberplatine 
 +  * Versorgungsteiler
  
-[{{  :kit:advanced_kit.png.jpg?200|HomeLab Advanced Kit}}]+== Kommunikationsmodul ==
  
-Includes all modules and components from Basic Kit and Motor and Sensor Add-On Kit. In additionfollowing modules are included:+  * Kommunikationsplatine2xRS232 
 +  * ZigBee oder Bluetooth Funkeinheit 
 +   
 +=== Zusätzliche HomeLab Module === 
 + 
 +Zusätzliche Module sind nicht in den Koffern enthalten, können jedoch direkt mit dem HomeLab Kommunikationsmodul verbunden werden. Es gibt für diese Module ebenfalls praktische Beispiele und Übungsaufgaben.
  
-== RFID module ==+== RFID Modul ==
  
-  * Reader+  * Hochfreqzenz RFID Lesegerät
   * Tag (2)   * Tag (2)
-  * Cable+  * Kabel
  
-== Communication module == 
  
-  * Bluetooth +== Machine Vision Module==
-  * Ethernet +
-  * SPI+
  
-== Machine vision module ==+  * Intelligentes Kamera Module (CMUcam3)
  
-  * Intelligent camera module (CMUcam3)+{{:kit:homelabv5.1.jpg?400|}}
  
-==== Controller module ====+--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +===== HomeLab Bibliothek =====
  
-Main module of a HomeLab is a controller development board (controller boardequipped with AVR ATmega128 micrcontrollerIn addition to microcontroller, the board consists of  several peripherals, voltage stabilizer, connectors etcThe controller board has the following features:+Die HomeLab Bibliothek besteht aus einigen C Header-Dateien (mit der Dateiendung „.h“und einer statischen Bibliotheksdatei (mit der Dateiendung „.a“). Während der Installation der Bibliothek werden diese Dateien vollständig in den AVR-GCC Unterordner kopiert. Hier findet der Compiler sie automatischDer Benutzer muss diese Dateien somit nicht mehr in den Programmordner kopieren.
  
-  * Atmega128-16AU microcontroller in the TQFP64 package (ROHS)  
-    * 8-channel 10-bit A/D converter  
-    * 128kB Flash memory (program memory)  
-    * 4kB EEPROM memory (data memory)  
-    * 6 channel programmable PWM  
-  * Standard 6-pin In system programming interface (ISP) connector  
-  * 14,7456 MHz clock (can be changed very easily, crystal is mounted on small 2-pin socket)  
-  * Real Time clock (RTC)  
-  * Reset protection circuitry for the ATmega128  
-  * Status LED and Power LED  
-  * Standard DB-9 serial port connector with RS232 transmitter / receiver  
-  * All Atmega signals available on three connectors (1. D, B, E ports, 2. G, C, A ports, 3. F port with ADC I/O lines) 
-  * Reset button  
-  * JTAG 10-pin Interface connector  
-  * 2-pin on/of connector – can be used for connecting on/off button  
-  * DC 2.1mm power connector  
-  * Built-in voltage stabilizer 
  
-[{{  :kit:cpu_module.jpg?580  |Controller module}}]+[{{  :images:homelab:library:homelab_library_files.png|HomeLab Bibliothek Quellcode Dateien}}]
  
-Module is equipped with AC/DC rectifier circuit and LDO voltage stabilizer (with low dropout) - external feeder with voltage stabilization is not needed +Die schrittweisen Installationsanweisungen der AVR Entwicklungssoftware für Windows und Linux sind im ersten Kapitel zu den praktischen Beispielen dargestellt. Auch wenn unterschiedliche Beispiele auf verschiedene Teile der Bibliothek zurückgreifen, muss in jedem Projekt die statische Bibliotheksdatei („.a“ Dateivorhanden sein. Nur die Header-Dateien können wahlweise eingeladen werdenHeader-Dateien, die in direktem Bezug zum AVR Mikrocontroller stehen, sind im „homelab“-Ordner abgelegtHomeLab modulspezifische Dateien sind im Ordner „homelab/module“ zu findenBeide Ordner befinden sich im Root-Ordner des Compilers. Um die Dateien dieser Ordner zu verwenden, müssen größer- / kleiner-Zeichen genutzt werden um den Pfad anzugeben. Nachfolgend finden Sie ein Beispiel, wie Header-Dateien für AVR Pins und HomeLab Motoren integriert werden können:
-   +
-Module can be powered just from step down transformer with  output voltage greater than 6 Volts and lower than 15 Volts. Module has wrong-polarization protection circuit  (Greatz bridge)POWER LED is signalizing connected feed (POWER” description on the board).+
    
-Circuit can be equipped with external power switch by connecting it to S2 2-pin on/off  
-connector. If external power switch is not used, S2 2-pin on/off connector must be shorted. 
-  
-All ATmega128 signals are available on three connectors on the edge of the board. Connectors pin assignment is described in the next part of this instruction. It includes full descriptions of ATmega128 pins and their alternative functions. The module is equipped with microprocessor reset circuit (when power on) and reset button for microprocessor restart. Microprocessor can be programmed with ISP or JTAG programmer. 
- 
-To the seventh pin of port B (named as PB7) is connected the status LED (described as PB7 on the board). This LED can be used as a status indicator of application software. Low state on PB7 pin causes the status LED to be lit. 
-  
-Module provides two serial ports described on the board as UART1 and UART2. The first one is 9-pin female connector (DB-9 PC serial port compatible) and the second is 3-pin connector. MAX232 circuit provides signal conversion to serial standard.  
-  
-Multiplexer 74HC4053 provides full use of ports, including those used for microprocessor programming, because in reset state (when programmed) the processor multiplexer switches PE0, PE1 and PB1 signals to ISP and JTAG connector. When processor is in run state these signals are switched to connectors on the edge of the board.    
- 
-Module is equipped with external memory (Atmel  AT45DB041B). It is 4Mbit serial data flash memory connected to Master/Slave SPI serial interface of the microprocessor. Internal Real Time Clock is connected to external 32.768 kHz crystal resonator named as X2 on the board.  
- 
-[{{:kit:atmega_plaat.png?580|}}] 
- 
-=== Connector pins and functions === 
- 
-[{{  :kit:pe-pb-pd.png?580  |}}] 
- 
-^Nr^Pin^Alternative function / Description^^ 
-|1|PD7|T2|Timer/Counter2 Clock Input | 
-|2|PD6|T1|Timer/Counter1 Clock Input | 
-|3|PD5|XCK1|USART1 External Clock Input/Output | 
-|4|PD4|IC1|Timer/Counter1 Input Capture Trigger | 
-|5|PD3|INT3/TXD1|External Interrupt3 Input or UART1 Transmit Pin | 
-|6|PD2|INT2/RXD1|External Interrupt2 Input or UART1 Receive Pin | 
-|7|PD1|INT1/SDA|External Interrupt1 Input or TWI Serial Data | 
-|8|PD0|INT0/SCL|External Interrupt0 Input or TWI Serial Clock | 
-|9|VCC|-|+5V | 
-|10|GND|-|GND | 
-|11|PB7|OC2/OC1C |Output Compare and PWM Output for Timer/Counter2 or Output Compare and PWM Output C for Timer/Counter1| 
-|12|PB6|OC1B|Output Compare and PWM Output B for Timer/Counter1 | 
-|13|PB5|OC1A|Output Compare and PWM Output A for Timer/Counter1 | 
-|14|PB4|OC0|Output Compare and PWM Output for Timer/Counter0 | 
-|15|PB3|MISO|SPI Bus Master Input/Slave Output | 
-|16|PB2|MOSI|SPI Bus Master Output/Slave Input | 
-|17|PB1|SCK|SPI Bus Serial Clock | 
-|18|PB0|SS|SPI Slave Select Input | 
-|19|PE7|INT7/IC3|External Interrupt 7 Input or Timer/Counter3 Input Capture Trigger | 
-|20|PE6|INT6/ T3|External Interrupt 6 Input or Timer/Counter3 Clock Input | 
-|21|PE5|INT5/OC3C |External Interrupt 5 Input or Output Compare and PWM Output C for Timer/Counter3| 
-|22|PE4|INT4/OC3B |External Interrupt4 Input or Output Compare and PWM Output B for Timer/Counter3 | 
-|23|PE3|AIN1/OC3A |Analog Comparator Negative Input or Output Compare and PWM Output A for Timer/Counter3 | 
-|24|PE2|AIN0/XCK0 |Analog Comparator Positive Input or USART0 external clock input/output | 
-|25|PE1|PDO/TXD0|Programming Data Output or UART0 Transmit Pin | 
-|26|PE0|PDI/RXD0|Programming Data Input or UART0 Receive Pin | 
- 
- 
-[{{  :kit:pa-pc.png?580  |}}] 
- 
-^Nr^Pin^Alternative function / Description^^ 
-|1|GND|-|GND | 
-|2|VCC|-|+5V | 
-|3|PA0|AD0|External memory interface address and data bit 0 | 
-|4|PA1|AD1|External memory interface address and data bit 1 | 
-|5|PA2|AD2|External memory interface address and data bit 2 | 
-|6|PA3|AD3|External memory interface address and data bit 3 | 
-|7|PA4|AD4|External memory interface address and data bit 4 | 
-|8|PA5|AD5|External memory interface address and data bit 5 | 
-|9|PA6|AD6|External memory interface address and data bit 6 | 
-|10|PA7|AD7|External memory interface address and data bit 7 | 
-|11|-|NC|Not connected | 
-|12|-|NC|Not connected | 
-|13|PG2|ALE|Address Latch Enable to external memory | 
-|14|-|NC|Not connected | 
-|15|PC6|A14|External memory interface address and data bit 14 | 
-|16|PC7|A15|External memory interface address and data bit 15 | 
-|17|PC4|A12|External memory interface address and data bit 12 | 
-|18|PC5|A13|External memory interface address and data bit 13 | 
-|19|PC2|A10|External memory interface address and data bit 10 | 
-|20|PC3|A11|External memory interface address and data bit 11 | 
-|21|PC0|A8|External memory interface address and data bit 8 | 
-|22|PC1|A9|External memory interface address and data bit 9 | 
-|23|PG0|WR|Write strobe to external memory | 
-|24|PG1|RD|Read strobe to external memory | 
-|25|-|NC|Not connected | 
-|26|-|NC|Not connected| 
- 
-[{{  :kit:pf.png?580  |}}] 
- 
-^Nr^Pin^Alternative function / Description^^ 
-|1|VCC|-|+5V | 
-|2|GND|-|GND | 
-|3|REF|AREF|Analog reference voltage for ADC | 
-|4|GND|-|GND | 
-|5|PF0|ADC0|ADC input channel 0 | 
-|6|GND|-|GND | 
-|7|PF1|ADC1|External memory interface address and data bit 4 | 
-|8|GND|-|GND | 
-|9|PF2|ADC2|External memory interface address and data bit 6 | 
-|10|GND|-|GND | 
-|11|PF3|ADC3|Not connected | 
-|12|GND|-|GND | 
-|13|PF4|ADC4/TCK|ADC input channel 4 or JTAG Test ClocK | 
-|14|GND|-|GND | 
-|15|PF5|ADC5/TMS|ADC input channel 5 or JTAG Test Mode Select | 
-|16|GND|-|GND | 
-|17|PF6|ADC6/TDO|ADC input channel 6 or JTAG Test Data Output | 
-|18|GND|-|GND | 
-|19|PF7|ADC7/TDI|ADC input channel 7 or JTAG Test Data Input | 
-|20|GND|-|GND | 
- 
-=== Connecting module === 
- 
-When connecting the Controller module with other peripheral modules and devices, connecting the power supply should be done last. If power is on, it is dangerous to connect and disconnect external devices. Modules have to be connected with each other with great care without applying strong force as this can bend connectors. JTAG-ICE programmer have to be connected to the correct port and the ribbon cable directs out from board (red stripe is by the power supply connector side). 
- 
-[{{:kit:kit_test.jpg?580|}}] 
- 
-==== Digital input-output module ==== 
- 
-digital i/o module is designed for simple tasks and basic process control. Module has three push-buttons and three LEDs, which can be used as digital inputs and outputs of microcontroller. Additionally to simple LEDs the module is equipped with 7-segment indicator and LCD display outputs. Digital i/o module is handy to use along with other modules enabling to control the output device behavior, like motors and display the sensor readings. 
- 
-Module features: 
-  * Green, yellow and red LED; 
-  * Three push-button; 
-  * 7-segment indicator; 
-  * Alphanumeric LCD connector; 
-  * Graphical LCD connector; 
-  * Ultrasonic distance sensor connector. 
- 
-{{:examples:digi:digital_io_board.jpg?350|}} 
- 
-=== electrical connections === 
- 
-[{{  :examples:digi:digi_io_port_schematics.png?308|Controller module and Digital i/o module connection}}] 
- 
-Digital i/o module is connected with Controller module by one ribbon cable to port PA/PC/PG, which includes the 8-pin ports PA and PC and 3-pin port PG. The module is also powered by the same cable. If the module is connected correctly the on-board SMD LED //+5V_OK// has to light up. In other case the cable is probably wrongly connected. 
- 
-Digital i/o module is equipped with three buttons S1, S2, S3 which are connected to ports PC0, PC1, PC2 accordingly. The other end of buttons are connected through the resistors to ground (logical 0). LED1, LED2 and LED3 on the module are connected to the ports PC3, PC4, PC5 accordingly. The anodes of LEDs are connected to the supply (logical 1). 
- 
-[{{  :examples:digi:digi_io_button_led_schematics.png?580  |Schematics of buttons and LEDs}}] 
- 
-~~CL~~ 
- 
-Digital i/o board is equipped with 7-segment indicator, which is connected with microcontroller ports through the driver A6275. Driver data bus (S-IN) is connected to pin PC6, clock signal (CLK) to the pin PC7 and latch signal (LATCH) to pin PG2. 
- 
-[{{  :examples:digi:digi_io_7seg_schematics.png?480  |Schematics of 7-segment indicator}}] 
- 
-~~CL~~ 
- 
-The module has two different connectors for port PA. The port is connected concurrently to separate pinout groups where one of them is connected through the voltage converter enabling to use 3.3 V devices (like graphical LCD). another port PA pinout is connected directly to microcontroller port (5 V level) and is aligned according to standard 2 x 16 alphanumeric LCD. Two unused ports - PG0 and PG1 are grouped on the board together with ground and supply (starting from module version 3.3). Different devices can be connected to this connector, for example ultrasonic distance sensor. However while connecting the ultrasonic sensor great care has to be paid in connecting power supply plug correctly. In case of mixing up the ground and supply the sensor will be permanently damaged.  
-For ultrasonic sensor, connect the black wire with ground (marked as GND on the board) and red wire with supply. Signal wires have to be connected with PG0 and PG1 ports. 
- 
- 
-[{{  :examples:digi:digi_io_porta_portg_schematics.png?580  |Schematics of LCD}}] 
- 
-=== Connecting the module === 
- 
-While connecting the module it is suggested to follow the order as described below. Before connecting any cable make sure that the power is removed from Controller board. 
- 
-  - Connect the Digital i/o module with Controller module by using the ribbon cable. 
-  - If needed connect the JTAG programmer with Controller module. 
-  - Connect the power supply with Controller module. 
- 
-[{{:examples:digi:digital_io_connection.jpg?580|Connecting the Digital i/o module}}] 
-==== LCD module ==== 
- 
-LCD module is a combination of connectors of Digital i/o module and two different LCD displays. Digital i/o module can provide two voltage level connections for the LCDs. Alphanumeric LCD which is working on the 5 V level and graphical LCD which is working on the 3.3 V level. The back-light intensity of alphanumeric LCD is regulated with small potentiometer (LCD_BG) on the digital i/o board and graphical LCD back-light can be controlled by the software. Both LCD displays are connected to the port PA but only one at a time. 
- 
- 
-=== Connecting the LCD module === 
- 
-It is suggested to follow the order below, for connecting the module. Before connecting any cable make sure that the power is removed from Controller board. 
- 
-  - Connect the Digital i/o module with Controller module by using the ribbon cable. 
-  - Connect LCD module with Digital i/o module (only one at a time) 
-  - If needed connect the JTAG programmer with Controller module. 
-  - Connect the power supply with Controller module. 
- 
-[{{:examples:display:lcd_connection.jpg?580|Connecting the LCDs}}] 
-==== Sensors module ==== 
- 
-Sensors module includes the combined board of sensors, low-pass filter and separate distance sensors. 
- 
-Sensors module features 
- 
-  * Ultrasonic distance sensor Devantech SRF05 with cable (measuring distance 1-400 cm) {{:kit:datasheets:srf05tech.pdf|datasheet}} 
-  * Infrared distance sensor Sharp GP2Y0A21YK0F (measuring distance 10-80 cm) {{:kit:datasheets:sharp_gp2y0a21yk0f.pdf|datasheet}} 
-  * Light intensity sensor (photoresistor) VT935G (resistance 18,5 kΩ on 10 lux) {{:kit:datasheets:ldr.pdf|datasheet}} 
-  * temperature sensor (thermistor NTC) (resistance 10 kΩ on 25 °C) {{:kit:datasheets:ntc10k.pdf|datasheet}} 
-  * Potentiometer 5 kΩ 
- 
-{{:examples:sensor:sensor_board.png?300|Sensors board}} 
- 
-=== Electrical connections === 
- 
-[{{  :examples:sensor:sensor_schematics_portf.png?300|Controller module and Sensors module connection}}] 
- 
-== Sensors == 
- 
-Every sensor on the board is connected through the jumper, enabling to select between on-board sensor or external sensor which can be connected to the same port on the CON2 connector. By default all on-board sensors are connected to the analogous inputs of the microcontroller (ADC0-ADC3). In addition to on-board sensors, several analogous external sensors can be connected with sensor board through the connection CON2 to ports ADC4-ADC7. Attention have to be paid to the fact that the ATmega128 is using same ports (ADC4-ADC7) for JTAG programming. Both functions cannot be used simultaneously, the microcontroller can be configured to use just one. Both functions cannot be used simultaneously; the microcontroller can be configured to use just one. However if there is a need to use e the external sensors together with JTAG program, they can be connected to ports ADC0-ADC3, but appropriate jumpers have to be shifted. 
- 
-[{{  :examples:sensor:sensor_schematics_sensor.png?400  |Schematics of sensors connections}}] 
- 
-== Low-pass filter == 
- 
-Low-pass filter can be composed between analogous inputs 0-3 (PF0-PF3). Resistor and capacitor will be connected to the socket for building up the low-pass filter. By default a low-pass filter is composed for the channel 0 (PF0). Resistor value is 10 kΩ and capacitor value is 100 nF. 
- 
-[{{:examples:sensor:sensor_schematics_lowpass.png?580|Schematics of low-pass filter}}] 
- 
-=== Connecting the module === 
- 
-While connecting the module it is suggested to follow the order as described below. Before connecting any cable make sure that the power is removed from Controller board. 
- 
-  - Connect the Sensors module with Controller module by using the ribbon cable. NB! Check that the ribbon-cable is connected to the CON1/PF connector - not CON2 
-  - If needed connect the infrared distance sensor (black wire to GND) 
-  - If needed connect the Digital i/o module with LCD. 
-  - If needed connect the ultrasonic distance sensor with Digital i/o module (black wire to GND) 
-  - If needed connect the JTAG programmer with Controller module. 
-  - Connect the power supply with Controller module. 
- 
-[{{:examples:sensor:sensor_connection.jpg?580|Connecting the Sensors module}}] 
- 
-==== Motors module ==== 
- 
-Motors module incorporates the motors driver board and different electrical motors. Motors board is designed to be compatible with the Controller module but can also successfully be used for other controller boards as it uses standard motor drivers.  
- 
-Motor power supplies are separated from the control signals on the Motors board and enable to connect all control signals with one ribbon cable 
- 
-{{:examples:actuator:actuator_board.jpg?400|}} 
- 
-It is possible to drive different types of motors with the module and all these can have separate voltage supply. 
- 
-Following motors can be connected with Motors board: 
-  * 4 x DC motors or 3 x DC motors and 2 x encoder. 
-  * 2 x unipolar stepper motors. 
-  * 1 x bipolar stepper motor. 
-  * 2 x RC servo motor. 
-  * UART connector. 
-  * Driver supply selection: jumper JP1 (from controller board or external). 
-  * Supply indicator LED. 
- 
-motors modules supply connector (PWR): 
- 
-^ Pin ^ Supply connection ^ Voltage ^ Current ^ 
-| 1    | DC motors                        | up to 36 V  | up to 600 mA | 
-| 2    | Bipolar stepper motor            | up to 36 V  | up to 600 mA | 
-| 3    | Servo motors                    | 4,8 - 6 V   | up to 1 A    | 
-| 4    | Unipolar stepper motors       | up to 50 V  | up to 500 mA | 
-| 5    | Drivers logic supply (selectable with JP1) | 5 V                      |   
-| 6    | Ground(GND)                        |                          |   
- 
-NB! Applied voltage and current are primary dependent of motors which are used and cannot exceed the limits of specific motor. These limits should be checked from motor datasheet. Motors provided with the kit are most commonly supplied with the voltage 5-6 V and therefore the power distribution cable is using voltage regulators, limiting the output to 5 or 6 V. 
- 
-=== Motors === 
- 
-Specific model or mark of the motor in a Add-On Kit can vary, but every kit has at least one DC motor, 1 RC servo motor and 1 bipolar or unipolar stepper motor. 
- 
-Following specific models can be found in the kit: 
-  * **DC motor ** 
-    * Micromotors L149.6.10 (with gear) {{:kit:datasheets:actuators:dc_gearmotor_6v_25rpm.pdf|datasheet}} 
-    * Micromotors L149.6.43 (with gear) {{:kit:datasheets:actuators:dc_gearmotor_6v_25rpm.pdf|datasheet}} 
-    * Micromotors LE149.6.10 (with gear + encoder) {{:kit:datasheets:actuators:dc_gearmotor_6v_52rpm_encoder.pdf|datasheet}} 
-  * **RC servo motor** 
-    * Robbe FS 100 {{:kit:datasheets:actuators:servo_robbe_fs100.pdf|datasheet}} 
-    * E Sky EK2-0501 {{:kit:datasheets:actuators:servo_esky_ek2-0501.pdf|datasheet}} 
-    * Futaba XT-S  
-    * Hitec HS422 {{:kit:datasheets:actuators:servo_hs422.pdf|datasheet}} 
-  * **Unipolar stepper motor** 
-    * Ming Jong ST35 {{:kit:datasheets:actuators:stepper_motorst35.pdf|datasheet}} 
-  * **Bipolar stepper motor** 
-    * Moons 42PM {{:kit:datasheets:actuators:moons_bipolar_stepper_motors.pdf|datasheet}} 
-    * Ming Jong ST28 {{:kit:datasheets:actuators:stepper_motor_st28.pdf|datasheet}} 
-  * **Piezo sound generator ** (optional) 
- 
-[{{  :examples:motor:motors.jpg?400  |Motors}}] 
- 
-~~PB~~ 
-=== Electrical connections === 
- 
-Motors module board is connected with Controller module with one ribbon cable to the port PE-PB-PD. The power supplies of the motors are connected with separate PWR connector, where every type of motor can have different voltage. Drivers on the board can be supplied externally or directly from Controller module. This is determined by the jumper JP1. If the jumper connects pin 1 and 2 the logic supply is taken from the Controller module. If logic supply is correctly provided the on-board LED //+5V// have to light up. The Motors board is equipped with UART connector which enables to connect external UART compatible devices directly to board. 
- 
-[{{  :examples:motor:actuator_schematics_port_pwr.png?580  |Signal connector of Motors module , powers supply of motors and UART connector}}] 
- 
-== DC motors == 
- 
-DC motors are connected to the connector group DC1. Every pair can handle one motor - all together 4 DC motors. In parallel of connector 3 two encoders ENC1 and ENC2 are connected. In case of using the encoders the DC motor connector 3 cannot be connected with DC motor at the same time (these ports have to be configured as inputs by the software). Motors are controlled with widely used H-bridges, L293D dual H-bridge driver is used for the DC motors. Motors can also be replaced by some other actuator which can be controlled digitally and if the current do not exceed 500 mA (piezo generator, relay etc.)  
- 
-[{{  :examples:motor:actuator_dc_schematics.png?580  |Schematics of DC motor connection}}] 
- 
-^ AVR pin ^ Control signal ^ AVR pin ^ Control signal ^ 
-| PB4 | Motor 1 1A | PD6 | Motor 3 1A | 
-| PB7 | Motor 1 2A | PD7 | Motor 3 2A | 
-| PD0 | Motor 2 1A | PD4 | Motor 4 1A | 
-| PD1 | Motor 2 2A | PD5 | Motor 4 2A | 
- 
-== Stepper motors == 
- 
-Motors board supports two different types of stepper motors. Two unipolar and one bipolar motor can be connected with the board. Bipolar stepper is controlled with dual H-bridge L293D and unipolar stepper is driven by transistor array ULN2803. The patterns of the stepper signals are generated by the software. It is important to check the sequence of the stepper motor windings. The supply wires of unipolar stepper motor are connected to pins 1 and 2. If unipolar stepper has only 5 wires, the pin 1 is left unconnected.  
- 
-Stepper motor connections: 
- 
-^ Pin  ^ Winding wire  ^ Unipolar 1 ^ Unipolar 2 ^ Bipolar ^ 
-| 1  | 1   | + supply | + supply |      | 
-| 2  | 2   | + supply | + supply |      | 
-| 3  | 1a  | PE0     | PE4     | PB0  | 
-| 4  | 2a  | PE1     | PE5     | PB1  | 
-| 5  | 1b  | PE2     | PE6     | PB2  | 
-| 6  | 2b  | PE3     | PE7     | PB3  | 
- 
- 
-[{{:examples:motor:stepper:samm_mootorid_skeem.png?580|Unipolar (left) and bipolar (right) stepper motor windings}}] 
- 
-[{{:examples:motor:actuator_stepper_schematics.png?580|Schematics of stepper motor connections}}] 
- 
-== Servo motor == 
- 
-RC servo motors are connected to the connector PWM1 and PWM2 on the Motors board. Motors are connected so that the signal wire (usually yellow or white) is on the pin 1 (close to the edge of the board).  Two servo motors can be used at the same time. The control signals are connected directly with microcontroller timer outputs. 
- 
-^ AVR pin ^ Control signal ^ 
-| PB5(OC1A) | PWM1        | 
-| PB6(OC1B) | PWM2        | 
- 
-=== Connectors of the motors === 
- 
-[{{:examples:motor:actuator_motor_con_schematics.png?580|Connectors of the motors}}] 
- 
- 
-=== Connecting the module === 
- 
-While connecting the module it is advised to follow the order as described below. Before connecting any cable make sure that the power is removed from Controller board. 
- 
-  - Connect the Motors module with Controller module by using the ribbon cable. 
-  - Connect the motors which are needed. 
-  - Connect the power distributor of the motors supply. 
-  - If needed connect the JTAG programmer with Controller module. 
-  - Connect the power supply with Controller module. 
- 
-[{{:examples:actuator:actuator_connection.jpg?580|Connecting the Motors module}}] 
-===== HomeLab library ===== 
- 
-HomeLab library is composed of several C language header files (with ".h" extension) and one static library file (with ".a" extension"). On library installation all these files are copied to the AVR-GCC subdirectories where compiler finds them automatically. User does not have to copy these files to his or her program folder. 
- 
-[{{  :images:homelab:library:homelab_library_files.png|HomeLab library source code files}}] 
- 
-Step-by-step AVR development software installation instructions for Windows and Linux are written in the first chapter of practical examples. Although different practical examples use different parts of the library, all of them must include static library (".a" file) in the project. Only header files can be included selectively. Header files which are directly related to the AVR microcontroller are in the "homelab" folder, HomeLab module specific files are in the "homelab/module" folder. Both these folders are in the compiler's root folder and to include the files from them, less-than and greater-than signs are needed to specify the path. An example of how to include AVR pins and HomeLab motors library header files: 
  
 <code c> <code c>
Line 1401: Line 1112:
 </code> </code>
  
-If HomeLab library is not usedthen the following avrlibc header file needs to be included into the project:+Falls die HomeLab Bibliothek nicht genutzt wirdmuss die folgende avrlibc Header-Datei in das Projekt eingefügt werden: 
  
 <code c> <code c>
Line 1407: Line 1119:
 </code> </code>
  
-In the HomeLab library, this file is already included in the //pin.h// file.+Die HomeLab Bibliothek enthält diese Datei bereits in der //pin.h// Datei. 
 + 
 +Das Installationsprogramm für die HomeLab Bibliothek ist auf der HomeLab Webseite verfügbar. Nutzer, die die Bibliothek an Ihre Bedürfnisse anpassen möchten, können hier auch den Quellcode dafür herunterladen. Das folgende Kapitel beschreibt die Funktionen der Bibliothek. 
 +==== Bitweise Operationen ====
  
-HomeLab library installer is freely available on the HomeLab web-pageUsers who are interested in customizing the library can also download the source code for itThe following chapters describe the functionality of the library +Die Bibliothek für bitweise Operationen beinhaltet eine Zusammenstellung von Makrofunktionen zur Durchführung von BitmanipulationsoperationenSie werden von den anderen Komponenten der Bibliotheken genutzt und können überall angewandt werdenDa die Makrofunktionen keinen speziellen Typ haben, sind sie mit jedem Datentyp kompatibel.
-==== Bitwise operations ====+
  
-Bitwise operations library contains a set of macro functions to do common bit manipulation operationsThey are used by the rest of the library and can be used everythere elseAs the macro functions have no typethey are compatible with any data type.+Der Bit-Index wird genutzt um das Bit in einer Binärzahl zu spezifizierenIndizes werden beginnend bei Null gezählt, wobei Null das niedrigstwertige Bit (LSB) kennzeichnetEine 8-Bit-Zahl hat zum Beispiel Indizes von 0 bis 7eine 16-Bit Zahl Indizes von 0 bis 15.
  
-Bit index is used to specify the bit in the binary number. Indexes are counted from zero, where zero represents the least significant bit (LSB). For example, 8-bit number have 8 bits with indexes from 0 to 7 and 16-bit number have 16 bits with indexes from 0 to 15. 
  
-=== Funktsioonid ===+=== Funktionen ===
  
   * **//bit_mask(bit)//** \\   * **//bit_mask(bit)//** \\
-    Bit index to bit mask convertingParameters+    Bit-Index zu Bitmaske konvertierenParameter
-    * //bit// - Bit index+    * //bit// - Bit-Index
-    * Returns bit mask.+    * Gibt Bitmaske aus.
  
   * **//bit_set(value, bit)//** \\   * **//bit_set(value, bit)//** \\
-    Sets a specified bit in the variableParameters:+    Setzt ein bestimmtes Bit in einer VariablenParameter:
     * //value// - Variable.     * //value// - Variable.
-    * //bit// - Bit index.+    * //bit// - Bit-Index.
  
   * **//bit_clear(value, bit)//** \\   * **//bit_clear(value, bit)//** \\
-    Clears a specified bit in the variableParameters:+    Löscht ein bestimmtes Bit in einer VariablenParameter:
     * //value// - Variable.     * //value// - Variable.
-    * //bit// - Bit index.+    * //bit// - Bit-Index.
  
   * **//bit_set_to(value, bit, state)//** \\   * **//bit_set_to(value, bit, state)//** \\
-    Set a specified bit in the variable to desired stateParameters:+    Setzt ein bestimmtes Bit einer Variablen in einen gewünschten ZustandParameter:
     * //value// - Variable.     * //value// - Variable.
-    * //bit// - Bit index+    * //bit// - Bit-Index
-    * //state// - State (//true// or //false//).+    * //state// - Status (//true// or //false//).
  
   * **//bit_invert(value, bit)//** \\   * **//bit_invert(value, bit)//** \\
-    Inverts a specified bit in the variableParameters:+    Invertiert ein bestimmtes Bit der VariableParameter:
     * //value// - Variable.     * //value// - Variable.
-    * //bit// - Bit index.+    * //bit// - Bit-Index.
  
   * **//bit_is_set(value, bit)//** \\   * **//bit_is_set(value, bit)//** \\
-    Checks whether a specified bit in the variable is set or notParameters:+    Überprüft, ob ein bestimmtes Bit in einer Variablen gesetzt ist oder nichtParameter:
     * //value// - Variable.     * //value// - Variable.
-    * //bit// - Bit index+    * //bit// - Bit-Index
-    * Returns boolean value //true// when bit is set and //false// when bit is cleared.+    * Gibt den Bool’schen Wert //true//, wenn das Bit gesetzt und //false// wenn das Bit gelöscht wurde zurück.
  
   * **//bit_is_clear(value, bit)//** \\   * **//bit_is_clear(value, bit)//** \\
-    Checks whether a specified bit in the variable is cleared or notParameters:+    Überprüft, ob ein bestimmtes Bit in einer Variablen gelöscht wurde oder nichtParameter:
     * //value// - Variable.     * //value// - Variable.
-    * //bit// - Bit index+    * //bit// - Bit-Index
-    * Returns boolean value //true// when bit is cleared and //false// when bit is set.+    * Gibt den Bool’schen Wert //true//, wenn das Bit gelöscht wurde und//false// wenn das Bit gesetzt wurde zurück.
  
-=== Example ===+=== Beispiel ===
  
-Setting up a third bit in the 8-bit variable //b// and inverting of the last one.+Das dritte Bit einer 8-Bit Variablen //b// setzen und Invertieren des letzten Bits.
  
 <code c> <code c>
Line 1472: Line 1185:
 </code> </code>
  
-=== Source === +=== Quelle === 
- +Nachfolgend eine gekürzte Version des Quellcodes der Bibliothek für bitweise Operationen.
-The following is a shortened version of the bitwise operations library source code.+
  
 <code c> <code c>
 // //
-// Functions for handling bits.+// Funktionen zur Bearbeitung von Bits.
 // //
 #define bit_mask(bit)            (1 << (bit)) #define bit_mask(bit)            (1 << (bit))
Line 1489: Line 1201:
  
 // //
-// Functions for handling bit masks.+// Funktionen zur Bearbeitung von Bitmasken.
 // //
 #define bitmask_set(value, bitMask)     value |= (bitMask) #define bitmask_set(value, bitMask)     value |= (bitMask)
Line 1500: Line 1212:
 ==== Pins ==== ==== Pins ====
  
-Pins library provides an easy way for operating with AVR digital input-output pinsUser can create a pin related variable and do all the pin operations with that variableThis way there's no need to deal with the register names and bit indexes like it is done while programming in direct register access methodPin's port and index must be specified only onceso the changes are easy to implement.+Die Pins-Bibliothek erleichtert die Arbeit mit digitalen AVR Inund Output-PinsDer Nutzer kann eine zu einem Pin gehörige Variable erstellen und mit dieser sämtliche Pin-Operationen vornehmenAuf diese Weise entfällt die Verwendung von Registernamen oder Bit-Indizes, wie es beim Programmieren mit direktem Zugriff auf das Register nötig istPort und Index des Pins müssen nur einmalig festgelegt werdensodass Änderungen leicht implementiert werden können.
  
-=== Data types ===+=== Datentypen ===
  
-  * **//pin//** \\ Data type to hold pin registers addresses and bit maskTo get the most efficent program, //pin// typed variables should be constant and they should be initialized at the beginning of the program codeIntializing can be done with macro function //PIN//, which first parameter is port letter (capital A, B, C, etc) and the other one is pin index (0 to 7). Only existing ports and pins can be used.+  * **//pin//** Datentyp für Adressen von Pin-Registern und BitmaskenUm das effizienteste Programm zu entwickelnsollten //pin// Variablen konstant sein und am Anfang des Programmcodes initialisiert werdenLetzteres kann mit der Makrofunktion //PIN// durchgeführt werdenderen erster Parameter der Buchstabe des Ports ist (A, B, C, etc.und zweiter Parameter der Pin-Index (0 – 7). Es können nur bestehende Ports und Pins verwendet werden.
  
-=== Functions ===+=== Funktionen ===
  
   * **//void pin_setup_output(pin pin)//** \\   * **//void pin_setup_output(pin pin)//** \\
-    Configures pin as an outputParameters+    Konfiguriert einen Pin als OutputParameter
-    * //pin// - Pin variable.+    * //pin// - Pin Variable.
   * **//void pin_setup_input(pin pin)//** \\   * **//void pin_setup_input(pin pin)//** \\
-    Configures pin as an input without pull-up resistorParameters+    Konfiguriert einen Pin als Input ohne Pull-up WiderstandParameter
-    * //pin// - Pin variable.+    * //pin// - Pin Variable.
   * **//void pin_setup_input_with_pullup(pin pin)//** \\   * **//void pin_setup_input_with_pullup(pin pin)//** \\
-    Configures pin as an input with pull-up resistorParameters+    Konfiguriert einen Pin als Input mit Pull-up WiderstandParameter
-    * //pin// - Pin variable.+    * //pin// - Pin Variable.
   * **//void pin_set(pin pin)//** \\   * **//void pin_set(pin pin)//** \\
-    Sets output pin high. Parameters+    Setzt einen Output-Pin high. Parameter
-    * //pin// - Pin variable.+    * //pin// - Pin Variable.
   * **//void pin_clear(pin pin)//** \\   * **//void pin_clear(pin pin)//** \\
-    Sets output pin low. Parameters+    Setzt einen Output-Pin low. Parameter
-    * //pin// - Pin variable.+    * //pin// - Pin Variable.
   * **//void pin_toggle(pin pin)//** \\   * **//void pin_toggle(pin pin)//** \\
-    Inverts output pin stateParameters+    Invertiert den Status eines Output-PinsParameter
-    * //pin// - Pin variable.+    * //pin// - Pin Variable.
   * **//void pin_set_to(pin pin, bool value)//** \\   * **//void pin_set_to(pin pin, bool value)//** \\
-    Sets output pin to desired stateParameters+    Setzt einen Output-Pin in den gewünschten ZustandParameter
-    * //pin// - Pin variable+    * //pin// - Pin Variable
-    * //value// - Desired state boolean value.+    * //value// - Gewünschter Status als Bool'scher Wert.
   * **//bool pin_get_value(pin pin)//** \\   * **//bool pin_get_value(pin pin)//** \\
-    Gets pin valueParameters+    Holt Pin-WertParameter
-    * //pin// - Pin variable+    * //pin// - Pin Variable
-    * Return boolean //true// when pin is high and //false// when pin is low.+    * Gibt Bool'schen Wert //true// wenn Pin high und //false// wenn Pin low ist aus.
   * **//bool pin_get_debounced_value(pin pin)//** \\   * **//bool pin_get_debounced_value(pin pin)//** \\
-    Reads pin value through the switch debounce filterFiltering takes at least 8 ms and may last up to 100 ms, depending of when the bouncing endsIf the bouncing does not end, //false// is returnedFunction use software delayParameters+    Liest den Pinwert durch den Switch-Debounce-FilterDas Filtern benötigt mindestens 8 ms und kann bis zu 100 ms benötigenje nachdem wann das Bouncing endetFalls es nicht endet wird //false// ausgegebenFunktionen nutzen SoftwareverzögerungParameter
-    * //pin// - Pin variable+    * //pin// - Pin Variable
-    * Return pin boolean value - //true// when pin is high and //false// when pin is low or undetermined.+    * Gibt dem Pin den Bool'schen Wert //true// wenn der Pin high ist und //false// wenn der Pin low oder unbestimmt ist.
  
-=== Example ===+=== Beispiel === 
 + 
 +Beispiel um einen Pin-Wert zu erhalten und zu setzen. Pin PC0 Wert wird invertiert und an Pin PC3 angeschlossen.
  
-Example of getting and setting a pin's value. Pin PC0 value is inverted and attached to pin PC3. 
  
 <code c> <code c>
Line 1553: Line 1266:
  bool value;  bool value;
  
- // Configuring pin as an output pin+ // Konfiguriert Pin als Output-Pin
  pin_setup_output(output_pin);  pin_setup_output(output_pin);
  
- // Configuring pin as an input pin with pull-up+ // Konfiguriert Pin als Input-Pin mit Pull-up Widerstand
  pin_setup_input_with_pullup(input_pin);  pin_setup_input_with_pullup(input_pin);
  
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Getting an input pin value+ // Wert eines Input-Pins erhalten
  value = pin_get_value(input_pin);  value = pin_get_value(input_pin);
  
- // Setting an output pin value+ // Wert für den Output-Pin setzen
  pin_set_to(output_pin, !value);  pin_set_to(output_pin, !value);
  }  }
 } }
 </code> </code>
-==== Analog to digital converter ====+==== Analog-Digital-Wandler====
  
-This library provides functions to use AVR analog to digital converterAll the conversion functions in library are blockingwhich means the processor waits as long as it takes to get the resultsThe conversion time depends on the ADC clock.+Diese Bibliothek enthält Funktionen um den AVR Analog-Digital-Wandler zu nutzenSämtliche Funktionen dieser Bibliothek sind blockierendd.h. der Prozessor wartet so lange, bis die Ergebnisse da sind. Die Zeit für die Konvertierung hängt von der ADC-Taktung ab.
  
-=== Data types ===+=== Datentypen ===
  
-  * **//adc_reference//** \\ ADC reference voltage enumeration data typeOptions+  * **//adc_reference//** \\ ADC Vergleichsspannung, AufzählungsdatentypMöglichkeiten
-    * //ADC_REF_AREF//Reference voltage from the AREF pin+    * //ADC_REF_AREF//Vergleichsspannung vom AREF Pin
-    * //ADC_REF_AVCC//Reference voltage from the AVCC pin+    * //ADC_REF_AVCC//Vergleichsspannung vom AVCC Pin
-    * //ADC_REF_2V56//Internal 2,56 V reference voltage.+    * //ADC_REF_2V56//Interne 2,56 V Vergleichsspannung.
  
-  * **//adc_prescale//** \\ ADC clock prescaler enumration data typeIt determines the division factor of system clockOptions+  * **//adc_prescale//** \\ ADC Takt-Vorteiler, AufzählungsdatentypDer Vorteiler gibt den Divisionsfaktor für den Systemtakt anMöglichkeiten
-    * //ADC_PRESCALE_2//Division factor 2. +    * //ADC_PRESCALE_2//Divisionsfaktor 2. 
-    * //ADC_PRESCALE_4//Division factor 4. +    * //ADC_PRESCALE_4//Divisionsfaktor 4. 
-    * //ADC_PRESCALE_8//Division factor 8. +    * //ADC_PRESCALE_8//Divisionsfaktor 8. 
-    * //ADC_PRESCALE_16//Division factor 16. +    * //ADC_PRESCALE_16//Divisionsfaktor 16. 
-    * //ADC_PRESCALE_32//Division factor 32. +    * //ADC_PRESCALE_32//Divisionsfaktor 32. 
-    * //ADC_PRESCALE_64//Division factor 64. +    * //ADC_PRESCALE_64//Divisionsfaktor 64. 
-    * //ADC_PRESCALE_128//Division factor 128.+    * //ADC_PRESCALE_128//Divisionsfaktor 128.
  
-=== Functions ===+=== Funktionen ===
  
   * **//void adc_init(adc_reference reference, adc_prescale prescale)//** \\   * **//void adc_init(adc_reference reference, adc_prescale prescale)//** \\
-    Initializes ADC. Parameters+    Initialisiert ADC. Parameter
-    * //reference//Reference voltage selection+    * //reference//Auswahl der Vergleichsspannung
-    * //prescale//Clock prescaler selection.+    * //prescale//Auswahl des  Takt-Vorteilers.
  
   * **//unsigned short adc_get_value(unsigned char channel)//** \\   * **//unsigned short adc_get_value(unsigned char channel)//** \\
-    Converts specified ADC channel analog value to digitalFunction is blocking. Parameter: +    Konvertiert bestimmte analoge ADC Kanalwerte in digitaleDie Funktion blockiert. Parameter: 
-    * //channel// - ADC channel number (0 to 7). +    * //channel// - ADC Kanalnummer (0 bis 7). 
-    * Return 10-bit digital value.+    * Liefert einen digitalen 10-bit Wert.
  
   * **//unsigned short adc_get_average_value(unsigned char channel, unsigned char num_samples)//** \\   * **//unsigned short adc_get_average_value(unsigned char channel, unsigned char num_samples)//** \\
-    Converts specified ADC channel analog value to digital desired number of times and calculates the averageFunction is blockinParameters: +    Konvertiert eine gewünschte Anzahl analoger Werte eines bestimmten ADC Kanals zur digitalen Werten und berechnet den MittelwertDie Funktion blockiert
-    * //channel// - ADC channel number (0 to 7). +    * //channel// - ADC Kanalnummer (0 bis 7). 
-    * //num_samples//Number of samples for calculation (1 to 64). +    * //num_samples//Anzahl der Werte für die Berechnung (1 bis 64). 
-    * Return 10-bit digital value.+    * Liefert einen digitalen 10-bit Wert.
  
-=== Example ===+=== Beispiel === 
 + 
 +Der ADC sei initialisiert und zwei analoge Kanalwerte zu digitalen konvertiert. Der Wert von Kanal 0 wird der Variable //x// zugewiesen und der durchschnittliche Wert von Kanal 1 der Variable //y//.
  
-For example ADC is initialized and two analog channel values are converted to digital. Value of channel 0 is assigned to variable //x// and averaged value of channel 1 to variable //y//. 
  
 <code c> <code c>
Line 1619: Line 1333:
  unsigned short x, y;  unsigned short x, y;
  
- // Initializing ADC. Reference voltage from AVCC. + // Initialisierung ADC. Vergleichsspannung von AVCC. 
- // Clock is times slower than system clock.+ // Takt ist mal langsamer als der Systemtakt.
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
  
- // Converting channel value.+ // Konvertierung des Wertes von Kanal 0.
  x = adc_get_value(0);  x = adc_get_value(0);
  
- // Converting and averaging channel value.+ // Konvertieren des Wertes von Kanal und Errechnung des Durchschnitts.
  y = adc_get_average_value(1, 10);  y = adc_get_average_value(1, 10);
 } }
Line 1632: Line 1346:
  
  
-==== Serial interface ====+==== Serielles Interface ====
  
-This library provides AVR asynchronous serial interface usage functions.+Diese Bibliothek bietet die Funktionen für das AVR asynchrone serielle Interface
  
-=== Data types ===+=== Datentypen ===
  
-  * **//usart//** \\ Data type to hold USART inteface controlstatus and data register addresses. //usart// typed variables should be initialized at the beginning of the program codeFor initializations, there is a macro-functions //USART// which only parameter is the index of interface (0 or 1).+  * **//usart//** \\ Datentyp für USART Interfacekontroll-Status- und Datenregisteradressen. //usart// Variablen sollten zu Beginn des Programms initialisiert werdenFür die Initialisierung gibt es eine Macrofunktion //USART// dessen einziger Parameter für den Index des Interface ist. (0 oder 1).
  
-  * **//adc_usart_databits//** \\ Data bits count enumeration data typeOptions+  * **//usart_databits//** \\ Zählen der Datenbits, AufzählungsdatentypMöglichkeiten
-    * //USART_DATABITS_5// - 5 data bits+    * //USART_DATABITS_5// - 5 Datenbits
-    * //USART_DATABITS_6// - 6 data bits+    * //USART_DATABITS_6// - 6 Datenbits
-    * //USART_DATABITS_7// - 7 data bits+    * //USART_DATABITS_7// - 7 Datenbits
-    * //USART_DATABITS_8// - 8 data bits+    * //USART_DATABITS_8// - 8 Datenbits
-    * //USART_DATABITS_9// - 9 data bits.+    * //USART_DATABITS_9// - 9 Datenbits.
  
-  * **//usart_stopbits//** \\ Stop bits count enumeration data typeOptions+  * **//usart_stopbits//** \\ Zählen der Stop-Bits, AufzählungsdatentypMöglichkeiten
-    * //USART_STOPBITS_ONE//One stop bit+    * //USART_STOPBITS_ONE//Ein Stop-Bit
-    * //USART_STOPBITS_TWO//Two stop bits.+    * //USART_STOPBITS_TWO//Zwei Stop-Bit.
  
-  * **//usart_parity//** \\ Parity mode enumeration data typeOptions+  * **//usart_parity//** \\ Paritätsmodus, AufzählungsdatentypMöglichkeiten
-    * //USART_PARITY_NONE//Disabled+    * //USART_PARITY_NONE//Ausgeschaltet
-    * //USART_PARITY_EVEN//Even parity+    * //USART_PARITY_EVEN//Gerade Parität
-    * //USART_PARITY_ODD//Odd parity.+    * //USART_PARITY_ODD//Ungerade Parität.
  
-=== Functions ===+=== Funktionen ===
  
   * **//USART_BAUDRATE_ASYNC(baud)//** \\   * **//USART_BAUDRATE_ASYNC(baud)//** \\
-    Macro function to calculate USART baud rate register value in asynchronous modeParameters+    Makrofunktion um den USART Baudratenregisterwert im asynchronen Modus zu berechnenParameter:  
-    * //baud// - Desired baud rate. +    * //baud// - Gewünschte Baudrate 
-    * Returns baud rate register value.+    * Gibt Baudratenregisterwert wieder.
  
   * **//void usart_init_async(usart port, usart_databits data_bits, usart_stopbits stop_bits, usart_parity parity, usart_baudrate baudrate)//** \\   * **//void usart_init_async(usart port, usart_databits data_bits, usart_stopbits stop_bits, usart_parity parity, usart_baudrate baudrate)//** \\
-    Initializes asynchronous USART. Parameters+    Initialisiert asynchrones USART. Parameter
-    * //port// - USART interface variable+    * //port// - USART Schnittstellenvariable
-    * //data_bits//Data bits+    * //data_bits//Datenbits
-    * //stop_bits// - Stop bits+    * //stop_bits// - Stop-Bits
-    * //parity// - Parity mode+    * //parity// - Paritätsmodus
-    * //baudrate//Baud rate register value (can be calculated with //USART_BAUDRATE_ASYNC// macro function).+    * //baudrate//Baudratenregisterwert (kann mit der Makrofunktion //USART_BAUDRATE_ASYNC// errechnet werden).
  
   * **//void usart_send_char(usart port, char symbol)//** \\   * **//void usart_send_char(usart port, char symbol)//** \\
-    Blocking character transmissionFunctions wait until transmit buffer empties before writing a character to the bufferParameters+    Blockiert die Übertragung von ZeichenDie Funktionen warten solange bis der Ausgabespeicher leer ist, bevor ein Zeichen in den Speicher geschrieben wirdParameter:  
-    * //port// - USART interface variable+    * //port// - USART Schnittstellenvariable
-    * //symbol// - Character to be sent.+    * //symbol// - zu sendendes Zeichen.
  
   * **//void usart_send_string(usart port, char *text)//** \\   * **//void usart_send_string(usart port, char *text)//** \\
-    Blocking string transmissionParameters+    Blockierende String-ÜbertragungParameter
-    * //port// - USART interface variable+    * //port// - USART Schnittstellenvariable
-    * //text// - Pointer to strin (char array). String has to end with null character.+    * //text// - Zeiger auf einen String(char array). Der String muss mit einer Null enden.
  
   * **//bool usart_has_data(usart port)//** \\   * **//bool usart_has_data(usart port)//** \\
-    Checks for data in receive bufferParameters+    Überprüft Empfangsspeicher auf DatenParameter
-    * //port// - USART interface variable+    * //port// - USART Schnittstellenvariable
-    * Returns //true// when there is a character in receive buffer, and //false// when not.+    * Gibt //true// zurück wenn Zeichen im Empfangsspeicher und //false// wenn nicht.
  
   * **//char usart_read_char(usart port)//** \\   * **//char usart_read_char(usart port)//** \\
-    Reads a character from receive bufferBefore reading user must check if there actually is  a received characterParameters:  +    Liest ein Zeichen aus dem EmpfangsspeicherZuvor muss der Nuter überprüfen ob tatsächlich ein Zeichen empfangen wurdeParameter
-    * //port// - USART interface variable+    * //port// - USART Schnittstellenvariable
-    * Returns character.+    * Gibt Zeichen aus.
  
   * **//bool usart_try_read_char(usart port, char *symbol)//** \\   * **//bool usart_try_read_char(usart port, char *symbol)//** \\
-    Reads a character from receive buffer if there is anyParameters+    Liest ein Zeichen aus dem Empfangsspeicher, falls eins vorhanden istParameter
-    * //port// - USART interface variable+    * //port// - USART Interfacevariable
-    * //symbol// - Pointer to character variableIf there is a character in receive bufferit is written to the pointed variable+    * //symbol// - Verweis auf die Variable des ZeichensWenn ein Zeichen im Empfangsspeicher vorhanden istwird es der betreffenden Variable zugeschrieben
-    * Returns //true// when there was a character in receive bufferand //false// when not.+    * Gibt //true// auswenn ein Zeichen im Empfangsspeicher vorhanden ist und //false// wenn nicht.
  
-=== Example ===+=== Beispiel ===
  
-USART interface is configured to use data bitsone stop bit, 9600 bps baud rate and no parity modeProgram sends a stringwaits until some character is received and then reads it out.+Die USART Schnittstelle ist konfiguriert um Datenbitsein Stop-Bit, 9600 bps Baudrate und keinen Paritätsmodus zu nutzenDas Programm sendet einen Stringwartet bis die Zeichen empfangen wurden und ließt sie dann aus.
  
 <code c> <code c>
 #include <homelab/usart.h> #include <homelab/usart.h>
  
-// Use USART interface 0.+// Nutze USART Schnittstelle 0.
 usart port = USART(0); usart port = USART(0);
  
Line 1711: Line 1425:
  char c;  char c;
  
- // Interface initialization.+ // Initialisierung der Schnittstelle.
  usart_init_async(port,  usart_init_async(port,
  USART_DATABITS_8,  USART_DATABITS_8,
Line 1718: Line 1432:
  USART_BAUDRATE_ASYNC(9600));  USART_BAUDRATE_ASYNC(9600));
  
- // String sending.+ // Senden des String.
  usart_send_string(port, "Hello\n");  usart_send_string(port, "Hello\n");
  
- // Waiting for incoming data.+ // Auf ankommende Daten warten.
  while (!usart_has_data(port)) {}  while (!usart_has_data(port)) {}
  
- // Read out the received character.+ // Empfangenes Zeichen auslesen.
  c = usart_read_char(port);  c = usart_read_char(port);
 } }
 </code> </code>
  
-==== Timers ====+==== Timer ====
  
-This library covers large part of the functionality of ATmega128 timersThere are data types and functions which make usage of timers easierUnfortunately, because of the complexity of AVR timersthere are no common functions to use different timersEach of the timer has functions which starts with the prefix of "timer" and its index.+Diese Bibliothek deckt einen großen Teil der Funktionen des Timers des ATmega128 abEs gibt Datentypen und Funktionen welche das Benutzen von Timern vereinfachenAufgrund der Komplexität der AVR Timer gibt es leider keine allgemeingültige Funktiondie für verschiedene Timer genutzt werden kannDie Funktionen jedes Timers beginnen mit dem Präfix "timer" und seinem Index.
  
-=== Data types ===+=== Datentypen ===
  
-  * **//timer0_prescale//** \\ Timer 0 prescaler enumeration data typeOptions+  * **//timer0_prescale//** \\ Timer 0 Vorteiler, AufzählungsdatentypMöglichkeiten
-    * //TIMER0_NO_PRESCALE//No prescaler (no division).+    * //TIMER0_NO_PRESCALE//Kein Vorteiler (keine Division).
     * //TIMER0_PRESCALE_8// - Clk / 8.     * //TIMER0_PRESCALE_8// - Clk / 8.
     * //TIMER0_PRESCALE_32// - Clk / 32.     * //TIMER0_PRESCALE_32// - Clk / 32.
Line 1744: Line 1458:
     * //TIMER0_PRESCALE_1024// - Clk / 1024.     * //TIMER0_PRESCALE_1024// - Clk / 1024.
  
-  * **//timer2_prescale//** \\ Timer 2 prescaler enumeration data typeOptions+  * **//timer2_prescale//** \\ Timer 2 Vorteiler, AufzählungsdatentypMöglichkeiten
-    * //TIMER2_NO_PRESCALE//No prescaler (no division).+    * //TIMER2_NO_PRESCALE//kein Vorteiler (keine Division).
     * //TIMER2_PRESCALE_8// - Clk / 8.     * //TIMER2_PRESCALE_8// - Clk / 8.
     * //TIMER2_PRESCALE_64// - Clk / 64.     * //TIMER2_PRESCALE_64// - Clk / 64.
     * //TIMER2_PRESCALE_256// - Clk / 256.     * //TIMER2_PRESCALE_256// - Clk / 256.
     * //TIMER2_PRESCALE_1024// - Clk / 1024.     * //TIMER2_PRESCALE_1024// - Clk / 1024.
-    * //TIMER2_PRESCALE_T2_FALLING//Clock on pin T2 falling edge+    * //TIMER2_PRESCALE_T2_FALLING//Taktgeber an Pin T2 fallende Flanke
-    * //TIMER2_PRESCALE_T2_RISING//Clock on pin T2 rising edge.+    * //TIMER2_PRESCALE_T2_RISING//Taktgeber an Pin T2 steigende Flanke.
  
   * **//timer1_prescale//**    * **//timer1_prescale//** 
-  * **//timer3_prescale//** \\ Timer 1/3 prescaler enumeration data typeOptions ("n" means or 3): +  * **//timer3_prescale//** \\ Timer 1/3 Vorteiler, AufzählungsdatentypMöglicheiten ("n" bedeutet oder 3): 
-    * //TIMERn_NO_PRESCALE//No prescaler (no division).+    * //TIMERn_NO_PRESCALE//Kein Vorteiler (keine Division).
     * //TIMERn_PRESCALE_8// - Clk / 8.     * //TIMERn_PRESCALE_8// - Clk / 8.
     * //TIMERn_PRESCALE_64// - Clk / 64.     * //TIMERn_PRESCALE_64// - Clk / 64.
     * //TIMERn_PRESCALE_256// - Clk / 256.     * //TIMERn_PRESCALE_256// - Clk / 256.
     * //TIMERn_PRESCALE_1024// - Clk / 1024.     * //TIMERn_PRESCALE_1024// - Clk / 1024.
-    * //TIMERn_PRESCALE_Tn_FALLING//Clock on pin Tn falling edge+    * //TIMERn_PRESCALE_Tn_FALLING//Taktgeber an Pin Tn fallende Flanke
-    * //TIMERn_PRESCALE_Tn_RISING//Clock on pin Tn rising edge.+    * //TIMERn_PRESCALE_Tn_RISING//Taktgeber an Pin Tn steigende Flanke.
  
   * **//timer1_ctc_top//**   * **//timer1_ctc_top//**
-  * **//timer3_ctc_top//** \\ Timer 1/3 CTC mode top value enumeration data typeOptions ("n" means or 3): +  * **//timer3_ctc_top//** \\ Timer 1/3 CTC Modus, Höchstwert, AufzählungsdatentypMöglichkeiten ("n" bedeutet oder 3): 
-    * //TIMERn_CTC_TOP_OCRA//Top value from timer 1/3 output compare register A. +    * //TIMERn_CTC_TOP_OCRA//Höchstwert des Timers 1/3 output compare register A. 
-    * //TIMERn_CTC_TOP_ICR//Top value from timer 1/3 input capture register.+    * //TIMERn_CTC_TOP_ICR//Höchstwert des Timers 1/3 input capture register.
  
   * **//timer1_fast_pwm_top//**   * **//timer1_fast_pwm_top//**
   * **//timer3_fast_pwm_top//** \\ Timer 1/3 fast PWM mode top value enumeration data type. Options ("n" means 1 or 3):   * **//timer3_fast_pwm_top//** \\ Timer 1/3 fast PWM mode top value enumeration data type. Options ("n" means 1 or 3):
-    * //TIMERn_FAST_PWM_TOP_256//Top value 255. +    * //TIMERn_FAST_PWM_TOP_256//Höchstwert 255. 
-    * //TIMERn_FAST_PWM_TOP_512//Top value 511. +    * //TIMERn_FAST_PWM_TOP_512//Höchstwert  511. 
-    * //TIMERn_FAST_PWM_TOP_1024//Top value 1023. +    * //TIMERn_FAST_PWM_TOP_1024//Höchstwert  1023. 
-    * //TIMERn_FAST_PWM_TOP_ICR//Top value from timer 1/3 input capture register. +    * //TIMERn_FAST_PWM_TOP_ICR//Höchstwert des Timers 1/3 input capture register. 
-    * //TIMERn_PAST_PWM_TOP_OCRA//Top value from timer 1/3 output compare register A.+    * //TIMERn_PAST_PWM_TOP_OCRA//Höchstwert des Timers 1/3 output compare register A.
  
   * **//timer1_fast_pwm_output_mode//**   * **//timer1_fast_pwm_output_mode//**
-  * **//timer1_fast_pwm_output_mode//** \\ Timer 1/3 fast PWM mode outputs configuration enumeration data type. Options ("n" means 1 or 3):+  * **//timer3_fast_pwm_output_mode//** \\ Timer 1/3 fast PWM mode outputs configuration enumeration data type. Options ("n" means 1 or 3):
     * //TIMERn_FAST_PWM_OUTPUT_DISABLE// - No output.     * //TIMERn_FAST_PWM_OUTPUT_DISABLE// - No output.
     * //TIMERn_FAST_PWM_OUTPUT_TOGGLE_ON_MATCH// - Output toggles on compare match.     * //TIMERn_FAST_PWM_OUTPUT_TOGGLE_ON_MATCH// - Output toggles on compare match.
Line 1783: Line 1497:
     * //TIMERn_FAST_PWM_OUTPUT_SET_ON_MATCH// - Output sets on compare match.     * //TIMERn_FAST_PWM_OUTPUT_SET_ON_MATCH// - Output sets on compare match.
  
-=== Functions ===+=== Funktionen ===
  
   * **//void timer0_init_normal(timer0_prescale prescale)//** \\   * **//void timer0_init_normal(timer0_prescale prescale)//** \\
-    Initializes timer in normal mode. In this mode timer counts from to 255 (including). Overflow interrupt can be usedParameters:+    Initialisiert Timer im normalen Modus. In diesem Modus zählt der Timer von bis 255 (inkl.). Overflowinterrupts können genutzt werden. Parameter.
     * //prescale// - Prescaler.     * //prescale// - Prescaler.
  
   * **//void timer2_init_normal(timer2_prescale prescale)//** \\   * **//void timer2_init_normal(timer2_prescale prescale)//** \\
-    Initializes timer in normal mode. In this mode timer counts from to 255 (including). Overflow interrupt can be usedParameters:+    Initialisiert Timer im normalen Modus. In diesem Modus zählt der Timer von bis 255 (inkl.). Overflowinterrupts können genutzt werden. Parameter.
     * //prescale// - Prescaler.     * //prescale// - Prescaler.
  
   * **//void timer0_stop()//**   * **//void timer0_stop()//**
   * **//void timer2_stop()//** \\   * **//void timer2_stop()//** \\
-    Stops timer 0/2.+    Stoppt Timer 0/2.
  
   * **//unsigned char timer0_get_value(void)//**   * **//unsigned char timer0_get_value(void)//**
Line 1920: Line 1634:
     Resets timer 1/3 input capture flag.     Resets timer 1/3 input capture flag.
  
-=== Example ===+=== Beispiel ===
  
-In the following program timer is started in normal mode with overflow interrupt.+Im folgenden Programm wird Timer im normalen Modus mit Overflowinterrupt gestartet.
  
 <code c> <code c>
Line 1945: Line 1659:
 } }
 </code> </code>
-==== Delay ====+==== Verzögerung ====
  
-This part of library contains functions to generate delays in program with software algorithms or with hardware timersDelays do not block interrupts therefore software delays are interfered by themDelay functions are not pre-compiled to be compatible with different clock frequencies.+Dieser Teil der Bibliothek enthält die benötigten Funktionen, um in einem Programm mit Hilfe von Software Algorithmen oder Hardwaretimern Verzögerungen zu generierenVerzögerungen blocken keine Interrupts, daher werden Softwareverzögerungen durch Interrupts unterbrochenVerzögerungsfunktionen sind nicht vor-kompiliert, sodass sie mit verschiedenen Taktfrequenzen genutzt werden können.
  
-=== Functions ===+=== Funktionen ===
  
   * **//void sw_delay_ms(unsigned short count)//** \\   * **//void sw_delay_ms(unsigned short count)//** \\
-    Software delay in millisecondsFunction expects the usage of some compiler optimization modeParameters+    Softwareverzögerung in Millisekunden (ms)Für diese Funktion wird ein Compiler Optimierungsmodus benötigtParameter
-    * //count// - Delay time in milliseconds. 0 to 65535 ms.+    * //count// - Verzögerungszeit in ms. 0 bis 65535 ms.
  
   * **//void sw_delay_us(unsigned short count)//** \\   * **//void sw_delay_us(unsigned short count)//** \\
-    Software delay in microsecondsFunction expects the usage of some compiler optimization modeParameters+    Softwareverzögerung in Mikrosekunden (μs)Für diese Funktion wird ein Compiler Optimierungsmodus benötigtParameter
-    * //count// - Delay time in microseconds. 0 to 65535 μs.+    * //count// - Verzögerungszeit in μs. 0 bis 65535 μs.
  
   * **//void hw_delay_ms(unsigned short count)//** \\'   * **//void hw_delay_ms(unsigned short count)//** \\'
-    Hardware timer based delay in millisecondsFunctions use ATmega128 8-bit timer 0. Depending of the clock frequency, up to several milliseconds delay error  may occurParameters+    Zeitgeber basierte Verzögerung in MillisekundenDiese Funktionen verwenden den ATmega128 8-bit Timer 0. In Abhängigkeit von der Taktfrequenz kann eine Verzögerung von bis zu einigen Millisekunden auftretenParameter
-    * //count// - Delay time in milliseconds. 0 to 65535 ms.+    * //count// - Verzögerungszeit in ms. 0 bis 65535 ms.
  
-=== Examples ===+=== Beispiele ===
  
-Demonstration of both types of delays.+Demonstration beider Typen einer Verzögerung:
  
 <code c> <code c>
Line 1972: Line 1686:
 int main(void) int main(void)
 {  {
- // Software base delay of 100 ms.+ // Software-basierte Verzögerung von 100 ms.
  sw_delay_ms(100);  sw_delay_ms(100);
   
- // Hardware timer based delay of 100 ms.+ // Hardware- (Timer-) basierte Verzögerung von 100 ms.
  hw_delay_ms(100);  hw_delay_ms(100);
 } }
 </code> </code>
  
-==== 7-segment LED display ====+--- 
 + MISSING PAGE --- 
 +==== 7-Segment LED Display ====
  
-//Related to: [HW] [[en:hardware:homelab:digi]]//+//In Bezug auf: [HW] [[en:hardware:homelab:digi]]//
  
-This library is intended to use 7-segment LED display on HomeLab Digital i/o module boardNumbers from to can be displayed with library.+Diese Bibliothek dient zur Nutzung des 7-Segment LED Displays der digitalen HomeLab digitalen I/O Modulplatine gedachtMit dieser Bibliothek können Zahlen von bis dargestellt werden.
  
-=== Functions ===+=== Funktionen ===
  
   * **//void segment_display_init(void)//** \\   * **//void segment_display_init(void)//** \\
-    Configures display driver control pins.+    Konfiguriert Kontrollpins für den Displaytreiber.
  
   * **//void segment_display_write(unsigned char digit)//** \\   * **//void segment_display_write(unsigned char digit)//** \\
-    Displayes a digit on displayParameters+    Zeigt eine Ziffer auf dem Display anParameter
-    * //digit// - Number value from to 9. Any other case like "erroris displayed.+    * //digit// - Zahlenwert von bis 9. Ansonsten wird ein für "Errorangezeigt.
  
-=== Example ===+=== Beispiel ===
  
-Number is showed on LED display.+Die Zahl wird auf dem LED-Display angezeigt.
  
 <code c> <code c>
Line 2004: Line 1720:
 int main(void) int main(void)
 { {
- // Display initialization.+ // Initialisierung des Displays
  segment_display_init();  segment_display_init();
  
- // Digit displaying.+ // Anzeige der Zahl.
  segment_display_write(5);  segment_display_write(5);
 } }
Line 2015: Line 1731:
  
  
-==== Alphanumeric LCD ====+==== Alphanumerisches LCD ====
  
-//Related to: [HW] [[en:hardware:homelab:lcd]]//+//Bezug nehmend auf: [HW] [[en:hardware:homelab:lcd]]//
  
-This library contains functions to use HomeLab alphanumeric LCD.+Diese Bibliothek enthält die Funktionen, um das alphanumerische LCD des HomeLab zu nutzen.
  
-=== Data types ===+=== Datentypen ===
  
-  * **//lcd_alpha_mode//** \\ LCD configuration enumeration data typeOptions+  * **//lcd_alpha_mode//** \\ LCD Konfiguration, AufzählungsdatentypMöglichkeiten
-    * //LCD_ALPHA_DISP_OFF// - Display off+    * //LCD_ALPHA_DISP_OFF// - Display aus
-    * //LCD_ALPHA_DISP_ON// - Display on with invisible cursor+    * //LCD_ALPHA_DISP_ON// - Display an mit unsichbarem Cursor
-    * //LCD_ALPHA_DISP_ON_CURSOR// - Display on with cursor+    * //LCD_ALPHA_DISP_ON_CURSOR// - Display an mit Cursor
-    * //LCD_ALPHA_DISP_ON_CURSOR_BLINK// - Display on with blinking cursor.+    * //LCD_ALPHA_DISP_ON_CURSOR_BLINK// - Display an mit blinkendem Cursor.
  
-=== Functions ===+=== Funktionen ===
  
   * **//void lcd_alpha_init(lcd_alpha_mode disp_attr)//** \\   * **//void lcd_alpha_init(lcd_alpha_mode disp_attr)//** \\
-    Initializes LCD. Parameters+    Initialisiert LCD. Parameter
-    * //disp_attr// - Display configuration.+    * //disp_attr// - Display Konfiguration.
  
   * **//void lcd_alpha_clear(void)//** \\   * **//void lcd_alpha_clear(void)//** \\
-    Clears the whole display. Cursor is moved to the beginning of the first line.+    Löscht die Anzeige. Cursor wird zum Anfang der ersten Zeile bewegt.
  
   * **//void lcd_alpha_clear_line(unsigned char line)//** \\   * **//void lcd_alpha_clear_line(unsigned char line)//** \\
-    Clears a line on display. Cursor is moved to the beginning of cleared lineParameters+    Löscht eine Zeile am Display. Cursor wird zum Anfang der ersten Zeile bewegtParameter
-    * //line// - Line number. or 1.+    * //line// - Zeilennummer: oder 1.
  
   * **//void lcd_alpha_home(void)//** \\   * **//void lcd_alpha_home(void)//** \\
-    Moves cursor to the beginning of the first line.+    Cursor wird zum Anfang der ersten Zeile bewegt.
  
   * **//void lcd_alpha_goto_xy(unsigned char x, unsigned char y)//** \\   * **//void lcd_alpha_goto_xy(unsigned char x, unsigned char y)//** \\
-    Moves cursor to the desired position. Parameters+    Bewegt den Cursor zur gewünschten PositionParameter: 
-    * //x// - X coordinate (column number). 0 to 15. +    * //x// - X Koordinate (Spaltennumner). 0 bis 15. 
-    * //y// - Y coordinate (line number). 0 to 1.+    * //y// - Y Koordinate (Zeilennumner). 0 bis 1.
  
   * **//void lcd_alpha_write_char(char c)//** \\   * **//void lcd_alpha_write_char(char c)//** \\
-    Writes a character to the cursor positionParameters+    Schreibt ein Zeichen auf die Position des CursorsParameter
-    * //c// - ASCII character.+    * //c// - ASCII Zeichen.
  
   * **//void lcd_alpha_write_string(const char *s)//** \\   * **//void lcd_alpha_write_string(const char *s)//** \\
-    Writes a string to the display starting from the position of the cursorParameters+    Schreibt einen String aufs Display, beginnend bei der CursorpositionParameter
-    * //s// - Pointer to string (char array).+    * //s// - Zeiger auf einen String(char array).
  
   * **//void lcd_alpha_write_string_p(const char *progmem_s)//** \\   * **//void lcd_alpha_write_string_p(const char *progmem_s)//** \\
-    Writes a string from program memory to the display starting from the position of the cursorParameters +    Schreibt einen String vom Programmspeicher aufs Displays, beginnt an der Cursorposition. 
-    * //progmem_s//Pointer to string in program memory.+    Parameter: 
 +    * //progmem_s//Zeiger auf String im Programmspeicher.
  
-=== Example ===+=== Beispiel ===
  
-Demonstration of how to use alphanumeric LCD to display text.+Nutzung des alphanumerischen LCD zur Darstellung von Text:
  
 <code c> <code c>
Line 2071: Line 1788:
 int main(void) int main(void)
 { {
- // LCD initialization.+ // Initialisierung des LCD.
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
  
- // Display clearing.+ // Löschen des Displays.
  lcd_alpha_clear();  lcd_alpha_clear();
  
- // Cursor to the beginning of second line.+ // Cursor an den Beginn der zweiten Zeile setzen.
  lcd_alpha_goto_xy(0, 1);   lcd_alpha_goto_xy(0, 1);
  
- // Text displaying.+ // Anzeige des Texts.
  lcd_alpha_write_string("Hello");  lcd_alpha_write_string("Hello");
 } }
 </code> </code>
  
-==== Graphic LCD ====+==== Graphisches LCD ====
  
-//Related to: [HW] [[en:hardware:homelab:lcd]]//+//Related to: [HW] [[en:hardware:homelab:digi]]//
  
-This library contains functions to use HomeLab graphical LCD. Although LCD is capable of displaying graphical images no such functions are implemented in the library. LCD is used as a 14 x 6 character alphanumeric display.+Diese Bibliothek enthält die Funktionen zur Nutzung des graphischen LCD des HomeLabObwohl das LCD graphische Bilder wiedergeben kann, enthält die Bibliothek diese Funktionen nichtDas LCD wird als alphanumerisches Display mit 14 x 6 Zeichen genutzt
  
-=== Functions ===+=== Funktionen ===
  
   * **//void lcd_gfx_init(void)//** \\   * **//void lcd_gfx_init(void)//** \\
-    Intializes LCD.+    Intialisiert das LCD.
  
   * **//void lcd_gfx_backlight(bool set)//** \\   * **//void lcd_gfx_backlight(bool set)//** \\
-    Switch LCD backlight on or offParameters+    Schaltet die Hintergrundbeleuchtung des LCD an/ausParameter
-    * //set// - //true// when backlight on, //false// when off.+    * //set// - //true// wenn Hintergrundbeleuchtung an, //false// wenn aus.
  
   * **//void lcd_gfx_clear(void)//** \\   * **//void lcd_gfx_clear(void)//** \\
-    Clears a whole display.+    Löscht das gesamte Display
  
   * **//void lcd_gfx_clear_line(unsigned char line)//** \\   * **//void lcd_gfx_clear_line(unsigned char line)//** \\
-    Clears a single text lineParameters+    Löscht eine Zeile TextParameter
-    * //line// - Line number. 0 to 5.+    * //line// - Zeilennummer. 0 bis 5.
  
   * **//void lcd_gfx_goto_char_xy(unsigned char x, unsigned char y)//** \\   * **//void lcd_gfx_goto_char_xy(unsigned char x, unsigned char y)//** \\
-    Selects a position to write text toParameters+    Wählt eine Position zum Beschreiben ausParameter
-    * //x// - X coordinate. 0 to 13. +    * //x// - X-Koordinate. 0 bis 13. 
-    * //y// - Y coordinate. 0 to 5.+    * //y// - Y-Koordinate. 0 bis 5.
  
   * **//void lcd_gfx_write_char(char c)//** \\   * **//void lcd_gfx_write_char(char c)//** \\
-    Writes a character to the pre-defined positionParameters+    Schreibt ein Zeichen an eine zuvor bestimmte PositionParameter
-    * //c// - ASCII character.+    * //c// - ASCII Zeichen.
  
   * **//void lcd_gfx_write_string(char *s)//** \\   * **//void lcd_gfx_write_string(char *s)//** \\
-    Writes a string to the display starting from the pre-defined positionParameters+    Schreibt einen String an eine zuvor bestimmte PositionParameter
-    * //s// - Pointer to string (char array).+    * //s// - Zeiger auf einen String(char array).
  
-=== Example ===+=== Beispiel ===
  
-Demonstration of using a graphical LCD.+Nutzung des graphischen LCD:
  
 <code c> <code c>
Line 2129: Line 1846:
 int main(void) int main(void)
 { {
- // LCD initialization.+ // Initialisierung des LCD.
  lcd_gfx_init();  lcd_gfx_init();
  
- // Display clearing.+ // Löschen des Displays.
  lcd_gfx_clear();  lcd_gfx_clear();
  
- // Cursor to the middle of the screen.+ // Cursor in die Mitte des Bildschirms bewegen.
  lcd_gfx_goto_char_xy(5, 2);  lcd_gfx_goto_char_xy(5, 2);
  
- // Displaying a text.+ // Anzeige eines Textes.
  lcd_gfx_write_string("Hello");  lcd_gfx_write_string("Hello");
 } }
 </code> </code>
-==== Motors ====+==== Motoren ====
  
-//Related to: [HW] [[en:hardware:homelab:motor]]//+//Bezug nehmend auf: [HW] [[en:hardware:homelab:motor]]//
  
-This library contains functions to control different HomeLab motorsThere are functions for DC, stepper and servo motors.+Diese Bibliothek enthält Funktionen zur Steuerung der verschiedenen HomeLab MotorenSie enthält Funktionen für Gleichstrom- (DC-), Schritt- und Servomotoren,
  
-=== Functions ===+=== Funktionen ===
  
   * **//void dcmotor_init(unsigned char index)//** \\   * **//void dcmotor_init(unsigned char index)//** \\
-    Initializes one of the DC motor controllersParameters+    Initialisiert einen der Controller für die DC MotorenParameter
-    * //index// - Index of motor controller. 0 to 3.+    * //index// - Index des Motorencontrollers. 0 bis 3.
  
   * **//void dcmotor_drive(unsigned char index, signed char direction)//** \\   * **//void dcmotor_drive(unsigned char index, signed char direction)//** \\
-    Drives one of the DC motor controllersParameters+    Betriebt einen der Controller der DC MotorenParameter
-    * //index// - Index of motor controller. 0 to 3. +    * //index// - Index des Motorencontrollers. 0 bis 3. 
-    * //direction//Motor polarity. -1, 0 or +1. In case of motor is stoppedotherwise it turns in given direction.+    * //direction//Polarität des Motors. -1, 0 oder +1. Bei wird der Motor angehaltenansonsten bewegt er sich in die vorgegebene Richtung.
  
   * **//void unipolar_init(unsigned char index)//** \\   * **//void unipolar_init(unsigned char index)//** \\
-    Initializes one of the unipolar stepper motor controllersParameters+    Initialisiert den Controller eines der unipolaren SchrittmotorenParameter
-    * //index// - Index of motor controller. 0 or 1.+    * //index// - Index des Motorencontrollers. 0 oder 1.
  
   * **//void unipolar_halfstep(unsigned char index, signed char direction, unsigned short num_steps, unsigned char speed)//** \\   * **//void unipolar_halfstep(unsigned char index, signed char direction, unsigned short num_steps, unsigned char speed)//** \\
-    Unipolar stepper motor half-stepping commandFunctions is blocking as it is fulfilled as long as steps are doneParameters: +    Befehl zum Halbschrittbetrieb für unipolaren Schrittmotor. Die Funktion ist blockierend bis sie erfüllt ist, bis alle Schritte durchgeführt wurdenParameter
-    * //index// - Index of motor controller. 0 or 1. +    * //index// - Index des Motorencontrollers. 0 oder 1. 
-    * //direction//Directions of rotation. -1 or +1. +    * //direction//Rotationsrichtung. -1 oder +1. 
-    * //num_steps//Count of half-steps+    * //num_steps//Zählen der Halbschritte
-    * //speed// - Time of a single step in milliseconds.+    * //speed// - Zeit eines einzelnen Schritts in Millisekunden.
  
   * **//void bipolar_init(void)//** \\   * **//void bipolar_init(void)//** \\
-    Initializes bipolar stepper motor controller+    Initialisiert den Controller des bipolaren Schrittmotors
 +    
   * **//void bipolar_halfstep(signed char direction, unsigned short num_steps, unsigned char speed)//** \\   * **//void bipolar_halfstep(signed char direction, unsigned short num_steps, unsigned char speed)//** \\
-    Bipolar stepper motor half-stepping commandFunctions is blocking as it is fulfilled as long as steps are doneParameters+    Befehl zum Halbschrittbetrieb für bipolaren SchrittmotorDie Funktion ist blockierend bis sie erfüllt ist, bis alle Schritte durchgeführt wurdenParameter
-    * //direction//Directions of rotation. -1 or +1. +    * //direction//Rotationsrichtung . -1 oder +1. 
-    * //num_steps//Count of half-steps+    * //num_steps//Zählen der Halbschritte
-    * //speed// - Time of a single step in milliseconds.+    * //speed// - Zeit eines einzelnen Schritts in Millisekunden.
  
   * **//void servomotor_init(unsigned char index)//** \\   * **//void servomotor_init(unsigned char index)//** \\
-    Initializes one of a servo motor PWM signal generations units in ATmega128 timer 1. PWM signal is 50 hz with high period of 1.5 ms ± 0.5 ms. Parameters+    Initialisiert eine der PWM Signal-generierenden Einheiten eines Servomotors des ATmega128 Timers 1. Das PWM Signal beträgt 50 hz bei einer high period of 1.5 ms ± 0.5 ms. Parameter
-    * //index// - Index of servo motor. 0 or 1.+    * //index// - Index des Servomotors. 0 oder 1.
  
   * **//void servomotor_position(unsigned char index, signed short position)//** \\   * **//void servomotor_position(unsigned char index, signed short position)//** \\
-    Servo motor pulse width control commandIf positioning servo motor is driven, its position is altered, if rotating oneits rotation speed is alteredParameters+    Takt des Servomotors mit KontrollbefehlDie Position eines Servomotors verändert sich wenn dieser betrieben wird. Wird er gedrehtverändert sich seine DrehzahlParameter
-    * //index// - Index of servo motor. 0 or 1. +    * //index// - Index des Servomotors. 0 oder 1. 
-    * //position// - Position or rotation speed. -100 to +100. 0 corresponds to stop.+    * //position// - Position oder Drehzahl. -100 bis +100. Bei stoppt der Motor.
  
-=== Example ===+=== Beispiel ===
  
-The following program demonstrates the usage of DC, stepper and servo motors.+Nutzung von Gleichstrom- (DC-)Schritt- und Servomotoren.
  
 <code c> <code c>
Line 2197: Line 1914:
 int main(void) int main(void)
 { {
- // DC motors initialization.+ // Initialisierung der DC Motoren.
  dcmotor_init(0);  dcmotor_init(0);
  dcmotor_init(1);  dcmotor_init(1);
  
- // Bipolar stepper initialization.+ // Initialisierung des bipolaren Schrittmotors.
  bipolar_init();  bipolar_init();
  
- // Servo motors initialization.+ // Initialisierung der Servomotoren.
  servomotor_init(0);  servomotor_init(0);
  servomotor_init(1);  servomotor_init(1);
  
- // One DC motors drives forwardanother in backward direction.+ // Ein DC Motor fährt vorwärtsein anderer rückwärts.
  dcmotor_drive(0, -1);  dcmotor_drive(0, -1);
  dcmotor_drive(1, +1);  dcmotor_drive(1, +1);
  
- // Rotating the stepper motor 100 steps in one direction + // Bewegt den Schrittmotor 100 Schritte in eine Richtung 
- // and then back with twice the speed.+ // und daraufhin zurück mit doppelter Geschwindigkeit.
  bipolar_halfstep(1, 100, 50);  bipolar_halfstep(1, 100, 50);
  bipolar_halfstep(-1, 100, 25);  bipolar_halfstep(-1, 100, 25);
  
- // Rotating servo motors in opposite directions.+ // Bewegt Servomotoren in entgegengesetzte Richtungen.
  servomotor_position(0, -100);  servomotor_position(0, -100);
  servomotor_position(1, +100);  servomotor_position(1, +100);
 } }
 </code> </code>
-==== Sensors ====+==== Sensoren ====
  
-//Related to: [HW] [[en:hardware:homelab:sensor]]//+//Bezug nehmend auf: [HW] [[en:hardware:homelab:sensor]]//
  
-This library contains functions to use different sensors in HomeLab kit.+Diese Bibliothek enthält Funktionen für die verschiedenen Sensoren im HomeLab kit.
  
-=== Data types ===+=== Datentypen ===
  
   * **//ir_distance_sensor//** \\   * **//ir_distance_sensor//** \\
-    Infrared distance sensor distance calculation parameters structureFormula for distance calculation is //a / (ADC + b) - k//. Structure members:+    Infrarotentfernungssensor, Distanzberechnungs-ParameterstrukturFormel für die Entfernungsberechnung ist //a / (ADC + b) - k//. Struktur:
     * //a// - Dividend.     * //a// - Dividend.
-    * //b// - Non-linear constant+    * //b// - Nicht-lineare Konstante
-    * //k// - Linearizing constant.+    * //k// - Lineare Konstante.
  
-=== Constants ===+=== Konstante ===
  
     * **//ir_distance_sensor GP2Y0A21YK//** \\     * **//ir_distance_sensor GP2Y0A21YK//** \\
-    Sharp GP2Y0A21YK distance calculation formula parameters.+    Sharp GP2Y0A21YK Formelparameter zur Entfernungsberechnung.
  
-=== Functions ===+=== Funktionen ===
  
   * **//signed short thermistor_calculate_celsius(unsigned short adc_value)//** \\   * **//signed short thermistor_calculate_celsius(unsigned short adc_value)//** \\
-    Calculates thermistor temperature in Celsius degrees from ADC conversion resultFunctions use pre-calculated conversion tableParameters+    Berechnet die Thermistor Temperatur in Grad Celcius aus ADC UmrechnungsergebnissenDie Funktionen benutzen eine vorgefertigte UmrechnungstabelleParameter
-    * //adc_value// - ADC conversion result (10-bit with +5 V reference voltage).+    * //adc_value// - ADC Umrechnungsergebnis (10-Bit mit +5 V Referenzspannung). 
-    * Returns temperature in Celsius degrees in the -20 to 100 degrees limit.+    * Gibt die Temperatur mit Grenzwerten von -20 bis 100 °C an.
  
   * **//signed short ir_distance_calculate_cm(ir_distance_sensor sensor, unsigned short adc_value)//** \\   * **//signed short ir_distance_calculate_cm(ir_distance_sensor sensor, unsigned short adc_value)//** \\
-    Calculates distance from ADC result received from IR distance sensor voltageParameters+    Berechnet die Entfernung von ADC Ergebnissen die vom IR-Entfernungssensor empfangene Spannung anParameter
-    * //sensor// - Distance sensor calculation parameters+    * //sensor// - Kalkulationsparameter des Distanzsensors
-    * //adc_value// - ADC conversion result (10-bit with +5 V reference voltage). +    * //adc_value// - ADC Umrechnungsergebnis (10-bit mit +5 V Referenzspannung). 
-    * Returns distance in centimeters or -1 if it cannot be calculated.+    * Gibt die Entfernung in cm an, oder -1 wenn eine Messung nicht möglich ist.
  
   * **//unsigned short ultrasonic_measure(pin trigger, pin echo)//** \\   * **//unsigned short ultrasonic_measure(pin trigger, pin echo)//** \\
-    Measures distance with ultrasonic distance sensorFunctions generate a trigger pulse on one pin and measures the time of echo pulse on another pinDistance is calculated from the timeFunction expects a 14.7456 MHz clock frequencyMeasuring may take up to 36 msParameters+    Misst die Entfernung mit dem UltraschallentfernungsmesserDie Funktionen generieren einen Auslöseimpuls an einem Pin und messen die Zeit bis zum Echopulses am anderen PinDie Entfernung wird über die Zeit berechnetDie Funktionen benötigen eine 14.7456Mhz TaktfrequenzDie Messung kann bis zu 36ms dauernParameter
-    * //trigger// - Trigger pin variable+    * //trigger// - Variable des auslösenden Pins
-    * //echo// - Echo pin variable. +    * //echo// - Variable des Echo-Pin variable. 
-    * Returns distance in centimeters or when measuring failed.+    * Gibt Entfernung in cm an, oder wenn Messung nicht möglich.
  
-=== Example ===+=== Beispiel ===
  
-The following program demonstrates usage of IR and ultrasonic distance sensors.+Nutzung des Infrarot- und Ultraschallentfernungssensors.
  
 <code c> <code c>
 #include <homelab/module/sensors.h> #include <homelab/module/sensors.h>
  
-// Ultrasonic distance sensor control pins.+// Kontroll-Pins des Ultraschallentfernungssensors.
 pin pin_trigger = PIN(G, 1); pin pin_trigger = PIN(G, 1);
 pin pin_echo    = PIN(G, 0); pin pin_echo    = PIN(G, 0);
Line 2273: Line 1990:
 int main(void) int main(void)
 { {
- unsigned short adc_value = 400; // random ADC result.+ unsigned short adc_value = 400; // zufälliges ADC Ergebnis.
  signed short distance;  signed short distance;
  
- // Distance calculation from IR distance sensor ADC result.+ // Entfernungsberechnung des ADC Ergebnisses des IR-Entfernungssensors.
  distance = ir_distance_calculate_cm(GP2Y0A21YK, adc_value);  distance = ir_distance_calculate_cm(GP2Y0A21YK, adc_value);
  
- // Measuring with ultrasonic distance sensor.+ // Messung mit Ultraschallentfernungssensor.
  distance = ultrasonic_measure(pin_trigger, pin_echo);  distance = ultrasonic_measure(pin_trigger, pin_echo);
 } }
 </code> </code>
  
-====== Practical examples ======+--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +====== Praktische Beispiele ======
  
 {{  :images:book:examples.jpg?580  |}} {{  :images:book:examples.jpg?580  |}}
  
-Practical examples are built up in uniform style and as concrete as possibleEach example begins with a short introduction of the theory and gives necessary knowledges for completing the following practical partPractical part contains commented example of the source code of the softwareGenerally the library of the HomeLab is used in the example of the codebut in some cases the registers are also configured. The first chapter is a little bit different with a bit different goal. It describes installation and set-up of necessary software. The examples are about Windows and Linux operation systems. Chapters and practical examples after the first chapter are suitable for both OS and development software.+Die, in diesem Kapitel vorgestellten, praktischen Beispiele sind einheitlich aufgebaut und so konkret und praxisnah wie möglich gestelltJedes Beispiel beginnt mit einer kurzen Einführung in die zugrunde liegende Theorie sowie einer Darstellung des zum Verständnis der Beispiele nötigen HintergrundwissensDer praktische Teil besteht hauptsächlich aus kommentierten Programmcode, welcher die konkrete Anwendung verdeutlichtNormalerweise wird dabei die HomeLab Library genutzt, in einigen Fällen wird die Hardware jedoch auch direkt über Register angesteuert.
  
-~~PB~~+Das erste Kapitel weicht etwas von diesem Schema ab, hier wird primär die Installation und Konfiguration der notwendigen Softwarekomponenten beschrieben. Die Installationsanweisungen sind für Windows und Linux Betriebssysteme ausgelegt. Nachdem die Software einmal eingerichtet wurde, macht es keinen Unterschied mehr, ob ein Windows oder ein Linux/Unix basierendes Betriebssystem verwendet. Die Handhabung und Programierung wird dadurch nicht beeinflusst. 
  
-**Buildup**+Ein praktisches Beispiel beginnt immer mit einer Aufzählung von erforderlichen Vorkenntnissen. Dabei werden Bezüge zu anderen Kapiteln hergestellt, welche mit folgenden Abkürzungen gekennzeichnet sind:
  
-There is a list of necessary knowledges to complete the example at each chapter of practical examplesIn this list are references to other chapters of the bookwhich are marked with icons as follows:+  * [HW] Physikalisches Modul, das im Beispiel genutzt wird. 
 +  * [LIB] Teil der Softwarebibliothekdie im Beispiel genutzt wird. 
 +  * [ELC] Verweis auf das Kapitel über die Grundlagen der Elektronik. 
 +  * [AVR] Verweis auf das Kapitel über die AVR Mikrocontrollermodule. 
 +  * [PRT] Verweis auf andere Aufgaben.
  
-  [HW] Physical module used in th example. +**Grundlegende Software für die Beispiele**
-  [LIB] Part of the software library used in the example. +
-  [ELC] Reference to the chapter Basics of electronics. +
-  [AVR] Reference to the chapter AVR microcontroller's module. +
-  * [PRT] Reference to other exercises.+
  
-**Basic software of the examples**+Wie zuvor erwähnt werden die Codebeispiele auf Basis der HomeLab Bibliothek erstellt. 
 +Die meisten AVR-spezifischen Operationen und Verfahren, die auf die HomeLab Kit Hardware  zugreifen sind in dieser Bibliothek enthalten. Bei Verwendung der HomeLab Bibliothek muss somit kein Hardware-spezifischer Programmcode mehr erzeugt werden. Durch Bereitstellung der für die Hardware in den Beispielen und Übungen notwendigen Software,kann der Nutzer sich vollkommen auf seine Algorithmen konzentrieren und muss keine Zeit mit Einzelheiten verbringen, die nicht für die zu benutzende Hardware notwendig sind. 
  
-As mentioned before, practical code samples are composed on the basis of the library of the HomeLab. There are most used specific AVR operations and procedures connected with the HomeLab’s modules written in the library. The usage of the library means that in order to start the modules the user does not have to write a hardware-like,  program code which uses registers, although this opportunity always exists. Separating the software which communicates with hardware from the examples and exercises, allows the user to focus on creating his/hers own algorithm instead of peculiarities not connected to the hardware. +**Programmierstil in den Beispielen**
  
-**Code style of the examples**+Die Beispielprogramme sind in einem einheitlichen Stil geschrieben, um so einen synoptischeren Programmcode zu erhalten. So wird das Programm leserlicher und einfache Syntaxfehler können vermieden werden. Daher sollte dieser Stil auch bei den Übungsaufgaben angewandt werden. Die Hauptcharakteristika sind:
  
-The example programs are written in one style, to achieve more synoptic program code. Uniform style makes the program more readable and prevents making simple syntax mistakes. It is advised to follow a certain style when making exercises. The main characteristics of the style: 
  
-  * Program, all its functions and variables are in English and in small lettersthe words are separated with an under-strike+  * Das Programm, all seine Funktionen und Variablen sind in englischer Sprache und Kleinbuchstaben geschriebendie Wörter werden durch einen Unterstrich getrennt
-  * Functions are in following form: //object_action_subject//+  * Die Funktionen werden wie folgt gekennzeichnet: //object_action_subject//
-  * more important places in the program are commented+  * Wichtigere Teile des Programms werden kommentiert
-  * Every block in C-language (marked with and } )starts and begins in separate row+  * Jeder Block in C-Code (markiert durch und } )startet und beginnt in einer neuen Zeile
-  * Blocks are tabulated with tabulator keysTabulator is not used inside rows+  * Blöcke werden mit der Tabulatortaste geordnetDie Tabulatortaste wird nicht innerhalb einer Zeile verwendet
-===== Beginning =====+===== Anfang =====
  
 {{  :examples:install:install.jpg?580  |}} {{  :examples:install:install.jpg?580  |}}
  
-Environment for writing the codecompiler for corresponding language and software for uploading written program to the controller are needed in order to program AVR controllerThe most comfortable method would be using special integrated developing environment (IDE). The AVR microcontroller can be programmed in many different programming languagesassembler, C, C+, Pascal, Basic, etc. This book is focusing on using the C-language when programming the microcontrollerThere is free software for programming AVR microcontroller for both the Windows OS and the Linux OS. Next chapters are introducing the usage of both  +Zur Programmierung des AVR Mikrocontrollers werden eine Programmierumgebungein Compiler für die betreffende Sprache sowie Software zum Laden der erstellten Programme auf den Controller benötigtDie komfortabelste Weg hierfür ist die Nutzung der speziellen DIE (Integrated Developing Environment). Der AVR Mikrocontroller kann in folgenden Programmiersprachen programmiert werdenAssembler, C, C+, Pascal, Basic, etc. In diesem Buch wird verwendet um den Mikrocontroller zu programmierenDie Software ist sowohl für Windows OS und Linux OS frei erhältlichDie folgenden Kapitel führen in die Verwendung dieser ein.
  
-All software for passing the exercises can be found from the homepage of the HomeLab+Sämtliche, zur Durchführung der Beispiele notwendige Software, ist auf der HomeLab-Homepage zu finden.
  
-==== Installation instructions for Windows ==== 
  
-this section contains the information necessary to install AVR development software on Windows operating system. +--- 
- + MISSING PAGE --- 
-=== Installation === +--- 
- + MISSING PAGE --- 
-You need the following software which can be downloaded from manufacturers homepage or acquired from the CD supplied with the HomeLab kit. +--- 
- + MISSING PAGE --- 
-**1. AVR Studio** +===== Digitale Input/Output Pins =====
- +
-AVR Studio 4 IDE (//Integrated Development Environment//) is a base software for writing the source code, compiling it and uploading the program to the controller. AVR Studio can be downloaded from Atmel homepage. +
- +
-**2. WinAVR** +
- +
-WinAVR is a GNU-GCC compiler for AVR microcontrollers. This is a freeware which can be downloaded from Sourceforge webpage. During the installation process WinAVR offers a folder name containing long version number. We suggest to cut the version number from folder name and install it just like shown below: +
- +
-  C:\WinAVR +
- +
-**3. HomeLab library** +
- +
-HomeLab library is a set of functions designed for HomeLab kit and AVR controllers. By using the library the programming is much easier and effective. Latest version of the library can be downloaded from the HomeLab webpage. This library should be installed in the same folder where WinAVR was installed. +
- +
-**4.. Virtual COM port driver** +
- +
-Driver enables to connect USB JTAG-ICE programmer with your PC. Driver have to be installed before connecting the programmer. Driver file name is "CDM x.xx.xx.exe", where "x" denotes the version number. After installing the driver you can connect the JTAG-ICE programmer through the USB port and let Windows to detect the device automatically. You should see the notice on the windows task bar. +
- +
-{{  :examples:install:windows:new_hardware_popup.png?349  |Notice of finding the new device}} +
- +
-According to number of virtual ports previously defined on the particular computer the windows assigns next port number for the new device. New COM port name (range number) is generated if the device is plugged in to the same computer using another USB port. Some AVR Studio versions can not use the programmer if the COM port number exceeds number 10 and number 4 in case of using it as debugger. To prevent this situation you can modify the assigned port number in //Device manager// and assign it to the range COM0...COM4. [[en:examples:setup:portissue|See the complete procedure here ]]. +
- +
-=== Creating new project === +
- +
-In order to write a program for the controller you need to create the project space. The project includes typically different files like source codes, header files, compiled program files, etc. It is strongly advised to create new folder for every project (which is offered also by the New Project Wizard). +
- +
-Following steps have to be completed when creating new project with the help of wizard. +
- +
-**1.** Open AVR Studio and press //New Project//. If the dialog box is not opened automatically select //Project New project// from the menu bar. Press //Next//. +
- +
-{{  :examples:install:windows:studio_welcome.png?400  |}} +
- +
-**2.** Next dialog box is about compiler and initial settings. Select AVR GCC compiler. On the left, insert the name of the project and main source file name. The source file name should have extension ".c". Two check boxes should be also checked, which will create the new folder and initial file. You should also show the folder where project files will be created. After proper selections press //Next//. +
- +
-NB! If AVR GCC is missing on the compiler list, it is not properly installed. In that case the WinAVR software have to be installed before starting to write C source code. +
- +
-{{  :examples:install:windows:studio_new_project.png?400  |}} +
- +
-**3.** On the next dialog box you have to select the debugger platform and microcontroller. HomeLab kit is using JTAG ICE as debugger platform and ATmega128 as microcontroller. After selections press //Finish//+
- +
-{{  :examples:install:windows:studio_project_programmer.png?400 |}} +
- +
-**4.** Now the project space is created and new window will open where you can start to write the program source code. +
- +
-{{  :examples:install:windows:studio_overview.png?500  |}} +
- +
-**5.** You need to set some project parameters before the first compilation. The important parameters are controller frequency and optimization method. HomeLab controller has frequency 14,7456 MHz (14745600 Hz). The frequency can be set in the project properties with Hz (not MHz): //Project -> Configuration Options -> General//. Optimization method should left -Os, if there is no need for other methods. +
- +
-{{  :examples:install:windows:studio_project_properties_general.png?400  |}} +
- +
-**6.** For using HomeLab library functions the software have to be properly installed. Every new project requires adding library to list of linked objects. To do that go to //Project -> Configuration Options -> Libraries// and add object "libhomelab.a"+
- +
-{{  :examples:install:windows:studio_project_properties_libraries.png?400  |}} +
- +
-If object //libhomelab.a// is missing from the left list the library is not properly installed to the system and it should be reinstalled. +
- +
-=== Setting's test === +
- +
-After set up of the development environment it is wise to test it, for ensuring its correctness. Simplest way is to write a short program, compile it and upload to controller.  +
- +
-**1.** Connect the programmer with ATmega128 board. Be sure that the programmer is correctly connected to JTAG connector (cable is directed away from controller boardsee next picture). Connect the controller board supply (small green LED should light up if correct power supply is connected).  +
- +
-Insert simple C source code: +
- +
-<code c> +
-#include <avr/io.h> +
-#include <homelab/delay.h> +
- +
-int main(void) +
-+
- // Pin PB7 to output +
- DDRB = 0x80; +
- +
- // Endless cycle +
- while (true) +
-+
- // Pin PB7 invertion +
- PORTB ^= 0x80; +
- hw_delay_ms(500); +
-+
-+
-</code> +
- +
-[{{  :examples:install:windows:studio_quick_buttons.png?267  |Compilation and programmer buttons}}] +
- +
-Compile the project with //Build// command (keyboard F7). Make sure that the compilation succeeded. For this you should see the following message on the message window. +
- +
-<code> +
-  Build succeeded with 0 Warnings... +
-</code> +
- +
-**2.** Open the controller window //Tools -> Program AVR -> Auto Connect//. Be sure that the tab  //Program// is open. +
- +
-{{  :examples:install:windows:studio_programmer.png?400  |}} +
- +
-If the described window does not open and //Connection Failed// window is opened instead you do not have proper connection with the board or programmer. First check that micrcontroller is correctly powered (green LED is on) and the programmer is properly connected to JTAG connector. If this is OK check the COM port number which is assigned by the Windows. If this is greater than 9, the AVR Studio can not recognize the programmer. Follow the instructions given in the beginning of the chapter and assign the port number between 0 and 4. +
- +
-{{  :examples:install:windows:studio_project_programmer_port.png?400  |}} +
- +
-**3.** On the programmer window insert into //Flash//-section textbox //Input HEX File// the location of the compiled program by pressing the "..." button. Compiled program is usually located in the project folders sub folder //default// and has same name as the project but with the extension ".hex", for example "labor1.hex". After selecting correct file press button //Program// which uploads the program to the controller. If all went well you should see the following message on the end of the window: +
- +
-  OK +
-  Reading FLASH input file.. OK +
-  Setting device parameters for jtag programming ..OK +
-  Entering programming mode.. OK +
-  Erasing device.. OK +
-  Programming FLASH ..       OK +
-  Reading FLASH ..       OK +
-  FLASH contents is equal to file.. OK +
-  Leaving programming mode.. OK +
-  +
-According to the program the on-board LED (PB7) should start flashing. If the program works you have successfully set up your programming environment and completed your first program. Congratulations! +
- +
-{{:kit:kit_test.jpg?500|}} +
- +
-=== Debugger === +
- +
-[{{  :examples:install:windows:studio_debugger_io_view.png?280|The list of registers in the debugger of the ATmega128.}}] +
- +
-Debugging a program means searching errors from the program. For that programs called debuggers are created, they allow to execute the program step by step and stopping it where it is needed.  Such implementation of the program allows checking the values of the variables at any phase of the program, contents of the registers and the sequence of executing the program. Debugging is especially important while dealing with more complex programs where it is often difficult to find errors. With microcontrollers, it is important that step-by-step implementation of program is done in the controller, which allows seeing change of real outputs in addition to the values of the registers. Two conditions must be met for using a debugger: microcontroller must support debugging and you must have necessary hardware – JTAG programmer which allows debugging. Cheaper programmers using ISP programming interface may upload compiled program into the controller but not necessarily allow debugging.    +
-  +
-To start the program in debugging mode with the AVR Studio, firstly it should be compiled by pressing button //build// (F7) and the compiled program started with the command //Run// (F5). Before that //break points// (F9) can be added to selected palces in  the source code. When implementation of the program reaches the break point, the program is stopped for determining the state of the microcontroller in that point. Implementation of the program may be continued with command //Run// again or use //Step Into// (F11) for implementing the program one command at the time.     +
- +
- +
-=== The usage of floating-point variables === +
- +
-Some times in AVR program it is necessary to use floating-point variables. For calculating with them and presenting with //printf//-type functions, the following set-up changes must be done to the configuration of the project: +
- +
-**1.** Open the set-up of the project from the menu //Project -> Configuration Options//. Add //libprintf_flt.a// and //libm.a// after //libhomelab.a// of the library of HomeLab in the configuration tab //Libraries//.  +
- +
-**2.** Next, open tab //Custom Options// and chose //[All files]//. Next add lines with "-lprintf_flt" ja "-lm" to the box on the right and line with "-uvfprintf" to the //[Linker Options]// section. +
- +
-**3.** Press OK and close configuration window. +
-==== The software environment for Linux ==== +
- +
-The following guide describes the installation and use of the AVR toolkit 9:10 Ubuntu operating system. +
- +
-=== Software Installation === +
- +
-Install the following software: +
- +
-**1. Linux software packages** +
- +
-  * gcc-avr – GNU C-language compiler for AVR +
-  * avrdude – Program for uploading hex-files to microcontroller +
-  * avr-libc – C language libraries to write code for AVR platform +
- +
-To install the packages, use the terminal command: +
- +
-  sudo apt-get install gcc-avr avrdude avr-libc +
- +
-or graphical installation software (such as Ubuntu software center or Synaptic packet manager). +
- +
-**2. HomeLab library** +
- +
-The library simplifies the writing of program code, since lower-level functions are ready-made. Visit the HomeLab website and download the file named //Homelab library vX.X.run//, where XX represents the version number. Run the following command to install the library: +
- +
-  sudo sh homelab_library_vX.X.run +
- +
-Make sure that your library installation is successful. +
- +
-**3. KontrollerLab** +
- +
-KontrollerLab is an IDE (//integrated development environment//) for writing, compiling, loading and debugging AVR software. Download 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 +
- +
-If you have problems with packet dependencies, run the command which installs the missing packages: +
- +
-  apt-get install –f +
- +
-{{  :kit:001_kontrollerlab_installer.png?500  |}} +
- +
-=== Connecting the programmer === +
- +
-Connect to programmer with computer and see if the computer recognizes it. Write the command "lsusb" in the terminal window which should show the list of connected USB devices. Programmers name is "Future Technology Devices International, Ltd FT 232 USB-Serial (UART) IC". +
- +
-{{  :kit:002_lsbusb.png?500  |}} +
- +
-To get the port to which the programmer is connected to, check the ///dev// folder using the commands //cd /dev// (sets ///dev// as a current folder) and //dir// (displays the content of the folder). As the programmer is USB-serial interface, it is named as a "ttyUSBx" where "x" marks the index of the inteface. If there are no other USB-serial devices this number is zero. +
- +
-{{  :kit:003_ttyusb0.png?500  |}} +
- +
-=== Creating a new project === +
- +
-To write an AVR program, a project must be created which contains all the necessary files: source codes, header files, compiled program, etc. To clearly seperate projects, a folder for each project should be made (this option is also given by the project wizard). +
- +
-To create a project follow the steps: +
- +
-**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 specified. In this example the locations is //../Homelab/blinkingLED///+
- +
-{{  :kit:004_new_project_kontrollerlab.png?500  |}} +
- +
-**2.** The project must have at least one C file where to write the program code. Files can be added from the //File -> New -> New// menu. In the opening window, select //C source// as a file type and specify the name of the file. +
- +
-{{  :kit:005_new_file_kontrollerlab.png?500  |}} +
- +
-**3.** Next, the project must be configured for HomeLab kit. From 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 specified. Pressing a //Set as default// button makes these configurations as a default for new projects. This is reasonable when working only with HomeLab AVR microcontroller. As the HEX and MAP files are also stored as a default it is recommended to use some general name for them, for example "out.hex"+
- +
-NB! As the HomeLab library can not be added on the //Linker// configuration tab, the command "-lhomelab" must be added behind the name of the MAP file. +
- +
-{{  :kit:006_project_conf_common.png?500  |}} +
- +
-Apply settings on the //Compiler// tab as shown on the following screenshot. Before pressing //OK// set compiler configurations also as a default. +
- +
-{{  :kit:007_project_conf_compiler.png?500  |}} +
- +
-**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  |}} +
- +
-**5.** At last, place the windows in the KontrollerLab as it is more convenient and get ready to write your first program. +
- +
-{{  :kit:010_kontrollerlab.png?500  |}} +
- +
-=== Writing and testing a program === +
- +
-After the configurations steps are done, it is time to programm. +
- +
-**1.** Connect the programmer with Controller module. Double-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  |}} +
- +
-**2.** Write the following program in the Kontrollerlab file editor window and compile it: +
- +
-<code c> +
-#include <avr/io.h> +
-#include <homelab/delay.h> +
-  +
-int main(void) +
-+
- // Set pin PB7 as an output +
- DDRB = 0x80; +
-  +
- // Lõputu tsükkel +
- while (true) +
-+
- // Inverting pin PB7 +
- PORTB ^= 0x80; +
- hw_delay_ms(500); +
-+
-+
-</code> +
- +
-[{{  :kit:011_compile_ignite.png?408  |Toolbar}}] +
- +
-Make sure that the output window shows "File compiled successfully" message. If the "Error(s) occurred: " message is shown, check the program code for mistakes. +
- +
-**3.** To download the program into the Controller press the //Ignite// button. After the succeful download, the "Project built and uploaded successfully" message should be shown. +
- +
-If everything was done correctly the red LED on the Controller board should blink periodically, with 1 second interval. +
- +
-=== Using floating-point numbers === +
- +
-Sometimes it is neccessary to use floating-point numbers in program. To calculate with them and use them with //printf//-typed functions, some modifications in project configuration must be done: +
- +
-**1.** Open the //Project Configurations// window and the //Linker// tab. Check the first line in the //Linker flags// list (look at the picture). +
- +
-{{  :kit:012_linker_fprintf.png?500  |}} +
- +
-**2.** Press //OK// and close the window. +
- +
-===== Digital input/output pins =====+
  
 {{  :examples:digi:digital.jpg?580  |Digital input-output}} {{  :examples:digi:digital.jpg?580  |Digital input-output}}
  
-Following chapters are introducing digital input/output which are basic functions of microcontroller. Input/output pins are microcontroller contactsThey are so called “legsDigital signal is received and transmitted through themIf pin is configured as inputthe status of switches or simple sensors connected to pin can be receivedWhen pin is configured as outputit can be used to light LEDs or control electrical equipment+Die folgenden Kapitel stellen den digtalen Input/Output Pin dar, welche Grundfunktionen des Mickocontrollers sind. Input/Output Pins sind MikrocontrollerkontakteEs sind die sogenannten "Beine" ("legs")Sie dienen dazu, digitale Signale zu empfangen und zu sendenIst ein Pin als Input konfiguriert, kann der Status von Schaltern oder einfachen Sensoren, die mit ihm verbunden sindvon diesem Pin empfangen werdenIst ein Pin als Output konfiguriert istkann er benutzt werden um LEDs oder elektrisches Anlagen zu steuern.
  
-Almost all typical microcontroller pins allow executing easier input-output functionsalthough often these pins have alternative functionsBefore addressing the alternative functionswitch are covered in separate chapters, it would be useful to get to know the pins by studying their basic functions+Fast alle typischen Mikrocontroller Pins erlauben die Ausführung einfacher Input-Output Funktionenauch wenn diese Pins häufig noch alternative Funktionen habenZunächst sollen jedoch erst die Pins mit ihren Grundfunktionen dargestellt werdenbevor in separaten Kapiteln auf die alternativen Funktionen eingegangen wird
-==== Light-emitting diode ====+==== Light-emitting Diode (LED) ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:controller]], [HW] [[en:hardware:homelab:digi]], [ELC] [[en:electronics:led_resistor]], [AVR] [[en:avr:registers]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:pin]]//+//Notwendiges Wissen: [HW] [[de:hardware:homelab:controller]], [HW] [[de:hardware:homelab:digi]], [ELC] [[de:electronics:led_resistor]], [AVR] [[de:avr:registers]], [AVR] [[de:avr:io]], [LIB] [[de:software:homelab:library:pin]]//
  
-=== Theory ===+=== Theorie ===
  
 [{{  :examples:digi:led:led_picture.jpg?150|5 mm legged LED}}] [{{  :examples:digi:led:led_picture.jpg?150|5 mm legged LED}}]
  
-Light-emitting diode is a semiconductor which emits light when forward voltage is appliedThe acronym for light-emitting diode is LEDThere are different color combination of diodes and the diodeswhich can also emit white lightLike a normal diode, the LED has two contacts – anode and cathodeOn drawings anode is marked as “+” and cathode as “-.+Leuchtdioden sind Halbleiter die Licht abstrahlen, wenn Strom in  Durchlassrichtung durch die Diode fließtDie Abkürzung LED steht für "light-emitting diode"Es gibt verschiedenfarbige Leuchtdiodenmittlerweile ist sogar weißes Licht möglichWie jede normale Diode auch hat die LED 2 Kontakte - Anode und KathodeIn Zeichnungen ist die Anode mit einem "+" markiert und die Kathode mit einem "-".
  
-[{{  :examples:digi:led:led_designator.png?150|Schematic symbol of LED and it's polarity}}]+[{{  :examples:digi:led:led_designator.png?150|Schematische Darstellung einer LED and ihrer Polarität}}]
  
-When forward voltage is applied, LED’s anode is connected to the positive voltage and cathode to the negative voltageThe voltage of LED depends on LED’s color longer wavelength (red) ~2 Vshorter wavelength (blue) ~3 VUsually the power of LED is no more than couple of dozens milliwatts, which means electrical current must be in the same rangeWhen applying greater voltage or current LED may burn out.+Wenn Strom in Durchlassrichtung durch die LED fließt, ist die Anode mit der positiven und die Kathode mit der negativen Spannung verbundenDie Spannung der LED hängt von der Farbe der LED ablange Wellenlängen (rot) ~2Vkürzere Wellenlängen (blau) ~3VDie Stromverbrauch einer LED ist in der Regel nicht mehr als ein paar Dutzend mWDie Stromstärke darf daher nicht zu hoch sein, wenn größere Stromstärken oder Spannungen verwendet werden kann die LED zerstört werden.
  
-If the LEDs are used specially to illuminateit is wise to use special electronic circuits witch would regulate current and voltage suited for LEDs. However LEDs are quite often used as indicators and they are supplied directly from microcontroller’s pinsSince the supply voltage for microcontrollers is usually higher than the voltage for LEDs, there must be a resistor connected into series with the LED, which limits current and creates the necessary voltage dropInstructions to calculate proper resistor can be found from electronics chapter.+Wenn die LEDs nur zur Beleuchtung verwendet werdensollte man spezielle elektrische Schaltkreise verwenden, welche die Spannung und die Stromstärke für die LEDs regulieren. 
 +Jedoch werden LEDs sehr oft als Indikatoren genutzt und direkt vom Mikrocontroller mit Strom versorgtDa die Betriebsspannung eines Mikrocontrollers höher ist, als die der LEDs, muss ein Widerstand in Serie mit der LED geschaltet werden um die Stromstärke zu regulieren und für den nötigen Spannungsabfall zu sorgenDas Kapitel "Elektronik" enthält Anleitungen zur Berechnung des richtigen Widerstands.
  
-LEDs are produced by a variety of casingsMost common LEDs with feet have 3 mm or 5 mm diameter round shell and two long metal connector pinsLonger pin stands for anodeshorter is cathode. Surface mounted casing LEDs (SMD – Surface Mounted Device) have a shaped symbol on the bottom to indicate the polaritywhere the roof of stands for the location of anode and pole marks cathode.+LEDs werden in vielen Formen gefertigtDie meisten LEDs haben runde eine Hülle mit 3mm oder 5mm Durchmesser und zwei lange metallische PinsDer längere Pin ist die Anodeder kürzere die Kathode"Surface mounted casingLEDs (SMD Surface Mounted Device) sind unten mit einem gekennzeichnetum so die Polarität anzugeben. Das Dach des T's steht für die Anode und der Fuß markiert die Kathode.
  
-[{{  :examples:digi:led:led_pin_markings.png?200|Polarity of legged and SMD LED's}}]+[{{  :examples:digi:led:led_pin_markings.png?200|Polarität von legged und SMD LED's}}]
  
-=== HomeLab practice 1 ===+=== HomeLab Übung 1 ===
  
-HomeLab Controller control module has one single red LED, witch anode is connected through resistor to +5 V power supply and cathode is connected to ATmega128 pin number PB7. In order to switch on and off this LEDPB7 should be defined as output pin and set low or high accordinglyWhich means if pin is set highLED is turned off and if pin is set low LED is turned onBasically it would be possible to connect LED also so that anode is connected to the pin of microcontroller and cathode is connected to the earth (somewhere has to be a resistor too– in that case when the pin is set as highLED is shining and when the pin is set as low LED is switched off.+Das HomeLab Controller Controllermodul hat eine rote LED, dessen Anode über einen Widerstand an die +5V Stromversorgung angeschlossen ist und dessen Kathode am ATmega128 Pin PB7. 
 +Um die LED an- und auszuschalten muss PB7 als Output Pin definiert werden und entweder high oder low gesetzt werdenWenn der Pin high gesetzt wird ist die LED aus, wird er low gesetzt ist die LED anGrundsätzlich ist es möglich die LED so anzubringen, dass die Anode am PB7 angeschlossen wird und die Kathode geerdet wird (Widerstand nicht vergessen
 +dann leuchtet die LED wenn der Pin high gesetzt ist und der LED ist aus wenn der Pin low ist.
  
-All practical examples for the HomeLab kit, LED switching includedare using HomeLab’s pin’s libraryPins’ library includes data type //pin//, witch contains addresses of pin related registers and pin’s bitmaskIf to create a pin type variable in the program and then initialize it by using macro function PINthe pin can be used freely with this variable (pin) through whole program without being able to use registers  +Alle praktischen Beispiele für das HomeLab kit, inklusive LEDs schaltennutzen die HomeLab Pin BibliothekDie Pin Bibliothek hat den Datentyp //pin//, welcher die Addressen des zum Pin gehörigen Register und der Bitmaske des Pins enthältWenn eine Pin Variable mit der Makrofunktion Pin im Programm erschaffen und initialisiert wirdkann der Pin mit dieser Variable im gesamten Programm genutzt werden, ohne Register benutzen zu müssen
-Here are example programswhich are doing exactly the same thing, but one is created on the basis of HomeLab’s librarythe other is not+Hier sind Beispielprogrammewelche exakt das gleiche machen. Das eine Programm nutzt die HomeLab Bibliothekdas andere nicht.
  
 <code c> <code c>
 // //
-// HomeLab Controller module LED test program+// HomeLab Controllermodule LED Testprogramm
-// The code is base on HomeLab library.+// Der Cose basiert auf der HomeLab Bibliothek.
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
  
 // //
-// LED pin configuration.+// LED Pin Konfiguration.
 // //
 pin debug_led = PIN(B, 7); pin debug_led = PIN(B, 7);
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
 { {
- // Configuring LED pin as an output+ // konfiguriert LED Pin als Output
  pin_setup_output(debug_led);  pin_setup_output(debug_led);
   
- // Lighting up LED+ // Aufleuchten der LED
  pin_clear(debug_led);   pin_clear(debug_led);
 } }
Line 2654: Line 2117:
 <code c> <code c>
 // //
-// HomeLab Controller module LED test program+// HomeLab Controllermodul LED Testprogramm
-// The code directly accesses registers.+// Der Code greift direkt auf Register zu.
 // //
 #include <avr/io.h> #include <avr/io.h>
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
 {  {
- // Configuring LED pin as an output+ // Konfiguriert LED Pin als Output
  DDRB |= (1 << 7);   DDRB |= (1 << 7);
   
- // Lighting up LED+ // Aufleuchten der LED
  PORTB &= ~(1 << 7);  PORTB &= ~(1 << 7);
 } }
 </code> </code>
  
-First example uses pins’ library (//pin.h// file). First a pin-type variable named //debug led// is created in the programwhich holds information about LED pinIn the main program this pin will be set as output by using //pin_setup_output// functionAfter that the pin is set as low by function //pin_clear//As the result LED will glowIn the second example variables are not used, setting LED output and lighting it will be done by changing port data direction and output registers valuesThe reader who knows more about AVR noticesthat in both examples there is no need to give command to light LED, because the default output value of the AVR is anyway, but here it is done by the means of correctness.+Das erste Beispiel nutzt die Pin Bibliothek (//pin.h// Datei). Zuerst wird eine Pin-Typ Variable //debug led// erschaffenwelche Informationen über den LED Pin enthält. 
 +Im Hauptprogramm wird dieser Pin mit //pin_setup_output// als Output gesetzt. 
 +Danach wird der Pin low gesetzt: //pin_clear//Das Ergebnis: die LED leuchtet. 
 +Im zweiten Beispiel werden keine Variablen genutzt. Um die LED als Output zu markieren und zum Leuchten zu bringen, werden die Datenrichtung des Port  und die Output Registerwerte verändertDer Leser, der mehr über den AVR weiß bemerktdass in beiden Beispielen kein Befehl nötig ist um die LED zum leuchten zu bringenda der Standardoutputwert des AVR 0 ist. Aus Gründen der Vollständigkeit wird es jedoch hier beschrieben.
  
-What is the difference between the use of the library and the registersThe difference is in the comfort – library is easierbecause you do not need to know the registers’ names and their effectsMost important benefit of library is adaptabilityUsing registers, you must change registers’ names and bitmasks through entire program in order to change pinWhen using libraryit must be done only in the beginning of the program where pin variable is initializedUsing registers has one deceptive advantage – usage of pin is direct and it is not done through program memory and time consuming functionsHowever, newer AVR-GCC compiler versions are so smart that they transform library’s functions to exactly same direct commands for manipulating registers like it would have been done directly in programMust be said that compilers can optimize the code only when it deals with constant single variables not with volatile variables that are changing during work and with arrays.+Was ist der Unterschied zwischen dem Gebrauch von Bibliothek und RegisterDer Unterschied liegt im Komfort - Die Bibliothek ist einfacherweil man die Registernamen und deren Auswirkungen nicht kennen mussDer entscheidende Vorteil der Bibliothek ist jedoch die Anpassungsfähigkeit. 
 +Arbeitet man mit Registern müssen im Programm stets die Registernamen und Bitmasken geändert werden um einen Pin zu ändernNutzt man die Bibliothek muss dieses nur am Anfangbei Initialisierung der Variable erfolgenDie Nutzung von Registern hat jedoch einen entscheidenden Vorteil: Die Nutzung eines Pins erfolgt direkt und nicht über den Programmspeicher und zeitfressenden FunktionenJedoch sind die neuren AVR-GCC Kompiler Versionen so schlau, dass sie die Bibliotheksfunktionen zu direkten Befehle für die Registermanipulation transformieren, so als würde man die Register direkt im Programm ansprechenDie Compiler können den Code aber nur dann optimieren wenn sie mit konstanten Variablen arbeiten und nicht mit unbeständigen Variablen die sich während des Programms oder mit Arrays ändern.
  
-The next program code is partial pin operations libraryIts purpose is to explain the procedures with pin variables. It might not be understandable for the beginners as it uses language pointers which are not covered in this bookbut a lot of materials about pointers can be found from books and internet.+Der folgende Programmcode ist ein Teil der Pin Operations Bibliothek, um die Vorgehensweise mit Pin Variblen zu erklärenEs wird für Anfänger nicht einfach sein zu verstehen, da C-Sprache Pointer genutzt werdendie nicht in diesem Buch beschrieben sind. Es gibt jedoch sehr viel Material über Pointer in Büchern und natürlich im Internet.
  
 <code c> <code c>
-// Macro constant for defining register pointer+// Makrokonstante um Register-Pointer zu definieren
 #define _REG_PTR_ volatile uint8_t * #define _REG_PTR_ volatile uint8_t *
    
 // //
-// Pin data type+// Pin Datentyp
 // //
 typedef struct pin typedef struct pin
Line 2695: Line 2162:
    
 // //
-// Macro function for pin variable initializing+// Makrofunktion für Initialisierung der Pin Variable
 // //
 #define PIN(port_char, bit_index) \ #define PIN(port_char, bit_index) \
Line 2706: Line 2173:
    
 // //
-// Configuring pin as output+// Konfiguriere Pin als Output
 // //
 inline void pin_setup_output(pin pin) inline void pin_setup_output(pin pin)
Line 2714: Line 2181:
    
 // //
-// Setting pin high+// Setze Pin high
 // //
 inline void pin_set(pin pin) inline void pin_set(pin pin)
Line 2722: Line 2189:
    
 // //
-// Setting pin low+// Setze Pin low
 // //
 inline void pin_clear(pin pin) inline void pin_clear(pin pin)
Line 2730: Line 2197:
 </code> </code>
  
-=== HomeLab practice 2 ===+=== HomeLab Übung 2 ===
  
-In addition to the Controller module, LEDs are also located on the Digital i/o module boardThey are connected electrically in the same way as Controller module’s LEDwhich means cathode is connected to the AVR pinRed LED is connected to the pin PC5, yellow to PC4 and green to PC3. Their HomeLab library based example program looks as follows+Zusätzlich zum Controllermodul befinden sich LEDs auch auf der digtalen I/O Modulplatine. 
 +Sie sind elektrisch genau so angeschlossen wie auf dem Controllerboarddie Kathode ist also am AVR Pin angeschlossenDie rote LED ist am PC5 Pin angeschlossendie gelbe am PC4, und die grüne am PC3. Das auf der HomeLab Bibliothek basierende Beispielprogramm sieht folgendermaßen:
  
 <code c> <code c>
 // //
-// HomeLab Digital i/o module LED test program.+// HomeLab Digitales i/o Modul LED Testprogramm.
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
  
 // //
-// LED's pin configuration.+// LED Pin Konfiguration.
 // //
 pin led_red    = PIN(C, 5); pin led_red    = PIN(C, 5);
Line 2748: Line 2216:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
 { {
- // Configuring LED pins as an output+ // Konfiguriere LED Pins als Output
  pin_setup_output(led_red);  pin_setup_output(led_red);
  pin_setup_output(led_yellow);  pin_setup_output(led_yellow);
  pin_setup_output(led_green);   pin_setup_output(led_green);
   
- // Lighting up green LED+ // Aufleuchten der grünen LED
  pin_clear(led_green);   pin_clear(led_green);
   
- // Turn off red and yellow LED+ // Ausschalten der roten und gelben LED
  pin_set(led_red);  pin_set(led_red);
  pin_set(led_yellow);  pin_set(led_yellow);
Line 2766: Line 2234:
 </code> </code>
  
-~~DISCUSSION~~ +~~Diskussion~~ 
-==== Switch ====+--- 
 + MISSING PAGE --- 
 +==== Schalter ====
  
-//Neccesary knowledge: [HW] [[en:hardware:homelab:digi]], [AVR] [[en:avr:registers]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:pin]], [PRT] [[en:examples:digi:led]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:digi]], [AVR] [[en:avr:registers]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:pin]], [PRT] [[en:examples:digi:led]]//
  
-=== Theory ===+=== Theorie ===
  
-A switch is an electromagnetic device which can connect or break an electrical circuitThere are many different types of switches; the most common mechanical switch is mechanically connectible electrical connectorsIf connectors are connectedelectrical circuit is closed and electricity can flow through the switchIf connectors are disconnectedelectricity cannot flow through the switch.+Ein Schalter ist ein elektromagnetisches Gerät, welches einen elektrischen Schaltkreis verbindet oder trenntEs gibt viele Typen von Schaltern, die am weitesten verbreiteten sind einfache mechanische Schalter, bei denen elektrische Anschlüsse mechanisch geschaltet werden. 
 +Sind die Anschlüsse verbundenwird der elektrische Schaltkreis geschlossen und Strom kann durch den Schalter fließenWenn die Anschlüsse nicht verbunden sindkann keine Elektrizität fließen.
  
-Switches are commonly used to electrify electrical circuitsbut can also be used as sensorsSwitch as a sensor is also the subject of this exercise and therefore examining specific high-voltage and high-amperage switches has been excludedSwitches can be differentiated by the number of contacts and by their connection methodDifferent types includetwo contact switches and double switcheswhere contact pairs are connectedbut also push buttonslidingrocker and toggle switches as well as switches which disconnect instead of connect electrical circuit+Schalter werden normalerweise benutzt um elektrische Schaltkreise zu schaltensie können jedoch auch als Sensoren benutzt werdenDer Schalter als Sensor ist auch Teil dieser Übung,  Hochspannungsschalter werden jedoch ausgelassenSchalter können anhand der Anzahl von Kontakten und ihrer Verbindungsmethode unterschieden werdenUnterschiedliche Typen sindzwei-Kontakt Schalter und Doppelschalterbei denen Kontaktpaare verbunden werdendarüber hinaus auch Druckknopf-Schiebe-, Kipp- und Wechselschalterebenso wie Schalter die Verbindungen trennen anstatt zu verbinden.
  
-Different schematic symbols are used for identifying different types of switchesBelow are examples of typical electrical switches used in electrical drawings with their symbols:+Es werden unterschiedliche Schaltbildsymbole genutzt um die verschiedenen Typen von Schaltern zu identifizierenUnterhalb sind Beispiele typischer elektrischer Schalter in einem Schaltbild:
  
- +Druckknopfschalter Wechselschalter Kippschalter Mikroschalter ^ DIL Schalter ^
-Push button switch Toggle switch Rocker switch Micro switch ^ DIL switch ^+
 |{{:examples:digi:switch:switch_pushbutton.jpg?100|}} | {{:examples:digi:switch:switch_tumbler.jpg?100|}} | {{:examples:digi:switch:switch_rocker.jpg?100|}} |  {{:examples:digi:switch:switch_micro.jpg?100|}} | {{:examples:digi:switch:switch_dil.jpg?100|}} | |{{:examples:digi:switch:switch_pushbutton.jpg?100|}} | {{:examples:digi:switch:switch_tumbler.jpg?100|}} | {{:examples:digi:switch:switch_rocker.jpg?100|}} |  {{:examples:digi:switch:switch_micro.jpg?100|}} | {{:examples:digi:switch:switch_dil.jpg?100|}} |
 | {{:examples:digi:switch:switch_sch_dpst.png?100|}} | {{:examples:digi:switch:switch_sch_spdt.png?100|}} | {{:examples:digi:switch:switch_sch_spdt.png?100|}} | {{:examples:digi:switch:switch_sch_spdt.png?100|}} | {{:examples:digi:switch:switch_sch_2_spst.png?100|}} | | {{:examples:digi:switch:switch_sch_dpst.png?100|}} | {{:examples:digi:switch:switch_sch_spdt.png?100|}} | {{:examples:digi:switch:switch_sch_spdt.png?100|}} | {{:examples:digi:switch:switch_sch_spdt.png?100|}} | {{:examples:digi:switch:switch_sch_2_spst.png?100|}} |
  
-In order to use a switch as a sensor connected to a microcontrollerone contact of the switch is connected to the microcontrollers pin and is set as input in the programIf contact is connected to the ground or input potentialthe bus’s bit rate of microcontroller’s pin is changedIt would sound logical to use toggle switchwhich allows connecting one contact with desired contact (in this case ground or input). For our purpose it is not as simplesince on the moment of shifting of the connections the contacts are not connectedThe moment itself is very short (milliseconds), but during this moment microcontrollers input pin is connected to nowhere and therefore has indefinite valueDue to electromagnetic interference (which exists everywhereinput pin that is connected to nowhere can have a value of or at random moments in time.+Um einen Schalter als Sensor mit einem Mikrocontroller zu nutzenmuss ein Kontakt des Schalters mit dem Pin des Mikrocontrollers verbunden sein und dieser muss als Input im Programm definiert werdenWenn der Kontakt mit der Masse oder einem Inputpotential verbunden istwir die Bus Bitrate des Mikrocontroller-Pins geändertEs erscheint logisch einen Wechselschalter zu nutzenwelcher es erlaubt einen Kontakt an den gewünschten Kontakt anzubringen (hier Masse oder Input). Für unseren Zweck ist es nicht ganz so einfachdenn im Moment des Schaltens sind die Kontakte nicht verbundenDer Moment an sich ist sehr kurz (ms), aber in diesem Moment ist der Input-Pin des Mikrocontrollers nicht verbunden und hat daher einen unendlichen Wert. 
 +Auf Grund elektromagnetischer Störung (welche überall existiertkann der Input-Pin der nicht angeschlossen ist, zu jeder Zeit zufällig einen Wert von oder haben.
  
-The interferences complicate the usage of switches. Most common method for avoiding the undetermined results is to connect microcontroller’s input to the ground or input potential through a resistor. A resistor for this function is called pull-down or pull-up resistor. Usually the resistance of pull-down or pull-up resistor varies from 1 kΩ to 1 MΩ. With open switch, the input is charged with voltage of the resistor, by closing the switch, the input receives the voltage of the switch since the resistivity of the switch is a lot smaller (close to zero) compared to the one of the resistor.  Basically it can be referred to as a volt-box. 
  
 +Die Störanfälligkeit macht die Nutzung von Schaltern kompliziert. Die am häufigsten verwendete Methode um dies zu verhindern, ist den Input des Microcontrollers durch einen Widerstand an die Erde oder das Inputpotential anzuschließen. Einen so benutzten Widerstand nennt man einen pull-down oder pull-up Widerstand. Normalerweise liegt der Widerstand eines pull-down oder pull-up zwischen 1kΩ bis 1 MΩ. Wenn der Schalter offen ist, wird der Input mit der Spannung des Widerstands geladen, wenn man den Schalter schließt, empfängt der Input die Spannung des Schalters, da der Leitungswiderstand des Schalters im Vergleich zum Widerstand beinahe 0 ist. Allgemein kann er als "volt-box" bezeichnet werden.
  
  
-[{{  :examples:digi:switch:switch_input_pull-up.png?200|Switch connection scheme with pull-up resistor}}] 
  
 +[{{  :examples:digi:switch:switch_input_pull-up.png?200|Schalter-Anschluss Schema mit einem pull-up Widerstand}}]
  
  
Line 2798: Line 2269:
  
  
-A simple two contact switch can be used as a sensor with pull-up or pull-down resistor, switch connects input with one and resistor to the other potentialUsually microcontrollers have built-in pull-up or pull-down resistor option; thereforethere is no need to add a resistor to the circuitFor example, AVR microcontrollers have 20 kΩ – 50 kΩ pull-up resistors on their IO pinsIt must be mentioned thatmechanical switches have one more problem – switch bounce. This causes several very short missconnections at the moment of connectionIt must be emphasized, that the examples used in this chapter are not affected by the switch bounce and the issue will be covered in more detail in the next chapter+Ein einfacher zwei-Kontakt Schalter kann als Sensor mit einen pull-up oder pull-down Widerstand genutzt werdenHierzu wird ein Kontakt des Schalters mit dem Input verbunden und der andere mit dem Widerstand. Normalerweise haben Mikrocontroller eingebaute pull-up oder down Widerständedaher ist es nicht notwendig einen Widerstand in den Schaltkreis einzubauen. 
 +AVR Mikrocontroller haben beispielsweise 20 kΩ – 50 kΩ pull-up Widerstände an ihren I/O Pins. 
 +Darüber hinaus muss noch erwähnt werdendass mechanische Schalter ein weiteres Problem haben, den "switch bounce"Hierdurch wird beim Schalten in sehr kleinen Abständen die Verbindung durch die Schwingung des mechanischen Schalters unterbrochenDie Beispiele dieses Kapitels werden nicht durch den "switch bounce" beeinflusst, das Problem wird im nächsten Kapitel ausführlicher bearbeitet.
      
  
  
-=== Practice === +=== Übung ===
  
-There are three push button-switches on the Digital i/o moduleThose switches connect the pins of microcontroller to the earthhowever not directly through a resistorthis is to avoid short circuiting when pressing the button while setting the pins as outputThe switches have also pull-up resistors, but those have much greater resistance than protective resistorstherefore while pressing the buttonthere will still be approximately 0 V voltages on the corresponding pin.+Es gibt drei Druckknopf-Schalter am digitalen I/O ModulDiese verbinden die Pins den Mikrocontrollers mit der Erdeaber nicht direkt durch einen Widerstand. Auf diese Weise soll ein Kurzschluss vermieden werdenwenn der Knopf gedrückt wird, während der Pin als Output definiert wirdDie Schalter besitzen einen pull-up Widerstandwelcher aber einen viel größeren Widerstand als die Schutzwiderstände hatdaher liegt beim Drücken des Schalter eine Spannung von nahezu 0 V am betreffenden Pin an.
  
-The switches are on PC0, PC1 and PC2 pinsIn order to read the status of the switches, the corresponding pins of the microcontroller must be set as inputsThere is no need to put AVR internal pull-up resistors into operationbecause the pins already have external resistorsWhen the button is pressed downthe corresponding bus of the pin has value 0, when the button is releasedthe value is 1. LED indicators can be used to see if the microcontroller understood the buttons action.+Die Schalter befinden sich an den PC0, PC1 und PC2 PinsUm den Status der Schalter zu lesen müssen die betreffenden Pins des Mikrocontrollers als Input gesetzt werdenMan benötigt nicht die internen pull-up Widerstände des AVRda die Pins schon externe Widerstände haben. 
 +Wenn der Schalter betätigt wirdhat der entsprechende Bus des Pins den Wert 0, wird er losgelassenden Wert 1. Mit Hilfe von LED Indikatoren kann überprüft werden, ob der Mikrocontroller den Status den Schalters verstanden hat.
  
-Sample code for using buttons is based on the HomeLab pins librarywhich was introduced in the example of LED.+Der Beispielcode zur Benutzung der Schalter basiert auf der HomeLab Pins Bibliothekwelche im LED Kapitel eingeführt wurde.
  
      
Line 2816: Line 2289:
 <code c> <code c>
 // //
-// Program for testing the buttons of the Digital i/o module+// Program zum Testen der Schalter des digitalen I/O Moduls
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
  
 // //
-// Determining the pins of LED-d and buttons.+// Festlegung der Pins von LED-d sowie der Schalter.
 // //
 pin leds[3]    = { PIN(C, 5), PIN(C, 4), PIN(C, 3) }; pin leds[3]    = { PIN(C, 5), PIN(C, 4), PIN(C, 3) };
Line 2827: Line 2300:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 2833: Line 2306:
  unsigned char i;  unsigned char i;
  
- // Setting the LED pins as outputs and buttons pins as inputs.+ // Setzt die LED Pins als Output und die Schalter-Pins als Input.
  for (i = 0; i < 3; i++)  for (i = 0; i < 3; i++)
  {  {
Line 2840: Line 2313:
  }  }
   
- // Endless cycle+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Each button has a corresponding LED, + // Jeder Schalter hat eine zugehörige LED, 
- // which lights when button is pressed.+ // die aufleuchtet, wenn er betätigt wird.
  for (i = 0; i < 3; i++)  for (i = 0; i < 3; i++)
  {  {
Line 2853: Line 2326:
 </code> </code>
  
- +Im Beispiel werden LEDS und Knöpfe als Array definiert - das ermöglicht es Sie in einer //for// Schleife zu nutzenWird das Programm gestartetwerden die LED Pins als Output und die Schalter als Input gesetzt. In der Endlosschleife des Programms wird durchgehend der Status der Schalter abgefragt, welcher den Status der dazugehörigen LED bestimmtDer erste Schalter ist für die grüne LED, der Zweite für die Gelbe und der Dritte für die Rote
-In the given example LEDs and buttons are defined as array – this allows them to be use in //for// loopWhen starting the program, LED pins are set as output and buttons as input. In the inter programs endless cycle a constant acquiring of the state of buttons is performed which in turn determines the state of corresponding LEDs. First button is lighting green LED, second yellow and third red. +==== Vermeidung von Kontaktprellung  ====
- +
- +
-/* +
-Attentive student may notice that regardless of the simplicity, compiled program is a little bit larger than presumed. The reason for this is, the pins of LEDs and buttons are defined as array, but like said in LED exercisethe compiler does not simplify the arrays of pinsCompiled program would be more compact if all LEDs and buttons were operated individually, without //for// loop, but in this case source code would be longer and more monotonous. When dealing with three buttons and three LEDs, it is difficult to prefer one to an other approach. If the number of LEDs and buttons is bigger, adding single code rows turns out to be more and more ineffective and therefore is better to use arrays. +
-*/ +
-==== Filtration of switch bounce  ====+
  
 //Vajalikud teadmised: [HW] [[en:hardware:homelab:digi]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:pin]],  [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:digi:switch]]// //Vajalikud teadmised: [HW] [[en:hardware:homelab:digi]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:pin]],  [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:digi:switch]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:digi:switch:switch_bounce.png?200|Bouncing of contacts of a switch}}]+[{{  :examples:digi:switch:switch_bounce.png?200|Kontaktprellung eines Schalters}}]
  
-As mentioned in the introductory chapter of switchesthere exists an issue of bouncing or flickering when dealing with mechanical switches. Problem arises since contacts are made of metal which has some elasticityat the moment of connecting or disconnecting the contacts bounce and this results in number of false switching’sThe number and duration of the switching's depends on the switchbut usually fits between just few millisecondsIn case a switch is used to start an electrical device it is not considered as a big issue but if the switch is used for controlling a devicemultiple switching’s may turn out to be harmful for the device.+Wie bereits im einleitenden Kapitel zu Schaltern erwähntgibt es im Ungang mit mechanischen Schaltern den Effekt des Prellens (ungewolltes, kurzzeitiges, wiederholtes Öffnen und Schließen eines Kontaktes bei dessen Betätigung)Dieses Problem wird durch die Elastizität des Metallsaus dem die Schalter bestehen, verursachtIm Moment des Ein- oder Ausschaltens prellen die Kontaktewas zu einer Vielzahl falscher Schaltungen führtDie Anzahl und Dauer der Schaltungen hängt von dem Schalter abliegt aber gewöhnlich im Bereich von wenigen Millisekunden. Für den Fall, dass ein Schalter genutzt wird, um ein elektronisches Gerät zu starten, hat dieses Problem keine großen Auswirkungen. Wird er jedoch zur Steuerung eines Gerätes verwendet kann mehrfaches Schalten das Gerät beschädigen.
  
  
-[{{  :examples:digi:switch:switch_input_rc_filter.png?200|RC-filter of a switch}}]+[{{  :examples:digi:switch:switch_input_rc_filter.png?200|RC-filter eines Schalters}}]
  
-Main method used for avoiding flickering caused by the bouncing of contacts is filteringFiltering can be done electrically or by softwareTo filter electrically the switch must be connected through a low-pass filter – for example a RC filter – witch smoothed changes of voltage and therefore the pin of microcontroller does not have transient values. RC filter is shown on the drawingFiltering by software is done by assessing the value of the pin where the switch is connected; if the value remains the same at number of times in pre set time limitit is considered to have a steady position and hence has no flickering problemHoweverwith each type of filtering a delay factor in defining the status must be taken under consideration+Die bekannteste Methode zur Vermeidung von Kontaktprellung ist die FiltrierungDieses kann elektrisch oder durch Software erfolgenUm elektrisch zu filtern muss der Schalter an einen Tiefpassfilter angeschlossen werden zum Beispiel an einen RC Filter - welcher die Spannungschwankungen beseitigt sodass der Pin des Mikrocontrollers keine schwankenden Werte erhältEin solcher RC Filter ist auf der Zeichnung abgebildetFiltrierung mittels Software wird durchgeführtindem dem Pin, an welchem der Schalter angeschlossen ist, ein Wert zugewiesen wirdBleibt dieser Wert zu verschiedenen Zeitpunkten innerhalb eines zuvor gesetzten Zeitlimits gleichkann angenommen werden, dass der Schalter stabil ist und kein Flimmer-Problem aufweist. Es muss jedoch bei jeder Art der Filtrierung ein Verzögerungsfaktor bei Definition des Status berücksichtigt werden.
  
    
-=== Practice ===+=== Praktisches Beispiel ===
  
-Electrical filtering is not used on HomeLab switches, since it would not allow practicing the elimination of miss switching’s with software. The exercise is in two parts. The goal of the first part is to demonstrate the bouncing of Digital i/o module switches. The following program is used for this; each pressing on the button will light the next LED in line. Wrongly pressed button will causes LEDs to light several times and it appears as the LEDs light randomly.  +Elektrische Filtrierung wird für die HomeLab Schalter nicht verwendet, da hier die Beseitigung von Fehlschaltungen mit Hilfe von Software geübt werden soll. Die Übung besteht aus zwei Teilen. Das Ziel des ersten Teils ist, das Prellen der Schalter des digitalen Input/Output Moduls zu zeigen. Hierzu wird das folgende Programm genutzt; durch jede Betätigung des Schalters wird die nachfolgende LED aufleuchten. Eine Fehlschaltung lässt die LEDs mehrfach und zufällig aufleuchten. Electrical filtering is not used on HomeLab switches, since it would not allow practicing the elimination of miss switching’s with software. The exercise is in two parts. The goal of the first part is to demonstrate the bouncing of Digital i/o module switches. The following program is used for this; each pressing on the button will light the next LED in line. Wrongly pressed button will causes LEDs to light several times and it appears as the LEDs light randomly.  
 <code c> <code c>
 // //
-// The Program for demonstrating switch bounce on Digital i/o module.+// Das Programm um Kontaktprellung am digitalen Input/Output Modul zu demonstrieren.
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
  
 // //
-// Determining pins of LEDs and buttons.+// Festlegung der LED-Pins und Schalter.
 // //
 pin leds[3] = { PIN(C, 5), PIN(C, 4), PIN(C, 3) }; pin leds[3] = { PIN(C, 5), PIN(C, 4), PIN(C, 3) };
Line 2892: Line 2359:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 2899: Line 2366:
  unsigned char index, counter = 0;  unsigned char index, counter = 0;
  
- // Setting LED pins as output.+ // LED-Pins als Output setzen.
  for (index = 0; index < 3; index++)  for (index = 0; index < 3; index++)
  {  {
Line 2905: Line 2372:
  }  }
  
- // Setting button'spins as input.+ // Schalter-Pins als Input setzen.
  pin_setup_input(button);  pin_setup_input(button);
  
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Reading the state of the button.+ // Status des Schalters auslesen.
  new_value = pin_get_value(button);  new_value = pin_get_value(button);
  
- // Controlwether the button is pushed down+ // Kontolleob der Schalter heruntergedrückt wurde
- // that means is the new state and old 0.+ // was bedeutet, dass der neue Status ist, der alte 0.
  if ((new_value) && (!old_value))  if ((new_value) && (!old_value))
  {  {
- // Enlarging the reader and taking module 3+ // Erweiterung des Lesegerätes und Nutzungvon Modul 3
  counter = (counter + 1) % 3;  counter = (counter + 1) % 3;
  
- // Lighting LED witch corresponds to the value of the reader.+ // Aufleuchten der LED, welche mit dem Wert des Lesegerätes übereinstimmt.
  for (index = 0; index < 3; index++)  for (index = 0; index < 3; index++)
  {  {
Line 2928: Line 2395:
  }  }
  
- // Remember the old state.+ // Berücksichtigung des alten Status.
  old_value = new_value;  old_value = new_value;
  }  }
Line 2934: Line 2401:
 </code> </code>
  
-Several software solutions are used for filteringthis can be performed either easy or complex way both with its advantages and disadvantagesIf the program is set to have only few infrequent pressings of the buttona long pause can be set to follow the pressing, this will rule out reaction to the switching caused by bounceHoweverwhile using this solution must be considered – in case the user holds the button down for a long period of timethe program reacts also on the miss witching caused by the release of the buttonA program which controls the state of the switch several times in fixed period of time is more dependable (the longer is the time and the higher is the number of controls performedthe better is the result). Below is a function for reading filtered values of a button for Digital i/o module:+Es gibt diverse Softwarelösungen zur Filtrierung. Sie können einfach oder komplex seinwobei jede ihre Vor- und Nachteile hatSieht das Programm nur wenige seltene Betätigungen des Schalters vorkann eine lange Pause als Folge der Betätigung eingefügt werdenAuf diese Weise können durch Kontaktprellung verursachte Wirkungen auf die Schaltung vermieden werden. Jedoch muss bei Anwendung dieser Lösung bedacht werdendasssofern der Nutzer den Schalter für eine längere Zeit gedrückt hält, das Programm ebenfalls auf die Fehlschaltung, welche durch Lösen des Schalters hervorgerufen wird, reagiertEin Programm, welches den Status des Schalters in einer festgeleten Zeitperiode mehrfach überprüft ist zuverlässiger (das Ergebnis ist umso besserje länger die Periode und je größer die Anzahl der Kontrollen ist). Nachfolgend ist eine Funktion abgebildet, um filtrierte Werte eines Schalters für das digitale Input/Output Mpdul auszulesen:
  
 <code c> <code c>
 // //
-// Function for reading filtered values of a IO extension module.+// Funktion zum Auslesen filtrierter Werte aus dem I/O Erweiterungsmodul.
 // //
 unsigned char pin_get_debounced_value(pin button) unsigned char pin_get_debounced_value(pin button)
Line 2945: Line 2412:
  unsigned char timeout = 100;  unsigned char timeout = 100;
  
- // We wait until the status of the button is celar or clearing the state expires+ // Abwarten, bis der Status des Schalters We wait until the status of the button is celar or clearing the state expires
  while (timeout-- > 0)  while (timeout-- > 0)
  {  {
Line 2955: Line 2422:
   
  // If all 8 bits are high, then the button is definitely pressed down  // If all 8 bits are high, then the button is definitely pressed down
- if (buffer = 0xFF)+ if (buffer == 0xFF)
  {  {
  return 1;  return 1;
Line 2961: Line 2428:
  
  // If all 8 bits are low, then the button is definitely up.  // If all 8 bits are low, then the button is definitely up.
- if (buffer = 0x00)+ if (buffer == 0x00)
  {  {
  return 0;  return 0;
Line 2976: Line 2443:
 </code> </code>
  
-This function generates a delay using a function which is explained in corresponding exerciseAt this moment all we need to know about the delay function is that it generates a 1 ms delay at the end of each cycle for reading the state of the button. If the button is in the same position during 8 readings, it returns to the counted position. In case the button is unstable the entire procedure may take up to 100 ms. This function is included in the library of pins, hence there is no need to add it to the program for passing the example. In order to try this first part of the exercise, it has to be altered a little - include library of generating the delay in the program and at the point where the value of the button was read, directly apply the function with filter. The result is as follows:+Diese Funktion generiert eine Verzögerung durch Nutzung einer Funktion, die in der entsprechenden Übung erläutert wurdeZu dieser Zeit müssen wir nur wissen, dass die Verzögerungsfunktion eine Verzögerung von 1 ms am Ende jedes Zyklus generiert, um den Status des Schalters lesen zu könnenBefindet sich der Schalter 8 Lesezyklen lang in der gleichen Position,  If the button is in the same position during 8 readings, it returns to the counted position. In case the button is unstable the entire procedure may take up to 100 ms. This function is included in the library of pins, hence there is no need to add it to the program for passing the example. In order to try this first part of the exercise, it has to be altered a little - include library of generating the delay in the program and at the point where the value of the button was read, directly apply the function with filter. The result is as follows:
  
 <code c> <code c>
Line 3034: Line 2501:
 </code> </code>
  
-If we test this program nowthe LEDs are lighting exactly in this sequence as the user is pressing the switch+Testen wir das Programm nunleuchten die LEDs in genau der Sequenz auf, in welcher der Nutzer den Schalter betätigt
-==== Digital i/o exercises ====+=== Aufgaben: Digitale I/===
  
-The goal is to write a program which is able to perform tasks described below.+Ziel ist es, ein Programm zu schreiben, welches die unten beschriebenen Aufgaben ausführt.
  
-=== Warm up exercise ===+=== Aufwärm-Übung ===
  
-  *By pressing S1 one LED is litpressing S2 two LEDs and S3 three LEDs lit.+ Durch Drücken von S1 leuchtet eine LED aufdrückt man S2 leuchten zwei und bei S3 drei LEDs.
  
-=== For beginners ===+=== Für Anfänger ===
  
-  - This simulates manually operated traffic light at pedestrian crossingUntil no button is pressed a green LED is lit for the carsAfter pressing a random button the green LED will start to blink for 3 secondsthis is followed by lighting the yellow LED for seconds and red for 10 seconds, after this sequence a green LED is lit again.  +  - Es wird eine von Hand betriebene Ampel an einer Fußgängerkreuzung simuliertSolange kein Schalter gedrückt wird, leuchtet eine grüne LED für die AutosNach Betätigung eines zufälligen Schalters beginnt die grüne LED für drei Sekunden zu blinkendaraufhin leuchtet die gelbe LED für Sekunden und die rote für 10 Sekunden. Nach dieser Sequenz leuchtet erneut die grüne LED. 
-  - This counts how many times the button is pressedOnly the full release of the button will complete the pressingThe result is displayed in binary code on LEDs. Maximum result for three LEDs is 7(23-1). Green marks 1. bityellow 2. bit and red 3. bit+  - Es soll gezählt werden, wie oft ein Schalter betätigt wurdeNur durch ein vollständiges Lösen des Schalters wird das Herunterdrücken vollendetDas Ergebnis wird als Binärcode auf den LEDs angezeigtDas maximale Ergebnis bei drei LEDs ist 7 (23-1). Die grüne markiert das erstedie gelbe das zweite und die rote das dritte Bit.  
-  - By pressing switch S1, LED1 and LED3 are lit; pressing S2 yellow LED is litpressing S3 all LEDs are switched offThis operation must be done by directly changing the values of corresponding registers (without using the library of the HomeLab). +  - Durch Drücken von Schalter 1 leuchten LED 1 und LED 3. Drückt man S2 leuchtet die gelbe LED, Schalter 3 sorgt dafür, dass keine LED leuchtetDiese Operation muss unter direkter Verwendung von Registerwerten (also ohne Nutzung der HomeLab Bibliothekdurchgeführt werden
-  - This counts how many times the button is pressedThe result is displayed by blinking of the LEDs. After each pressing the number of blinking is increased by oneA random button can be selectedIn order for the LED to blink a sub function must be usedwith parameters set on the number of blinks+  - Es soll gezählt werden, wie oft ein Schalter gedrückt wurdeDas Ergebnis wird durch Blinken der LEDs dargestelltNach jeder Betätigung des Schalters wird die Anzahl der blinkenden LEDs um eins erhöhtDer Schalter kann zufällig ausgewählt werdenDamit die LED blinkt muss eine Unterfunktion genutzt werdenderen Parameter die blinkenden LEDs zählt
-  - When pushing button S1, red LED will blink “SOS” in MorseBy pressing S2, yellow LED blinks “CQD” and by pressing S3, green will blink “OK+  - Wird S1 betätigtsendet die rote LED durch Blinken "SOS" im MorsecodeDrückt man S2, sendet die gelbe LED "CQD" und durch Drücken von S3 zeigt die grüne LED "OK".
  
-=== For advanced ===+=== Für Fortgeschrittene ===
  
-  - For each of the three buttons corresponds one LED which lights up when the button is pressed. For turning on or offregisters must be used and only one assigning operation (hint: use bit shifts). +  - Zu jedem der drei Schalter gehört eine LED, welche aufleuchtet wenn der Schalter betätigt wirdZum anoder ausschalten sollen Register und nur eine zuordnende Operation genutzt werden (HinweisNutzen Sie Bitverschiebungen).  
-  For each of the three buttons corresponds one LED which lights up when the button is pressed. For turning on or off, registers must be used and only one assigning operation (hintuse bit shifts). +  - Für jede LED gibt es einen SchalterDer Controller bringt die LEDs in zufälliger Reihenfolge zum Blinken und der Nutzer muss diese Sequenz wiederholenDie Blinksequenz verlängert sich, nach jeder Runde kommt eine LED hinzuBei einem falschen Eintrag blinken alle LEDs dreimal (Die Anzahl korrekter Einträge des Nutzers muss auf einem LCD-Display angezeigt werden). 
-  - There is one button for each LED. The controller blinks LEDs randomly and the user has to repeat the same sequenceThe sequence of blinks gets longer – one random LED is added with a new roundThe sequence is controlled after each user. The time gap between each entry is two seconds. In case of  an incorrect entry all LEDs blink three times. (The number of correct entries by the user may be displayed on a LCD screen).  +  - Das Programm misst die Zeit für eine ReaktionEine zufällige LED leuchtet auf und der Nutzer muss den zugehörigen Schalter so schnell wie möglich betätigenDie Zeit bis zum Aufleuchten der LED ist zufälligaber nicht kleiner als 100 ms. Das Ergebnis wird auf einem LCD-Display in Millisekunden dargestelltDer Wert der Schalter kann nicht mit einer Filterfunktion für das Flackern gelesen werdenda diese eine weitere Verzögerung verursacht.
-  - The program measures time for reactionA random LED is lit and the user has to press the corresponding button as fast as possibleThe time when the LED is lit is randombut not less than 100 ms. the result is displayed on a LCD screen in millisecondsThe value of the buttons cannot be read with filtering function for the flickeringsince this will cause an extra delay.+
  
-=== Questions ===+=== Fragen ===
  
-  - What is the difference between operations”=” and”=” ? Give two examples to verify the statement+  - Was ist der Unterschied zwischen den Operationen ”=” und ==”? Nennen Sie zwei Beispiele um Ihre Antwort zu verifizieren
-  - What is the difference between operations “|” and “||”? Give two examples to verify the statement+  - Was ist der Unterschied zwischen den Operationen “|” und “||”? Nennen Sie zwei Beispiele um Ihre Antwort zu verifizieren
-  - Write an expression using the equation “x = x + 1” twelve times+  - Schreiben Sie einen Ausdruck, welcher die Gleichung “x = x + 1” zwölfmal verwendet
-  - How an endless loop is written in C-programming languageProvide two different examples+  - Wie wird eine Endlosschleife in C geschriebenNennen Sie zwei Beispiele
-  - What type of a variable do you choose in C–language to present positive values between and 154? +  - Welcher Variablentyp wird in C verwendet um positive Werte zwischen und 154 dazustellen
-  - Witch register determines the direction of a portProvide an example of configuring settings of ports’ input and output+  - Welches Register legt die Richtung eines Anschlusses festNennen Sie ein Beispiel zur Konfiguration von Input und Output eines Anschlusses
-  - What are the methods for eliminating the bouncing of the contacts and the false connections caused by flickeringProvide examples of solutions using both hardware and software+  - Welche Methoden gibt es um das Zurückspringen von Kontakten zu sowie der durch Flimmern hervorgerufenen falschen Verbindungen zu verhindernGeben Sie Lösungsbeispiele unter der Nutzung von Hard- und Software
-  - What is bit shiftGive a practical example with an explanation+  - Was versteht man unter einer BitverschiebungNennen Sie ein praktisches Beispiel und erklären Sie dieses
-  - Why are pull-up resistors used in switchesHow is their resistance determined+  - Warum werden pull-up Widerstände in Schalter verwendetWie ist deren Widerstand festgelegt?  
-  - Calculate the resistance for regulating LED currentthe voltage is 5 V, forward voltage of the LED is 2,7 V and the current is 30 mA. +  - Errechnen Sie den Widerstand für die regulierende LED Stromstärkedie Spannung beträgt 5 V, die Durchlassspannung der LED beträgt 2,7 V und die Stromstärke 30 mA. 
-===== Timers and delays =====+ 
 +===== Timer und Verzögerungen =====
  
 {{  :examples:timer:timers.jpg?580  |Timers}} {{  :examples:timer:timers.jpg?580  |Timers}}
  
-This chapter introduces the possibility of co-ordinate time of the microcontrollers - timers and delaysThese are helpful in applications which require time measuringmake breaks or accurately steer processesAll timers and delays are similar by their nature yet are clearly distinguishable at the same timeThe timers are physical modules of microcontroller which are functioning independently from the processor of the microcontrollerdelays are paragraphs of software program which are specifically designed to use working time of a processorFrom the aspect of similarity both work by counting the firing strokes of the microcontroller+Dieses Kapitel beschreibt die Möglichkeit, die Zeit der Mikrocontroller durch Timer und Verzögerungen zu kontrollierenDies ist hilfreich für alle Anwendungendie eine Zeitmessung benötigen, Unterbrechungen machen oder für präzise SteuerprozesseAlle Timer und Verzögerungen sind ähnlich im Aufbau, jedoch können sie voneinander unterschieden werdenTimer sind physikalische Module des Mikrocontrollerswelche unabhängig vom Prozessor des Mikrocontrollers funktionieren, Verzögerungen sind Abschnitte eines Softwareprogramms welche dazu entwickelt werden, die Arbeitszeit des Prozessors zu nutzenBeide arbeiten ähnlich, indem sie den Arbeitstakt des Microcontrollers zählen.
  
-Both methods have their pros and cons; which are covered in more detail in corresponding exercises. Out of correctness should be said, in the beginning the timers were separate integrated circuits and not as a part of a microcontrollerSeparate timer chips exist also todaybecause in some applications the microcontrollers are not needed and some timers are more efficient than those integrated into the microcontroller.+Beide Methoden haben ihre Vor- und Nachteilewelche in den entsprechenden Übungen besprochen werden. Anfangs waren Timer separate Schaltkreise, die nicht Teil eines Mikroprozessors warenAuch heute gibt es noch immer separate Timerchipsda in einigen Anwendungen keine Mikrocontroller verwendet werden, und einige Timer effizienter sind, als die eines Mikrocontrollers.
  
-Timers have evolved from being simple time counting devices to complex systems for receiving and generating signalsThey modulate and demodulate signals and they are capable of multiplying and dividing (taktsignaal?)There are also special time-to-digital converters (TDC), which can register time in picoseconds. At this moment we are concentrated on more simple timers +Timer haben sich von einfachen Zeitzählgeräten zu komplexen System entwickelt, welche Signale empfangen und generierenSie modulieren und demodulieren Signale und ermöglichen, Taktsignale zu multiplizieren und dividierenDarüber hinaus gibt es spezielle "Time-To-Digital" Konverter (TDC), welche Zeit in Picosekunden messen können, aber wir werden uns hier nur auf einfachere Timer konzentrieren.
  
-==== Software delay ====+==== Softwareverzögerungen ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:controller]], [AVR] [[en:avr:architecture]], [LIB] [[en:software:homelab:library:pin]], [LIB] [[en:software:homelab:library:delay]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:controller]], [AVR] [[en:avr:architecture]], [LIB] [[en:software:homelab:library:pin]], [LIB] [[en:software:homelab:library:delay]]//
  
-=== Theory ===+=== Theorie ===
  
-There is often a need to create delays in programs of microcontrollersit is necessary to time the actions or wait them to endBy its concept one of the easiest methods for creating a break in the work of a microcontroller is overloading its processor with some alternative action – for example order it to count big numbersFrom the stroke frequency of the processor can be calculated to which number it should count in order to get a certain time delayCounting a number from zero up to the value of the stroke frequency of the processor in hertz-sshould theoretically create a delay for one secondFor number of reasons this is not as simple in practice+Oft ist es wichtig in einem Programm eines Mikrocontrollers Verzögerungen einzubaueneinige Aktionen zu terminieren, oder zu warten bis sie abgeschlossen sindDie einfachste Methode die Arbeit eines Mikrocontrollers zu pausieren ist, ihn mit einer alternativen Operation zu überladen - z.Bdurch einen Befehlgroße Nummern zu zählenAus der Taktfrequenz des Prozessors kann man errechnen, wie weit das Programm zählen sollte um eine Verzögerung hervorzurufen
-     +Eine Zahl von Null bis zum Wert der Taktfrequenz des Prozessors in Hzsollte theoretisch eine Verzögerung von einer Sekunde erzeugenAus verschiedenen Gründen ist dieses jedoch praktisch nicht ganz so einfach.
-If the processor of the microcontroller calculates using numbers which’s binary form is as wide as its inner bus (AVR has 8 bits)then it takes one firing stroke of the processor to perform one arithmetical operation for example adding 1 to any valueIn order to operate with thousands or millions the number has to be 16 or 32 bit and for an 8 bit processor it takes more than one firing stroke to calculate them. Hence when dealing with large numbers, one has to be familiar with the inside of the processor – exactly its commands  +
  
-When programming in advanced languages (C-language for example), the programs are not written directly on the basis of the commandin order to create a software delay, one needs to know also its compiler which converts the program to the machine codeFrom this depends how many instructions (and phases therefore) it takes to perform one arithmetical operationComplexity is added by compilers ability to convert the program into the machine code in several ways – for exampleby making the machine code as memory saving as possible or easily executableSuch compiler’s actions are called optimizationWith different modes of optimization the software delay’s machine codes and their duration come out different   +Wenn der Prozessor des Microcontrollers mit Nummern rechnet, deren Binärform so groß ist wie der innere Bus (AVR hat 8 Bits), dann braucht es einen Taktzyklus des Prozessors um eine arithmetische Operationwie z.B1 zu einem Wert zu addierendurchzuführenSoll mit tausenden oder millionen gerechnet werden, muss die Nummer 16 oder 32 Bit groß sein und ein 8-Bit Prozessor benötigt zur Berechnung mehr als eine TaktfrequenzDaher sollte man sich mit der Arbeitsweise und insbesondere den Befehlen des Prozessors auskennen, wenn man mit großen Werten arbeitet.
  
 +Wenn man in fortgeschrittenen Sprachen programmiert (z.B. C), werden die Programme nicht auf Basis des Befehls geschrieben, um eine Softwareverzögerung zu erzeugen. Vielmehr muss man auch den Compiler kennen, welcher das Programm zu Maschinencode konvertiert. Davon hängt ab, wie viele Befehle (und Phasen) es braucht um eine arithmetische Operation durchzuführen. Das wird durch mehrere Gründe komplexer, durch die Fähigkeit des Compilers das Programm in Maschinencode umzuwandeln - z.B. dadurch, dass der Maschinencode für Speicherverbrauch optimiert, oder einfacher auszuführen wird. Diesen Compilervorgang nennt man Optimierung. Durch verschiedene Optimierungsmodi verändern sich die Maschinencodes für die Softwareverzögerung sowie die Dauer der Verzögerung.
  
-=== Practice ====+=== Beispiel ====
  
-The following is an example of generating software delay with AVR microcontrollerA part of a program in C-language is written, which counts the variable of for-cycle from to 100. Inside each cycle a no-action empty instruction is completedIt is needed, because if the content of the cycle is emptythe compiler optimizes it out of the program as it considers this to be useless.+Das folgende Beispiel generiert eine Softwareverzögerung im AVR MikrocontrollerEin Teil des in C geschriebenen Programms zählt eine Variable in vier Zyklen von bis 100. 
 +In jedem Zyklus wird ein leerer "no-action empty" Befehl ausgeführtDieser wird benötigtder Compiler einen Zyklus ohne Inhalt als nutzlos betrachtet und ihn daher aus dem Programm werfen würde
  
 <code c> <code c>
 unsigned char x; unsigned char x;
  
-// Cycle until is 100+// Zyklus bis ist 100
 for (x = 0; x < 100; x++) for (x = 0; x < 100; x++)
 { {
- // With empty instruction nop+ // Mit "empty"-Befehl nop
  asm volatile ("nop");  asm volatile ("nop");
 } }
 </code> </code>
  
-This is the same part of a program after compiling2 hexadecimal numbers on the left is machine code and on the right is the command with operand(s) in assembler languageThe machine code and the assembler language are conformalthe assembler is just for presenting the machine code for humans in a readable formIn compiling, the optimization of the length of the program is used (compiler’s parameter –Os).+Dies ist der gleiche Teil des Programms nach dem KompilierenDie beiden Hexadezimalzahlen links geben den Maschinencode an, und rechts befindet sich der Befehl mit den Operanden in Assembler. 
 +Der Maschinencode und die Assemblersprache sind konformAssembler dient nur dazu, den Maschinencode für Menschen lesbar zu machenKompiliert wurde mit der Optimierungsmethode für die Länge des Programms (Parameter -Os).
  
 <code asm> <code asm>
-80 e0     ldi  r24, 0x00   ; r24 loading number to the index +80 e0     ldi  r24, 0x00   ; r24 lädt Zahl in den index 
-00 00     nop              ; Empty operation +00 00     nop              ; "Empty" Operation 
-8f 5f     subi r24, 0xFF   ; subtracting 255 form the r24 indexthat means adding +1 +8f 5f     subi r24, 0xFF   ; subtrahieren von 255 aus dem r24 Indexwas bedeutet +1 addieren 
-84 36     cpi  r24, 0x64   ; comparing r24 index with number 100 +84 36     cpi  r24, 0x64   ; r24 Index mit der Zahl 100 vergleichen 
-e1 f7     brne .-8         ; If the comparison was wrongthen transfer 8-baits back+e1 f7     brne .-8         ; Falls der Vergleich nicht übereinstimmt, 8-Bits zurücktransferieren
 </code> </code>
  
- +In der kompilierten Form erkennt manwas mit dem Zyklus der C-Sprache passiert und man kann berechnen wie viele Taktfrequenzen benötigt werden, um den Zyklus einer Periode zu beendenDie Information über die Wirkung der Befehle und ihre Laufzeit findet man im AVR DatenblattIm vorliegenden Beispielbraucht es Taktzyklen um Befehle in einer Periode auszuführenda jeder Befehl einen Takt benötigtZusätzlich wird ein Takt vor dem Zyklus benötigt, um die Befehle zu laden und ein Taktum den Zyklus zu beenden. 
-In the compiled form can be seenwhat is actually happening with the cycle of the C-language and it can be used to calculate how many clock sycles is needed to complete a cycle of one periodThe information about the effect of the instructions and operating time can be found from AVR’s instructions datasheetIn the given exampleit takes clock cycles to complete instructions in one cycle periodbecause all instructions demand one clock rateIn additionone clock rate is used before the cycle for loading instruction and afterwards one extra clock rate for exiting the cycleBy assuming, that the working clock rate of the controller is 14,7456 MHz, the whole delay produced by the program can be calculated+Wenn man nun den Arbeitstakt von 14,7456 MHz annimmtkann man die vom Programm verursachte Verzögerung berechnen.
  
 (1 + 100 ⋅ 4 + 1) / 14745600 = 27,26 μs (1 + 100 ⋅ 4 + 1) / 14745600 = 27,26 μs
  
-The delay produced in the example, is in microseconds and the variable used is 8-bit so the machine code is fairly simpleIn order to produce a break in millisecondwe need to count much larger numbers and thus the machine code gets longerCycles working inside each other may also be usedbut with this method the delay is not in linear relation with the number of the cycles because with each level of cycle a small extra delay occurs. +Die Verzögerung in diesem Beispiel ist in Mikrosekunden angegeben und die Variable nutzt 8-Bit, daher ist der Maschinencode recht einfachUm eine Pause in Millisekunden zu verursachenmüssen weitaus größere Nummern gezählt werden, wodurch dann der Maschinencode auch länger wirdEs können ebenfalls Zyklen verwendet werdendie ineinander greifen, jedoch steht dann die Verzögerung nicht in linearer Relation mit der Nummer des Zyklusda mit jedem Level des Zyklus eine kleine zusätzliche Verzögerung verursacht wird.
-       +
-The goal of this exercise is not creating precise software delay on the level of machine codebecause it is quite an accurate work and we already have the functions necessary to produce delays in the avr-libc and in the library of the HomeLab. Those are used also in the following examples.+
  
-When dealing with the software delay it is important to knowthat regardless its basic simplicity; it is extremely inefficient method from the power consumption point of view During all of these clock rates when the microcontroller is counting the useless, energy is consumed. So if using applications operating on batteries, it is not wise to write long software delays. Wiser is to use hardware timers, which are working independently and wake the processor from hibernating when it is time to continue the work   +Das Ziel dieser Übung ist es nicht präzise Softwareverzögerungen in Maschinencode zu erstellenda diese eine sehr präzise Arbeit ist und die Funktionen zur Erzeugung von Verzögerungen bereits in der avr-libc und der Bibliothek von HomeLab hinterlegt sindDiese werden auch in den folgenden Beispielen genutzt.
  
 +Bei der Arbeit mit Softwareverzögerungen arbeitet, ist es wichtig zu wissen, dass diese trotz ihrer Einfachheit, eine sehr ineffiziente Methode sind was den den Stromverbrauch betrifft.
 +Während jedes Taktes in dem der Mikrocontroller unnötig Zahlen zählt, wird Energie verbraucht. Wenn also batteriebetriebene Anwendungen genutzt werden, ist es nicht sinnvoll lange Softwareverzögerungen zu schreiben. Für diesen Fall sollte man lieber Hardwaretimer nutzen, welche unabhängig arbeiten und den Prozessor aus dem Ruhezustand holen wenn es an der Zeit ist die Arbeit fortzuführen.
  
-=== Practice ====+=== Übung ==== 
 + 
 +Der folgende Programmcode beinhaltet die Softwareverzögerunsfunktion //sw_delay_ms//, welche einen gegebene Verzögerung in ms mit dem Parameter //count// verursacht. Die Funktionen nutzt die Funktion der Bibliothek avr-libc //_delay_ms// welche zum Teil in Assembler geschrieben ist. 
 +//_delay_ms// wird in dieser Übung nicht genutzt, da hiermit bei langen Verzögerungen Probleme auftreten können. //sw_delay_ms// erlaubt es aber bis zu 65535ms lange Verzögerungen ohne Komplikationen zu nutzen. 
  
-The following code of a program is about software delay function //sw_delay_ms// , which makes a given delay in milliseconds using the parameter //count//. The function uses avr-libc library’s function //_delay_ms// which is partly written in assembler language. The reason why the //_delay_ms// is not used in this exercise immediately is that when using the //_delay_ms// problems may occur when the delays are long. The //sw_delay_ms// enables creating 65535 ms long delays without any complications.  
  
 <code c> <code c>
 // //
-// Software delay in milliseconds.+// Softwareverzögerung in Millisekunden.
 // //
 void sw_delay_ms(unsigned short count) void sw_delay_ms(unsigned short count)
 { {
- // Counting the variable of the delay to 0+ // Zählen der Variable der Verzögerung auf 0
  while (count-- > 0)  while (count-- > 0)
  {  {
- // 1ms delay with a special function.+ // 1ms Verzögerung mit spezieller Funktion.
  _delay_ms(1);  _delay_ms(1);
  }  }
Line 3149: Line 2620:
 </code> </code>
  
-The following program is for using the given functionthis creates two delays in the endless loop: 100 ms and 900 ms. During the shorter delay LED is lit and during the longer it is switched off, the result – the LED is blinking periodically+Das folgende Programm dient dazudie gegebene Funktion zu nutzen, es erzeugt zwei Verzögerungen in der Endlosschleife: 100 ms und 900 ms. Während der kürzeren Verzögerung wird eine LED eingeschaltet und während der längern ausgeschaltet. Das Resultat: die LED blinkt periodisch. 
  
 <code c> <code c>
 // //
-// The demonstration program of the software delay of the HomeLab. +// Das Vorführprogramm des HomeLab für Softwareverzögerungen
-// The program is blinking a LED for a moment after ~1 second.+// Es lässt eine LED für ~1 Sekunde aufleuchten.
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
Line 3160: Line 2632:
    
 // //
-// Determining the pin of the test LED+// Festlegung des Pins zum Testen der LED
 // //
 pin debug_led = PIN(B, 7); pin debug_led = PIN(B, 7);
    
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
 { {
- // Setting the pin of the LED as output.+ // Setzt LED Pin als Output
  pin_setup_output(debug_led);  pin_setup_output(debug_led);
    
- // Endless loop + // Endlosschleife
  while (true)  while (true)
  {  {
- // Lighting the LED+ // Aufleuchten der LED
  pin_clear(debug_led);  pin_clear(debug_led);
    
- // Software delay for 100 ms+ // Softwareverzögerung für 100 ms
  sw_delay_ms(100);  sw_delay_ms(100);
    
- // Switching off the LED+ // Ausschalten der LED
  pin_set(debug_led);  pin_set(debug_led);
  
- // Software delay for 900 milliseconds.+ // Softwareverzögerung für 900 ms.
  sw_delay_ms(900);  sw_delay_ms(900);
  }  }
Line 3190: Line 2662:
 </code> </code>
  
-Although it seems that the LED blinks in every 1 secondthe time is actually a little bit longerbecause the callouts of LED’s and delay functions are taking a couple of clock rates of the microcontroller +Auch wenn es so aussieht, als blinke die LED jede Sekundedauert es tatsächlich etwas längerda das ansprechen der LED und die Verzögerungsfunktionen ein paar Taktfrequenzen des Mikrocontrollers benötigen. 
-==== Hardware delay ====+==== Hardwareverzögerung ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:controller]], [AVR] [[en:avr:timers]], [LIB] [[en:software:homelab:library:pin]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:timer]], [PRT] [[en:examples:timer:software_delay]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:controller]], [AVR] [[en:avr:timers]], [LIB] [[en:software:homelab:library:pin]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:timer]], [PRT] [[en:examples:timer:software_delay]]//
  
-=== Theory ===+=== Theorie ===
  
-The software delay is not the only method for creating breaks. The same can be done using timer. Timer is a hardware which counts up or down with a certain frequencyThe clock frequency of the timer can be generated from microcontroller’s frequency or from some kind of other outside paceIn general the clock frequency can  be divided with a multiplier to reach a smaller frequency - this is done with prescalerImportant fact is that the fixed clock frequency timer’s value is linearly related to the timeThe time can be calculated by multiplying the period of the clock frequency of the timer with the value of the timer.+Neben der Softwareverzögerung gibt es auch Timer, um Unterbrechungen zu erzeugen. Timer sind Hardwarekomponenten, die mit einer bestimmten Frequenz hoch oder runter zählen. Die Taktfrequenz des Timers kann über die Frequenz des Mikrocontrollers oder einen externen Taktgeber erzeugt werdenAllgemein kann die Taktfrequenz mit einem Multiplikator dividiert werden um eine geringere Frequenz zu erreichenHierzu wird ein Vorteiler verwendetWichtig ist jedoch, dass die festgelegte Taktfrequenz des Timers linear zu der Zeit istDie Zeit kann durch Multiplikation der Periode der Taktfrequent des Timers mit dem Wert des Timers berechnet werden.
  
-[{{  :examples:timer:timer_counter.png?300|The events which come with the changes of AVR timer.}}]+[{{  :examples:timer:timer_counter.png?300|Durch Veränderung des AVR Timers hervorgerufene Ereignisse.}}]
  
-AVR counters can be made to inform about overflow of the counter or achieving compare machOverflow happens when the counter has the maximal possible value and the cycle starts all over again form 0. With reaching a pre set value during the moment of growth of the counter’s value it is compared to the value given by the userOn the occurrence of the event, the bits in the status indexes of the AVR are automatically set as high.   +AVR Taktgeber können so eingestellt werden, dass sie bei Überlauf des Timers oder bei Vergleichstreffern informierenEin Überlauf tritt auf, wenn der Timer seinen maximalen Wert erreicht hat und der Zyklus wieder bei anfängtNach Erreichen eines vorgegebenen Wertes beginnt der Timer bei jedem Anstieg seines Wertes diesen mit einem vom Benutzer vorgegebenen Wert zu vergleichenDaraufhin werden die Bits des AVR-Statusindexes automatisch high gesetzt.
-  +
-For generating a delay using a timer, it is only necessary to set the timer and waiting for the status bit to go high. Different from the software delay, the work of the timer is not depending on the compiler, which makes them more reliable. At the same time the diversity (or complexity) of the set-up of the AVR counter can be considered fairly troublesome. Depending on the microcontroller’s timing signal, may happen that it will not divide exactly with the desired delay period and the delay will not be accurate.  +
  
-=== Practice === +Um eine Verzögerung mit einem Timer zu generierenmuss man nur den Timer setzen und darauf warten, dass das Statusbit high wirdIm Unterschied zur Softwareverzögerung ist die Arbeit des Timers nicht vom Compiler abhängigwodurch er zuverlässiger istGleichzeitig ist die Diversität (bzwKomplexität) der Einstellungen des AVR Timers hochJe nach Taktsignal des Mikrocontrollers kann es seindass es nicht exakt mit der gewünschten Verzögerungsperiode dividiert und die Verzögerung so ungenau wird.
-The program code below is a delay function based on a timerwhich is simplified a little bitThe principle of counting is the same as it is at software delay function – a desired amount of 1 ms long delays are produced. The delay is produced with an 8-bit ATmega 128 counter 0. It is calculated previously that at clock frequency 14,7456 Mhz the timing signal has to be divided at least 64 times, so that the counter would not reach to overflow in 1 msThe value which the counter must have so that the overflow occurs after 1 ms is presented in the form of an expression and the variable is //timer_start////F_CPU// which is a constant in macro-language, that shows clock frequency in HzThe clock frequency should be 25,6 at the moment but since fractions can not be used, the initial value will be set 26. Unfortunately here arises a mistake in delay time, however it is fairly small (-1,7 μs)+
  
-In the cycle takes place initialing of the counter and zeroing the flag of the overflow (by writing into that). Then is waited until the counter counts to 256 from the initial valuei.e. to the overflow. At the moment of the overflow the flag goes high and the delay of 1 ms has taken placeIn the end of the function the timer is stopped      +=== Übung === 
 + 
 +Der Programmcode unterhalb stellt eine vereinfachte Timer-basierte Verzögerungsfunktion dar. Das Zählen funktioniert genauso wie bei einer Softwareverzögerungsfunktion. Es wird eine gewünschte Verzögerung von 1 ms mit dem Timer 0 eines 8-Bit ATmega128 erzeugt. Die zuvor errechnete Taktfrequenz liegt bei 14,7456 MHz und das Timersignal muss mindestens 64 Mal dividiert werden, so dass der Timer seinen Überlauf nicht in einer Millisekunde erreicht. 
 +Der Wert den der Timer haben muss, so dass der Überlauf nach 1 ms stattfindet wird mit durch die Variable //timer_start// dargestellt. //F_CPU//, eine Konstante in der Makrosprache, gibt die Taktfrequenz in Hz an. Diese sollte 25,6 betragen, da nur ganze Zahlen berücksichtigt werden, liegt der Startwert bei 26. 
 +Leider entsteht hier eine gewisse Ungenauigkeit, welche aber sehr gering ist (- 1,7µs). 
 + 
 +In dem Zyklus wird der Timer initialisiert und die Überlauf-Flagge genullt (in dem eine hineingeschrieben wird). Dann wird abgewartet bis der Timer vom Startwert bis 256 gezählt hatalso zum ÜberlaufIn dem Moment wird die Flagge hoch gesetzt und eine Verzögerung von einer 1 ms hat stattgefundenAm Ende der Funktion wird der Timer gestoppt.
  
  
 <code c> <code c>
 // //
-// Hardware delay in milliseconds.+// Hardwareverzögerung in Millisekunden.
 // //
 void hw_delay_ms(unsigned short count) void hw_delay_ms(unsigned short count)
 {  {
- // Calculating the initial value of the timer.+ // Berechnung des Startwertes des Timers.
  register unsigned char timer_start = 256 - F_CPU / 1000 / 64;  register unsigned char timer_start = 256 - F_CPU / 1000 / 64;
   
- // Starting the timer.+ // Start des Timers.
  timer0_init_normal(TIMER0_PRESCALE_64);  timer0_init_normal(TIMER0_PRESCALE_64);
  
- // Counting the variable of the delay to the 0.+ // Zählen der Verzögerungsvariable auf 0.
  while (count-- > 0)  while (count-- > 0)
  {  {
- // Initializing the timer.+ // Initialisierung des Timers.
  timer0_set_value(timer_start);  timer0_set_value(timer_start);
  
- // Zeroing the overflow flag.+ // Überlauf-Flagge auf Null setzen.
  timer0_overflow_flag_clear();   timer0_overflow_flag_clear();
   
- // Waiting for overflow.+ // Warten auf den Überlauf.
  while (!timer0_overflow_flag_is_set())  while (!timer0_overflow_flag_is_set())
  {  {
Line 3239: Line 2714:
  }  }
  
- // Zeroing the overflow flag.+ // Überlauf-Flagge auf Null setzen.
  timer0_overflow_flag_clear();   timer0_overflow_flag_clear();
  
- // Stoping the timer.+ // Timer anhalten.
  timer0_stop();   timer0_stop();
 } }
 </code> </code>
  
-The following is a similar program to the example of the software delay. In the shorter 100 ms half-period the LED is lit and on the longer 900 ms half-period it is switched offAs the result the LED is blinking after every secondUnfortunately, in this example the period isn't precisely 1 second eitherbecause executing other functions of the program takes also timeFor exact timing 16-bit timer with interruptions must be used+Das folgende Programm ist ähnlich wie das für die Softwareverzögerung. In der kürzeren 100 ms langen halb-Periode wird die LED eingeschaltet und in der längeren 900 ms halb-Periode ausgeschaltetDas Resultat: die LED blinkt jede SekundeLeider beträgt die Periode in diesem Beispiel ebenfalls nicht exakt eine Sekundeda die Ausführung anderer Funktionen des Programms ebenfalls Zeit verbrauchtFür ein exaktes Timing, muss ein 16-Bit Timer mit Interrupts genutzt werden.
  
 <code c> <code c>
 // //
-// Demonstration program of hardware delay of the HomeLab. +// Beispielprogramm für eine Hardwareverzögerung mit dem HomeLab. 
-// The Program blinks LED for a moment after every ~1 second.+// Das Programm lässt eine LED immer nach ~1 Sekunde blinken.
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
Line 3258: Line 2733:
  
 // //
-// Determining the pin of the Test LED.+// Festlegung des Pins der Test-LED.
 // //
 pin debug_led = PIN(B, 7); pin debug_led = PIN(B, 7);
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
 { {
- // Setting the pin of the  LED as output.+ // LED Pin als Output setzen.
  pin_setup_output(debug_led);  pin_setup_output(debug_led);
  
- // Endless loop. + // Endlosschleife.
  while (true)  while (true)
  {  {
- // Lighting the LED.+ // Aufleuchten der LED.
  pin_clear(debug_led);  pin_clear(debug_led);
   
- // Hardware delay for 100 milliseconds.+ // Hardwareverzögerung von 100 ms.
  hw_delay_ms(100);  hw_delay_ms(100);
  
- // Switch off of the LED.+ // Ausschalten der LED.
  pin_set(debug_led);  pin_set(debug_led);
   
- // Hardware delay for 900 milliseconds.+ // Hardwareverzögerung von 900 ms.
  hw_delay_ms(900);  hw_delay_ms(900);
  }  }
Line 3288: Line 2763:
 </code> </code>
  
-==== Periodic interrupt ====+==== Periodische Interrupts ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:controller]], [HW] [[en:hardware:homelab:digi]], [AVR] [[en:avr:interrupts]], [AVR] [[en:avr:timers]], [LIB] [[en:software:homelab:library:pin]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:timer]], [PRT] [[en:examples:timer:software_delay]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:controller]], [HW] [[en:hardware:homelab:digi]], [AVR] [[en:avr:interrupts]], [AVR] [[en:avr:timers]], [LIB] [[en:software:homelab:library:pin]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:timer]], [PRT] [[en:examples:timer:software_delay]]//
  
-=== Theory ===+=== Theorie ===
  
-The goal of these practical exercises is to demonstrate the usage of the interrupts on the example of the countersThe interrupts are program parts which are reacting to the events taking place in the microcontrollersThey are usually used for quick response to an eventbut they can also be used for completing several parallel processesprecisely timed action and saving powerFor example, it is possible to make a LED blinking using interruptions, so that blinking frequency does not depend on what is happening in the program at the moment+Ziel dieses praktischen Beispiels ist es, die Verwendung von Interrupts an Beispiel von Timern darzustellenInterrupts sind Programmteile welche auf Ereignisse, die in einem Mikrocontroller stattfinden, reagierenNormalerweise dienen sie dazuschnell auf ein Event zu reagieren. Sie können jedoch auch dazu genutzt werden, um mehrere parallel ablaufende Vorgänge oder zeitlich abgestimmte Aktionen auszuführenoder zur Energieeinsparung. 
 +Es ist beispielsweise möglich eine LED durch Interrupts blinken zu lassen, so dass die Blinkfrequenz nicht von einem Programm abhängig ist.
  
-=== Practice ===+=== Übung ===
  
-The following program shows how the counter is set up to make an interruptThere are 2 LEDs of the Digital i/o module in the program, the state of the red LED is changed periodically with software delaythe state of the green LED is changed when interrupts occurThere is a separate exercise for blinking LED with software delay and it is not explained hereThe main goal is to explain the usage of the library of the counters and interrupts+Das folgende Programm zeigt wie Timer eingestellt werden, um einen Interrupt auszulösen. 
 +Das Programm nutzt zwei LEDs des digitalen I/O Moduls. Der Status der roten LED wird mit einer Softwareverzögerung periodisch geändertder Status der grünen LED wird geändert wenn ein Interrupt auftrittEs gibt ein separates Beispiel für blinkende LEDs durch Softwareverzögerung, daher wird es an dieser Stelle nicht näher erläutertZiel ist es, die Bibliothek für Counter und Interrupts zu verwenden.
  
-In the beginning of the program, the 16-bit counter/timer has been set up with the function //timer1_init_ctc// With this function the counter CTC //clear timer on compare match// has been set to the mode where the maximum value of the timer is not 216 – but can be selected. In this case the maximum value is set to equal the value of the ICR1 indexThe divider of the counter is 1024 and the value of ICR1 is 14400, so when the clock frequency is 14,7456 MHz, the period will be exactly one secondIt is easy to calculate with following formula+Zu Beginn des Programms wird der 16-Bit Timer mit der Funktion //timer1_init_ctc// eingestelltDadurch wird der Timer in den CTC //clear timer on compare match// Modus gesetzt, wodurch sein maximaler Wert nicht 216 ist, sondern vom Benutzer eingestellt werden kann. In diesem Fall wird der maximale Wert so gesetzt dass er gleich dem Wert des ICR1 Indexes ist. 
 +Der Teiler des Timers ist 1024 und der Wert des ICR1 beträgt 14400. Bei einer Taktfrequenz von 14,7456MHz umfasst eine Periode somit genau eine SekundeDieses kann mit folgender Formel berechnet werden:
  
 f = 14745600 Hz / 1024 / 14400 = 1  f = 14745600 Hz / 1024 / 14400 = 1 
  
-After allowing the interrupt to achieve the maximum value of the counter 1, an interrupt must be allowed also at the global levelthat means in the microcontroller. For allowing global interruptsthere is a function //sei// and for forbidding //cli//A header file //avr/interrupt.h// must be included for defining the program part of these functions and interruptsThe program part of the interrupt is defined with macro function ISR, which parameter is the name of the interrupt vectorIn this set-up the vector of counter 1’s maximum value achievement interrupt is //TIMER1_CAPT_vect//.  +Nachdem zugelassen wurde, dass ein Interrupt den maximalen Wert von Counter erreichtmuss ein Interrupt auch global, also im Mikrocontrollerzugelassen werden. Dazu gibt es die Funktion //sei//, um sie zu untersagen die Funktion //cli//Um den Programmteil für diese Funktionen und Interrupts festzulegen muss die Headerdatei //avr/interrupt.h// eingefügt werden. 
 +Ein Interrupt wird im Programm durch die Makrofunktion ISR definiertderen Parameter der Name des Interruptvektors istIm folgenden Beispiel beträgt der Interruptvektor des maximal erreichbaren Wertes von Counter 1 //TIMER1_CAPT_vect//.  
  
  
 <code c> <code c>
 // //
-// The HomeLab's example of blinking LED which blinks due to counter interruptings+// HomeLab Beispiel für blinkende LED aufgrund von Counter-Interrupts
-// For comparison to the LED blinking due to interrupts,  +// Zum Vergleich blinkender LEDs aufgrund von Interrupts,  
-// there is a software delay blinking LED working parallel.+// gibt es parallel eine durch Softwareverzögerung blinkende LED.
 // //
 #include <homelab/pin.h> #include <homelab/pin.h>
Line 3319: Line 2798:
  
 // //
-// Determining the pins of the LEDs.+// Festlegung der Pins der LEDs.
 // //
 pin led_red   = PIN(C, 5); pin led_red   = PIN(C, 5);
Line 3325: Line 2804:
  
 // //
-// Interruption+// Interrupt
 // //
 ISR(TIMER1_CAPT_vect) ISR(TIMER1_CAPT_vect)
 { {
- // Changing the state of the green LED.+ // Status der grünen LED ändern.
  pin_toggle(led_green);  pin_toggle(led_green);
 } }
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
 { {
- // Setting the pins of the LEDs as outputs.+ // LED Pins als Output setzen.
  pin_setup_output(led_red);  pin_setup_output(led_red);
  pin_setup_output(led_green);  pin_setup_output(led_green);
  
- // Seting the timer up in the CTC mode. + // Timer in den CTC Modus setzen.
  timer1_init_ctc(  timer1_init_ctc(
  TIMER1_PRESCALE_1024,  TIMER1_PRESCALE_1024,
  TIMER1_CTC_TOP_ICR);  TIMER1_CTC_TOP_ICR);
  
- // The maximal value of the timer is 14400, which + // Maximaler Wert des Timers ist 14400, wodurch 
- // makes the length of the period 1 s. + // die Periode 1 s lang ist
- // Formula: 14,7456Mhz / 1024 = 14400+ // Formel: 14,7456Mhz / 1024 = 14400
  timer1_set_input_capture_value(14400);  timer1_set_input_capture_value(14400);
  
- // Allowing interruption of achieving the value.+ // Dem Interrupt erlauben, den Wert zu erreichen.
  timer1_input_capture_interrupt_enable(true);  timer1_input_capture_interrupt_enable(true);
  
- // Allowing global interruption.+ // Globalen Interrupt zulassen.
  sei();  sei();
  
- // Endless loop.+ // Endlosschleife.
  while (true)  while (true)
  {  {
- // Software delay 1000 ms.+ // Softwareverzögerung 1000 ms.
  sw_delay_ms(1000);  sw_delay_ms(1000);
  
- // Change of the state of the red LED.+ // Status der roten LED ändern.
  pin_toggle(led_red);  pin_toggle(led_red);
  }  }
Line 3370: Line 2849:
 </code> </code>
  
-At the start of the program it is seen that regardless of what the microcontroller is doing in the main programthe interrupts are taking place and the green LED is blinking.+Zu Beginn des Programms sieht mandass unabhängig davon was der Mikrocontroller gerade im Hauptprogramm macht, Interrupts stattfinden und die grüne LED blinkt.
  
-If we let the program to work for a couple of minutesan important aspect occurs, that was not so easily noticeable during software delay exerciseAlthough the delay in red LED blinking is 1000 ms, the actual time for completing the full cycle is a little bit longerThis is because the change of the LED’s statecallout of the function of the delay and completion of the cycle are demanding some clock cycles of time for the processorAs a result the blinking of the red LED is always behind from the blinking of the green LED. This is why  it is not advised to design clocks and other precise actions with delay but with interruptions of the counter+Läuft das Programm ein paar Minuten wird ein entscheidender Aspekt deutlichder im Rahmen der Softwareverzögerung nicht so einfach zu erkennen istAuch wenn die Verzögerung der blinkenden roten LED 1000 ms beträgtist die tatsächlich benötigte Zeit um einen Zyklus zu beenden längerDas liegt darandass die Änderung vom LED-Status'die Angabe der Verzögerungsfunktion und das Beenden vom Zyklus einige Taktzyklen des Prozessors dauernDaher sieht es so aus, als blinke die rote LED immer nach der grünenAus diesem Grund sollten Taktgeber oder andere präzise Vorgänge nicht mit Verzögerungen, sondern mit Timer-Interrupts ausgeführt werden
-==== Exercises ====+==== Aufgaben ====
  
-The goal is to write a program performing tasks described below+Ziel ist es, ein Programm zu schreiben welches die unten genannten Aufgaben durchführt
  
-=== Warm up exercise ===+=== Aufwärm-Übung ===
  
-  * Make the red LED blinkThe period is 10 seconds (half period is seconds). Create function of software delaywith amount of seconds as a parameter.+  * Lassen Sie die rote LED blinkenDie Periode soll 10 Sekunden (Halbperiode SekundenbetragenNutzen Sie eine Softwareverzögerungsfunktionmit der Sekundenanzahl als Parameter.
  
-=== For beginners ===+=== Für Anfänger ===
  
-  - Display on LCD screen, with the accuracy of 100 ms, time between pressing of any random two buttonsExecution of the time measurement is your own choice +  - Zeigen Sie mit einer Genauigkeit von 100 ms auf dem LCD Display die Zeit zwischen der Betätigung von 2 beliebigen Schaltern an. Die Art der Zeitmessung können Sie frei bestimmen
-  - Pressing button S1, the blinking speed of all three LEDs is slowed down two times Pressing button S3, the blinking gets 2 times faster and pressing button S2 the frequency of the blinking will be set to 1 Hz. Use delay functions or interruptions (the interruptions are more difficult but when delay functions are used there will be an extra delay due to the filtering function of the buttons). +  - Wird Schalter S1 betätigtwird die Blinkgeschwindigkeit aller 3 LEDs zweimal reduziertDurch Betätigung von S3, blinken die LEDs  doppelt so schnell, und S2 setzt die Blinkfrequenz auf 1 Hz. Nutzen Sie Verzögerungsfunktionen oder Interrupts (die Interrupts sind schwieriger, aber bei der Verwendung von Verzögerungsfunktionen wird eine zusätzliche Verzögerung durch die Filterfunktion der Schalter auftreten.)  
-  - Display the frequency of pressing down the button S1 on the segment LED indicator in Hz-s. The display of the frequency must be limited with at the bottom and with at the top.  +  - zeige die Druckfrequenz von Schalter S1 auf dem Segment LED-Display in Hz-s. Die Anzeige der Frequenz muss nach unten mit und nach oben mit begrenzt werden
-  - If button S1 is pressedthe program counts down the seconds from 60 to and then lights the red LED. If button S2 is pressed the time is 30 secondsfollowed by lighting of the yellow LED.  For S3 the time is 10 seconds and the LED is greenAll the processes have to take place simultaneouslyThe LEDs switch off when corresponding buttons are pressed+  - Wird Schalter S1 gedrückt wirdzählt das Programm die Sekunden von 60 bis herunter und schaltet dann die rote LED einBei S2 beträgt die Zeit nur 30 sanschließend wird die gelbe LED eingeschaltetDie Zeit bei Betätigung von S3 beträgt 10 s, dann leuchtet die grüne LED. Alle Prozesse müssen gleichzeitig stattfindenDie LEDs schalten sich aus, wenn der dazugehörige Schalter betätigt wird
-  - Display the Time on the LCD as follows: hh:mm:ss. Use hardware timer with interruptions and the Time must be configurable with the buttonsIt is advised to use three buttons, S1 for increasing rotationally the hours, S2 for minutes and S3 for seconds.+  - Zeigen Sie die Zeit auf dem LCD wie folgt an: hh:mm:ss. Nutzen Sie den Hardwaretimer mit Interrupts, die Zeit muss mit den Schaltern eingestellt werden könnenEs sollten drei Schalter genutzt werden, S1 erhöht die Stunden, S2 die Minuten, und S3 die Sekunden.
  
-=== For advanced ===+=== Für Fortgeschrittene ===
  
-  - Design a stopwatchwhich displays hoursminutesseconds and milliseconds on LCD screenButton S1 starts the time, S2 stops it and S3 zeros itInterruption of the timer must be used+  - Entwickeln Sie eine Stoppuhrdie StundenMinutenSekunden, und Millisekunden auf dem LCD anzeigtSchalter S1 startet die Zeit, S2 hält sie an, und S3 nullt die UhrEs müssen Interrupts des Timers genutzt werden
-  - In 2 second intervals redyellow and green LED are smoothly lit and switched off after each otherThe smooth lighting is achieved by modulating the LEDs with hundredths of hertz (by lighting and switching it off very fastand by changing the proportions between lighted/switched off timecausing to appear for the  eye, that the brightness of the LEDs is changing (this is Pulse With Modulation). +  - Die rotegelbe und grüne LED müssen in 2-Sekunden Intervallen fließend nacheinander ein- und ausgeschaltet werdenDas fließende Licht wird erzeugt, in dem man die LED mit mehreren hundert Hertz moduliert (also sehr schnell ein- und ausschaltetund die Abstände zwischen dem Ein- und Ausschalten verändert. Dadurch wird für das Auge der Effekt erzeugtdass sich die Helligkeit der LED ändert (Pulsweitenmodulation). 
-  - Make a part of program in C-language which produces a delay of 10 μs ± 10 % at frequency of 14,7456 MHz. Verify the functioning of the delay theoretically compiled program. By commenting the instructions in assembler language in the .lss file of compiled program+  - Erstellen Sie einen Programmteil in C, welcher eine Verzögerung von 10 µs ± 10% bei einer Taktfrequenz von 14,7456 MHz erzeugtVerifizieren Sie theoretisch, dass die Verzögerung funktioniert, indem Sie die Assembler-Befehle in der .lss Datei des kompilierten Programms kommentieren.
  
-=== Questions ===+=== Fragen ===
  
-  - What are the methods for crating delay+  - Welche Methoden zur Erstellung von Verzögerungen gibt es
-  - How is software delay createdOn which parameters depends the duration of the software delay+  - Wie wird eine Softwareverzögerung erstelltVon welchen Parametern hängt die Softwareverzögerung ab
-  - What makes us use hardware delay/timer with interruptions+  - Warum werden Hardwareverzögerungen/Timer mit Interrupts genutzt
-  - Calculate the overflow interruption period for 8-bit timerif the clock rate is 16 MHz and frequency divider's factor is 1024. +  - Berechnen sie die die Überlauf-Interruptperiode für einen 8-Bit Timerwenn Taktfrequenz 16M Hz und Frequenzteilerfaktor 1024 betragen
-  - What is RTC hidden in the computers+  - Was ist ein Echtzeitgeber in einem Computer
-  - What happens on the 19.01.2038 in the world of computers+  - Was geschieht am 19.01.2038 in der Computerwelt
-  - What can be done with the AVR timers besides counting time+  - Wozu können AVR Timer noch genutzt werden, außer um Zeit zu zählen
-  - What indexes can be used to set up the ATmega128 timer 0? What can be adjusted with these registers+  - Welche Indizes können genutzt werden um den ATmega128 Timer einzustellenWas kann mit diesen Register verändert werden
-  - Which is the longest duration of the interruptions in milliseconds which can be achieved with ATmega128 micro-controller that work at the clock frequency of 14,7456 MHz? Show the calculation formula+  - Wie lang ist die längste Zeitspanne von Unterbrechungen in Millisekunden, die mit einem ATmega128 mit einer Taktfrequenz von 14,7456 MHz erreicht werden kannStellen Sie die Berechnung dar
-  - In case the processor is heavily loaded with an execution of a program (for exampleit controls several motors and the values of several sensors at once), does this have an effect on the accuracy of the timerExplain your answer+  - Hat es einen Effekt auf die Genauigkeit von Timernwenn der Prozessor mit der Ausführung eines Programms stark ausgelastet ist (z.B. mehrere Motoren und Werte verschiedener Sensoren gleichzeitig kontrollieren)? Erläutern Sie Ihre Antwort
-===== Indicators and displays =====+===== Anzeigen und Displays =====
  
 {{  :examples:display:displays.jpg?580  |Displays}} {{  :examples:display:displays.jpg?580  |Displays}}
  
-One of the easiest methods for being convinced that the microcontroller is functioning is adding a code to the program which blinks a LED or LEDs during certain activitiesQuite often it is not enoughbecause it is necessary to forward more information than it is possible by using LED and some applications require user interface where text or numbers are displayedHere become handy all sorts of indicators and displayswhich allow to display numberstexts or even picturesOne of the most known information displaying devices is computer monitor and typical programmer does not see anything special about using itbut it takes a great deal of effort using microcontrollers to bring every single pixel on the display+Einer der einfachsten Methoden um sicher zu gehen, dass ein Mikrocontroller funktioniert ist Code zu einem Programm hinzuzufügen, um eine oder mehrere LEDs bei einer bestimmten Aktivität blinken zu lassenSehr oft ist dies nicht genugweil mehr Informationen überprüft werden müssen, als mit einer LED möglich oder da einige Anwendungen brauchen eine Benutzerschnittstelle, welche Text oder Nummern anzeigt, benötigenHier finden alle Arten von Indikatoren und Displays Verwendungwelche das Anzeigen von NummernTexten oder sogar Bildern ermöglichen. Computerbildschirme zählen zu den bekanntesten AnzeigegerätenFür einen Programmierer ist die Arbeit mit ihnen alltäglichjedoch ist es sehr aufwändig Pixel mit Hilfe von Mikrocontrollern auf einem Bildschirm anzuzeigen
  
-The following chapters are introducing simpler types of displays and screens – indicator with LED segments and two types of monochromatic LCDIn addition to those also LED matrixes and (quite common today) organic color LED (OLED) screens are being used with microcontrollers quite activelyOnce filament numerical indicators were usedwhich had separate glowing filament for each numberThere are also electromechanical screenswhere different colored facet segments are turned physicallyLatelyelectronic paper has become popular,which can imitate printings alreadyFirst e-papers (electronic paperwere consisting of balls with different colored sides which were turned in electric fieldNewer e-papers contain small capsuleswhere two colors of charged particles are influenced by electric field whether to sing down or stay on the surfaceLast two examples are made to visualize different possibilitiesbut these are not viewed more closely in HomeLab concept.+Das folgende Kapitel befasst sich mit einfachen Displays und Bildschirmen. Anzeigen mit LED-Segmenten und zwei Typen von monochromen LCD´sZusätzlich zu diesen werden auch LED-Matrizen und organischen Farb-LED´s(OLED) mit Mikrocontrollern genutztFrüher wurden Nixie-Röhren verwendetwelche separate Glühdrähte für jede Zahl hattenDarüber hinaus gibt es elektromechanische Anzeigenderen verschiedenfarbige Segmente physisch gedreht werdenNeuerdings erfreuen sich E-Paper-Displaysmit denen gedruckte Texte nachgebildet werden könnengroßer BeliebtheitDie Ersten E-Paper (elektronisches Papierbestanden aus Kugeln mit verschieden farbigen Seiten, welche in einem elektrischen Feld gedreht wurdenNeuere E-Paper enthalten kleine Kapselnin denen geladene Partikel zweier Farben durch ein elektrisches Feld dahingehend beeinflusst werden, ob sie herabsinken oder an der Oberfläche bleiben sollenDie letzten beiden Beispiele wurden zur Erläuterung diverser Anzeigetechniken dargestelltsie werden im HomeLab jedoch nicht weiter verfolgt.
  
-==== 7-segment LED display ==== 
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:digi]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:module:segment_display]], [PRT] [[en:examples:digi:led]]//+==== 7-Segment-LED-Anzeige ====
  
-=== Theory ===+//Notwendiges Wissen: [HW] [[en:hardware:homelab:digi]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:module:segment_display]], [PRT] [[en:examples:digi:led]]//
  
-7-segmented LED number-indicator is a display which consists of 7 LEDs positioned in the shape of number 8. By lighting or switching off the corresponding LEDs (segments), it is possible to display numbers from 0 to nine as well as some letters.+=== Theorie ===
  
-[{{  :examples:display:segment_display:segment_display_leds.png?300|Positioning of the LED indicator's segments and electrical scheme}}]+Die 7-Segment-LED-Zifferanzeige ist ein Display, welches aus sieben, in Form einer Acht angeordneten, LEDs besteht. Durch Ein- oder Ausschalten der entsprechenden LED´s (Segmente) ist es möglich Zahlen von 0-9 sowie einige Buchstaben darzustellen. 
  
-Electrically all anodes of the LEDs are connected to one anode pin //ca//. LEDs are lit by switching their cathodes (//a, b, c...//). Exists also reversed connectionswhere the indicators have a common cathode //cc//Generally several number-indicators are used for displaying multi digit numbers for this purpose the indicators are equipped with coma (pointsegment //dp//All in all one indicator has segmentsbut they are still called 7-segmented according to the number of number-segments  +[{{  :examples:display:segment_display:segment_display_leds.png?300|Positionierung der Anzeigensegmente des LED sowie elektrisches Schema.}}] 
 + 
 +Elektrisch werden alle Anoden der LEDs an einer Anode am Pin //ca// angeschlossenDie LEDs leuchten durch Schalten ihrer Kathoden (//a, b, c ...//). Es gibt auch andere Verbindungenbei denen die Anzeigen eine gemeinsame Kathode //cc// haben Allgemein werden verschiedene Zifferanzeigen zur Darstellung mehrstelliger Ziffern genutzt. Hierzu verfügt das Display über ein Komma- (Punkt-Segment //dp//Insgesamt besitzt eine Anzeige dann Segmentewird jedoch aufgrund der Anzahl von Ziffer-Segmenten weiterhin 7-Segment-Display genannt
  
 LED number-indicators are easy to use, they can be controlled directly from the pins of the microcontroller, but there are also special drivers, which able to control number-indicators using fewer pins of the microcontroller. There are different colors of LED number indicators, which can be very bright and very large. For displaying the entire Latin alphabet exist indicators with extra segments.   LED number-indicators are easy to use, they can be controlled directly from the pins of the microcontroller, but there are also special drivers, which able to control number-indicators using fewer pins of the microcontroller. There are different colors of LED number indicators, which can be very bright and very large. For displaying the entire Latin alphabet exist indicators with extra segments.  
  
-=== Practice ===+Die Benutzung von LED Zifferanzeigen ist recht einfach. Sie können direkt über die Pins des Mikrocontrollers kontrolliert werden. Es gibt jedoch auch spezielle Treiber, die dafür sorgen, dass für die Nutzung der Anzeige weniger Pins des Mikrocontrollers benötigt werden. Es gibt zwei verschiedene Farben von LED-Zifferanzeigen, die sehr klar und groß sein können. Zur Anzeige des gesamten Alphabets gibt es Anzeigen mit zusätzlichen Segmenten. 
 +  
 +=== Übung ===
  
-There is one 7-segment LED number-indicator on the Digital i/o moduleIt is controlled through a driver with serial interface A6275. The serial interface of the driver is similar to SPI, where both clock signal and data signal are usedDifferent from SPI the //chip-select// is not used there, and is replaced with //latch// functionThe above mentioned three lines are connected to the ATmega128 as follows  +Am digitalen I/O Modul befindet sich eine 7-Segment-LED-ZifferanzeigeSie wird über einen Treiber mit der seriellen Schnittstelle A6275 kontrolliertDie serielle Schnittstelle des Treibers ist dem SPI ähnlichbei dem sowohl Taktsignal als auch Datensignale genutzt werdenAnders als beim SPI wird //chip-select// nicht genutzt und wird durch die //latch// Funktion ersetztEs ist mit dem ATmega128 wie folgt verbunden 
  
-[{{  :examples:display:segment_display:segment_display_driver_logic.png?300|The build-up of the LED driver's shift-index with corresponding segments of the indicator.}}]+[{{  :examples:display:segment_display:segment_display_driver_logic.png?300|Aufbau des Verschiebungsindexes des LED Treibers mit den zugehörigen Segmenten der Anzeige.}}]
  
-  * Latch-signal (//latch//) - PG2 +  * Latch-Signal (//latch//) - PG2 
-  * Clock-signal (//clock//) - PC7 +  * Taktsignal (//clock//) - PC7 
-  * Data-signal (//data//) - PC6+  * Datensignal (//data//) - PC6
  
 ~~CL~~ ~~CL~~
  
-The data is delivered by bits through the data pinEvery time the clock signal goes high, the contents of the shift-index is shifted to the right and the bit from the data-pin is read to the left most cellBy this 8-bits are loaded to the shift-index. If the latch signal is set high, the value of the shift-index is loaded to the latch-indexwhere it remains until new loadingEach bit of the latch-index is connected through the current switching to one number-indicator’s segmentThe segment is lit during the high bit-rate.+Die Daten werden in Form von Bits über den Datenpin gesendetImmer, wenn das Taktsignal high wirdwird der Inhalt des Verschiebungsindexes nach rechts geschoben und das Bit vom Datenpin wird in die Zelle ganz links gelesenSo werden Bits in den Verschiebungsindex geladen. Wenn das Latch-Signal high gesetzt wirdwird der Wert des Verschiebungsindexes in den Latch-Index geladenund verbleibt dort bis zu einem erneuten LadenJedes Bit des Latch-Indexes ist durch eine Spannungsschaltung mit einem Segment der Zifferanzeige verbundenDas Segment leuchtet während die Bitrate high ist
  
-For displaying the numbers on the HomeLabs Digital i/o module indicator, the following functionality is written to the library of the HomeLab  +Zur Darstellung von Ziffern auf der digitalen I/O Modulanzeige des HomeLab sind die folgenden Funktionen in der Bibliothek von HomeLab enthalten:   
  
  
 <code c> <code c>
 // //
-// Set-up of the pins+// Einrichtung der Pins
 // //
 static pin segment_display_latch =    PIN(G, 2); static pin segment_display_latch =    PIN(G, 2);
Line 3455: Line 2937:
  
 // //
-// Marking card+// Markierung der Karte
-// The bits are marking the segmentsLower ranking is A, higher ranking is DP.+// Die Bits markieren SegmenteEin niedriger Rang wird mit A, ein hoher mit DP gekennzeichnet.
 // //
 static const unsigned char segment_char_map[11] =  static const unsigned char segment_char_map[11] = 
Line 3470: Line 2952:
  0b01111111,  0b01111111,
  0b01100111,  0b01100111,
- 0b01111001   // E like Error+ 0b01111001   // E wie "Error"
 }; };
    
 // //
-// Start-up of the 7-segment indicator.+// Start der 7-Segment-Anzeige.
 // //
 void segment_display_init(void) void segment_display_init(void)
Line 3485: Line 2967:
    
 // //
-// Displaying number on the 7-segment indicator.+// Darstellung einer Ziffer auf der 7-Segment-Anzeige.
 // //
 void segment_display_write(unsigned char digit) void segment_display_write(unsigned char digit)
Line 3492: Line 2974:
  signed char i;  signed char i;
      
- // Check-up of the number+ // Überprüfung der Ziffer
  if (digit > 9)  if (digit > 9)
  {  {
Line 3498: Line 2980:
  }  }
   
- // Number as the card of the segments.+ // Ziffer wie Segmentkarte.
  map = segment_char_map[digit];  map = segment_char_map[digit];
    
- // Latch-signal off+ // Latch-Signal aus
  pin_clear(segment_display_latch);  pin_clear(segment_display_latch);
    
- // Sending he bitsHigher ranking goes first.+ // Senden von he BitsHöherrangige zuerst.
  for (i = 7; i >= 0; i--)  for (i = 7; i >= 0; i--)
  {  {
- // Setting the pin according to the value of the bit of the card.+ // Pin entsprechend Bitwert der Karte setzen.
  pin_set_to(segment_display_data_out, bit_is_set(map, i));  pin_set_to(segment_display_data_out, bit_is_set(map, i));
    
- // The clock-signal as high for a moment.+ // Taktsignal high setzen.
  pin_set(segment_display_clock);  pin_set(segment_display_clock);
  _delay_us(1);  _delay_us(1);
    
- // The clock-signal as low.+ // Taktsignal low setzen.
  pin_clear(segment_display_clock);  pin_clear(segment_display_clock);
  _delay_us(1);  _delay_us(1);
  }  }
    
- // Latch-signal on.+ // Latch-Signal ein.
  pin_set(segment_display_latch);  pin_set(segment_display_latch);
 } }
 </code> </code>
  
-For displaying numbers and the letter “Eis created a constant array //segment_char_map//, where lighting of all 8 segments is marked with bit and switch off is market with bit 0. The bits form higher to lower (from left to right in binary formare marking segments DP, G, F, E, D, C, B, A. The control interface of the driver is realized through software SPI, i.e. by using a software for controlling the data communication pins in the program All three pins are set as output with // segment_display_init// function. // segment_display_write// is for displaying the functionwhich finds the segment-card of the mark from the array and transmits bit by bit  all values of the segments to the driverThe frequency of the clock signal with the software delays is now approximately 500 kHz. +Um Ziffern und den Buchstaben "E" darzustellenwird ein konstantes Array //segment_char_map// erstelltbei dem das Leuchten von allen acht Segmenten mit Bit und das Ausschalten mit Bit markiert wirdDie Bits markieren von hoch zu niedrig (von links nach rechts in BinärformSegmente DP, G, F, E, D, C, B, A. Die Kontrollschnittstelle des Treibers wird durch SPI Software realisiertzum Beispiel durch Nutzung einer Software, die die Datenkommunikationspins des Programms kontrolliertAlle drei Pins werden durch // segment_display_init// als Outputs gesetzt. // segment_display_write// dient der Darstellung der Funktionwelche die Segmentkarte der Markierung vom Array erkennt und diese bitweise zum Treiber überträgtDie Taktfrequenz mit Softwareverzögerung liegt bei ungefähr 500 kHz.
- +
-The following is a more concrete example of a program for using the number-indicator.  Previously described function of the library is described in the program. The program counts numbers from 0 to 9 with approximate interval of 1 second. Such counting is achieved by taking a module from a much larger number.  +
  
 +Das nachfolgende Beispielprogramm beschreibt die Nutzung der Zifferanzeige. Die zuvor beschriebene Funktion der Bibliothek wird in dem Programm erläutert. Das Programm Zählt Ziffern von 0 bis 9 mit einem Intervall von etwa einer Sekunde. Dieses wird dadurch erreicht, dass ein Modul mit einer weitaus größeren Ziffer verwendet wird.
  
 <code c> <code c>
 // //
-// The example program of the 7-segment LED indicator of the HomeLab'+// Das Beispielprogramm der 7-Segment-LED-Anzeige des I/O-Moduls des HomeLab
-// input-output module.+
 // //
 #include <homelab/module/segment_display.h> #include <homelab/module/segment_display.h>
Line 3538: Line 3018:
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
Line 3544: Line 3024:
  int counter = 0;  int counter = 0;
  
- // Set-up of the 7-segment indicator.+ // Einrichtung der 7-Segment-Anzeige.
  segment_display_init();  segment_display_init();
  
- // Endless loop.+ // Endlosschleife.
  while (true)  while (true)
  {  {
- // Displaying the ones values of the counter.+ // Anzeige der Werte des Timers.
  segment_display_write(counter % 10);  segment_display_write(counter % 10);
  
- // Counting very long.+ // Lange zählen.
  counter++;  counter++;
  
- // Delay for second.+ // Verzögerung von Sekunde.
  sw_delay_ms(1000);  sw_delay_ms(1000);
  }  }
 } }
 </code> </code>
-==== Alphanumeric LCD ==== +==== Alphanumerisches LCD ====
- +
-//Necessary knowledge: [HW] [[en:hardware:homelab:lcd]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:timer:periodic_interrupt]]//+
  
-=== Theory ===+//Notwendiges Wissen: [HW] [[en:hardware:homelab:lcd]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:timer:periodic_interrupt]]//
  
-Alphanumeric LCD is liquid crystal display, with the purpose of displaying letters and numbers.  In basic LCD is used liquid crystal which is placed between transparent electrodes, and which changes the polarization of the passing light in electrical field. The electrodes are covered by polarization filters, which assure that only one way polarized light can pass the screen. If the liquid crystal changes its polarity due to an electrical field, the light can not pass the screen or part (segment) of it and it looks dark. +=== Theorie ===
  
-Main characteristic of alphanumerical LCD is the placing of its segmentsThe screen is divided into many indicatorsEach indicator has either enough segments for displaying letters and numbers or it is formed from matrix of little square segments (pixels). For examplea matrix of 5x7 pixels is enough to display all numbersand letters of Latin alphabet. There are usually 1 – 4 rows of indicators and 8 – 32 columns. Each indicator has a small difference similar to the differences of the letters in text.+Das alphanumerische LCD ist ein Flüssigkristall-Display, welches zur Darstellung von Buchstaben und Ziffern dientIn einfachen LCD's werden flüssige Kristalle verwendet, welche zwischen transparenten Elektroden angeordnet sind und die Polarisation des durchstrahlenden Lichts im elektrischen Feld verändernAuf den Elektroden befinden sich Polarisationsfilterwelche sicher stellendas nur in eine Richtung polarisiertes Licht auf den Bildschirm trifft. 
 +Wenn der Flüssigkristall seine Polarisation durch das elektrische Feld ändert, erreicht das Licht den Bildschirm oder ein Segment des Bildschirms nicht und er bleibt schwarz.
  
 +Hauptmerkmal eines alphanumerischen LCD ist die Anordnung der Segmente. Der Bildschirm ist in verschiedene Anzeigen unterteilt. Jede Anzeige hat entweder genügend Segmente um Buchstaben oder Nummern anzuzeigen oder es wird eine Matrix aus Pixeln gebildet. Eine Matrix aus 5x7 Pixeln ist beispielsweise ausreichend, um alle Nummern und Buchstaben des lateinischen Alphabets darzustellen. Die Anzeigeelemente bestehen gewöhnlich aus 1 bis 4 Zeilen sowie 8 bis 32 Spalten. Zwischen den Elementen befinden sich kleine Abstände ähnlich wie bei Buchstaben im Text.
  
-[{{  :examples:display:lcd_alphanumeric:lcd_alphanumeric_abc.png?200|The text formed of alphanumerical LCD pixels' matrixes.}}]+[{{  :examples:display:lcd_alphanumeric:lcd_alphanumeric_abc.png?200|Darstellung eines Textes durch eine Pixelmatrix eines alphanumerischen LCD.}}]
  
-Besides the screen Alphanumerical LCD has also controller which controls the segments of the screen according to the commands from the communication interface.  A controller has a preprogrammed card of letterswhere each letternumber or symbol has its own indexDisplaying the text on the screen is basically done by sending the indexes to the controllerIn reality there must be more control orders sent to the controller before anything can be displayed. It is important to get familiarize with each LCD data-sheetbecause there are many different types of LCDs and they all are controlled differently.+Neben dem Bildschirm hat das alphanumerische LCD auch einen Controller, welcher die Segmente des Bildschirms gemäß den Befehlen der Kommunikationsschnittstelle steuertEin Controller verfügt über eine vorprogrammiertes Set von Buchstaben mit einem eigenen Index für jeden Buchstaben, jede Nummer sowie jedes Symbol. Die Darstellung des Textes auf dem Bildschirm  erfolgteinfach gesagtindem die Indizes zum Controller gesendet werdenTatsächlich müssen jedoch weitere Kontrollbefehle übermittelt werden, bevor irgendetwas dargestellt werden kannDa es viele verschiedene Ausführungen von LCDs gibt, die jeweils unterschiedlich gesteuert werden, ist es wichtigsich mit dem Datenblatt jedes LCDs vertraut zu machen.
  
-Alphanumerical LCDs are usually with passive matrixwhere renewal of the electrical field of the segments is tone in turnsThat is why the screens with passive matrix are slower and have less contrast compared with the active matrix screens where the charge of each segment is controlled by separate transistorSome LCDs are with reflective back and others with backlight sometimes even with several different backlightsBut segment colour for alphanumerical LCDs is usually still one – which is blackhowever there are also screens with white and colorful writings     +Alphanumerische LCDs besitzen normalerweise eine passive Matrix. Hier erfolgt die Erneuerung des elektrischen Feldes der Segmente turnusmäßig. Aus diesem Grund sind Bildschirme mit einer passiven Matrix langsamer und Darum sind die Bildschirme mit passiver Matrix langsamer und bieten weniger Kontrastals Bildschrime mit aktiver MatrixBei Aktivmatrix-Bildschrimen wird die Ladung jedes einzelnen Segments durch einen eigenen Transistor gesteuertEinige LCDs haben einen reflektierenden Hintergrund, andere haben Hintergrundbeleuchtungen und wieder andere sogar verschiedene HintergrundbeleuchtungenDie Segmente eines alphanumerischen LCDs haben jedoch immer nur eine Farbe. In der Regel sind sie schwarzes gibt jedoch auch Bildschrime mit weißer oder farbiger Schrift.
  
  
-=== Practice ===+=== Übung ===
  
-HomeLabs Digital i/o module connects a 2x16 symbol alphanumerical LCD WC 1602A. For controlling the screen, there is a 4-bit data-bus and control pins, but its communication protocol is too capacious, to be explained hereFor simplicitythe library of the HomeLab has corresponding functions for using the display+Am digitalen I/O Modul des HomeLab ist ein alphanumerisches, 2x16 Zeichen großes, LCD WC 1602A angeschlossenZur Steuerung des Bildschirms gibt es einen 4-Bit Datenbus sowie Kontroll-PinsDa das Kommunikationsprotokoll des Bildschirms zu umfangreich ist, um es hier zu erläuternenthält die HomeLab Library die entsprechenden Funktionen zur Nutzung des Displays
  
-Before using the display it is vital to adjust its settingsFor this purpose is the // lcd_alpha_init// functionwhich sets a blinking cursor on the screenOn screen is always only one active position for the cursor where next letter is enteredregardless whether it can be seen or notSo before entering the textthe cursor must be taken to the desired placeFor changing the position of the cursor is a function lcd_alpha_goto_xy and for displaying it lcd_alpha_write_string. All the functions of the alphanumerical LCD are explained in its library.+Vor der Nutzung des Displays ist es notwendig, seine Einstellungen anzupassenHierzu dient die //lcd_alpha_init// Funktionwelche einen blinkenden Cursor auf dem Bildschirm erscheinen lässtHier gibt es nur eine aktive Position für den Cursoran welcher der nächste Buchstabe eingegeben werden kannBevor also Text eingegeben wirdmuss der Cursor an die gewünschte Position bewegt werdenUm die Position des Cursors zu verändern gibt es die Funktion //lcd_alpha_goto_xy// und für die Darstellung die Funktion //lcd_alpha_write_string//Sämtliche Funktionen des alphanumerischen LCDs sind in der Library erklärt.
  
-The following program code demonstrates the usage of alphanumerical LCD as a clockThe Time begins at 00:00:00 and grows approximately in every secondSince the counting of the time is done with the delay functionit is not very preciseThe inaccuracy is explained in the exercise of the periodic interruptionThe program counts the seconds and converts them into minutes and seconds. For using clock time is a standard function in the C-language: //sprintf//    +Der folgende Programm-Code zeigt wie das alphanumerische LCD als Uhr genutzt werden kannDie Zeit beginnt bei 00:00:00 und nimmt etwa jede Sekunde zuDa das Zählen der Zeit mit Hilfe einer Verzögerungsfunktion geschiehtist das Ergebnis nicht sehr genauDiese Ungenauigkeit wird im Rahmen der Aufgabe zu periodischen Unterbrechungen erklärt. Das Programm zählt die Sekunden und konvertiert diese in Minuten und SekundenUm Uhrzeit darzustellen wird die Standard-Funktion in C genutzt: //sprintf//    
  
  
 <code c> <code c>
 // //
-// The example of using the alphanumerical LCD of the HomeLab. +// Beispiel zur Nutzung des alphanumerischen LCD des HomeLab. 
-// The clock time starting at the beginning of the program is displayed on the LCD.+// Die Startzeit zu Beginn des Programms wird auf dem LCD angezeigt.
 // //
 #include <stdio.h> #include <stdio.h>
Line 3598: Line 3078:
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
 { {
- int seconds = 0; +    int seconds = 0; 
- char text[16];+    char text[16];
  
- // Set-up of the LCD. +    // Einrichtung des LCD. 
- lcd_alpha_init(LCD_ALPHA_DISP_ON);+    lcd_alpha_init(LCD_ALPHA_DISP_ON);
  
- // Cleaning of the LCD. +    // Löschen des LCD. 
- lcd_alpha_clear();+    lcd_alpha_clear();
  
- // Name of the program+    // Name des Programms
- lcd_alpha_write_string("The Time Counter");+    lcd_alpha_write_string("The Time Counter");
  
- // Endless loop  +    // Endlosschleife     
- while (true) +    while (true) 
-+    
- // Converting the seconds to the clock form+        // Konvertieren der Sekunden in die Zeitanzeige
- // hh:mm:ss +        // hh:mm:ss 
- sprintf(text, "%02d:%02d:%02d", +        sprintf(text, "%02d:%02d:%02d", 
- (seconds / 3600) % 24, +            (seconds / 3600) % 24, 
- (seconds / 60) % 60, +            (seconds / 60) % 60, 
-  seconds % 60);+             seconds % 60);
  
- // Displaying the clock text in the beginning of the second row of the LCD. +        // Anzeige der Zeit am Anfang der zweiten Reihe des LCD. 
- lcd_alpha_goto_xy(0, 1); +        lcd_alpha_goto_xy(0, 1); 
- lcd_alpha_write_string(text); +        lcd_alpha_write_string(text); 
-  +         
- // Growing seconds by 1. +        // Anstieg der Sekunden um 1. 
- seconds++; +        seconds++; 
-  +         
- // Hardware delay 1000 ms. +        // Hardwareverzögerung 1000 ms. 
- hw_delay_ms(1000); +        hw_delay_ms(1000); 
- }+    }
 } }
 </code> </code>
-==== Graphic LCD ====+==== Graphisches LCD ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:lcd]], [LIB] [[en:software:homelab:library:module:lcd_graphic]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:display:lcd_alphanumeric]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:lcd]], [LIB] [[en:software:homelab:library:module:lcd_graphic]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:display:lcd_alphanumeric]]//
  
-=== Theory ===+=== Theorie ===
  
-Graphical LCD //liquid crystal display// is a display which allows displaying pictures and textIts construction is similar to the alphanumerical LCD, with a difference that on the graphic display all pixels are divided as one large matrixIf we are dealing with a monochrome LCDthen a pixel is one square segment. Color displays’ one pixel is formed of three subpixelsEach of the three subpixels lets only one colored light pass (redgreen or blue). Since the subpixels are positioned very close to each otherthey seem like one pixel.+Das graphische LCD //liquid crystal display// ist ein Display zur Darstellung von Bildern und TextEs ist ähnlich aufgebaut wie das alphanumerische LCD, mit dem Unterschied, dass sich auf dem graphischen LCD alle Pixel in einer großen Matrix befindenBei monochromen LCDs entspricht ein Pixel einem quadratischen Segmentbei Farbdisplays besteht ein Pixel aus drei UnterpixelnJedes der Unterpixel lässt nur eine Lichtfarbe durch (rotgrün oder blau). Da die Unterpixel sehr nah beieinander liegenwerden sie als ein Pixel wahrgenommen.
  
-[{{  :examples:display:lcd_graphic:lcd_graphic_abc.png?200|The text formed of pixels of a graphic LCD.}}]+[{{  :examples:display:lcd_graphic:lcd_graphic_abc.png?200|Der durch Pixel eines graphischen LCDs dargestellte Text.}}]
  
-Monochrome graphic displays have usually passive matrixlarge color displays including computer screens have active matrix All information concerning the color of the background and the pixels of the graphic LCDs are similar to alphanumerical LCDsSimilar to the alphanumerical displaysgraphic displays are also equipped with separate controller, which takes care of receiving information through the communication interface and generates the electrical field for the segmentsIf for alphanumerical LCD is enough to send indexes of the signs in order to display textthen  graphic displays are not capable of generating letters by themselves – all the pictures and text needs to be generated pixel by pixel by the user    +Monochrome graphische Displays haben normalerweise eine passive Matrixgroße Farbdisplays (auch Computer-Bildschirme) eine aktiveIm Hinblick auf die Farbe des Hintergrunds und der Pixel entspricht das graphische LCD dem alphanumerischenAuch das graphische Display verfügt über einen separaten Controllerwelcher die Information über die Kommunikationsschnittstelle empfängt und das elektrische Feld für die Segmente generiertIm Gegensatz zum alphanumerischen LCD, welches Text anzeigt, indem die Indizes der darzustellenden Zeichen gesendet werden, kann das graphische LCD keine Buchstaben eigenständig generieren - sämtliche Bilder und Texte müssen Pixel für Pixel vom Nutzer generiert werden. 
 +   
  
-=== Practice ===+=== Übung ===
  
-In the Home-Lab set is a 84x48 pixels monochrome graphic LCD. It is the same display as used in Nokia 3310 mobile phones. Philips PCD8544 controller is attached to the display which can be communicated through SPI-like serial interfaceThe background lighting of the display module is separately controlledCommunicating with the display is not very difficultbut due to the large amount of the functions it is not explained hereHome-Labs library has functions for using it.+Das HomeLab Kit enthält ein 84x48 Pixel großes, monochromes, graphisches LCD. Es ist das gleiche, welches auch im Mobiltelefon Nokia 3310 verwendet wirdEin Philips PCD8544 Controller ist am Display angebracht, mit welchem über eine SPI-ähnliche serielle Schnittstelle kommuniziert werden kannDie Hintergrundbeleuchtung des Displays wird separat gesteuert.Die Kommunikation mit dem Display ist nicht sehr schweraufgrund der vielen Funktionen wird sie hier jedoch nicht erläutertDie HomeLab Library enthält die dafür notwendigen Funktionen.
  
-The functions of the graphic LCD are similar to the alphanumeric LCD functionsFirst, the screen must be started with // lcd_gfx_init// functionAfter start-up it is advised to clean the screenmore precisely controllers memory with the //lcd_gfx_clear// functionThere is a letter map in side of the library with full Latin alphabetnumbers and with most common signs writtenThe height of the letter is and the width of the letter is pixelsThe gap between each letter is horizontally and vertically pixels, i.e. in total it fits rows and 14 columns of lettersTo display a letter or textfirst its position must be determined by using function // lcd_gfx_goto_char_xy//For displaying s letter is // lcd_gfx_write_char// function and for displaying text // lcd_gfx_write_string// function.+Die Funktionen für das graphische LCD sind ähnlich zu denen des alphanumerischen LCD. Zuerst muss der Bildschirm mit der Funktion //lcd_gfx_init//gestartet werdenNach dem Start sollte man den Bildschrimbzw. den Speicher des Controllers mit der //lcd_gfx_clear// Funktion leerenDie Library enthält eine Abbildung des vollständigen lateinischen Alphabetsder Zahlen sowie der am häufigsten verwendeten ZeichenDie Buchstaben ist Pixel hoch und Pixel breitDer Abstand zwischen den Buchstaben beträgt horizontal und vertikal PixelEs können also Buchstaben in 6 Reihen mit 14 Spalten auf dem Display dargestellt werdenZur Darstellung von Buchstaben oder Textmuss zunächst mit der Funktion //lcd_gfx_goto_char_xy// die Position festgelegt werdenMit der Funktion //cd_gfx_write_char// wird ein Buchstabe angezeigt, die Funktion //lcd_gfx_write_string// ermöglicht die Darstellung eines Textes.
  
-The following is an example of time counterThe program counts seconds (approximately), minutes and hoursFor converting time to text //sprintf// function is used +Nachfolgend ist ein Beispiel des Zeitzählers dargestelltDas Programm zählt Sekunden (annähernd), Minuten und StundenZum Konvertieren von Zeit in Text wird die Funktion //sprintf// genutzt.
  
 <code c> <code c>
 // //
-// Example of using the graphic LCD of the HomeLab. +// Beispiel für die Nutzung des graphischen LCD des HomeLab. 
-// Time of day is displayed on LCD since the beginning of the program.+// Die Tageszeit wird ab Beginn des Programms auf dem LCD angezeigt.
 // //
 #include <stdio.h> #include <stdio.h>
Line 3666: Line 3147:
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
 { {
- int seconds = 0; +    int seconds = 0; 
- char text[16];+    char text[16];
  
- // Set-up of the LCD. +    // Einrichten des LCD. 
- lcd_gfx_init();+    lcd_gfx_init();
  
- // Cleaning the screen+    // Löschen des Displays
- lcd_gfx_clear();+    lcd_gfx_clear();
  
- // Switching on the background light+    // Einschalten der Hintergrundbeleuchtung
- lcd_gfx_backlight(true); +    lcd_gfx_backlight(true);   
  
- // Displaying the name of the program+    // Anzeige des Programmnamens
- lcd_gfx_goto_char_xy(1, 1); +    lcd_gfx_goto_char_xy(1, 1); 
- lcd_gfx_write_string("Aja loendur");+    lcd_gfx_write_string("Aja loendur");
  
- // Endless loop.  +    // Endlosschleife   
- while (true) +    while (true) 
-+    
- // Converting the seconds to the form of clock+        // Sekunden in die Form der Uhrzeit konvertieren
- // hh:mm:ss +        // hh:mm:ss 
- sprintf(text, "%02d:%02d:%02d", +        sprintf(text, "%02d:%02d:%02d", 
- (seconds / 3600) % 24, +            (seconds / 3600) % 24, 
- (seconds / 60) % 60, +            (seconds / 60) % 60, 
-  seconds % 60);+             seconds % 60);
  
- // Displaying the clock text+        // Anzeige des Zeittextes
- lcd_gfx_goto_char_xy(3, 3); +        lcd_gfx_goto_char_xy(3, 3); 
- lcd_gfx_write_string(text); +        lcd_gfx_write_string(text); 
-  +        
- // Adding one second+        // Eine Sekunde hinzufügen
- seconds++; +        seconds++; 
-  +        
- // Hardware delay for 1000 ms. +        // Hardwareverzögerung von 1000 ms. 
- hw_delay_ms(1000); +        hw_delay_ms(1000); 
- }+    }
 } }
 </code> </code>
-==== Exercises ==== 
  
-The goal is to write a program which is able to perform tasks described below. +==== Aufgaben ====
  
-=== Warm up exercise ===+Ziel ist es, ein Programm zu schreiben, welches die unten beschriebenen Aufgaben erüllt.
  
-  * It counts numbers 1...9 and then back 9...1 on the 7-segment indicator. The period of the counting is 1 second.+=== Aufwärmübung ===
  
-=== For beginner ===+  * Das Programm soll von 1 bis 9 und dann zurück von 9 bis 1 auf der 7-Segment-Anzeige zählen. Die Zählperiode beträgt 1 Sekunde.
  
-  - Present numbers in hexadecimal system randomly on the 7-segment display. The frequency is 1 Hz.   +=== Für Anfänger ===
-  - Light in circular sequence 6 outside segments on the 7-segment indicator with the period of 500 ms. +
-  - Write the following text on the alphanumerical LCD: “õun öö äpu ülo” +
-  - Show special symbols on the alphanumerical LCD. Display the following text in two rows: “My program ©”, “HomeLab™”    +
-  - Display 10 rows of text on the graphic display which can be scrolled up and down using the buttons S1 and S2. +
-  - Make user interface using three buttons for inserting text. For example, one button chooses the sign, second verifies the sign and finally the third verifies the text. The maximum length of the text is 10 signs and the text must be turned backwards and displayed on the second row. You may use just Latin alphabet. LCD by own choice.+
  
-=== For advanced ===+  - Stellen Sie die Zahlen im Hexadezimalsystem zufällig auf der 7-Segment-Anzeige dar. Die Frequenz beträgt 1 Hz. 
 +  - Lassen Sie die äußeren 6 Segmente der 7-Segment-Anzeige periodisch im Abstand von 500 ms aufleuchten. 
 +  - Schreiben Sie ein Programm für das LCD, welches den Code und das zugehörige Symbol anzeigt. Verwenden Sie Codes von 0 bis 255. Jedes Code-Symbol-Paar wird 1 Sekunde lang auf dem Display angezeigt. 
 +  - Schreiben Sie ein Programm, mit welchem das Symbol "X" über den Bildschrim bewegt werden kann. Mit dem Schalter S1 kann es nach links bewegt werden, mit Schalter S3 nach rechts und mit Schalter S2 wird die Reihe gewechselt.  
 +  - Stellen Sie auf dem graphischen Display 10 Zeilen Text dar. Mit den Schaltern S1 und S2 kann innerhalb des Textes hoch- und runtergescrollt werden. 
 +  - Erstellen Sie eine Benutzerschnittstelle über welche mit den drei Schaltern Text eingegeben werden kann. Ein Schalter wählt beispielsweise das Zeichen aus, der zweite überprüft das Zeichen und der dritte überprüft schließlich den Text. Die maximale Länge des Textes beträgt 10 Zeichen und der Text soll in umgekehrter Reihenfolge in der zweiten Reihe dargestellt werden. Sie können das lateinische Alphabet nutzen und das Display selbst auswählen.
  
-  - Display Greek letters on the graphic LCD. Display the following rows:  “Resistance Ω”, “∑R=∑πR²”, “π=3.141592”. Use source code of the HomeLab's library (from the website). +=== Für Fortgeschrittene ===
-  - Write a converter for converting decimal numbers to binary code. Use buttons S3-S1 for inserting decimal numbers (S3- hundredths, S2 – tenths, S1 – ones) in 10 seconds. For example, pressing button S3 4 times signifies number 400. Present the sign for starting the insertion and the result in binary code on a random LCD. +
-  - Write a function which displays a rectangle on the graphic LCD when the width, length and the coordinates of the top left corner are given. The width of the line is 1 pixel. Check if the rectangle fits inside the screen. It is advised to study the library of the HomeLab. +
-  - Write a simple worm game on the graphic LCD. The width of the worm is 1 pixel and the length is 5 pixels. The worm can be made to turn either left or right using buttons. The worm must be able to avoid collision with the border of the screen (turning before). Bonus points are for ability of picking up the eggs and making the worm to grow. The simplest solution is to make the worm out of the letter “O”. +
-  - 5. Write a program for displaying different weather conditions on the graphic LCD. Sunny weather  - icon of the sun, rainy weather – a cloud with rain, cloudy weather – just a cloud, snow – snowflake. The size of the icons may vary, main point is that the icons are clearly distinguishable. A possibility to change the icons by pressing a button must be present. +
  
-=== Questions ===+  - Stellen Sie griechische Buchstaben auf dem graphischen LCD dar. Dabei sollen folgende Zeilen angezeigt werden: “Widerstand Ω”, “∑R=∑πR²”, “π=3.141592”. Nutzen Sie den Quellcode aus der HomeLab Library (von der Webseite). 
 +  - Schreiben Sie ein Programm, um Dezimalzahlen in Binärzahlen zu konvertieren. Verwenden Sie die Schalter S3 bis S1 zum Einfügen von Dezimalzahlen in zehn Sekunden ( S3 - Hunderter S2 - Zehner S1 - Einer). Durch vierfaches Betätigen von Schalter S3 wird so beispielsweise die Zahl 400 angezeigt. Das Zeichen für den Beginn der Eingabe und für das Ergebnis sollen in Binärzahlen ausgegeben werden. Verwenden Sie hierzu ein beliebiges LCD. 
 +  - Schreiben Sie eine Funktion zur Darstellung eines Rechtecks auf dem LCD. Breite, Länge sowie die Koordinaten der oberen linken Ecke sind dabe vorgegeben. Die Linienstärke beträgt 1 Pixel. Überprüfen Sie, ob das Rechteck ins Display passt. Hierzu ist es ratsam, sich mit der HomeLab Library zu befassen. 
 +  - Programmieren Sie ein einfaches Wurm-Spiel für das graphische LCD. Der Wurm ist 1 Pixel breit und 5 Pixel lang. Durch Betätigung der Schalter kann der Wurm sich nach rechts oder links bewegen. Er muss auf diese Weise Kollisionen mit dem Displayrand vermeiden können. Es gibt Bonuspunkte für das Einsammeln von Eiern, wodurch der Wurm wächst. Die einfachste Lösung ist, den Wurm aus dem Buchstaben "O" zu entwickeln. 
 +  - Schreiben Sie ein Programm zur Darstellung verschiedener Wetterbedingungen auf dem graphischen LCD. Nutzen Sie für sonniges Wetter ein Bild der Sonne, für Regen eine Regenwolke, für bewölkt eine Wolke und für Schnee eine Schneeflocke. Die Größe der Bilder kann variieren, wichtig ist nur, dass die Bilder sich deutlich voneinander unterscheiden. Die Bilder sollen mittels eines Schalters gewechselt werden können.
  
-  How many pins uses the 7-segment number-indicator (with point segment), if it is connected directly to the controllerHow many pins would be needed if if were controlled through the driver (//driver// - A6275)? +=== Fragen === 
-  - What determines the brightness of the 7-segment number-indicatorHow can it be adjusted if the number-indicator is controlled a)directly b)through the driver (//driver// - A6275)? + 
-  - If the 7-segment number indicator is connected directly to the port of the controller, so that the segment is PA0, B is PA1 ... and DP is PA7, then which are the values of the PORTA register with numbers  0...9? +  Wie viele Pins nutzt die 7-Segment Zifferanzeige (mit Punktsegment), wenn sie direkt mit dem Controller verbunden ist? Wie viele Pins werden benötigt, wenn sie über einen Treiber gesteuert wird? (//Treiber// - A6275) 
-  - What is the difference between 4-bit and 8-bit alphabetic LCD controllers?  +  - Was bestimmt die Helligkeit der 7-Segment ZifferanzeigeWie kann sie angepasst werden wenn die Anzeige a) direkt oder b) über einen Treiber (//Treiber// - A6275) gesteuert wird
-  - Through which pins and how is the background light of the alphanumerical LCD regulated+  - Wenn die 7-Segment Zifferanzeige direkt an Port des Controllers angeschlossen ist sodass das Segment A PA0, B PA1 ... und DP PA7 istwie lauten dann die Werte des PORTA Registers mit den Ziffern bis 9? 
-  - Which I/O protocol uses graphic LCD? Explain the meaning of the I/O pins? +  - Was ist der Unterschied zwischen alphabetischen 4-Bit und 8-Bit LCD Controllern
-  - How can the numbers in decimal system be converted to binary system (to textand vice versa+  - Über welche Pins und wie wird die Hintergrundbeleuchtung der alphanumerischen LCDs reguliert
-  - Draw the consisting layers of LCD using //twisted nematic// technology+  - Welches I/O Protokoll nutzt das graphische LCD? Erläutern Sie die Bedeutung der I/O Pins. 
-  - How are the letters formed on a graphical LCD? +  - Wie können Dezimalzahlen in binäre (in Textkonvertiert werden und umgekehrt
-  - How is monochrome (black and white)LCD different from color LCD+  - Zeichnen Sie die Schichten aus denen ein LCD besteht mittels der //twisted nematic// Technologie
-===== Sensors =====+  - Wie werden Buchstaben auf dem graphischen LCD angezeigt
 +  - Wie unterscheidet sich ein monochromes (schwarz/weiß) LCD von einem Farbdisplay?  
 +===== Sensoren =====
  
 {{  :examples:sensor:sensors.jpg?580  |Sensors}} {{  :examples:sensor:sensors.jpg?580  |Sensors}}
  
-Sensors are devices converting any kind of physical attributes (temperatureluminanceforceacceleration etc.) to a understandable form for humans or machinesWith the help from sensors the microcontroller receives information from the surrounding environment and makes decisions based on itThere are many types of sensorsapproximately 195 different types are listed in Wikipedia. Only sensors with electrical output signal can be connected to microcontrollersBased on electrical output signalis possible to segment sensors as digital and analogue sensors.+Sensoren sind Geräte welche jede Form von physikalischen Attributen (TemperaturBeleuchtungKraftBeschleunigung usw. ) in eine verständliche Form für Menschen oder Maschinen bringenMit der Hilfe von Sensoren erhält der Mikrocontroller Informationen über seine Umgebung und trifft Entscheidungen basierend auf diesen InformationenEs gibt viele Arten von Sensorenca. 195 verschiedene Typen werden in Wikipedia aufgelistetNur Sensoren mit einem elektrischen Outputsignal können an einem Mikrocontroller angeschlossen werden. Basierend auf dem elektrischen Outputsignal ist es möglich, Sensoren in digitale oder analoge Sensoren zu unterteilen. 
 + 
 +Bei analogen Sensoren bewirkt jede physikalische Änderung eine Änderung des elektrischen Wertes, i. d. R. Spannung, Stromstärke oder Widerstand. Da Mikrocontroller digitale Geräte sind, muss das analoge Signal in ein digitales umgewandelt werden, bevor es zum Controller gesendet wirdDafür werden Analog-zu-Digital Konverter benutztwelche normalerweise im Mikrocontroller verbaut sind.
  
-In analogue sensor any change in physical attributes changes one of its electrical valuesusually voltage, current or resistanceSince microcontrollers are digital devicesthe signal have to be converted from analogue to digital before delivering it to controllerFor this purpose analogue-digital converters are used witch usually are built-in to the microcontroller +Analoge Sensoren welche die Information digitalisierenwerden digitale Sensoren genanntDigitale Sensoren können darüber hinaus Information standardisierenSensoren kalibrieren und viele andere Funktionen ausführen. Es gibt verschiedene Möglichkeiten um Information von einem digitalen Sensor an einen Mikrocontroller zu senden. Die einfachste Möglichkeit ist es mit logischen Signalen Informationen zu übertragen. Eine komplexere Variante geht über eine Datalink SchnittstelleDie folgenden Übungen führen aber nur einfachere und in der Robotik genutzte Sensoren ein.
  
-Analogue sensor which already includes digitizer of information, it is called digital sensor. Digital sensors can also standardize information, calibrate sensors and perform a great deal of other functions. There are many ways for transmitting info from digital sensor to microcontroller: the easiest is with logical signals, more complex way – through some data link interface. The following exercises though, are introducing simpler sensors and sensors known in robotics.  +==== Potentiometer ====
  
-==== Potentsiometer ====+//Notwendiges Wissen: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:digi]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:segment_display]]//
  
-//Necessary knowledge : [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:digi]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:segment_display]]//+=== Theorie ===
  
-=== Theory ===+[{{  :examples:sensor:potentiometer:sensor_potentiometer_designator.png?120|elektrisches Symbol eines Potentiometers}}]
  
-[{{  :examples:sensor:potentiometer:sensor_potentiometer_designator.png?120|Electric symbol of potentiometer}}]+Ein Potentiometer ist ein elektronisches Widerstandsbauelement mit drei Anschlüssen. Zwischen den beiden Seitenkontakten ist der Widerstand fix, zwischen Seiten- und Mittelkontakt ist er variabel. Im Grunde ist ein Potentiometer ein Spannungsteiler, dessen Widerstand zwischen den Seiten- und Mittelkontakten hergestellt wird.
  
-Potentiometer is a three terminal resistor, witch has fixed resistance between its two side contacts and variable resistance between side and middle contact. In principle a potentiometer is a attenuator (voltage divider), where resistance is formed between side contacts and middle contact. 
  
-[{{  :examples:sensor:potentiometer:sensor_potentiometer_turn.jpg?120|Single-turn potentiometer}}]+[{{  :examples:sensor:potentiometer:sensor_potentiometer_turn.jpg?120|einfaches Drehpotentiometer}}]
  
-A typical potentiometer consists of a resistor with conducting surfaces and of a sliding contact called slider. The closer the slider is to the edge of the resistorthe smaller is the resistance between the slider and the edge and vice versaA material with high resistivity or coil made of resistance wire can act as a resistorSome potentiometers have linear or logarithmic relations between the resistance and the slider positionPotentiometers are mainly single turn-potentiometers (example on the picture), but exist also slider potentiometersA special type of potentiometers are digital potentiometerswhere the regulation of the resistance is done inside the micro scheme according to the signals.+Ein typisches Potentiometer besteht aus einem Widerstand mit einer leitenden Oberfläche und einem Schiebekontakt (slider)Je näher der Schiebekontakt am Rand des Widerstandes angebracht istdesto geringer ist der Widerstand zwischen Slider und Ecke des Widerstands und umgekehrtEin Material mit hohem Widerstand oder einer Spule aus Widerstandsdraht kann als Widerstand fungierenBei einigen Potentiometern sind die Beziehungen zwischen Widerstand und Sliderposition linear oder logarithmischPotentiometer sind normalerweise einfache Drehpotentiometer (siehe Bild), es gibt aber auch SchiebepotentiometerEin spezieller Typ von Potentiometer sind digitale Potentiometerbei denen die Regulation des Widerstands intern über Signale geschieht.
  
-=== Practice ===+=== Übung ===
  
-On the module of the HomeLab is a 4.7 kΩ turn potentiometerThis potentiometer is connected between ground and +5 V potentials and the slider is connected to the channel of the analogue-digital converterWith this connection, the output voltage of the potentiometer can be regulated between V and 5 V. The digital value of the potentiometer output voltage on its entire adjusting range can be measured if the comparison voltage from AVR digital-analogue converter is taken from AVCC pinThe following function for AVR ADC are in the library of the HomeLab:    +Am HomeLab Modul befindet sich ein 4,7 kΩ DrehpotentiometerDas Potentiometer ist mit der Masse und dem +5 V Potential angeschlossen, und der Schiebekontakt ist am Kanal des analog-digital Konverters angeschlossenSo kann der Spannungsoutput des Potentiometers zwischen und 5 V reguliert werdenDer digitale Wert der Potentiometeroutputspannung kann gemessen werden indem die Vergleichsspannung vom AVR digital-analog Konverter vom AVCC Pin genommen wirddie Folgende Funktionen für den ACR ADC sind in der HomeLab Bibliothek enthalten.
  
 ~~CL~~ ~~CL~~
Line 3832: Line 3315:
 } }
 </code> </code>
-The function //adc_init// must be called out in the beginning of the program, this is used for making the ADC to work. The reference voltage must be chosen from either AREF pin or AVCC pin, or fixed inner voltage of 2.56 V must be selected. In addition the clock cycle of the converter must be set by the prescaler (factor of frequency divider), which will be used to divide the controller clock cycle. The conversion is quicker when using higher clock cycle but with this the accuracy may suffer. Function //adc_get_value// is for measuring, this able to select the channel and it returns 10 bit results as 16 bit integer. The function for measuring is inter locking, hence it waits for the end of conversion and returns the results only after all measuring is done. 
  
-In previously explained example program analogue-digital converter and 7 segment number indicator library are usedThe 10 bit value of analogue-digital converter is multiplied by 10 and divided by 1024 to get the value between 0 and 9The value 10 is impossible to reach because while dividing in C-language only integer value is calculated and not rounded resultFunction of averaging the result of converter is used to get more accurate resultDerived from this the operating program shows the numbers 0 to 9which correspond to the position of the potentiometer on the indicator.+Die Funktion //adc_init// muss zu Beginn des Programms ausgeführt werdenSie sorgt dafür, dass der ADC funktioniertDie Vergleichsspannung muss entweder vom AREF oder AVCC Pin kommen, oder es muss die eingestellte interne Spannung von 2,56 V ausgewählt werdenDazu muss der Taktzyklus des Konverters mit einem Vorzähler gesetzt werden (Faktor des Frequenzteilers), welcher den Taktzyklus des Controllers teiltDie Umsetzung ist schnellerwenn höhere Taktzyklen verwendet werden, jedoch kann die Genauigkeit drunter leiden. Die Funktion //adc_get_value// dient zur Messung. Es kann der Kanal gewählt werden und sie gibt 10-Bit Ergebnisse als ganze 16-Bit Zahlen aus. Die Funktion zur Messung wartet bis die Konversion beendet ist und gibt das Ergebnis erst dann aus.
  
 +In den zuvor erklärten Beispielprogrammen werden die Bibliotheken des ADC und des 7-Segment-Zifferanzeige genutzt. Der 10-Bit Wert des ADC wird mit 10 multipliziert und durch 1024 dividiert um einen Wert zwischen 0 und 9 zu erhalten. Der Wert 10 kann nicht erreicht werden, weil in C nur ganzzahligewerte berechnet werden und keine gerundeten Ergebnisse.
 +Um die Genauigkeit des Ergebnisses zu erhöhen, wird eine Funktion zur Berechnung des Durchschnitts der Ergebnisse des ACSs genutzt. Daraus abgeleitet gibt das Programm auf der Anzeige einen Wert von 0 bis 9 aus, welcher der Position des Potentiometers entspricht.
  
 <code c> <code c>
 // //
-// Example program of potentiometer on the Sensor module +// Beispielprogramm für das Potentiometer des Sensormoduls 
-// The position of the potentiometer is displayed on the 7-segment indicator+// Die Position des Potentiometers wird auf der 7-Segmentanzeige dargestellt
 // //
 #include <homelab/adc.h> #include <homelab/adc.h>
Line 3846: Line 3330:
  
 // //
-// Selecting the channel+// Auswahl des Kanals
 // //
-//  1 = photoresistor +//  1 = Photoresistor 
-//  2 = thermistor +//  2 = Thermistor 
-//  3 = potentiometer+//  3 = Potentiometer
 // //
 #define ADC_CHANNEL 3 #define ADC_CHANNEL 3
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 3861: Line 3345:
  int value;  int value;
  
- // Adjusting 7-segment indicator+ // Anpassung der 7-Segmentanzeige
  segment_display_init();  segment_display_init();
  
- // Adjusting ADC+ // Anpassung des ADC
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
  
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Reading 4 times rounded values of the channel+ // Liest viermal gerundete Werte aus dem Kanal
  value = adc_get_average_value(ADC_CHANNEL, 4);  value = adc_get_average_value(ADC_CHANNEL, 4);
  
- // Displaying the hundreds of the indicated value+ // Zeigt Hunderter des angezeigten Wertes an
  segment_display_write(value * 10 / 1024);  segment_display_write(value * 10 / 1024);
  }  }
Line 3880: Line 3364:
 ==== Thermistor ==== ==== Thermistor ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:sensor:thermistor:sensor_thermistor_ntc_picture.jpg?80|NTC thermistor}}]+[{{  :examples:sensor:thermistor:sensor_thermistor_ntc_picture.jpg?80|NTC Thermistor}}]
  
-A thermistor is a type of resistor which resistance varies with temperatureThere are two types of thermistors: positive temperature coefficient of resistance and negative temperature coefficient of resistanceThe resistance of thermistors with positive temperature coefficient of resistance is increasing when the temperature grows and with negative the resistance decreasesThe respective abbreviations are PTC (//positive temperature coefficient//and NTC (//negative temperature coefficient//). +Ein Thermistor ist temperaturabhängiger WiderstandEs gibt Thermistoren mit positiven und mit negativen TemperaturkoeffizientenDer Widerstand von Thermistoren mit positiven Koeffizienten nimmt mit steigender Temperatur zu, bei Thermistoren mit negativen Koeffizienten steigt er mit sinkender TemperaturDie dazugehörigen Abkürzungen sind PTC(//positive temperature coefficient//und NTC (//negative temperature coefficient//).
- +
-The thermistors resistances' dependence of the temperature is not linear and this complicates the usage of it. For accurate temperature measurements in wider temperature flotation the Steinhart-Hart third-order exponential equation is used as the thermistors resistance is linear only in small temperature range. The following simplified Steinhart-Hart equation with B-parameter exists for NTC thermistors:+
  
 +Die Temperaturabhängigkeit des Widerstands verläuft nicht linear zu der Temperatur, was die Nutzung erschwert. Für genaue Temperaturmessungen bei größeren Temperaturschwankungen wird die exponentielle Steinhart-Hart Gleichung dritter Ordnung genutzt, da der Thermistorwiderstand nur innerhalb kleiner Temperaturbereiche linear ist. Für NTC Thermistoren gibts es folgende vereinfachte Steinhart-Hart-Gleichung mit dem Parameter B:
  
 {{:examples:sensor:thermistor:sensor_ntc_equation.png?130|The relation between temperature and resistance of a NTC thermistor.}} {{:examples:sensor:thermistor:sensor_ntc_equation.png?130|The relation between temperature and resistance of a NTC thermistor.}}
  
-where:\\ +mit:\\ 
-  * T<sub>0</sub> nominal temperatureusually 25 °C.\\ +  * T<sub>0</sub> nominale Temperaturnormalerweise 25 °C.\\ 
-  * R<sub>0</sub> resistance at nominal temperature.\\ +  * R<sub>0</sub> Widerstand bei nominaler Temperatur.\\ 
-  * B   parameter B.+  * B   Parameter B.
  
-Parameter B is a coefficientwhich is usually given in the datasheet of the thermistorBut it is stable enough constant only in a certain ranges of temperaturefor example at ranges 2550 °C or 2585 °C. If the temperature range measured is wider the data sheet should be used for retrieving the equation.+Der Parameter B ist ein Koeffizientwelcher normalerweise im Datenblatt des Thermistors vorgegeben istAber er ist nur in bestimmten Temperaturbereichen ausreichend konstantz.B. in Bereichen zwischen 25 und 50 °C oder zwischen 25 und 85 °C. Wenn der gemessene Temperaturbereich größer istsollte das Datenblatt des Thermistors zu Rate gezogen werden um die Gleichung zu erhalten.
  
-  +Normalerweise wird ein Spannungsteiler genutztum den Widerstand eines Thermistors zu messenDabei wird ein Widerstand durch einen Thermistor ausgetauscht wird und die Inputspannung ist konstant. Es wird die Outputspannung des Spannungsteilers gemessenwelche sich in Abhängigkeit der Widerstandsänderung des Thermistors verändertWenn Spannung anliegtfließt Strom durch den Thermistor, wodurch sich dieser bedingt durch den Thermistorwiderstand aufheizt und damit den Widerstand verändertDer durch das Aufheizen entstehende Fehler kann berechnet werden, jedoch ist es einfacher einen Thermistor zu nutzenwelcher einen hohen Widerstand hat und sich nicht so viel aufheizt.
-Usually a voltage-divider is used for measuring the resistance of a thermistorwhere one resistor is replaced with a thermistor and the input voltage is constantThe output voltage of the voltage-divider is measuredwhich changes according to the change of the resistance of the thermistorIf the voltage is appliedcurrent goes through the thermistor which heats up the thermistor due to thermistors resistance and therefore alters again the resistanceThe  fault caused by heating up of the thermistor can be compensated with calculationsbut it is easier to use a thermistor that has higher resistance and therefore heats up less.+
  
-With restricted resources and with less demands on accuracypreviously calculated charts and tables for temperatures are usedGenerally the tables have ranges of temperatures and respective values of resistancevoltage or analogue-digital convertersAll exponential calculations are already done and the user needs to only find the correct row and read the temperature given+Bei begrenzten Ressourcen und geringerem Anspruch auf Genauigkeitwerden zuvor errechnete Diagramme und Tabellen für die Temperaturen genutztNormalerweise enthalten die Tabellen Temperaturbereiche und die entsprechenden Werte für WiderstandSpannung und ADCAlle exponentiellen Berechnungen wurden bereits durchgeführt sodass der Nutzer nur noch die entsprechende Reihe finden und die Werte auslesen muss.
  
 +=== Übung ===
  
-=== Practice === +Das Sensormodul des HomeLab enthält einen NTC Thermistor mit nominellem Widerstand von 10 kΩ. Bei Temperaturen von 25 bis 50 °C ist der Parameter des Widerstands 3900.  
- +Ein Pin des Thermistors ist an die +5 V Betriebsspannung angeschlossen der andere an Kanal 2 (Pin PF2). Ein typischer 10 kΩ Widerstand ist auch am gleichen Pin des Mikrocontrollers und an die Masse angeschlossenSo entsteht zusammen mit dem Thermistor ein Spannungsteiler. Da hier ein NTC Thermistor genutzt wirdbei welchem der Widerstand sinkt wenn die Temperatur steigtwird die Outputspannung des Spannungsteilers bei steigender Temperatur höher.
-The Sensor module of the HomeLab is equipped with a NTC type thermistor which has 10 kΩ nominal resistanceAt temperatures 25-50 °C the parameter of the thermistor is 3900. One pin of the thermistor is connected to +5 V supply and the other one is connected to the channel 2 (pin number PF2) of the analogue-digital converterA typical 10 kΩ resistor is also connected with the same pin of the microcontroller and earth and together with the thermistor forms a voltage dividerSince we are dealing with a NTC thermistorwhich resistance decreases as the temperature grows; the output voltage of the voltage divider is increasing repectively with growing temperature. +
- +
-While using the AVR it is practical to use a conversion table of values of temperature and analogue-digital converter to find the correct temperature. It is wise to find corresponding value of analogue-digital converter for each temperature degree of desired range of temperature because reverse table will be too large due to the amount of 10 bit ADC values. It is recommended to use any kind of spreadsheet program (MS Excel, Openoffice Calc, etc.) to make the table. //Steinhart-Hart// formula which is customized for the mentioned NTC thermistors able's to find the resistance of the thermistor which corresponds to the temperature. Derived from the resistanceis possible to calculate the output voltage of the voltage divider and using this output voltage to calculate the value of the ADCCalculated values can be inserted to the program as follows:    +
  
 +Während der Nutzung des AVR ist es nützlich, eine Tabelle mit den Temperaturwerten und den Werten des ADC zu verwenden, um die korrekte Temperatur zu finden. Es ist sinnvoll, für jede Gradzahl der gewünschten Temperaturstufe des Messbereichs den korrespondierenden ADC Wert aus der Tabelle herauszusuchen, da die Tabelle aufgrund der 10 Bit ADC Werte sehr groß sein wird. Es wird empfohlen, ein Tabellenkalkulationsprogramm (MS Excel, Openoffice Calc, etc.) zur Erstellung der Tabelle zu nutzen. Die //Steinhart-Hart// Gleichung, welche für den NTC angepasst wurde, gibt den zur entsprechenden Temperatur korrespondierenden Widerstand aus. Abgeleitet aus dem Widerstand, ist es möglich die Outputspannung des Spannungsteilers zu berechnen und daraus den Wert des ADC. Berechnete Werte können wie folgt in das Programm eingefügt werden:
  
 <code c> <code c>
 // //
-// Table for converting temperature values to ADC values+// Tabelle zur Konvertierung von Temperaturwerten ind ADC Werte
-// Every element of the array marks one Celsius degree+// Jedes Element des Arrays kennzeichnet ein Grad Celsius. 
-// Elements begin from -20 degree and end at 100 degree+// Die Elemente beginnen bei -20 Grad und enden bei 100 Grad
-// There are 121 elements in the array.+// Ein Array enthält 121 Elemente.
 // //
 const signed short min_temp = -20; const signed short min_temp = -20;
Line 3939: Line 3420:
 </code> </code>
  
-Following algorithm may be used to find the temperature which corresponds to the parameters of the ADC:+Folgender Algorithmus kann genutzt werden um die mit den ADC Parametern korrespondierende Temperatur zu finden:
  
 <code c> <code c>
 // //
-// Converting the ADC values to Celsius degrees:+// Konvertierung der ACD Werte in Grad Celsius:
 // //
 signed short thermistor_calculate_celsius(unsigned short adc_value) signed short thermistor_calculate_celsius(unsigned short adc_value)
Line 3949: Line 3430:
  signed short celsius;  signed short celsius;
  
- // Covering the table backwards:+ // Tabelle von hinten beginnend durchgehen:
  for (celsius = max_temp - min_temp; celsius >= 0; celsius--)  for (celsius = max_temp - min_temp; celsius >= 0; celsius--)
  {  {
- // If the value in the table is the same or higher than measured  + // Ist der Wert aus der Tabelle gleich oder höher dem gemessenen  
- // valuethen the temperature is at least as high as the temperature + // Wertist die Temperatur mindestens so hoch wie die mit dem Element  
- // corresponding to the element.+ // korrespondierende Temperatur.
  if (adc_value >= conversion_table[celsius]))  if (adc_value >= conversion_table[celsius]))
  {  {
- // Since the table begins with but values of the elements from -20,        + // Da die Tabelle mit beginnt, die Werte der Elemente jedoch mit -20,        
- // the value must be shifted.+ // muss der Wert geshiftet werden.
  return celsius + min_temp;  return celsius + min_temp;
  }  }
  }  }
  
- // If the value was not found the minimal temperature is returned.+ // Wurde der Wert nicht gefunden, wird die minimale Temperaur ausgegeben.
  return min_temp;  return min_temp;
 } }
 </code> </code>
-The algorithm searches range from the table where the ADC value is and acquires the lower ranking number of this range. The ranking number marks degrees, adding the primary temperature to this a temperature with accuracy of 1 degree is reached. 
  
-This conversion table and function are already in the library of the HomeLab, therefore there is no need to write them for this exercise. In the library the conversion function is named //thermistor_calculate_celsius//Must be consideredthat the conversion is valid only when used on the thermistor on the Sensors module of the HomeLab. For using other thermistorsa conversion table needs to be created and more complex function described in the manual of the library must be usedExample program of this exercise is a thermometerwhich measures temperature in Celsius scale and displays it on an alphabetical LCD.  +Der Algorithmus sucht den Bereich aus der Tabelle in dem der ACD Wert liegt und wählt die niedrigere Nummer dieses Bereiches. Die Ranknummer markiert die Gradzahl und durch das Addieren der anfänglichen Temperatur wird eine Genauigkeit von 1°C erreicht. 
 + 
 +Umrechnungstabelle und Funktion sind schon in der HomeLab Bibliothek enthaltensie müssen somit nicht extra für diese Aufgabe erstellt werden. In der Bibliothek heißt die Umrechnungsfunktion //thermistor_calculate_celsius//Hierbei muss beachtet werdendass die Funktion nur korrekt ist, wenn sie mit dem Thermistor des Sensormoduls aus dem HomeLab verwendet wirdWerden andere Thermistoren genutztmuss eine entsprechende Umrechnungstabelle erstellt und eine komplexere Funktion verwendet werden, welche im Handbuch der Bibliothek beschrieben wirdDas Beispielprogramm dieser Übung ist ein Thermometerwelches Temperatur in °C mißt und sie auf dem alphabetischen LCD ausgibt.
    
  
 <code c> <code c>
 // //
-// Example program of the thermistor of Sensors module+// Beispielprogramm des Thermistors des Sensormoduls
-// The temperature is displayed on the LCD.+// Die Temperatur wird auf dem LCD angezeigt.
 // //
 #include <stdio.h> #include <stdio.h>
Line 3983: Line 3465:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 3991: Line 3473:
  char text[16];  char text[16];
    
- // Setting the LCD+ // Einrichten des LCD
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
    
- // Cleaning the LCD+ // Löschen des LCD
  lcd_alpha_clear();  lcd_alpha_clear();
    
- // Name of the program+ // Name des Programms
  lcd_alpha_write_string("Termomeeter");  lcd_alpha_write_string("Termomeeter");
    
- // Setting the ADC+ // Einrichten des ADC
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
    
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Reading the times rounded values of the voltage of the thermistor+ // Auslesen der 4-fach gerundeten Spannungswerte aus dem Thermistor
  value = adc_get_average_value(2, 4);  value = adc_get_average_value(2, 4);
  
- // Converting the values of ADC into celsius scale+ // Konvertieren der ADC Werte in Grad Celsius
  temperature = thermistor_calculate_celsius(value);  temperature = thermistor_calculate_celsius(value);
  
- // Converting the temperature in to text.+ // Konvertieren der Temperatur in Text.
  // To display the degree sign, the octal variable is 337.  // To display the degree sign, the octal variable is 337.
  sprintf(text, "%d\337C   ", temperature);  sprintf(text, "%d\337C   ", temperature);
  
- // Displaying the text in the beginning of the second row of the LCD.+ // Anzeige des Textes am Anfang der zweiten Zeile des LCDs.
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
  lcd_alpha_write_string(text);  lcd_alpha_write_string(text);
Line 4025: Line 3507:
 === Extra === === Extra ===
  
-  * {{:examples:sensor:thermistor:ntc.xls|The diagram of temperature of a 10 kΩ NTC thermistor}}+  * {{:examples:sensor:thermistor:ntc.xls|Das Temperaturdiagramm eines 10 kΩ NTC Thermistors}}
  
-==== Photoresistor ====+==== Fotowiderstand ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [PRT] [[en:examples:setup:windows]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [PRT] [[en:examples:setup:windows]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:sensor:photoresistor:sensor_photoresistor.jpg?150|A photoresistor}}] +[{{  :examples:sensor:photoresistor:sensor_photoresistor.jpg?150|Ein Fotowiderstand}}] 
-[{{  :examples:sensor:photoresistor:sensor_photoresistor_designator.png?150|Electrical symbol for a photoresistor}}]+[{{  :examples:sensor:photoresistor:sensor_photoresistor_designator.png?150|Elektrisches Symbol für einen Fotowiderstand}}]
  
-A photoresistor is a sensor which electrical resistance is altered depending on the light intensity falling on itThe more intense is the light the more free carriers are formed and therefore the lower gets the resistance of the elementTwo exterior metal contacts of the photoresistor are reaching through the ceramic base material to the light sensitive membranewhich determines the electrical resistance properties with its geometry and material propertiesSince photo sensitive material itself has high resistancewith narrowcurvy track between the electrodeslow total resistance at average light intensity is gainedSimilarly to the human eyethe photoresistor is sensitive at certain range of wavelengths and needs to be considered when selecting a photo element, otherwise it may not react to the light source used in the applicationFollowing is simplified list of wavelengths of visible light segmented by colours        +Ein Fotowiderstand ist ein Sensor, dessen elektrischer Widerstand sich je nach einfallender Lichtintensität verändertJe intensiver das Licht ist, desto mehr freie Ladungsträger werden gebildet, und umso geringer wird dadurch der Widerstand des BauteilsDurch das keramische Basismaterial führen zwei externe Metallkontakte des Widerstands zur lichtempfindlichen Membrandessen Widerstand abhängig von der Geometrie und den Materialeigenschaften istDa lichtempfindliches Material durch die schmalekurvige Spur zwischen den Elektroden bereits einen hohen Widerstand hatkann der niedrigste totale Widerstand schon bei durchschnittlichen Lichtintensitäten erreicht werden. Der Fotowiderstand reagiert ähnlich dem menschlichen Auge nur auf bestimmte Wellenlängenwas bei der Auswahl eines solchen Bauteils bedacht werden mussAndernfalls kann es vorkommendass der Widerstand nicht auf die in der Anwendung genutzte Lichtquelle reagiertNachfolgend ist eine Tabelle abgebildet, welche vereinfacht die Wellenlängen des sichtbaren Lichts mit den entsprechenden Farben darstellt       
  
-Colour            Range of wavelength (nm)  ^ +Farbe            Wellenlängen (nm)  ^ 
-Purple       | 400 – 450                  | +Violett      | 400 – 450                  | 
-Blue         | 450 – 500                  | +Blau         | 450 – 500                  | 
-Green        | 500 – 570                  | +Grün         | 500 – 570                  | 
-Yellow       | 570 – 590                  |+Gelb         | 570 – 590                  |
 | Orange       | 590 – 610                  | | Orange       | 590 – 610                  |
-Red          | 610 – 700                  |+Rot          | 610 – 700                  |
  
-A range of working temperature is set for photoresistorWishing the sensor to work at different temperaturesprecising conversions must be executedbecause the resisting properties of the sensors are depending on the temperature of the ambient+Der Fotowiderstand arbeitet innerhalb eines bestimmten, festgelegten TemperaturbereichsSoll der Sensor bei anderen Temperaturen genutzt werdenmüssen präzise Umrechnungen durchgeführt werdenda die Widerstandseigenschaften des Sensors abhängig von der Umgebungstemperatur sind
  
-For characterizing light intensiveness physical concept called light intensity (E) is usedthis shows the quantity of light reaching any given surfaceMeasuring unit is lux (lx), where lux represents, the even flow of light lumenfalling on a surface of 1m2Hardly ever in reality falls light (living area) on a surface evenly and therefore light intensity is reached generally as a average numberBelow are few examples of light intensity  +Zur Kennzeichnung der Lichtintensität wird die Beleuchtungsstärke (E) genutzt. Diese zeigt die Menge Licht andie auf eine bestimmte Oberfläche trifftDie Maßeinheit ist Lux (lx), wobei Lux dem konstanten Lichtfluss von einem Lumen entsprichtwelcher auf eine Oberfläche von 1m² strahltIn der Realität fällt Licht jedoch eigentlich nie gleichmäßig auf eine Oberfläche weshalb die Beleuchtungsstärke meistens als Durchschnittswert ermittelt wirdUnten sind ein paar Beispiele von Beleuchtungsstärken dargestellt:
        
 +Vergleichswerte von Beleuchtungsstärken:
  
-Values of light intensity for comparison: +Umgebung             ^ Beleuchtungsstärke (lx) ^ 
- +Vollmond             | 0,1          |  
-Environment             ^ Intensity of light (lx) ^ +Abenddämmerung            | 1            | 
-Full moon             | 0,1          |  +
-Dusk                     | 1            | +
 | Auditorium             | 10            | Auditorium             | 10           
-Class room             | 30           |  +Klassenraum             | 30           |  
-Sunset or sunrise         | 400          |  +Sonnenaufgang / -untergang| 400          |  
-Operating room (hospital) | 500 - 1000   |  +OP-Saal (Krankenhaus    | 500 - 1000   |  
-Direct sun light     | 10000        | +direktes Sonnenlicht     | 10000        | 
  
-=== Practice === +=== Übung ===
-The Sensor module in the HomeLab is equipped with VT935G photoresistor. One pin of the photoresistor is connected to +5 V power supply and second pin to the channel 1 (pin PF1) of the analogue-digital converter. Between this pin and the ground 10 kΩ resistor is also connected, which forms a voltage divider with the photoresistor. Since the electrical resistance of the photoresistor is decreasing as the light intensity falling on it grows, the measured voltage on the pin of the microcontroller grows as light intensity grows. It is worth to take into account that the photoresistor used in the HomeLab reacts most on orange and yellow light. +
-   +
-The sensor VT935G is not meant to be a specific measuring device. It is meant to be more a device to specify overall lighting conditions – is there a lighted lamp in the room or not. In this case one has to just measure the resistance of the sensor in the half dark room, note it in the program and compare measured values – is it lighter or darker.+
  
-The exercise here is a little bit more complex as the light intensity is measured also in luxFor doing thisexists an approximate formula and floating-point variablesIn the C-language are floating-point variables //float-// and //double//-type variableswhich can be used to present fractions. Their flaw  is high demand of resourcesComputers have special hardware to calculate floating-point variablesin the 8-bit AVR microcontroller calculations are executed in software which demands a lot of memory and timeIf the flaws are not criticalthe floating-point variables are worth using  +Das Sensormodul aus dem HomeLab verfügt über einen VT935G FotowiderstandEin Pin des Widerstands ist an der +5 V Stromversorgung angeschlossender zweite an Kanal 1 (Pin PF1) des ADCZwischen diesem Pin und der Masse ist ein 10 kΩ Widerstand angeschlossenwelcher zusammen mit dem Fotowiderstand einen Spannungsteiler erzeugtDa sich der elektrische Widerstand des Fotowiderstands mit einfallender Lichtintensität verkleinertwird die gemessene Spannung am Pin des Mikrocontrollers mit dem Ansteigen der Lichtstärke größerHierbei sollte bedacht werdendass der Fotowiderstand des HomeLab am stärksten auf oranges und gelbes Licht reagiert.
  
 +Der Sensor VT935G ist nicht als spezifisches Messinstrument gedacht. Er soll vielmehr dazu dienen, Informationen über die allgemeinen Lichtverhältnisse (z. B. befindet sich eine eingeschaltete Lampe im Raum oder nicht) anzugeben. Dazu muss nur der Widerstand des Sensors in einem halbdunklen Raum gemessen und ins Programm eingetragen werden. Daraufhin kann man die gemessenen Werte vergleichen und feststellen ob es heller oder dunkler ist.
  
-[{{  :examples:sensor:photoresistor:sensor_photoresistor_vt935g_slope.png?260|Relationship between resistance (R) of VT935G and intensity of light (E)}}]+Die nun folgende Aufgabe ist ein wenig komplexer, da die Beleuchtungsstärke auch in Lux gemessen wird. Hierzu werden eine Annäherungsformel sowie Gleitkomma-Variablen angewendet. In C sind Gleitkomma-Variablen //float-// und //double-//-Typ Variablen, welche zur Darstellung von Brüchen genutzt werden können. Nachteilig ist jedoch, dass während der Nutzung dieser Variablen viele Ressourcen in Anspruch genommen werden müssen. Während Computer spezielle Hardware zur Berechnung von Gleitkomma-Variablen besitzen, wird diese bei den 8-Bit AVR Microcontrollern mittels einer Software durchgeführt, wodurch viel Zeit und Speicher benötigt wird. Sofern die Nachteile jedoch nicht entscheidend sind, lohnt es sich, Gleitkomma-Variablen zu verwenden. 
 + 
 + 
 +[{{  :examples:sensor:photoresistor:sensor_photoresistor_vt935g_slope.png?260|Verhältnis zwischen Widerstand (R) des VT935G und Lichtintensität (E)}}] 
 + 
 +Das Datenblatt des Sensors beinhaltet eine Annäherungsformel für den Zusammenhang zwischen Beleuchtungsstärke und elektrischem Widerstand. Wie im logarithmisch skalierten Graphen rechts dargestellt, sind Widerstand und Beleuchtungsstärke nahezu linear abhängig und bilden eine lineare Funktion, wenn folgende Konversion angewendet wird:
  
-There is an approximate formula showing the relationship between the intensity of light and electrical resistance in the sensor datasheet. As seen on the graph (on the right), with using logarithm scale, the resistance and intensity of light are almost in linear relationship and form a in-line formula, because following conversion applies:     
  
 log(a/b) = log(a) - log(b) log(a/b) = log(a) - log(b)
  
-The relation is characterised by the ascent of the factor γ (ascend of the line), which is 0,9 on VT935G sensorWe have also data on one of the points on that line resistance 18.5 kΩ (R<sub>A</sub>at 10 lx intensity of light (E<sub>A</sub>). Hence we have the coordinates of one point as well as the ascent of the line and for calculating any other point, we only need one coordinateMeaningif sensors' resistance (R<sub>B</sub>is measuredit is possible to calculate from the equation of line, the intensity of light E<sub>B</sub>that falls on the sensorFinding E<sub>B</sub> from the equation of line:+Die Relation wird durch den Anstieg des Y-Faktors (Steigung der Geradenbeschriebenwelcher für den VT935G Sensor den Wert 0,9 hatDarüber hinaus ist ein Punkt auf dieser Geraden bekanntDer Widerstand beträgt 18.5 kΩ (R<sub>A</sub>bei 10 lx Beleuchtungsstärke (E<sub>A</sub>). Mittels dieser Koordinaten und der Steigung der Geraden lässt sich nun jeder beliebige Punkt berechnenDas bedeutetwird der Widerstand (R<sub>B</sub>am Sensor gemessenist es möglich die Beleuchtungsstärke E<sub>B</sub>wie folgt mit der Formel der Geraden zu berechnen.
  
 log(E<sub>B</sub>) = log(R<sub>A</sub>/R<sub>B</sub>) / γ + log(E<sub>A</sub>) \\ \\ log(E<sub>B</sub>) = log(R<sub>A</sub>/R<sub>B</sub>) / γ + log(E<sub>A</sub>) \\ \\
 E<sub>B</sub> = 10<sup>log(R<sub>A</sub>/R<sub>B</sub>) / γ + log(E<sub>A</sub>)</sup> E<sub>B</sub> = 10<sup>log(R<sub>A</sub>/R<sub>B</sub>) / γ + log(E<sub>A</sub>)</sup>
  
-This gives the formula for calculating the intensity of light when the resistance is knownThe resistance can not be measured directly with microcontrollerFor this the photoresistor is in the voltage divider. The output voltage of this voltage divider is converted to a specific variable by the analogue-digital converter (ADC)To find the resistance, the output voltage (U<sub>2</sub>of the voltage divider must be calculated first, using the ADC value, also comparison voltage (U<sub>ref</sub>) of the converter must be taken into account:  +So erhält man die Formel zur Berechnung der Beleuchtungsstärke bei gegebenem WiderstandDa der Widerstand nicht direkt von Microcontroller gemessen werden kann befindet sich der Fotowiderstand im SpannungsteilerDie Output-Spannung des Spannungsteilers wird durch den ADC zu einer spezifischen Variable konvertiertZur Bestimmung des Widerstands muss diese Output-Spannung (U<sub>2</sub>zunächst mittels des ADC-Wertes berechnet werden. Dabei muss auch die Vergleichs-Spannung des Konverters berücksichtigt werden. Folgende Formel wird zur Berechnung verwendet:
-The formula is following:+
  
 U<sub>2</sub> = U<sub>ref</sub> * (ADC / 1024) U<sub>2</sub> = U<sub>ref</sub> * (ADC / 1024)
  
-From the formula for voltage divider(check the chapter on voltage dividerthe resistance of the upper photoresistor (R<sub>1</sub>can be found:+Mit Hilfe der Formel für Spannungsteiler (siehe Kapitel über Spannungsteilerkann der Widerstand des Fotowiderstands (R<sub>1</sub>ermittelt werden:
  
 R<sub>1</sub> = (R<sub>2</sub> * U<sub>1</sub>) / U<sub>2</sub> - R<sub>2</sub> R<sub>1</sub> = (R<sub>2</sub> * U<sub>1</sub>) / U<sub>2</sub> - R<sub>2</sub>
  
-In the following calculation of voltage and resistancethe known factors are replaced with numbers and indexes have been removed:+In der folgenden Berechnung von Spannung und Widerstandwerden die gegebenen Werte eingesetzt und die Indizes entfernt:
  
 U = 5 * (ADC / 1024) \\ \\ U = 5 * (ADC / 1024) \\ \\
 R = (10 * 5) / U - 10 \\ \\ R = (10 * 5) / U - 10 \\ \\
  
-For finding the intensity of light, simplifying conversions can be done:+Die Beleuchtungsstärke kann dann mittels der folgenden vereinfachten Konversion genutzt werden:
  
 E = 10<sup>log(18.5/R) / 0.9 + 1</sup> = 10<sup>log(18.5/R) * 10/9</sup> * 10<sup>1</sup> = \\ \\ E = 10<sup>log(18.5/R) / 0.9 + 1</sup> = 10<sup>log(18.5/R) * 10/9</sup> * 10<sup>1</sup> = \\ \\
Line 4101: Line 3583:
 = (18.5<sup>10/9</sup> / R<sup>10/9</sup>) * 10 = 18.5<sup>10/9</sup> * 10 * R<sup>-10/9</sup> = (18.5<sup>10/9</sup> / R<sup>10/9</sup>) * 10 = 18.5<sup>10/9</sup> * 10 * R<sup>-10/9</sup>
  
- +Durch die Berechnung der Konstante vor der Variable des Feldes R, bleibt folgender Ausdruck:
-By calculating the constant in front of the variable of the field R, the expression remains follows:+
  
 E = 255,84 * R<sup>-10/9</sup> E = 255,84 * R<sup>-10/9</sup>
  
-These formulas help only if the photoresistor on the module of sensors of the HomeLab is usedIf circuit is used equipped with different componentsrespective variables need to be changedNextsource code of the example program is presented, which measures and calculates using ADC and displays the intensity of light on the LCD. But before compiling the programthe settings for using floating-point variables must be written in the projectHow to do that is explained in the chapter of installing the software. +Die dargestellten Formeln sind jedoch nur im Zusammenhang mit Fotowiderständen des HomeLab Sensor-Moduls nützlichWird ein Schaltkreis mit anderen Komponenten bestücktmüssen die Variablen verändert werden. 
- +Nachfolgend ist der Quellcode eines Beispielprogramms dargestelltwelches die Beleuchtungstärke mit Hilfe des ADC misst und berechnet und auf dem LCD darstelltBevor das Programm kompiliert wirdmüssen die Einstellungen für die Gleitkomma-Variablen im Projekt festgelegt werdenDieser Schritt wird in dem Kapitel über die Installation der Software erläutert.
-In the example program variables of voltage, resistance and intensity are defined using type //double// of floating-point variables. The variables which should be used as floating-point variables must always contain a decimal point (it can be also just 0, because then the compiler understands it correctly). When using //sprintf// for converting floating-point variable to text, “%f” format must be used, this may be enhanced using integers and decimal places. For example: “%3.2”, which displays always 3 integers and 2 decimal places+
  
 +In diesem Beispielprogramm werden die Variablen für Spannung, Widerstand und Beleuchtungsstärke als //double// Gleitkomma-Variablen definiert. Die Variablen, welche nun als Gleitkomma-Variablen genutzt werden, müssen immer eine Dezimalstelle beinhalten (diese kann auch einfach 0 sein, so verarbeitet der Compiler es korrekt). Wird die Funktion //sprintf// genutzt, um die Gleitkomma-Variable in Text zu konvertieren, muss das "%f" Format genutzt werden, welches durch Nutzung von ganzen Zahlen und Dezimalstellen erweitert werden kann. So gibt "%3.2" beispielsweise immer 3 ganze Zahlen und 2 Dezimalstellen an.
  
 <code c> <code c>
 // //
-// The example program of the photoresistor of the module of sensors of the HomeLab +// Beispielprogramm des Fotowiderstands aus dem Sensormodul des HomeLab 
-// Approximate value of the intensity of light is displayed on the LCD.+// Der angenäherte Wert der Beleuchtungsstärke wird auf dem LCD dargestellt.
 // //
 #include <stdio.h>  #include <stdio.h> 
Line 4123: Line 3604:
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
Line 4131: Line 3612:
  double voltage, resistance, illuminance;  double voltage, resistance, illuminance;
  
- // Initializing the LCD+ // Initialisiere LCD
  lcd_alpha_init(LCD_ALPHA_DISP_ON);   lcd_alpha_init(LCD_ALPHA_DISP_ON); 
  
- // Clearing the LCD.+ // Lösche LCD.
  lcd_alpha_clear();  lcd_alpha_clear();
  
- // Name of the program+ // Name des Programms
  lcd_alpha_write_string("Luxmeter");  lcd_alpha_write_string("Luxmeter");
  
- // Setting the ADC+ // Einrichten des ADC
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);   adc_init(ADC_REF_AVCC, ADC_PRESCALE_8); 
  
- // Endless loop.+ // Endlosschleife.
  while (true)  while (true)
  {  {
- // Reading the average value of the photoresistor+ // Durchschnittlichen Wert des Fotoresistors auslesen
  adc_value = adc_get_average_value(1, 10);  adc_value = adc_get_average_value(1, 10);
  
- // Calculating the voltage in the input of the ADC+ // Input-Spannung am ADC berechnen
  voltage = 5.0 * ((double)adc_value / 1024.0);  voltage = 5.0 * ((double)adc_value / 1024.0);
  
- // Calculating the resistance of the photoresistor in the voltage divider+ // Widerstand des Fotoresistors im Spannungsteiler berechnen
  resistance = (10.0 * 5.0) / voltage - 10.0;  resistance = (10.0 * 5.0) / voltage - 10.0;
  
- // Calculating the intensity of light in lux + // Beleuchtungsstärke in lux berechnen
  illuminance = 255.84 * pow(resistance, -10/9);  illuminance = 255.84 * pow(resistance, -10/9);
  
- // Converting the intensity of light to text + // Beleuchtungsstärke in Text konvertieren
  sprintf(text, "%0.1f lux   ", illuminance);   sprintf(text, "%0.1f lux   ", illuminance); 
  
- // Displaying it on the LCD+ // Darstellung auf dem LCD
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
  lcd_alpha_write_string(text);  lcd_alpha_write_string(text);
  
- // Delay 500 ms+ // Verzögerung 500 ms
  sw_delay_ms(500);  sw_delay_ms(500);
  }  }
Line 4171: Line 3652:
 </code> </code>
  
-==== Infrared distance sensor ====+==== Infrarot-Entfernungsmesser ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//
  
-=== Theory ===+=== Theorie ===
  
 [{{  :examples:sensor:ir_distance:sensor_ir_distance_gp2y0a21yk_picture.jpg?240|Sharp GP2Y0A21YK}}] [{{  :examples:sensor:ir_distance:sensor_ir_distance_gp2y0a21yk_picture.jpg?240|Sharp GP2Y0A21YK}}]
  
-For measuring the distance to an object there are optical sensors using triangulation measuring methodCompany “Sharp” produces most common infra-red (IR) wavelength using distance sensors which have analogue voltage outputThe sensors made by “Sharp” have IR LED equipped with lenswhich emits narrow light beamAfter reflecting from the objectthe beam will be directed through the second lens on a position-sensible photo detector (PSD). The conductivity of this PSD depends on the position where the beam fallsThe conductivity is converted to voltage and if the voltage is digitalized by using analogue-digital converterthe distance can be calculatedThe route of beams  reflecting from different distance is presented on the drawing next to the text+Um die Distanz zu einem Objekt zu messen, gibt es optische Sensoren, welche die Triangulation als Messmethode nutzenDie am häufigsten verwendeten Infrarot-Entfernungsmesser werden von der Firma "Sharp" produziert und verfügen über einen analogen Spannungs-OutputDiese Sensoren besitzen eine Infrarot-LED mit einer Linsewelchen einen schmalen Lichtstrahl aussendetDieser wird von dem Objektzu welchem die Distanz gemessen werden soll, reflektiert und dann durch die zweite Linse zu einem optischen Positionssensor (OPSgelenktDie Leitfähigkeit dieses OPS ist abhängig davon, an welcher Stelle der Lichtstrahl einfälltSie wird in Spannung umgewandelt, die Spannung wird mittels eines Analog-Digital-Konverters digitalisiert und daraufhin kann die Entfernung berechnet werden. Die Zeichnung auf der rechten Seite zeigt die Wege von Strahlendie aus unterschiedlichen Entfernungen reflektiert werden.
  
-[{{  :examples:sensor:ir_distance:sensor_ir_distance_principle.png?240|The route of the light beam from an IR distance sensor}}]+[{{  :examples:sensor:ir_distance:sensor_ir_distance_principle.png?240|Wege der Lichtstrahlen eines Infrarot-Entfernungsmessers}}]
  
-[{{  :examples:sensor:ir_distance:sensor_ir_distance_graph.png?240|Diagram of voltage-distance of IR distance sensor}}]+[{{  :examples:sensor:ir_distance:sensor_ir_distance_graph.png?240|Das Verhältnis von Spannung und Entfernung eines Infrarot-Entfernungsmessers}}]
  
-The output of distance sensors by "Sharp" is inversely proportional, this means that when the distance is growing the output is decreasing (decreasing is gradually slowing). Exact graph of the relation between distance and output is usually on the data-sheet of the sensorAll sensors have their specific measuring range where the measured results are creditable and this range depends on the type of the sensorMaximum distance measured is restricted by two aspectsthe amount of reflected light is decreasing and inability of the PSD registering the small changes of the location of the reflected rayWhen measuring objects which are too farthe output remains approximately the same as it is when measuring the objects at the maximum distanceMinimum distance is restricted due to peculiarity of Sharp sensorsmeaning the output starts to decrease (again) sharply as the distance is at certain point (depending on the model 4-20 cm). This means that to one value of the output corresponds two values of distance. This problem can be avoided by noticing that the object is not too close to the sensor.+Der Output der Infrarot-Entfernungsmesser von "Sharp" ist anti-proportional. Das meintmit größer werdender Entfernung verringert sich der Output (die Abnahme des Outputs, also der Spannung, wird jedoch nach und nach schwächer). Der Graph mit dem exakten Verhältnis zwischen Entfernung und Spannung ist gewöhnlich im Datenblatt des Sensors abgebildet. 
 +Jeder Sensor-Typ hat seinen spezifischen Messbereich, innerhalb welchem die gemessenen Ergebnisse verlässlich sindDie maximale Messdistanz wird von zwei Aspekten beschränktZum Einen von der Abnahme der Menge des reflektierten Lichts, zum Anderen vom Unvermögen des OPS, kleine Positonsänderungen des reflektierten Strahls zu registrierenMisst man die Entfernung zu Objektenwelche zu weit entfernt sind, entspricht der Output nahezu dem, bei der Messung zur maximalen Distanz. 
 +Die minimale Entfernung wird durch die Besonderheit der Sharp Sensoren eingeschränkt. So fällt der Output steil absobald die Entfernung einen bestimmten Punkt unterschreitet (je nach Baureihe liegt dieser bei bis 20 cm) Das hat zur Folge, dass zu einem Outputwert zwei korrespondierende Entfernungswerte existieren. 
 +Dieses Problem kann vermieden werden, indem beachtet wird, dass die Distanz zwischen Objekt und Sensor nicht zu gering ist.
                        
-=== Practice  ===+=== Übung  ===
  
-The HomeLab set of sensors includes IR distance sensor SHARP GP2Y0A21YK. Measuring range of the sensor is 10 cm – 80 cm. The output voltage of this sensor is, depending on the distance measured, up to 3 V. The distance sensor is connected to the Sensor moduleIts output voltage is sent to the channel 0 of the analogue-digital converter of the AVR. On the basis of previous exercises of sensorsit is easy to write a program which measures the output voltage of the distance sensorsbut in addition, this exercise includes converting this output voltage to distance +Das HomeLab Sensor-Kit enthält den Infrarot-Entfernungsmesser SHARP GP2Y0A21YK.  
 +Der Messbereich dieses Sensors liegt zwischen 10 cm und 80 cm. Seine Output-Spannung hängt von der Entfernung ab und erreicht bis zu 3 V. Der Entfernungssensor ist am Sensormodul angeschlossenDie Output-Spannung wird über Kanal 0 zum ADC des AVR gesendetAufbauend auf den vorangehenden Übungen zu Sensorenist es einfach ein Programm zu schreibenwelches die Output-Spannung des Entfernungsmessers misst. Zusätzlich dazu behandelt diese Aufgabe die Umwandlung der Spannung in eine Entfernung.
  
-On the datasheet of the GP2Y0A21YK is graph of relation between its output voltage and measured distanceThis graph is not a linear one, however the graph of inverse values of output voltage and distance almost is, and from that is quite easy to find the formula for converting voltage to distanceTo find the formulathe points of the same graph must be inserted to any kind of spreadsheet application and then generate a new graphIn spreadsheet programs is possible to calculate automatically the trend-lineNextthe graph of GP2Y0A21YK corrected output voltage inverse value’s relation to the corrected inverse value of measured distance with linear trend-line is presented. To simplify, the output voltage is already converted to 10 bit +5 V values of analogue-digital converter with comparison voltage +Das Datenblatt des GP2Y0A21YK beinhaltet einen Graphen welcher die Relation von Output-Spannung und gemessener Entfernung darstelltDieser Graph verläuft nicht linear. Der Graph der inversen Werte ist jedoch annähernd linearwodurch relativ einfach die Formel zur Umwandlung von Spannung in Entfernung gefunden werden kannHierzu werden Punkte des Graphens in ein Tabellenkalkulationsprogramm eingefügt und so ein neuer Graph generiert. Die meisten Programme berechnen automatisch eine Trendlinie. 
 +Nachfolgend ist der Graph des GP2Y0A21YK mit der Relation der korrigierten inversen Werte der Outputspannung zu den korrigierten inversen Werten der gemessenen Distanzinklusive einer Trendlinie abgebildet. Zur Vereinfachung wurde die Output-Spannung schon in 10-Bit +5 V Werte des ADC mit Vergleichspannung konvertiert.
  
-[{{  :examples:sensor:ir_distance:sensor_ir_distance_gp2y0a21yk_graph_calculation.png?580  |The graph of linearizing ADC value and distance}}]+[{{  :examples:sensor:ir_distance:sensor_ir_distance_gp2y0a21yk_graph_calculation.png?580  |Graph zur linearen Darstellung von ADC Wert und Entfernung}}]
  
-As seen on the graphthe trend-line (blue) overlaps quite precisely with the points of the graphSuch overlapping is achieved by using the help of the corrective constantThis corrective constant is discovered by using the trial-and-error method – many variables were tested until such was found which made the graph overlap the trend-line the mostThis corrective constant of present graph is +2; this means that to all real distances +2 is addedThis way the graph is very similar to the linear trend line and a generalization can be made and +Wie der Graph zeigtüberschneiden sich die blaue Trendlinie und die Punkte des Graphen fast genauDieses wird durch die Nutzung einer Korrektur-Konstante erreichtDiese Konstante wird mit der "trail-and-error"-Methode gefunden - es werden dabei viele Variablen getestet, bis diejenige gefunden ist, die den Graph mit der Trendlinie überlappen lässt. 
- say that the relation between the distance and the voltage is following:+Im abgebildeten Graph ist die Korrektur-Konstantet +2; das bedeutet, zu allen realen Entfernungen muss +2 hinzuaddiert werdenDaruch verläuft der Graph nahezu gleich der Trendline und es kann für die Relation zwischen Entfernung und Spannung verallgemeinert folgende Formel angenommen werden:
  
 1 / (d + k) = a * ADC + b 1 / (d + k) = a * ADC + b
  
-where +wobei
- +
-  * d - distance in centimeters. +
-  * k - corrective constant (fund using tial-and-error method) +
-  * ADC - digitalized value of voltage. +
-  * a - linear member (value is determined by the trend line equation) +
-  * b - free member(value is determined by the trend line equation)+
  
 +  * d - Entfernung in cm.
 +  * k - Korrektur-Konstante (gefunden mittels trial-and-error Methode)
 +  * ADC - digitalisierter Wert der Spannung.
 +  * a - lineares Element (Wert wird durch die Trendlinien-Gleichung bestimmt)
 +  * b - freies Element (Wert wird durch die Trendlinien-Gleichung bestimmt)
  
-Distance can be expressed from the formula:+Die Entfernung kann durch folgende Formel dargestellt werden:
  
 d = (1 / (a * ADC + B)) - k d = (1 / (a * ADC + B)) - k
  
-Now it is basically possible to calculate the distance by using this formulabut this requires floating-point calculations, since while dividing fractions will occurBecause the microcontroller operates using integersthe formula must be simplified and converted to larger ratiosThen when dividing the quotient with a linear-member it will look as follows:+Nun ist es generell möglich die Entfernung mit der Formel zu berechnen. Da jedoch Brüche dividiert werdensind zudem Gleitkomma-Berechnungen nötigWeiterhin muss die Formel vereinfacht und auf größere Quotienten ausgeweitet werdenda Microcontroller mit Ganzzahlen arbeitenDurch die Division des Quotienten mit einem linearen Element erhält man folgende Formel:
  
 d = (1 / a) / (ADC + B / a) - k d = (1 / a) / (ADC + B / a) - k
  
-When introducing the corrective constant to the formula and also the linear-member and the free-member from the trend-line equationthe formula for calculating the distance will be:+Durch Aufnahme der Korrekturkonstante sowie des linearen und freien Elements der Trendlinien-Gleichungergibt sich folgende Formel zur Berechnung der Entfernung:
  
 d = 5461 / (ADC - 17) - 2 d = 5461 / (ADC - 17) - 2
  
-This formula is computable with 16-bit integers and completely suitable to AVR. Before calculatingmust be ensured that the value of the ADC is over 17, otherwise dividing with or negative distance may occur+Diese Formel kann mit 16-Bit Zahlen berechnet werden und ist daher vollständig für den AVR geeignetVor der Berechnung muss sicher gestellt seindass der Wert des ADC größer als 17 istansonsten kann der Fall eintreten, dass durch geteilt werden muss oder eine negative Distanz ausgegeben wird
  
-Following is the function for converting the values of ADC to centimetersit is written in the library of the HomeLab. Linearand free-member and corrective constant are not stiffly written into the functionthey are fed with the structure object parameters of the IR distance sensor. By holding the parameters in separate constantit is easy to add new IR distance sensors to the program +Nachfolgend ist die Funktion dargestelltdie dazu dient, ADC-Werte in Centimeter zu konvertieren. Sie ist in der HomeLab Library enthaltenLineare und freie Elemente sowie die Korrektur-Konstantesind nicht fest in die Funktion integriert, sondern werden mittels der Objektparameter des Infrarot-Entfernungsmessers eingespeist. Dadurch, dass diese Parameter als separate Konstanten verwendet werdenist es sehr einfach, neue Infrarot-Entfernungsmesser in das Programm zu integrieren.
  
  
 <code c> <code c>
 // //
-// The structure of the parameters of the IR distance sensors+// Die Struktur der Parameter des Infrarot-Entfernungsmessers
 // //
 typedef const struct typedef const struct
Line 4239: Line 3724:
  
 // //
-// The object of the parameters of GP2Y0A21YK sensor+// Die Parametereigenschaften des GP2Y0A21YK Sensors
 //  // 
 const ir_distance_sensor GP2Y0A21YK = { 5461, -17, 2 }; const ir_distance_sensor GP2Y0A21YK = { 5461, -17, 2 };
  
 // //
-// Converting the values of the IR distance sensor to centimeters +// Konvertieren der Werte des Infrarot-Entfernungsmessers in Centimeter  
-// Returns -1, if the conversion did not succeed+// Gibt -1 auswenn die Konvertierung nicht erfolgreich war
 // //
 signed short ir_distance_calculate_cm(ir_distance_sensor sensor, signed short ir_distance_calculate_cm(ir_distance_sensor sensor,
Line 4259: Line 3744:
 </code> </code>
  
-To make the conversion the function //ir_distance_calculate_cm// must be engagedThe first parameter of this function is the object of the parameters of the IR distance sensorsecond is the value of the ADC. The function returns the calculated distance in centimetersIf the operation is wrong (unnatural value of the ADC) the returned value is -1.  Following program demonstrates the use of IR distance sensor and conversion functionAlphanumeric LCD is usedwhere measured results are displayedIf the distance is unnatural “?” is displayed  +Zur Durchführung der Konvertierung muss die Funktion //ir_distance_calculate_cm// genutzt werdenDer erste Funktionsparameter gibt die Eigenschaften der Parameter des Infrarot-Entfernungsmessers ander zweite den ADC-WertDie Funktion gibt dann die berechnete Entfernung in Centimetern ausSchlägt die Konvertierung fehl (unzulässige ADC-Werte), wird der Wert -1 ausgegebenDas folgende Programm veranschaulicht die Verwendung des Infrarot-Entfernungsmessers und der KonvertierungsfunktionEs wird das alphanumerische LCD genutztauf welchem die gemessenen Werte dargestellt werdenFalls die Distanz unzulässig ist, wird ein "?" angezeigt.
  
 <code c> <code c>
 // //
-// The example program of the IR distance sensor of the HomeLab +// Beispielprogramm des Infrarot-Entfernungsmessers des HomeLab 
-// Measured results in centimeters is displayed on the LCD+// Die in Centimetern gemessenen Ergebnisse werden auf dem LCD abgebildet
 // //
 #include <stdio.h> #include <stdio.h>
Line 4273: Line 3758:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 4281: Line 3766:
  char text[16];  char text[16];
    
- // Initialization of LCD+ // External sensor selection 
 + pin ex_sensors = PIN(G, 0); 
 + pin_setup_output(ex_sensors); 
 + pin_set(ex_sensors); 
 + 
 + // Initialisierung des LCD
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
    
- // Clearing the LCD+ // Löschen des LCD
  lcd_alpha_clear();  lcd_alpha_clear();
    
- // Name of the program+ // Name des Programms
  lcd_alpha_write_string("Distance sensor");  lcd_alpha_write_string("Distance sensor");
    
- // Setup of the ADC+ // Installation des ADC
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
    
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Reading the 4 times rounded value of the output voltage of the sensor+ // Auslesen des viermal gerundeten Wertes der Outputspannung des Sensors
  value = adc_get_average_value(0, 4);   value = adc_get_average_value(0, 4);
  
- // Conversing ADC value to distance+ // Konvertieren des ADC-Wertes in Entfernung
  distance = ir_distance_calculate_cm(GP2Y0A21YK, value);  distance = ir_distance_calculate_cm(GP2Y0A21YK, value);
  
- // Was the calculation successful?+ // War die Berechnung erfolgreich?
  if (distance >= 0)  if (distance >= 0)
  {   {
- // Conversing distance to text+ // Konvertieren von Entfernung in Text
  sprintf(text, "%d cm   ", distance);  sprintf(text, "%d cm   ", distance);
  }  }
  else  else
  {   {
- // Creating the text for unknown distance+ // Text für eine unbekannte Entfernung erzeugen
  sprintf(text, "? cm   ");  sprintf(text, "? cm   ");
  }  }
  
- // Displaying the text in the beginning of the second row on the LCD+ // Anzeige des Textes am Anfang der zweiten Zeile auf dem LCD
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
  lcd_alpha_write_string(text);  lcd_alpha_write_string(text);
Line 4324: Line 3814:
 </code> </code>
  
-=== Extra materials ===+=== Zusätzliches Material ===
  
-  * {{:examples:sensor:ir_distance:ir_distance.ods|Graph of the Sharp GP2Y0A21YK sensor}} +  * {{:examples:sensor:ir_distance:ir_distance.ods|Graph des Sharp GP2Y0A21YK Sensors}} 
-  * [[http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html|Linearizing Sharp Ranger Data]]+  * [[http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html|Linearisierung der Sharp Entfernungsdaten]]
  
-==== Ultrasonic distance sensor ====+==== Ultraschall-Entfernungsmesser ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:controller]], [HW] [[en:hardware:homelab:lcd]], [AVR] [[en:avr:timers]], [LIB] [[en:software:homelab:library:timer]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:controller]], [HW] [[en:hardware:homelab:lcd]], [AVR] [[en:avr:timers]], [LIB] [[en:software:homelab:library:timer]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:sensor:ultrasonic_distance:sensor_ultrasonic_srf04.jpg?160|Ultrasonic distance sensor SRF04}}]+[{{  :examples:sensor:ultrasonic_distance:sensor_ultrasonic_srf04.jpg?160|Ultraschall-Entfernungsmesser SRF04}}]
  
-Ultrasonic distance sensor determines the distance to an object by measuring the time taken by the sound to reflect back from that objectThe frequency of the sound is somewhere in the range of ultrasoundthis ensures more concentrated direction of the sound wave because sound at higher frequency dissipates less in the environmentA typical ultrasonic distance sensor consists of two membranesOne membrane produces soundanother catches reflected echoBasically they are speaker and microphoneThe sound generator generates short (the length is a couple of periodsultrasonic impulses and triggers the timerSecond membrane registers the arrival of the sound impulse and stops the timer.From the timers time it is possible to to calculate the distance traveled by the soundThe distance to the object is half of the distance traveled by the sound wave   +Ein Ultraschall-Entfernungsmesser bestimmt die Entfernung zu einem Objekt, indem er die Zeit misst, die ein Schall zu einem Objekt hin und zurück benötigtDie Frequenz des Geräusches liegt im Bereich des Ultraschalls. Dies garantiert, dass die Schallwelle gebündelt gelenkt wirdda sich hochfrequenter Schall weniger in der Umgebnung zerstreutEin typischer Ultraschall-Entfernungsmesser besteht aus zwei MembranenEine Membran produziert den Schalldie andere empfängt das EchoIm Grunde besteht er also aus einem Lautsprecher und einem MikrophonDer Schallgenerator generiert kurze (wenige Perioden umfassendeUltraschallimpulse und startet den TimerDie zweite Membran registriert die Ankunft des Echos und stoppt den TimerMit der Zeit des Timers ist es möglich, die zurückgelegte Entfernung des Schalls zu berechnenDie Entfernung zu einem Objekt entspricht der Hälfte der zurückgelegten Entfernung des Schalls
  
-[{{  :examples:sensor:ultrasonic_distance:sensor_ultrasonic_principle.png?280|Working principle of the ultrasonic distance sensor.}}]+[{{  :examples:sensor:ultrasonic_distance:sensor_ultrasonic_principle.png?280|Funktionsweise eines Ultraschall-Entfernungsmessers.}}]
  
-The ultrasonic sensors have quite a lot of use in everyday lifeThey are used to replace measuring tapes in measuring devices at construction sitesCars are equipped with ultrasonic parking sensors. Besides measuring distancesthey can just register the presence of the object in the measuring rangefor example in danger zones of working machinesIf ultrasound transmitter and receiver are separatedthe flowing speed of the substance between them can be measuredbecause the sound wave travels slower upstream and vice versa+Der Ultraschall-Entfernungsmesser findet im täglichen Leben eine Vielzahl von AnwendungsmöglichkeitenEr wird beispielsweise als Ersatz für Maßbänder auf Baustellen eingesetzt, Autos besitzen Ultraschall-Entfernungsmesser als ParksensorenNeben der Entfernungsmessung dient er auch dazudas bloße Vorhandensein eines Objekts im Messbereich zu erkennenz. B. in der Gefahrenzone einer ArbeitsmaschineSind Ultraschalltransmitter und -empfänger getrenntkann die Fließgeschwindigkeit des Materials zwischen ihnen bestimmt werdenda Schallwellen langsamer aufwärts fließen
  
-=== Practice ===+=== Übung ===
  
-HomeLab is equipped with Devantech SRF04/SRF05 ultrasonic distance sensor. SRF04/SRF05 is just a sensor and it does not give direct information about the distanceBesides the power supply pins the sensor has also a triggering pin and a echo pinWhen the triggering pin is set high the sensor generates 40 kHz ultrasonic wave which is 8 periods longAt that moment the echo pin becomes high and remains high until the reflected sound is reached back to the sensorSo the echo signal reflects basically the time during which the sound reaches to the object and comes back from the objectBy measuring that time and multiplying it by the speed of sound and then divide it by twois calculated the distance to the objectThe following graph represents the relationship of time and the signals of sound transmittertrigger and echo:  +Das HomeLab enhält einen Devantech SRF04/SRF05 Ultraschall-EntfernungsmesserDer SRF04/SRF05 ist jedoch nur ein Sensor und gibt keine direkte Information über die DistanzNeben den Stromversorgungspins besitzt der Sensor auch einen Trigger- und einen Echo-Pin. 
 +Ist der Trigger-Pin "high", generiert der Sensor eine acht Perioden lange 40 kHz UltraschallwelleDaraufhin wird der Echo-Pin "high" und bleibt "high", bis das Echo zurück kommtDas Echo-Signal gibt also generell die Zeit an, die der Schall benötigt um das Objekt zu erreichen und zum Sensor zurück zu kommenDie Entfernung zum Objekt ergibt sich darausdass die gemessene Zeit mit der Schallgeschwindigkeit multipliziert und dann durch zwei dividiert wirdDer folgende Graph zeigt den Zusammenhang zwischen Zeit und den Signalen des EmpfängersTriggers und des Echos:  
  
-[{{  :examples:sensor:ultrasonic_distance:sensor_ultrasonic_signals.png?280|The signals of the SRF04}}]+[{{  :examples:sensor:ultrasonic_distance:sensor_ultrasonic_signals.png?280|Die Signale des SRF04}}]
  
-To use the SRF04/SRF05 with the AVR, its trigger pin and echo pin should be connected to some of the AVR pins For measuring timeit is suitable to use a 16-bit timerfor example //timer3//Following is a function which executes all measuring procedures – it generates the signal of the triggerstarts the timermeasures the length of the echo signal and converts it to the distance in centimetersThe function is blockingmeaning the processor is occupied by it until the result of measuring is received or the measuring takes too long timeThe faster the echo arrives the faster the result is returnedIf the echo does not arrivethe function waits for it for 36 ms and returns to 0. It is important to leave approximately 20 ms break between each measuringto able the sound generated during the previous measuring to die out and the new measuring will not be affectedIt is important to notice that the sound waves don’t disturb each otherwhen several ultrasonic sensors are used simultaneously+Um den SRF04/SRF05 mit dem AVR zu nutzenmüssen Trigger- und Echo-Pin an den AVR Pins angeschlossen werdenZur Zeitmessungsollte ein 16-Bit Timer genutzt werdenz.B. //timer3//Nachfolgend ist eine Funktion dargestelltdie alle Messvorgänge ausführt - sie generiert das Signal des Triggersstartet den Timer, misst die Länge des Echosignals und konvertiert dies zur Entfernung in CentimeternDie Funktion blocktdas bedeutet sie hält den Prozessor beschäftigt, bis die Messung abgeschlossen ist oder zu lange dauertJe schneller das Echo ankommt, desto schneller erhält man ein ErgebnisFalls kein Echo ankommtwartet die Funktion 36 ms und geht dann auf zurückEs ist wichtig zwischen den Messungen eine Pause von mindestens 20 ms Pause einzuhaltenum den Soundgenerator komplett zum Stillstand kommen zulassen, so dass die neue Messung nicht durch die alte beeinträchtigt wird. 
 +Außerdem sollte darauf geachtet werdendass die Schallwellen sich nicht gegenseitig stören, wenn verschiedene Ultraschallsensoren gleichzeitig genutzt werden.
  
 <code c> <code c>
Line 4355: Line 3847:
  
 // //
-// Instant ultrasonic distance measuring+// Sofortige Ultraschall-Entfernungsmessung
 // //
 unsigned short ultrasonic_instant_measure(pin trigger, pin echo) unsigned short ultrasonic_instant_measure(pin trigger, pin echo)
 {  {
- // Pin setup+ // Pin-Setup
  pin_setup_output(trigger);  pin_setup_output(trigger);
  pin_setup_input_with_pullup(echo);  pin_setup_input_with_pullup(echo);
  
- // Set timer to normal mode + // Timer auf den normalen Modus setzen 
- // with period of F_CPU / 8+ // mit der Periode des F_CPU / 8
  timer3_init_normal(TIMER3_PRESCALE_8);  timer3_init_normal(TIMER3_PRESCALE_8);
  
- // Create trigger pulse+ // Erzeugung des Aulöse-Impulses
  pin_set(trigger);  pin_set(trigger);
   
- // Reset timer+ // Timer zurücksetzen
  timer3_overflow_flag_clear();  timer3_overflow_flag_clear();
  timer3_set_value(0);   timer3_set_value(0);
   
- // Wait ~10 us+ // ~10 us warte
  while (timer3_get_value() < 18) {}  while (timer3_get_value() < 18) {}
   
- // End trigger pulse+ // Auslöse-Impuls beenden
  pin_clear(trigger);  pin_clear(trigger);
   
- // Wait for echo start+ // Warten auf den Echo-Start
  while (!pin_get_value(echo))  while (!pin_get_value(echo))
  {  {
Line 4390: Line 3882:
  }  }
   
- // Reset timer again+ // Timer erneut zurücksetzen
  timer3_set_value(0);  timer3_set_value(0);
   
- // Wait for echo end + // Warten auf Beendigung des Echos
  while (pin_get_value(echo))  while (pin_get_value(echo))
  {  {
Line 4403: Line 3895:
  }  }
   
- // Convert time to distance+ // Konvertierung von Zeit in Entfernung
- //   distance timer * (1 / (F_CPU / 8)) * speed / 2+ //   Entfernung Timer * (1 / (F_CPU / 8)) * Geschwindigkeit / 2
  return (unsigned long)timer3_get_value() *  return (unsigned long)timer3_get_value() *
  ULTRASONIC_SPEED_OF_SOUND / (F_CPU / 4);  ULTRASONIC_SPEED_OF_SOUND / (F_CPU / 4);
Line 4410: Line 3902:
 </code> </code>
  
-Presented function allows the user to choose the echo pin and the trigger pinso the sensor can be connected where it is more suitable or where is more spaceIn additionthe freedom of choosing the pins allows to use the function also elsewhere than only in the HomeLab. Presented function belongs already to the library of the HomeLab so it is not necessary to write itOne thing must be rememberedthe function in the library of the HomeLab is stiffly connected to the clock rate of the Controller module of the HomeLab. The clock rate is 14,7456 MHz and while using the function with other clock-ratesit would give incorrect result. To use the function with other clock-ratesit should be written in the program manuallyFollowing code of program demonstrates the use of SRF04/SRF05 ultrasonic sensor with the library of the HomeLab.    +Die gegebene Funktion erlaubt dem Nutzer den Echo-und den Trigger-Pin so zu wählendass der Sensor dort angeschlossen werden kann wo es am günstigesten ist und genug Platz vorhanden istZusätzlich erlaubt diesdie Funktion auch außerhalb von HomeLab zu nutzenDie dargestellte Funktion ist bereits in der HomeLab Library enthalten und muss somit nicht geschrieben werdenEs gibt noch eine Sache zu beachtenDie Funktion in der Library ist streng an die Taktrate des Controller-Moduls von HomeLab gekoppeltDie Taktrate beträgt 14,7456 MHz, wenn die Funktion mit anderen Taktraten genutzt wirdliefert sie falsche ErgebnisseUm die Funktion mit anderen Taktraten zu nutzen sollte sie manuell programmiert werden. Der folgende Code demonstriert die Nutzung des  SRF04/SRF05 Ultraschall-Entfernungsmessers mit der HomeLab Library:
  
 <code c> <code c>
 // //
-// The example program of the ultrasonic distance sensor of the HomeLab +// Beispielprogramm für den Ultraschall-Entfernungsmesser des HomeLab 
-// Measuring the distance is blocking.+// Die Entfernungsmessung wirkt blockierend.
 // //
 #include <stdio.h> #include <stdio.h>
Line 4424: Line 3916:
  
 // //
-// Pins of ultrasonic sensor+// Pins des Ultraschallsensors
 // //
 pin pin_trigger = PIN(G, 1); pin pin_trigger = PIN(G, 1);
Line 4430: Line 3922:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 4437: Line 3929:
  char text[16];   char text[16];
    
- // Initialization of the LCD+ // Initialisierung des LCD
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
    
- // Clearing of the LCD+ // Löschen des LCD
  lcd_alpha_clear();  lcd_alpha_clear();
    
- // Name of the program+ // Name des Programms
  lcd_alpha_write_string("Ultra sound");  lcd_alpha_write_string("Ultra sound");
  
- // Little break+ // Kleine Unterbrechung
  sw_delay_ms(100);  sw_delay_ms(100);
  
-  // Endless loop.+  // Endlosschleife.
  while (true)  while (true)
  {  {
- // Measuring+ // Messen
  distance = ultrasonic_measure(pin_trigger, pin_echo);  distance = ultrasonic_measure(pin_trigger, pin_echo);
  
- // Was the measuring successful ?+ // War die Messung erfolgreich?
  if (distance > 0)  if (distance > 0)
  {   {
- // converting the distance to text.+ // Konvertierung von Entfernung in Text.
  sprintf(text, "%d cm   ", distance);  sprintf(text, "%d cm   ", distance);
  }  }
- // Were there errors during the measuring ?+ // Sind während der Messung Fehler aufgetreten?
  else  else
  {  {
- // Text of the errer.+ // Text des Fehlers.
  sprintf(text, "Error    ");  sprintf(text, "Error    ");
  }   }
  
- // Displaying the text in the beginning of the second row of the LCD+ // Darstellung des Textes am Anfang der zweiten Zeile des LCD
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
  lcd_alpha_write_string(text);  lcd_alpha_write_string(text);
    
- // Little break.+ // Kleine Unterbrechung.
  sw_delay_ms(500);  sw_delay_ms(500);
  }  }
 } }
 </code> </code>
-==== Exercises ====+--- 
 + MISSING PAGE --- 
 +==== Übungen ====
  
-The goal is to write a program which executes following task:+Ziel ist es, ein ein Programm zu schreiben welches folgende Aufgaben ausführt:
  
-=== Warm-up exercise === 
  
-  * The value of the resistance of the potentiometer is displayed on the LCD in ohms. The nominal value of the resistance is 5 kΩ. +=== Aufwärmübung ===
  
-=== For beginners =+  * Der Widerstand des Potentiometers soll auf dem LCD in Ohm angezeigt werden. Der nominale Wert des Widerstands beträgt 5 kΩ. 
  
-  - The value of the resistance of the potentiometer in the range of (0 Ω…999 Ω) is displayed in ohms and in the range of (1000 Ω…5000 Ω) in kilo ohms. The nominal value of the resistance of the potentiometer is 5kΩ. The result is displayed in correct units and correct symbols.    +=== Für Anfänger =
-  - Measuring the distance to an object. The distance to an object is measured with an IR sensor by pressing the button S1. During the measuring yellow LED is blinked. If the object is beyond 50 cm a green LED is lit and when the object is closer than 50 cm a red LED is lit. +
-  - The distance to an object is measured using an IR sensor. The result is displayed in binary system using three LEDs (LED1, LED2, and LED3). If the distance is growing,  the displayed value must grow respectively. The scale should be approximately 1 bit 1 dm. +
-  - The value of the NTC temperature sensor is displayed on the LCD in degrees. By pressing the S2 button the units may be selected: Kelvin (K), Fahrenheit (F) and Celsius (C). The temperature is displayed in correct units and symbols. +
-  - By using a light intensity sensor, rapid changes of light intensity are registered (switching lamps on-off). If the change is rapid, red LED is blinked for 5 seconds. If the light changes smoothly the direction of the change is shown. Green LED means that the light intensity grows and yellow shows that it diminishes.+
  
-=== For advanced ===+  - Der Widerstand des Potentiometers wird im Bereich von (0 Ω…999 Ω) in Ohm dargestellt und im Bereich von (1000 Ω…5000 Ω) in kOhm. Der nominale Wert des Widerstands beträgt 5 kΩ.  Das Ergebnis wird mit korrekten Einheiten und Symbolen dargestellt.    
 +  - Messung der Distanz zu einem Objekt. Die Distanz zu dem Objekt wird mit einem Infrarot-Entfernungsmesser gemessen wenn der Schalter S1 betätigt wird. Während der Messung blinkt eine gelbe LED. Ist das Objekt weiter als 50 cm entfernt, leuchtet eine grüne LED, ist es weniger weit entfernt, die rote. 
 +  - Die Distanz zu dem Objekt wird mit einem Infrarot-Entfernungsmesser gemessen. Das Ergebnis wird im binären System mit den 3 LEDs dargestellt (LED1, LED2, und LED3). Vergrößert sich die Entfernung, muss auch der angezeigte Wert größer werden. Als Skala sollte etwa 1 dm 1 Bit verwendet werden. 
 +  - Der Wert des NTC Temperatursensors wird auf dem LCD in Grad angezeigt. Durch Betätigung des Schalters S2 können die Einheiten ausgewählt werden: Kelvin (K), Fahrenheit (F) und Celsius (C). Die Temperatur wird in korrekten Einheiten und Symbolen angezeigt. 
 +  - Mit dem Lichtintensitätssensor werden schnelle Änderungen der Lichtintensität festgestellt. (Licht an- / ausschalten). Verläuft die Änderung schnell, blinkt die rote LED für 5 Sekunden. Ändert sich die Intensität langsam, wird die Änderungsrichtung gezeigt. Die grüne LED zeigt an, dass die Lichtintensität ansteigt, die gelbe, dass sie abnimmt. 
  
-  - Data recorder. The values of all analogue sensors are measured constantly and minimum and maximum values are recorded. By pressing button S1 the user may change the information displayed on the LCD. Displayed must be: name of the sensor (shortly) and present minimum and maximum values. The sequence of changing the sensors: IR distance sensor -> Photoresistor -> Thermistor  -> Potentiometer.  +=== Für Fortgeschrittene ===
-  - Distance sensor. If the button number S2 is pressed, 10 sequential measurements are taken place in one second. After measuring the average distance to the object in decimetres it is displayed on 7-segment indicator. By pressing button S1, minimum measured value is displayed and by pressing button S3 maximum value is displayed.    +
-  - Velocity. According to the changing rate of the distance to the object, it is shown with LEDs as follows: slow change – green LED, moderate change – yellow LED and rapid change red LED. The speed may be displayed on the LCD. +
-  - Automatic measuring range. According to the current measuring results minimum and maximum temperatures measured are found and correspondingly the range in which the values fit is scaled from  0 to 9. Value is displayed on 7-segment indicator. +
-  - By combining IR and ultrasonic distance sensors the distance to the object, velocity of the object and direction of the object are determined. Results are displayed on LCD.+
  
-~~PB~~+  - Datenschreiber. Die Werte aller analogen Sensoren werden konstant gemessen und die minimalen und maximalen Werte werden festgehalten. Mit Betätigung von S1 kann der Nutzer die auf dem LCD angezeigten Information wählen. Angezeigt werden muss: Der Name des Sensors(kurz) und die bislang erreichten minimalen / maximalen Werte. Die Sequenz des Durchschaltens ist folgende: IR Entfernungsmesser -> Fotowiderstand -> Thermistor  -> Potentiometer.  
 +  - Entfernungsmesser. Wenn der Schalter S2 gedrückt wird, werden der Reihe nach 10 Messungen in einer Sekunde durchgeführt. Nach der Messung wird die durchschnittliche Entfernung zum Objekt in Dezimeter auf dem 7-Segment Indikator angezeigt. Bei Betätigung des Schalters S1, wird die minimale gemessene Entfernung angezeigt und durch S3 die maximale.   
 +  - Geschwindigkeit. Die Änderungsrate der Entfernung zu einem Objekt wird wie folgt angezeigt: langsame Änderung - grüne LED, mittlere Änderung - gelbe LED, schnelle Änderung - rote LED. Die Geschwindigkeit wird auf dem LCD dargestellt. 
 +  - Automatische Messreichweite. Je nach aktueller Messung werden die minimal oder maximal  gemessenen Temperaturen augegeben und der zugehörige Wertebereich wird auf einer Skala von 0 bis 9 angezeigt. Der Wert wird auf der 7-Segment-Anzeige dargestellt. 
 +  - Durch Kombination von Infrarot- und Ultraschall-Entfernungsmesser kann die Entfernung zum Objekt, die Geschwindigkeit sowie die Richtung des Objektes bestimmt werden. Die Ergebnisse werden auf dem LCD dargestellt.
  
-=== Questions ===+<pagebreak>
  
-  - How accurate is the digital-analogue converter of ATmega128 microcontrollerHow small is the minimal change of input voltage which can be measured+=== Fragen === 
-  - How long takes one ADC processHow is the operating frequency changed+ 
-  - Which is the the range of input voltage of the ADC? Is it possible to be changedHow+  Wie exakt ist der ADC des ATmega128 MikrocontrollersWelches ist die kleinste noch messbare Veränderung der Inputspannung?  
-  - What is the difference between positive temperature coefficient (PTC) thermistor and negative temperature coefficient(NTC)What are the advantages of each+  - Wie lange dauert ein ADC-ProzessWie kann die Arbeitsfrequenz geändert werden
-  - What is the purpose of a voltage divider in a measuring circuit+  - Welchen Inputspannungsbereich hat der ADC? Kann dieser geändert werdenWie
-  - Combine a voltage dividerwhich allows to use an analogue sensor with ATmega128 microcontrollerThe maximum output voltage of the sensor is 10 V. In addition determine the contents of the ADMUX register+  - Was ist der Unterschied zwischen PTC-Thermistoren und NTC-ThermistorenWorin bestehen die jeweiligen Vorteile
-  - Extra resistors were added to the potentiometer pins and voltage of 5 V were applied on themHow big must be the resistances of extra resistors and the potentiometer so the regulated voltage on the slider of the potentiometer can be regulated between V and 2 V (from one end to the other end)? The current should not exceed 10 mA.  +  - Was ist der Grund eines Spannungsteilers in einem Messschaltkreises
-  - Which parameters of the surroundings have an effect on the functioning of ultrasonic distance sensor and why+  - Kombinieren Sie einen Spannungsteilerwelcher die Nutzung eines analogen Sensors mit dem ATmega128 Mikrocontrollers ermöglichtDie maximale Outputspannung des Sensors beträgt 10 V. Ermitteln Sie zusätzlich den Inhalt des ADMUX Registers
-  - Which light sensitive sensors could be used in a robotics project. Count at least three principal components and explain their differences+  - Zusätzliche Widerstände werden an den Pins des Potentiometers angeschlossen und eine 5 V Spannung wird angelegtWie groß müssen die zusätzlichen Widerstände sein, damit die Spannung vom Potentiometer zwischen und 2 V reguliert werden kann (von einem Ende zum anderen)? Die Stromstärke darf 10 mA nicht überschreiten.  
-  - Besides trigonometrical methodhow is distance determined by using lightName at least 3 methods+  - Welche Umgebungsparameter haben einen Effekt auf die Funktion des Ultraschallentfernungsmessers und warum
-===== Motors =====+  - Welche Lichtsensivitätssensoren können in einem Robotikprojekt genutzt werden? Nennen Sie mindestens 3 grundlegende Komponenten und erklären Sie die Unterschiede
 +  - Wie kannneben der trigonometrischen Methode, die Entfernung mittels Licht gemessen werdenNennen Sie mindestens drei Methoden
 +===== Motoren =====
  
 {{  :examples:motor:motors.jpg?580  |}} {{  :examples:motor:motors.jpg?580  |}}
  
-Motors are actuator devicesactually some of them are and those can also be very differentbeginning with operating principles and ending with power and size. In robotics mainly electric motors are usedElectrical motor is a device which converts electrical energy to mechanical energy (work). It works on principles of electromagnetism. +Motoren sind Antriebsgerätesie können in jeder Form sehr verschieden seinvom Arbeitsprinzip bis hin zu Kraft und Größe. In der Robotik werden hauptsächlich Elektromotoren benutztDiese wandeln elektrische Energie in mechanische Energie (ArbeitumSie funktionieren auf dem Prinzip des Elektromagnetismus.
- +
  
-There are several ways to classify electrical motorsMost important is to divide them as alternate current (AC) and direct current (DC) motorsIn additionthere are electrical motors with brushes and brush-less motors, linear motors and rotary motorsnano-motors and large motors and so onOn the other hand, some of the segmentations are provisionalFor example, linear motion is achieved usually using rotary electrical motorwhich is integrated into unitary body with screw mechanism and treated so as linear actuator. In this chapter are covered three most common types of electrical motors in robotics: DC motor with permanent magnets, RC servos and stepper-motor +Es gibt viele Möglichkeiten, elektrische Motoren zu klassifizierenDie bedeutendste Unterscheidung ist die zwischen AC(Wechselstrom-) und DC- (Gleichstrom-MotorenHinzu kommen Motoren mit Bürsten oder ohnelineare Motoren und RotationsmotorenNano-Motoren und große Motoren uswDahingegen erfolgen einige Klassifizierungen nur provisorischSo werden z.B. lineare Bewegungen durch einen elektrischen Rotationsmotor bewerkstelligtwelcher mit Schrauben in einem einheitlichen Gehäuse verbaut ist und so als linearer Antrieb zählt. In diesem Kapitel werden die drei häufigsten Motoren, die in der Robotik zum Einsatz kommen,beschrieben: DC-Motoren mit Magneten, RC-Servomotoren und Schrittmotor.
  
-==== DC motor ====+==== Gleichstrommotor ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:motor]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:module:motor]], [LIB] [[en:software:homelab:library:delay]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:motor]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:module:motor]], [LIB] [[en:software:homelab:library:delay]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:motor:dc:motor_dc_picture.jpg?220|DC motor}}]+[{{  :examples:motor:dc:motor_dc_picture.jpg?220|DC Motor}}]
  
-Permanent magnet DC motors are very common in different applicationswhere small dimensionshigh power and low price are essentialDue to their fairly high speedthey are used together with transmission (to output lower speed and higher torque).+Ein Gleichstrommotor mit permanenten Magneten wird häufig für die verschiedensten Anwendungen genutztbei denen kleine Ausmaßegroße Kraft und ein geringer Preis entscheidend sindAuf Grund ihrer hohen Geschwindigkeitwerden sie oft mit einer Übersetzung genutzt. (Um eine niedrigere Output-Geschwindkeit und höheres Drehmoment zu erreichen.)
  
-[{{  :examples:motor:dc:motor_dc_performance.png?220|The perfect graph of relationship between speed (V), current (I), power (P), efficiency (η)and torque (T)of a DC motor. }}] 
  
-Permanent magnet DC motors have quite simple construction and their controlling is quite elementaryAlthough controlling is easytheir speed is not precisely determined by the control signal because it depends on several factorsprimarily of the torque applied on the shaft and feeding current. The relationship between torque and speed of a ideal DC motor is linearwhich means: the higher is the load on the shaft the lower is the speed of the shaft and the higher is the current through the coil.+[{{  :examples:motor:dc:motor_dc_performance.png?220|Der perfekte Graph des Verhältnisses von Geschwindigkeit (V)Stromstärke(I)Kraft(P)Effizienz (η) und Drehmoment (T) eines DC Motors}}]
  
-Brushed DC motors are using DC voltage and basically do not need special control electronics because all necessary communication is done inside the motorWhen the motor is operatingtwo static brushes are sliding on the revolving commutator and holding the voltage on the coils. The direction of revolving of the motor is determined by the polarity of the current. If the motor must revolve in only one directionthen the current may come through relay or some other simple connectionIf the motor has to revolve in both directions, then an electronic circuit called H-bridge is used. +Gleichstrommotoren mit permanenten Magneten sind vom Aufbau her sehr einfache und ihre Bedienung ist relativ einfachAber auch wenn die Kontrolle sehr einfach istwird die Geschwindigkeit nicht präzise über das Steuersignal bestimmtweil hierauf noch viele andere Faktoren, wie das Drehmoment und der Speisestrom, einwirkenDas Verhältnis zwischen Drehmoment und Geschwindigkeit ist in einem idealen Gleichstrommotor linearDas bedeutet, je höher das zu erzeugende Drehmoment ist, desto geringer die Geschwindigkeit und desto höher der Strom in der Spule.
-                                   +
-[{{  :examples:motor:dc:motor_h_bridge_principle.png?220|The working principle of H-bridge used on switches.}}]+
  
-In the H-bridge are four transistors (or four groups) directing the current for driving the motorThe electrical scheme of the H-bridge is similar to the letter H and that is where it gets its nameThe peculiarity of the H-bridge is the possibility to apply both directional polarities to the motorPicture on the side shows the principal scheme of the H-bridge based on the example of the switches. If two diagonal switches are closedthe engine starts operatingThe direction of the revolving of the motor depends on in which diagonal the switches are closedIn the real H-bridge the switches are replaced with transistors which are selected according to the current of the motor and voltage+Gleichstrommaschinen nutzen Gleichstrom und brauchen eigentlich keine spezielle Kontrollelektronik, da dienNotwendige Kommunikation im Motor selbst passiertWenn der Motor arbeitet gleiten zwei statische Schleifbürsten an dem sich drehenden Kommutator und halten die Spannung an den SpulenDie Richtung in der sich der Motor dreht, hängt davon ab, wie der der Strom durch den Motor fließtWenn der Motor sich nur in eine Richtung bewegen muss kann der Strom über ein Relais oder ein einfache Schaltung kommen. Falls der Motor sich in zwei Richtungen drehen muss, wird ein Schaltkreis, der Vierquadrantensteller (H-Bridge)genutzt. 
 +                                   
 +[{{  :examples:motor:dc:motor_h_bridge_principle.png?220|Die Arbeitsweise eines Vierquadrantenstellers, genutzt an Schaltern.}}]
  
-In addition to changing direction of revolving the H-bridge allows to change the speed of revolvingTo do thatthe transistors need to be closed and opened constantly using pulse width modulation (PWM), so the total energy supplied to the motor is somewhere between motor switched off and motor running on full powerOpened time in the whole PWM period is called duty cyclewhich is marked as percents0% means the transistor is closed constantly – it is not conducting current100% means the transistor is constantly open and is conducting current all the time. The frequency of the PWM has to be high enough to avoid vibrations in the shaft of the motor. At low frequencies the motor produces noise and due to thatmodulation frequencies over 20 kHz are used quite often. On the other hand the efficiency of the H-bridge is not so good at higher frequencies. Vibrating of the shaft of the motor is reduced by inertia of the rotor and the inductivity of the coils+Der Vierquadrantensteller besitzt vier Transistoren die den Strom lenken, um den Motor zu betreiben. Das elektrische Schaltbild des Vierquadrantenstellers ist ähnlich des Buchstaben H, daher der englische Name H-BridgeDas Besondere am Vierquadrantensteller istdass man damit beide Polaritäten am Motor anlegen kannDas Bild auf der Seite zeit das grundsätzliche Schema eines Vierquadrantenstellers am Beispiel der Schalter. Werden zwei diagonale Schalter geschlossenarbeitet der MotorDie Drehrichtung des Motors hängt davon ab welche diagonalen Schalter geschlossen werdenIm wirklichen Vierquadrantensteller sind die Schalter durch Transistoren ersetztwelche je nach Stromstärke und Spannung des Motors gewählt werden.
  
-There exist also integrated H-bridges, for conducting smaller currentsFor higher currents special power MOSFET-s are usedThe H-bridge with other electronics is called motor controller or driverThe driver of DC motor in the HomeLab L293D includes 2 integrated H-bridges and circuit breaking diodes. The motor is controlled with three digital signals,one of them is operation enabling signal //enable// and the other two are determining the state of the transistors in the H-bridgeNever can occur that two vertical transistors are openedbecause this would short-circuit the power sourceThis means that the driver is designed as foolproof and only option that can be chosen is which transistor (upper or bottom) of one side of the H-bridge (of “semi-bridge”) is openedIn other words the polarity is selected using two driving signals which is applied to the two ends of the coil of the motor.+Zusätzlich zur Richtungsänderung kann der Vierquadrantensteller auch die Geschwindigkeit des Motors verändernDazu werden die Transistoren konstant durch Pulsweitenmodulation geöffnet und geschlossenDamit ist die Energie, die der Motor erhält irgendwo zwischen vollem und keinem StromdurchflussDie Zeit in der die Transitoren geöffnet sind, wird in der PWM-Periode Arbeitszyklus genanntwelche in % angegeben wird. Bei 0 % ist der Transistor konstant geschlossen und es fließt kein StromBei 100 % ist der Transistor ist durchgehend geöffnetund Strom fließt die ganze ZeitDie Frequenz der PWM muss hoch genug sein, um Vibrationen der Motorwelle zu verhindern. Bei niedrigen Frequenzen produziert der Motor Geräusche, daher wird oft eine Modulationsfrequenz von über 20 kHz genutzt. Auf der anderen Seite ist die Effizienz des Vierquadrantenstellers nicht so gut bei hohen FrequenzenVibrationen der Motorwelle werden durch die Trägheit des Rotors und der Induktionswiderstand der Spulen reduziert.
  
-Note: do not mix up RC PWM signal with ordinary PWM signals.+Es gibt auch integrierte Vierquadrantensteller für niedrigere Stromstärken. Für höhere Stromstärken werden spezielle Metall-Oxid-Halbleiter-Feldeffekttransistoren verwendet. Der Vierquadrantensteller mit anderer Elektronik wird Motorcontroller oder Treiber genannt. 
 +Der Teiber des Gleichstrommotors im HomeLab L293D hat 2 eingebaute Vierquadrantensteller und Ausschaltdioden. Der Motor wird mit drei digitalen Signalen gesteuert, eins davon ist das //enable// Signal, welches Funktionen einschaltet, die anderen beiden bestimmten den Status der Transistoren des Vierquadrantenstellers. Dabei dürfen niemals beide vertikalen Transistoren geöffnet werden, da dadurch ein Kurzschluss verursacht wird. Damit wurde der Treiber "idiotensicher" gemacht, und nur eine Option bzgl. der Transistoren auf einer Seite des Vierquadrantenstellers  ausgewählt werden kann. Anders gesagt, die Polarität wird ausgewählt, indem die beiden Treibersignalen, die an den beiden Enden der Spule des Motors anliegen, genutzt werden.
  
 +Beachte: Verwechslen Sie nicht RC PWM Signal und gewöhnliche PWM Signale.
  
-=== Practice ===+=== Übung ===
  
-The board of the motors of the HomeLab allows connecting up to four DC motorsThe schemes and instructions for connection are found in the chapter “Motors module”Basicallyfor every motor there is a H-bridge which is controlled with two digital output pins of the microcontrollerbecause the //enable// pin is constantly high. If both controlling pins have same valuethen the motor is stopped if different then it revolves in the corresponding directionThe state of the H-bridge is described in the following table:+Das Board der Motoren des HomeLab erlaubt den Anschluss von bis zu 4 GleichstrommotorenDas Schaltbild und die Anleitung für die Anschlüsse können im Kapitel "Motormodul" gefunden werdenFür jeden Motor gibt es einen Vierquadrantenstellerwelcher über zwei digitale Output-Pins des Mikrocontrollers kontrolliert wirdda der //enable// Pin konstant "high" ist. 
 +Wenn beide Kontrollpins den gleichen Wert habenwird der Motor gestoppt. Wenn verschiedene Werte vorliegen, wird der Motor in eine bestimmte Richtung gedrehtDer Status des Vierquadrantenstellers ist in der folgende Tabelle beschrieben:
  
 ^ Input A ^ Input B ^ Output A ^ Output B ^ Result                   ^ ^ Input A ^ Input B ^ Output A ^ Output B ^ Result                   ^
-|  0        0        -        |  -        | The motor is stopped             | +|  0        0        -        |  -        | Der Motor wird gestoppt             | 
-|  1        1        +        |  +        | The motor is stopped             +|  1        1        +        |  +        | Der Motor wird gestoppt              
-|  1        0        +        |  -        | The motor revolves in direction 1 | +|  1        0        +        |  -        | Der Motor dreht in Richtung 1 | 
-|  0        1        -        |  +        | The motor revolves in direction 2 |+|  0        1        -        |  +        | Der Motor dreht in Richtung 2 |
  
-DC motors can be controlled by manipulating directly corresponding driver pins with microcontrollerThough, special functions for driving the motor are in the library of the HomeLab.+Gleichstrommotoren können durch Änderung der dazugehörigen Treiberpins mit dem Mikrocontroller kontrolliert werdenDie speziellen Funktionen um den Motor zu steuern sind in der HomeLab Bibliothek enthalten.
  
 <code c> <code c>
 // //
-// The setup of the pins driving pins.+// Die Einrichtung von Pins als Treiberpins.
 // //
 static pin dcmotor_pins[4][2] = static pin dcmotor_pins[4][2] =
Line 4576: Line 4072:
  
 // //
-// Allowing the control of the chosen DC motor.+// Steuerung des gewählten DC Motors zulassen.
 // //
 void dcmotor_init(unsigned char index) void dcmotor_init(unsigned char index)
Line 4585: Line 4081:
    
 // //
-// Determining the operation and the direction of the chosen DC motor.+// Festlegung der Funktion und Richtung des gewählten DC Motors.
 // //
 void dcmotor_drive(unsigned char index, signed char direction) void dcmotor_drive(unsigned char index, signed char direction)
Line 4594: Line 4090:
 </code> </code>
  
-With the array //dcmotor_pins// in the librarythe controlling pins of four motor-controllers are determinedBefore controlling the motorsfunction //dcmotor_init// with the number of the motor-controller (0 – 3) must be called outIt sets the pins as outputFor controlling is the function //dcmotor_drive//, with it the negative //direction// parameter is used to give to the motor one revolving direction and other direction with positive parameterand if the motor is stopped.+Mit dem Array //dcmotor_pins// aus der Bibliothekwerden die Kontrollpins der vier Motorcontroller bestimmtBevor der Motor gesteuert wirdmuss die Funktion //dcmotor_init// mit der Nummer des Motorcontrollers (0-3) benannt werdenSie setzt die Pins als OutputFür die Steuerung ist die Funktion //dcmotor_drive// vorhandender negative //direction// Parameter gibt die Richtung der Motordrehung andie andere Richtung wird mit dem positiven Parameter angegeben. dient dazu, den Motor anzuhalten.
  
-The following is an example program which controls first and second DC motor so that they alter their revolving direction after every secondThe speed could be controlled if one controlling pin were modulated with PWM signal+Das folgende Beispielprogramm steuert den ersten und zweiten Gleichstrommotor so, dass sie jede Sekunde ihre Drehrichtung ändernDie Geschwindigkeit kann gesteuert werden, wenn ein Kontrollpin mit einem PWM Signal moduliert wird.
  
 <code c> <code c>
 // //
-// Testing program of the DC motor of the motor's module of the home-lab.+// Testprogramm für den DC Motor aus dem DC Motorenmodul des HomeLab.
 // //
 #include <homelab/module/motors.h> #include <homelab/module/motors.h>
Line 4606: Line 4102:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
 { {
- // Variable of direction+ // Richtungsvariable
  signed char direction = 1;  signed char direction = 1;
  
- // Setup of motors no and 2.+ // Einrichtung von Motor und 2.
  dcmotor_init(0);  dcmotor_init(0);
  dcmotor_init(1);  dcmotor_init(1);
   
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // One motor revolves in one direction and the other one to other direction.+ // Ein Motor dreht sich in die eine, der andere in die entgegengesetzte Richtung.
  dcmotor_drive(0, -direction);  dcmotor_drive(0, -direction);
  dcmotor_drive(1, +direction);  dcmotor_drive(1, +direction);
  
- // Break for second.+ // Unterbrechung für Sekunde.
  sw_delay_ms(1000);  sw_delay_ms(1000);
  
- // Reversing the direction.+ // Umkehr der Richtung.
  direction = -direction;  direction = -direction;
  }  }
 } }
 </code> </code>
 +---
 + MISSING PAGE ---
 ==== Servomotor ==== ==== Servomotor ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:motor]], [HW] [[en:hardware:homelab:sensor]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:module:motor]], [LIB] [[en:software:homelab:library:adc]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:motor]], [HW] [[en:hardware:homelab:sensor]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:module:motor]], [LIB] [[en:software:homelab:library:adc]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:motor:servo:motor_servomotor.jpg?220|RC servo motor}}]+[{{  :examples:motor:servo:motor_servomotor.jpg?220|RC Servomotor}}]
  
-[{{  :examples:motor:servo:motor_servo_signal_position.png?220|The relationship between width of the signal and position of Servo PWM.}}]+[{{  :examples:motor:servo:motor_servo_signal_position.png?220|Das Verhältnis von Signalweite und Position der PWM des Servomotors.}}]
  
-Servo motors are often used in radio-controlled (RC) modelsand are very useful in +Servomotoren werden oft in funkgesteuerten (RC) Modellen benutzt und sind sehr nützlich für kleine robotischen Anwendungenda sie sehr kompakt und günstig sind
-different kinds of small robotics applications because they are compact and inexpensive+Ein RC-Servomotor verfügt über einen eingebauten Gleichstrommotorein Getriebeeinen Positionsfeedbacksensor (meistens ein Potentiometerund eine Steuerelektronik. RC-Servomotren können mit einem externen PWM-Signal gesteuert werdenWenn das Signal den RC Servotiming-Vorraussetzungen entspricht"beschreibt" es normalerweise ein Positionsinput für die Servo-Steuer-ElektronikDie Servomotor Elektronik vergleicht die Achsenstellung mit der eingegebenen Position und versucht eine übereinstimmende Position zu erreichen. Das Positionskontrollsignal ist eine durchgehende Rechteckschwingungwie in dem Bild dargestellt
-An RC servo motor includes a built-in DC motorgearboxposition feedback sensor +
-(usually potentiometer)and drive electronics. RC servo motors can be controlled by +
-an external pulse-width modulation (PWM) signalIf a signal meets RC servo timing +
-requirementsit usually “describes” a (target) position input for the servo drive +
-electronics. Servo motor electronics compare the shaft position with the inputted +
-position, trying to find a shaft position where they matchThe position control signal +
-is a continuous square-wave signalas depicted in figure.+
  
-RC (//radio-controlled//servo-motors are very common actuator devices in robotics and model buildingRC servo motors are consisting of small DC motorreduction gear and control logic deviceUsually the rotor of the servo motor moves to a certain position and tries to maintain that position. The position of the rotor depends of the control signal received by the servo motorDepending on the type of the motorthe maximum revolving angle of the motor may differServo motors that revolve constantly are rare. In this casethe control signal determines not the revolving angle but the speed of revolvingServo motor “hack” is also quite commonThis makes the position determining servo motor to constantly revolving servo. In this case the feedback potentiometer is replaced by two fixed resistors and the mechanical resistor that prevents full rotations is removed from the gearA very important characteristic of servo motors is its power-weight ratio.+RC (//radio-controlled//Servomotoren sind in der Robotik und im Modellbau sehr verbreitete AntriebeSie bestehen aus einem kleinen Gleichstrommotoreiner Übersetzung und der logischen KontrolleinheitNormalerweise versucht der Rotor des Servomotors sich in eine bestimmte Position zu bringen und diese zu haltenDie Position des Rotors hängt von dem Kontrollsignal abdass der Servomotor empfangen hatJe nach Typ des Motors kann der maximale Drehwinkel des Motors variieren. Servomotoren, die sich konstant drehen, sind selten. In diesem Fall gibt das Kontrollsignal nicht den Rotationswinkelsondern die Rotationsgeschwindigkeit anServomotor-Hacks sind auch sehr verbreitetHierdurch wird ein positionsbestimmender Servomotor zu einem konstant drehenden. In diesem Fall wird das Feedback Potentiometer durch zwei Widerstände ersetzt, und der mechanische Widerstand, welcher verhindert, dass eine vollständige Rotation stattfinden kann, wird entfernt. 
 +Eine wichtige Eigenschaft des Servomotors ist das Kraft-Gewicht-Verhältnis.
  
-The controlling signal of servo motor is specific pulse with modulated signal (PWM), where width of the pulse determines the position of the rotorThe period of the signal is 20 ms (50 Hz) and the width of the high period is 1 ms – 2 ms. 1 ms marks one extreme position and 2 ms marks the second one. 1,5 ms marks the middle position of the servo motor’s rotor +Das Kontrollsignal des Servomotors ist ein speziell pulsweitenmoduliertes Signal (PWM), bei dem die Pulsweite die Position des Rotors angibtDie Periode des Signals liegt bei 20 ms (50 Hz) und die Weite der hohen Periode ist 1 ms 2 ms. 1 ms markiert die eine äußerste Position 2 ms die Andere. 1,5 ms markieren die Mittelposition des Servomotorrotors.
  
-Traditional RC servo motor is also known as analogue-servo motorIt is because in the last decade so called digital servo motors were becoming commonThe difference between those two is that in analogue servo motor the motor is controlled by the same 50 Hz PWM input signalIn digital servo motor the motor is controlled by a microcontroller with much higher frequency signal. The input signal is the same in the digital servo motor but higher modulation frequency of the motor enables much more precise and faster position determining +Traditionelle RC-Servomotoren sind auch bekannt als analoge ServomotorenDies liegt daran, dass in dem letzten Jahrzehnt so genannte digitale Servomotoren auf den Markt kamenDer Unterschied zwischen beiden besteht darin, dass analoge RC-Servomotoren mit einem 50 Hz PWM Signal gesteuert werden, digitale RC-Servomotoren durch einen Mikrocontroller mit einem höherfrequenten SignalDas Inputsignal ist das Gleiche, jedoch ist durch die höhere Modulationsfrequenz wird eine schnellere und präzisere Positionsbestimmung ermöglicht.
  
 ~~CL~~ ~~CL~~
  
-=== Practice ===+=== Übung ===
  
-On the board of module of motors of the HomeLab are two plugs for connecting RC servo motorsThe PWM ends of the plugs are connected to the PB5 and PB6 pins of the microcontrollerwhich alternative functions are outputs of comparing units and of the timer 1. Timer 1 is capable of producing PWM signal and due to that the control of motors is very simple in the programOnly difficulty is set-up of the timer.+Auf dem Platine des HomeLab Motormoduls sind 2 Anschlüsse für RC-Servomotoren vorhanden. 
 +Die PWM-Enden der Stecker sind an den Pins PB5 und PB6 am Mikrocontroller angeschlossendessen sekundäre Funktion das Vergleichen der Einheiten und von Timer ist. Timer 1 kann ein PWM Signal erzeugen, und daher ist das Steuern eines Motors sehr einfach zu programmierenDie einzige Schwierigkeit besteht im Einstellen des Timers.
  
-  +Timer muss in den PWM-Produktionsmodus eingestellt werdenwobei der maximale Wert des Timers mit dem ICR Register bestimmt wirdDurch Änderung des maximales Wertes im Programm und im Taktgeber des Timerskann die präzise PWM Frequenz zur Steuerung des Servomotors bestimmt werdenMit dem Vergleichs-Register des Timers werden die Längen für beiden hohen Semi-Perioden des Signals bestimmt. Der Timer hat eine spezielle Vergleichseinheitwelche den Wert des Zählwerks beobachtet und für den Fall, dass es gleich dem Wert des Vergleichs-Registers ist, den Output-Wert der Vergleichseinheit ändertEs folgt ein Programm-Code der Servomotor-Steuerbibliothek des HomeLab. Für die Ausführung nutzt es Parameter für Timer welche durch Makrofunktionen bestimmt werdenZum Beispielwird die Periode durch die F-CPU Konstante angegebenwelche die Taktrate des Mikrocontrollers angibtWenn man Makros nutztmüssen die Parameter des Timers für verschiedene Taktzyklen nicht berechnet werden und der Compiler konvertiert die Operationen mit Makros zu Konstanten. Dadurch erhöht sich der Programmspeicher nichtund es wird auch nicht mehr Rechenzeit benötigt.
-The timer must be set up in PWM production modewhere the maximum value of the timer is determined with ICR registerWith the maximum value changed in the program and in the pace divider of the timerthe precise PWM frequency for controlling the servo motor can be determinedWith the comparison register of the timerlengths of both high semi periods of PWM signal can be determinedThe timers have special comparing units which are monitoring the value of the counter and in case it remains equal with the value of the comparison register they change the output value of comparing units. The following is the program code of the servo motor control library of the HomeLab. For the purpose of functionality, it uses parameters for timers which are determined with macro functionsFor examplethe period is found using F_CPU constantwhich marks the clock rate of the microcontrollerWhen using macrosthere is no need to calculate the parameters of timer for different clock rates and the compiler converts the operations with macros to constants anywayso the program memory is not growing and does not demand more time     +
  
  
 <code c> <code c>
 // //
-// The value of the timer (20 ms)for achieving the full period of PWM. +// Der WErt des Timers (20 ms) zum ERreichen der vollen PWM-Periode
-// F_CPU is the clock rate of the microcontroller which is divided with 50 Hz and 8.+// F_CPU ist die Taktrate des Mikrocontrollers, welche durch 50 Hz und dividiert wird.
 // //
 // //
Line 4677: Line 4169:
    
 // //
-// Middle position of PWM servo (5 ms / 20 ms) +// Mittlere Position der PWM des Servomotors (5 ms / 20 ms) 
-// Middle position is 15/200 of full period.+// Mittlere Position liegt bei 15/200 der vollen Periode.
 // //
 #define PWM_MIDDLE_POS  (PWM_PERIOD * 15 / 200) #define PWM_MIDDLE_POS  (PWM_PERIOD * 15 / 200)
    
 // //
-// Factor for converting the percents (-100% to 100%)to periods+// Faktor zur Konvertierung von Prozenten in Perioden(-100% to 100%). 
-// +1 is added to ensure that semi periods would reach to the boundaries of 1 ms and 2 ms or // a little over.+// +1 wird addiert um sicherzustellen, dass die Halbperioden die Grenzen von 1 ms und 2 ms erreichen oder //  etwas höher liegen.
 // //
 #define PWM_RATIO       (PWM_PERIOD / 20 / 2 / 100 + 1) #define PWM_RATIO       (PWM_PERIOD / 20 / 2 / 100 + 1)
  
 // //
-// Set-up of the pins.+// Einrichtung der Pins.
 // //
 static pin servo_pins[2] = static pin servo_pins[2] =
Line 4697: Line 4189:
  
 // //
-// Preparing the servo motor for working.+// Servomotor vorbereiten.
 // //
 void servomotor_init(unsigned char index) void servomotor_init(unsigned char index)
 { {
- // The pin of PWM signal for output.+ // Pin des PWM Signals als Output.
  pin_setup_output(servo_pins[index]);   pin_setup_output(servo_pins[index]); 
    
- // Setup of timer 1. + // Einrichtung von Timer 1. 
- // Prescaler = 8 + // Vorzähler = 8 
- // Fast PWM modewhere TOP = ICR + // Schneller PWM Moduswobei TOP = ICR 
- // OUTA and OUTB to low in comparisson.+ // OUTA und OUTB auf low im Vergleich.
  timer1_init_fast_pwm(  timer1_init_fast_pwm(
  TIMER1_PRESCALE_8,  TIMER1_PRESCALE_8,
Line 4715: Line 4207:
  TIMER1_FAST_PWM_OUTPUT_DISABLE);  TIMER1_FAST_PWM_OUTPUT_DISABLE);
    
- // Determining the period by maximum value.+ // Festlegung der Periode durch maximalen Wert.
  timer1_set_input_capture_value(PWM_PERIOD);   timer1_set_input_capture_value(PWM_PERIOD);
 } }
  
 // //
-// Determining the position of the servo motor+// Festlegung der Postition des Servomotors
-// The parameter of the position is from -100% to +100%.+// Parameter der Position liegen zwischen -100% und +100%.
 // //
 void servomotor_position(unsigned char index, signed short position) void servomotor_position(unsigned char index, signed short position)
Line 4740: Line 4232:
 </code> </code>
  
-The example program uses described functions of the library of the HomeLab. In the beginning of the program the first servo motor’s PWM signal generator is started with the //servomotor_init// functionThe value of the position of the servo motor is obtained from the channel number of the analogue-digital converterwhere a potentiometer on the board of sensors is connectedTo get the range -100 % +100 % necessary for controlling the servo motorhalf of the maximum (512) is subtracted of the ADC value and the result is divided with 5 The result is +/- 102, but small inaccuracy does not count because servo motors also differ by the relation of the PWM signal and revolving angleFinal PWM‘s semi period’s width in applications has to be determined using test-and-error methodAlso the remote controls of RC models have corresponding opportunities for precise setupWhen the program is started the rotors position of the servomotor is changed according to the position of the potentiometer+Das Beispielprogramm nutzt beschriebene Funktionen der HomeLab BibliothekAm Anfang des Programms wird der erste PWM-Signal Generator des Servomotors mit der //servomotor_init// Funktion gestartetDer Wert der Position des Servomotors wird durch die Kanalnummer des Analog-Digital-Konverters (ADC) empfangenan dem ein Potentiometer an der Sensorplatine angeschlossen istUm die Reichweite von -100 % bis +100 %, die für die Steuerung des Servomotors notwendig, ist zu erhalten wird die Hälfte des Maximums (512) vom ADC Wert abgezogen und das Ergebnis durch fünf dividiertDas Ergebnis ist +/- 102, kleine Ungenauigkeiten können unbeachtet bleiben, da Servomotoren sich auch in der Relation des PWM-Signals und des Drehwinkels unterscheidenDie finale PWM Halbperiodenweite in Anwendungen muss über das "Try-and-Error"-Verfahren gefunden werdenAuch wenn die Funksteuerungen von RC-Modellen Möglichkeiten für ein präzises Setup besitzenWenn das Programm läuft, wird die Rotorposition des Servomotors je nach Position des Potentiometers verändert.
  
 <code c> <code c>
 // //
-// Testing program of the motors module of the HomeLab kit.+// Testprogramm des Motormoduls des HomeLab kit.
 // //
 #include <homelab/adc.h> #include <homelab/adc.h>
Line 4750: Line 4242:
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
Line 4756: Line 4248:
  short position;  short position;
  
- // Set-up of the ADC.+ // Einrichtung des ADC.
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
  
- // Set-up of the motor.+ // Einrichtung des Motors.
  servomotor_init(0);  servomotor_init(0);
  
- // Endless loop.+ // Endlosschleife.
  while (true)  while (true)
  {  {
- // Reading the position of the potentiometer and converting the range of + // Auslesen der Position aus dem Potentiometer und Konvertiereung der Reichweite 
- // the servo motor.+ // des Servomotors.
  position = ((short)adc_get_value(3) - (short)512) / (short)5;  position = ((short)adc_get_value(3) - (short)512) / (short)5;
  
- // Determining the position of the servo motor.+ // Festlegung der Position des Servomotors.
  servomotor_position(0, position);  servomotor_position(0, position);
  }  }
 } }
 </code> </code>
-==== Stepper motor ====+==== Schrittmotor ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:motor]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:module:motor]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:motor]], [AVR] [[en:avr:io]], [LIB] [[en:software:homelab:library:module:motor]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:motor:stepper:stepper.jpg?220|Stepper-motor}}]+[{{  :examples:motor:stepper:stepper.jpg?220|Schrittmotor}}]
  
-Stepper motors can generally be divided into unipolar and bipolar steppers+Schrittmotoren können generell in unipolare und bipolare Schrittmotoren eingeteilt werden
-Unipolar stepper motors are characterized by their centre-tapped windingswhich +Unipolare Schrittmotoren haben charakteristische Windungen welche die zwei Spulen in vier unterteilen. Schrittmotoren haben keine eingebauten Bürsten oder Elektronikd.h. jegliche Kommunikation muss extern erfolgenDer am meisten benutzte Kommutationstyp ist der offene-Regelkreis- ("open-loop") Modusder Der Schrittmotortreiber lädt die Spulen nach einem bestimmten Musternutzt aber kein FeedbackSchritte können so verpasst werden falls die Motorwelle eine Drehmomentüberladung erfährtVerpasste Schritte verursachen ungenaue PositionierungBipolare Schrittmotoren haben normalerweise vier Drähte und zwei separate Spulen im InnerenSie ähneln den unipolaren Schrittmotoren stark. Unipolare Schrittmotoren können als bipolare Schrittmotoren genutzt werdenaber nicht umgekehrt.
-divide two coils into fourStepper motors have neither built-in brushes nor internal +
-electronics, meaning all commutation must be performed externally. The most +
-common commutation type is the open-loop modethe motor driver energizes the +
-coils following a certain patternbut uses no feedbackSteps can be missed in case of +
-motor shaft torque overloadMissed steps cause inaccurate positioningBipolar +
-stepper motors usually have four wires and two separate coils inside; they have many +
-features similar to those of unipolar steppersUnipolar stepper motors can be run as +
-bipolar stepper motorsbut not vice versa.+
  
-Stepper-motors are widely used in applications which demand accuracyUnlike DC motorsstepper motors do not have brushes nor commutator – they have several independent coilswhich are commutated with exterior electronics (drivers). Rotating the rotor is done by commutating coils step by stepwithout feedbackThis is one of the faults in stepper motors – in case of mechanical overloadingwhen the rotor is not rotatingthe steps will be mixed up and movement becomes inaccurateTwo types of stepper motors are distinguished by coils unipolar and bipolar stepper motorsBy construction three additional segments are considered:+Schrittmotoren werden oft in Applikationen genutzt, die Genauigkeit benötigenAnders als Gleichstrommotoren haben Schrittmotoren weder Bürstennoch Kommutatoren. Sie haben verschiedene unabhängige Spulenwelche durch externe Elektronik (Treiberangetrieben werdenUm den Rotor anzutreibenwerden die Spulen Schritt für Schritt umgeschaltet, ohne FeedbackDas ist der Nachteil des Schrittmotors. Bei mechanischer Überladungwenn der Rotor nicht rotiertwerden so die Schritte durcheinander gebracht und die Bewegung wird ungenauZwei Typen von Schrittmotoren werden anhand der Spulen unterschiedenUnipolare und bipolare SchrittmotorenDurch Aufbau werden drei zusätzliche Segemente bedacht:
              
-  * Variable Reluctance Stepper (high accuracylow torquelow price+  * Reluktanzschrittmotor (hohe Genauigkeitwenig Drehmomentniedriger Preis
-  * Permanent Magnet Stepper (low accuracyhigh torquelow price+  * Permanentmagnetschrittmotor (niedrige Genauigkeit,hohes Drehmomentniedriger Preis
-  * Hybrid Synchronous Stepper (high accuracyhigh torquehigh price)+  * Hybrider Schrittmotor (hohe Genauigkeithohes Drehmomenthoher Preis)
  
-Variable reluctance stepper motors have toothed windings and toothed iron rotorThe largest pulling force is when the teeth of both sides are covering each otherIn Permanent magnet stepper motor,just like the name hintsare permanent magnets which orientate according to the polarity of the windingsIn hybrid synchronous steppers both technologies are used.+Der Reluktanzschrittmotor verfügt über gezahnte Windungen und einen gezahnten WeicheisenrotorDie größte Zugkraft entsteht, wenn die Zähne beider Seiten sich gegenseitig abdeckenDer Permanentmagnetschrittmotor bestitzwie der Name schon sagtPermanentmagneten welche sich je nach Polarität der Windung orientierenDer hybride Schrittmotor nutzt beide Techniken.
  
-Depending on the model of stepper motorperforming one full rotation (360 degreesof the rotor, demands hundredths of steps of commutationsFor stable and smooth movementappropriate control electronics are used which control the motor according to its parameters (inertia of the rotortorqueresonance etc.). In addition to control electronics different commutating methods may be applied Commutating one winding in a row is called Full Step Drive and if the drive is alternated between one and two windings it is called Half SteppingCosine micro stepping is also usedallowing specially accurate and smooth controlling+Je nach Modell des Schrittmotorsbraucht eine vollständige Rotation (360°des Rotors hunderte Schritte von StromwendungenFür stabile und weiche Bewegungenwird eine bestimmte Kontrollelektronik genutzt, welche den Motor je nach Parameter kontrolliert (Trägheit des RotorsDrehmomentResonanz etc.). Zusätzlich zur Kontrollelektronik werden verschiedene Methoden zur Stromwendung genutztWird eine Windung in Reihe umgewandelt, wird dieser Vorgang "Ganzschrittantrieb" genannt, verändert sich der Antrieb zwischen zwei Wicklungen, nennt man diesen HalbschrittDarüber hinaus werden "Kosinus-Mikroschritte" genutztum eine sehr genaue und weiche Kontrolle zu ermöglichen.
  
  
-~~PB~~+<pagebreak>
  
-**Unipolar stepper-motor **+**Unipolare Schrittmotoren **
  
-[{{  :examples:motor:stepper:motor_stepper_unipolar.png?250|The windings of an unipolar-stepper motor}}]+[{{  :examples:motor:stepper:motor_stepper_unipolar.png?250|Die Wicklungen eines unipolaren Schrittmotors}}]
  
-Unipolar-stepper motor has 5 or 6 leadsAccording to the scheme of the motor only ¼ of the windings is activated. //Vcc// lines are usually connected to the positive power supplyDuring commutation the ends of windings 1a, 1b, 2a and 2b are connected through transistors (transistor array of the motor board ULN2803) only to the ground and that makes their control electronics fairly simple +Unipolare Schrittmotoren haben fünf oder sechs AnschlüsseJe nach Aufbau des Motors werden nur ¼ der Wicklungen aktiviert. //Vcc// Leitungen werden normalerweise an der positiven Stromquelle angeschlossenWährend der Umwandlung sind die Enden der Wicklungen 1a, 1b, 2a und 2b über Transistoren (Transistorarray der Motorplatine ULN2803) nur an die Masse angeschlossen, was die Kontrollelektronik recht einfach macht.
  
-**Bipolar stepper-motor**+**Bipolare Schrittmotoren**
  
-[{{  :examples:motor:stepper:motor_stepper_bipolar.png?250|The Windings of a bipolar stepper-motor.}}]+[{{  :examples:motor:stepper:motor_stepper_bipolar.png?250|Die Wicklungen eines Bipolaren Schrittmotors.}}]
  
-Bipolar stepper motor differs from unipolar stepper motor by having the polarity of the windings altered during the commutationHalf of the windings are activated togetherthis allows to gain higher efficiency than unipolar stepper motorsBipolar stepper motors have four leadseach connected to a different half-bridge (driver L293 on the board of motors). During commutation half-bridges are applying either positive or negative voltage to the ends of the windingsUnipolar motors can be started using bipolar driver: just connect lines 1a, 1b, 2a and 2b of the windings (//Vcc// will be not connected). +Bipolare Schrittmotoren unterscheiden sich von unipolaren, da sie die Polarität ihrer Wicklungen während der Umwandlung verändernDie Hälfte der Wicklungen wird gleichzeitig aktiviertdaher sind sie effizenter als unipolare SchrittmotorenBipolare Schrittmotoren haben 4 Anschlüssejeder wird an einen anderen Vierquadrantensteller angeschlossen (Treiber L293 auf der Motorenplatine). Während der Kommutation legen die Vierquadrantensteller entweder negative oder positive Spannung am Ende der Wicklung anUnipolare Motoren können mit einem bipolaren Treiber gestartet werden indem einfach die Leitungen 1a, 1b, 2a und 2b der Wicklungen angeschlossen werden (//Vcc// wird nicht angeschlossen).
- +
-The commutation necessary for controlling stepper-motors with windings at full step mode and half step mode is displayed in the table below. Since in drivers for uni-polar stepper motors only opening of the transistors takes place, the steps are marked by 0 and 1. Controlling of bipolar stepper motors may need more signals and therefore the steps are marked using the polarity of the driver outputs:  +
  
 +Die notwendige Kommutation, um Schrittmotoren mit Wicklungen im Ganzschrittmodus und im Halbschrittmodus zu kontrollieren, wird in der Tabelle unhalb angezeigt. Da in Treibern für unipolare Schrittmotoren nur das Öffnen von Transistoren stattfindet, werden die Schritte mit 0 und 1 markiert. Zur Steuerung eines bipolaren Schrittmotors braucht es Signale und daher wird jeder Schritt mit der Polarität des Treiber-Outputs markiert:
 + 
  
 ^ ^   Unipolar   ^^^^   Bipolar   ^^^^ ^ ^   Unipolar   ^^^^   Bipolar   ^^^^
-Step ^ 1A ^ 2A ^ 1B ^ 2B ^ 1A ^ 2A ^ 1B ^ 2B ^ +Schritt ^ 1A ^ 2A ^ 1B ^ 2B ^ 1A ^ 2A ^ 1B ^ 2B ^ 
-^   Full step   ^^^^^^^^^+^   Ganzschritt   ^^^^^^^^^
 | 1 ^ 1 | 0 | 0 | 0 ^ + | - | - | - | | 1 ^ 1 | 0 | 0 | 0 ^ + | - | - | - |
 | 2 | 0 ^ 1 | 0 | 0 | - ^ + | - | - | | 2 | 0 ^ 1 | 0 | 0 | - ^ + | - | - |
 | 3 | 0 | 0 ^ 1 | 0 | - | - ^ + | - | | 3 | 0 | 0 ^ 1 | 0 | - | - ^ + | - |
 | 4 | 0 | 0 | 0 ^ 1 | - | - | - ^ + | | 4 | 0 | 0 | 0 ^ 1 | - | - | - ^ + |
-^   Half step   ^^^^^^^^^+^   Halbschritt   ^^^^^^^^^
 | 1 ^ 1 | 0 | 0 | 0 ^ + | - | - | - | | 1 ^ 1 | 0 | 0 | 0 ^ + | - | - | - |
 | 2 ^ 1 ^ 1 | 0 | 0 ^ + ^ + | - | - | | 2 ^ 1 ^ 1 | 0 | 0 ^ + ^ + | - | - |
Line 4838: Line 4322:
 | 8 ^ 1 | 0 | 0 ^ 1 ^ + | - | - ^ + | | 8 ^ 1 | 0 | 0 ^ 1 ^ + | - | - ^ + |
  
-=== Practice ===+=== Übung ===
  
-The goal of this exercise is to start a bipolar stepper motorwhich can be replaced by unipolar stepper motor using the above described methodThere are driverson the board of motors, which must be controlled via four input pins by the microcontrollerEach pin represents the polarity of one end of a winding The voltage of the end of the winding is positive if the pin is high and negative if the pin is low. To the ends 1A, 1B, 2A and 2B correspond the pins of the microcontroller PB0, PB1, PB2 and PB3. +Das Ziel dieser Aufgabe ist esunter Anwendung der oben beschrieben Methode einen bipolaren Schrittmotor zu starten, welcher mit einem unipolaren Schrittmotor getauscht werden kannEs gibt Treiber auf der Motorenplatinewelche vom Mikrocontroller über vier Inputpins kontrolliert werdenJeder Pin gibt die Polarität einer Wicklung wiederDie Spannung am Ende der Wicklung ist positiv wenn der Pin high ist und negativ wenn der Pin low ist. 
- +Zu den Enden 1A, 1B, 2A und 2B gehören die entsprechenden Pins PB0, PB1, PB2 Und PB3 am Mikrocontroller.
-There is function //bipolar_init// in the library of the HomeLab for controlling the bipolar stepper motors setting the pins as output and function //bipolar_halfstep// executes revolving by determined half steps. The commutation is done by the table of half steps, but more complex bit operations are used.   +
  
 +In der HomeLab Bibliothek gibt es die Funktion //bipolar_init//, um bipolare Schrittmotoren zu steuern, indem die Pins als Output gesetzt werden. Die Funktion //bipolar_halfstep// führt Rotationen mit bestimmten Halbschritten aus. Die Kommutation wird mit der Tabelle der Halbschritte durchgeführt, aber es werden komplexere Bitoperationen genutzt.
  
 <code c> <code c>
 // //
-// Preparing for controlling the bipolar stepper motor.+// Vorbereitung der Steuerung des bipolaren Schrittmotors.
 // //
 void bipolar_init(void) void bipolar_init(void)
 { {
- DDRB |= 0x0F; +    DDRB |= 0x0F; 
- PORTB &= 0xF0;+    PORTB &= 0xF0;
 } }
  
 // //
-// Moving the bipolar stepper motor by half steps.+// Bewegung des bipolaren Schrittmotors mit Halbschritten.
 // //
 void bipolar_halfstep(signed char dir, void bipolar_halfstep(signed char dir,
- unsigned short num_steps, unsigned char speed)+    unsigned short num_steps, unsigned char speed)
 { {
- unsigned short i; +    unsigned short i; 
- unsigned char pattern, state1 = 0, state2 = 1;+    unsigned char pattern, state1 = 0, state2 = 1;
  
- // Insuring the direction +- 1 +    // Festlegung der Richtung +- 1 
- dir = ((dir < 0) ? -1 : +1);+    dir = ((dir < 0) ? -1 : +1);
  
- // Execution of half-steps+    // Durchführung von Halbschritten
- for (i = 0; i < num_steps; i++) +    for (i = 0; i < num_steps; i++) 
- {  +            
- state1 += dir; +        state1 += dir; 
- state2 += dir;+        state2 += dir;
  
- // Creating the pattern+        // Erstellung des Musters
- pattern = (1 << ((state1 % 8) >> 1)) | +        pattern = (1 << ((state1 % 8) >> 1)) | 
-           (1 << ((state2 % 8) >> 1)); +                  (1 << ((state2 % 8) >> 1)); 
-  +         
- // Setting the output+        // Output setzen
- PORTB = (PORTB & 0xF0) | (pattern & 0x0F);+        PORTB = (PORTB & 0xF0) | (pattern & 0x0F);
  
- // Taking a break to wait for executing the step+        // Pause um auf die Ausführung des Schrittes zu warten
- sw_delay_ms(speed); +        sw_delay_ms(speed); 
- }+    }
  
- // Stopping the motor+    // Anhalten des Motors
- PORTB &= 0xF0;+    PORTB &= 0xF0;
 } }
 </code> </code>
  
-Usage of the functions is demonstrated by the example program which rotates the motor alternately to one direction and then to the other direction 200 half stepsThe speed of rotating the motor is determined by the length of the brakes made between the stepsIf the break is set to be too shortthe motor can not accomplish the turn due to the inertia of the rotor and the shaft does not move.+Die Funktion wird durch ein Beispielprogramm demonstriert, welches den Motor abwechselnd alle 200 Halbschritte in eine Richtung rotieren lässtDie Geschwindigkeit der Rotation wird durch die Länge der Pausen zwischen den Schritten bestimmtWenn die Pause zu kurz istkann der Motor sich aufgrund der Trägheit nicht drehen.
  
 <code c> <code c>
 // //
-// The test program for the bipolar stepper motor of the motor's +// Das Testprogramm für den bipolaren Schrittmotor des Motormoduls  
-//module of the HomeLab.+// des HomeLab.
 // //
 #include <homelab/module/motors.h> #include <homelab/module/motors.h>
  
 // //
-// Main program.+// Hauptprogramm.
 // //
 int main(void) int main(void)
 { {
- // Set up of the motor+    // Einrichtung des Motors
- bipolar_init(); +    bipolar_init(); 
-  +         
- // Endless loop+    // Endlosschleife
- while (true) +    while (true) 
-+    
- // Turning the rotor 200 half steps to one direction at speed of 30 ms/step+        // Bewegung des Rotors 200 Halbschritte in eine Richtung mit einer Geschwindigkeit von 30 ms/Schritt
- bipolar_halfstep(+1, 200, 30);+        bipolar_halfstep(+1, 200, 30);
  
- // Turning 200 half steps to the other direction at speed 30 ms/step+        // Bewegung des Rotors 200 Halbschritte in die andere Richtung mit einer Geschwindigkeit von 30 ms/Schritt
- bipolar_halfstep(-1, 200, 30); +        bipolar_halfstep(-1, 200, 30); 
- }+    }
 } }
 </code> </code>
-==== Exercises  ==== +==== Aufgaben  ====
-The goal is to write a program which is able to perform tasks described below.+
  
-=== Warm up exercise === +Ziel ist esein Programm zu schreibenwelches die folgenden Aufgaben erfüllen kann.
-  * Controlling the DC motor using a digital board. By pressing S1 buttonLED1 is lit and the motor turns clockwise. By pressing S3 buttonLED3 is lit and the motor revolves anti clockwise. By pressing S2, LED2 is lit and the motor is stopped+
  
-=== For beginners === +=== Aufwärmübung ===
-   - Robot, by using two DC motors and touch sensors movement of a robot is simulated. Touch sensors are the buttons of the digital board (S1…S3). The motor is controlled by pressing the buttons. S1 stops the left motor for 2 seconds and then starts both motors at full speed. S2 stops the right motor for two second and then starts both motors at full speed. If both buttons are pressed, the motors are rotating in reverse direction until the buttons are released. +
-   - Servo motor, the servo motor is controlled via the buttons of the digital board. By pressing down S1 the servomotor moves one step to the right. By pressing down S3, the servo motor moves one step to the left and S2 makes the servo motor to move to the initial (middle) position. The position of the servo motor is displayed live on the 7 segment display (each number corresponds to 10 degrees of the turn: middle position equals 5).         +
-  - Radar, functioning of radar is simulated. In order to identify objects closer than 0,5 meters, IR distance sensor is installed to the lever of the servo motor. The lever of servo motor is moving constantly form one extreme position to the other and it carries this sensor all the time with itself. If there happens to be an object in closer range than 0,5 meters of the sensor, then the servo motor is stopped for 5 seconds and by signaling a LED (PB7) on the controller board detection of the object is announced. +
-  - Stepper motor, after each pressing on the buttons S1 and S3 it rotates 10 steps, accordingly clock wise and anti clock wise. The rotation is stopped immediately by pressing on the button S2.  +
-  - All three different types of the motors are connected. By pressing a button it starts and stops a certain motor. S1 controls the DC motor. S2 controls the servo-motor and S3 controls the stepper-motor.+
  
-=== For advanced === +  * Steuern des Gleichstrommotors mit dem digitalen Board. Durch Betätigung von Schalter S1 leuchtet LED1 auf und der Motor dreht sich im UhrzeigersinnDurch Betätigung von Schalter S3 leuchtet die LED3 auf und der Motor dreht sich gegen den UhrzeigersinnDurch Betätigung von Schalter S2 leuchtet LED2 auf und der Motor wird gestoppt.
-  - DC motor accelerates when S1 is pressed down and holds achieved speed when the button is releasedBy holding S2 pressed down, the motor decelerates smoothly. By pressing button S3, the motor stops instantly (simulating emergency stop) +
-  - Tracking an object. By using ultrasonic distance sensor, which is installed on the lever of the servo-motor, the servomotor has to track a bypassing object. The motor turns according to the movement of the object so that the object is all the time in the middle of the tracking sector of the sensor.  +
-  - Stepper motor keeps the last position of the motor after change of each sequence. When activating new sequence, use variable, so the movement continues exactly from the last position of the motor.   +
-  - Acceleration, the program allows changing the acceleration/deceleration of the stepper motor. Use linear speed slopes which can be easily identified at visual inspection. Longer movements have to follow the following scheme: acceleration --> steady speed --> deceleration. +
-  - Design a PID regulator for a DC motor. NB! This exercise demands a motor with feedback. This exercise may be solved also theoretically+
  
-==== Questions ==== +=== Für Anfänger ===
-  - For what is the H-bridge used? On what principle is it working? +
-  - How is the position of the shaft of RC servo motor determined? +
-  - What is the main difference between unipolar- and bipolar-stepper motors? +
-  - How can half step and micro step modes of stepper-motor be applied? Give an example. +
-  - How is the rotation speed of a DC motor controlled? Give an example. +
-  - Which PWM working cycle is needed to achieve DC motor's shaft rotation speed 70% of nominal? +
-  - How is the direction of motor's rotation determined when encoder is used? +
-  - How can a DC motor be electrically slowed? +
-  - What happens if the scheme of commutation of a stepper-motor is changing too fast?  +
-  - Is it possible and if yes, how is it possible to use dynamical braking? +
-===== Data interfaces =====+
  
-{{  :examples:communication:communications.jpg?580  |Data interfaces}}+   - RoboterDurch Nutzung von zwei Gleichstrommotoren und Berührungssensoren wird die Bewegung eines Roboters simuliert. Berührungssensoren sind die Schalter am digitalen Board (S1…S3). Die Motoren werden durch die Betätigung der Schalter gesteuert. S1 stoppt den linken Motor für zwei Sekunden und startet dann beide Motoren mit voller Geschwindigkeit. S2 stoppt den rechten Motor für zwei Sekunden und startet dann beide Motoren mit voller Geschwindigkeit. Wenn beide Schalter betätigt werden drehen beide Motoren rückwärts, bis der Schalter losgelassen wird. 
 +   - ServomotorDer Servomotor wird mit den Schaltern des digitalen Boards kontrolliert. Wenn S1 gedrückt wird macht der Servomotor einen Schritt nach rechts, bei S3 einen Schritt nach links und S2 bewegt den Servomotor wieder in die ursprüngliche Position (Mitte). Die Position des Motors wird direkt auf dem 7-Segment Display dargestellt (jede Nummer steht für 10° Drehung, Mittelposition = 5) 
 +   - RadarDie Funktion eines Radars wird simuliertUm ein Objekt, welches näher als 0.5 Meter ist, zu identifizieren, wird auf dem Hebel des Servomotors der IR-Entfernungsmesser installiert. Der Hebel des Servomotors bewegt sich konstant von einem Ende zum anderen Ende der Bewegungsreichweite des Motors. Falls ein Objekt näher als 0.5 Meter am Sensor ist, wird der Servomotor für 5 Sekunden gestoppt und eine LED (PB7) zeigt auf dem Controllerboard die Entdeckung eines Objekts an.     
 +  - Schrittmotor: Nach jeder Betätigung von S1 oder S3, rotiert der Motor 10 Schritte im oder gegen den Uhrzeigersinn. Die Rotation wird sofort angehalten wenn S2 gedrückt wird. 
 +  - Alle drei Motorentypen werden angeschlossen. Durch Betätigung eines Schalters wird ein bestimmter Motor gestartet und angehalten. S1 steuert den Gleichstrommotor, S2 den Servomotor und S3 den Schrittmotor.
  
-With microcontrollers it is possible to control actuators, read the values of sensors and many other stuff, but always stays the need for connecting all kind of devices, which does not allow to communicate by sending simple digital signals. The reason may be: there are too many control signals needed to control the device or there is too much data to be sent. That is why there are many data interface standards developed for microcontrollers or for every kind of electronics. The standards are determining the electrical parameters of the signals and the rules of transmission of the signals (the protocol).+=== Für Fortgeschrittene ===
  
-One simple example of a protocol is the Morse codewhere the information is transmitted using peeps and pauses and varying their lengthsDigital data transmitting protocols are functioning similarly; in there the info is transmitted as bit values and depending on the interface also as modulated formDifferent data transmitting interfaces with their protocols have been created according to the need but the data quantities have always grown and new methods have been constantly addedThe situation in the data transmission between the electronics components is calmerThere are I²C, SPI and UART interfaces used already for a long timeMore traditional intersystem transmission interfaces are RS-232, Rs-485, LIN and CAN, but many microcontrollers are already produced with USB, Ethernet and wireless ZigBee interfacesThis chapter is focusing on the data transmitting by using RS-232 interface.       +  - Der Gleichstrommotor beschleunigt wenn S1 gedrückt wird und hält die momentane Geschwindigkeitwenn der Schalter losgelassen wirdWenn S2 gedrückt wird, erfährt der Motor eine gleichmäßige Abbremsung. Wenn S3 gedrückt wird, hält der Motor sofort an (Simulation eines Notstopps). 
 +  - Ein Objekt verfolgen: Durch das Nutzen des Ultraschall-Entfernungsmessers, welcher auf dem Hebel des Servomotors installiert wird, verfolgt der Servomotor ein vorbeikommendes Objekt. Der Motor dreht sich je nach Bewegung des Objekts, so das immer das Objekt in der Mitte des Mess-Sektors des Sensors ist. 
 +  - der Schrittmotor hält die letzte Position des Motors nach Änderung jeder SequenzWenn eine neue Sequenz aktiviert wird, nutzen Sie eine Variable, so dass die Bewegung exakt von der letzten Position des Motors fortgeführt wird. 
 +  - Beschleunigung: Das Programm ermöglicht die Beschleunigung oder Abbremsung des Schrittmotors. Nutzen Sie lineare Geschwindigkeitssteigerungen welche bei visueller Betrachtung einfach identifiziert werden können. Weite Bewegungen müssen folgendes Schema erfüllen: Beschleunigung --> konstante Geschwindigkeit --> Abbremsung. 
 +  - Entwerfen Sie einen PID-Regulator für einen Gleichstrommotor. Achtung! Diese Aufgabe benötigt einen Motor mit Feedback. Diese Aufgabe kann daher auch theoretisch gelöst werden. 
 + 
 +==== Fragen ==== 
 + 
 +  - Welcher Vierquadrantensteller wird genutzt? Nach welchem Prinzip funktioniert er? 
 +  - Wie wird die Position der Achse eines RC-Servomotors bestimmt? 
 +  - Was ist der Hauptunterschied zwischen unipolaren und einem bipolaren Schrittmotoren? 
 +  - Wie können Halbschritt und Mikroschrittmodi eines Schrittmotors genutzt werden? Nennen Sie ein Beispiel. 
 +  - Wie kann die Rotationsgeschwindigkeit eines DC Motors gesteuert werden? Nennen Sie ein Beispiel. 
 +  - Welcher PWM-Arbeitszyklus wird benötigt um eine Gleichstrommotorrotation mit 70% der nominalen Geschwindigkeit zu erreichen? 
 +  - Wie wird die Richtung der Motorrotation bestimmt, wenn ein Encoder genutzt wird? 
 +  - Wie kann ein Gleichstrommotor elektronisch gebremst werden? 
 +  - Was passiert, wenn das Schema der Stromwendung eines Schrittmotors sich zu schnell ändert? 
 +  - Ist dynamisches Bremsen möglich? Wenn ja, wie? 
 + 
 +===== Datenschnittstellen ===== 
 + 
 +{{  :examples:communication:communications.jpg?580  |Datenscbnittstellen}} 
 + 
 +Mit Microcontrollern können Antriebe gesteuert werden, Werte von Sensoren ausgelesen werden und viel mehr. Diese Geräte müssen dazu jedoch immer mit dem Mikrocontroller verbunden sein; es ist somit nicht möglich, durch einfache Signale zu kommunizieren. Das liegt darin begründet, dass zu viele Steuerungssignale zur Steuerung der Schnittstelle benötigt werden oder, dass zu viele Daten gesendet werden müssen. Daher wurden zahlreiche Standards von Datenschnittstellen für Mikrocontroller oder andere Elektronik entwickelt. Die Standards bestimmen die elektrischen Parameter der Signale und die Übertragungsregeln für die Signale (das Protokoll). 
 + 
 +Ein einfaches Beispiel eines Protokolls ist der Morse Code, womit Informationen durch Nutzung von Pieptönen und Pausen in verschiedenen Abständen übertragen werden. Digitale Datenübertragungsprotokolle arbeiten ähnlich. Dort werden die Informationen als Bit Werte gesendet und je nach Schnittstelle Angepasst an versschiedene Bedürfnisse wurden diverse Schnittstellen zur Datenübertragung entwickelt. Da die Datenmengen jedoch stetig ansteigen, werden immer wieder neue Methoden entwickelt. Bei elektronischen Komponenten ist die Situation dahingehend etwas stabilerDie I²C, SPI und UART Schnittstellen werden schon sehr lange verwendetTraditionellere Schnittstellensysteme für die Übertragung innerhalb eines Systems sind RS-232, Rs-485, LIN and CAN, aber viele Mikrocontroller werden schon mit USB, Ethernet und kabellosen ZigBee Schnittstellen produziertDieses Kapitel konzentriert sich auf die RS-232 Schnittstelle.       
  
 ==== RS-232 ==== ==== RS-232 ====
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:controller]], [AVR] [[en:avr:usart]], [LIB] [[en:software:homelab:library:usart]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:controller]], [AVR] [[en:avr:usart]], [LIB] [[en:software:homelab:library:usart]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]]//
  
-=== Theory ===+=== Theorie ===
  
-[{{  :examples:communication:comm_rs232_cable.jpg?220|Cable RS-232. Left plug is „male” and the right one is „female” plug."}}]+[{{  :examples:communication:comm_rs232_cable.jpg?220|Cable RS-232. Der linke Stecker ist „male”, der rechte „female”."}}]
  
-RS-232 is a standard of physical data interface, which is used for delivering binary dataThe standard is used mainly in serial ports of computerswhich are also called “COM” ports in everyday languageNowadays is the RS-232 largely replaced by USB interface, but due to its simplicity it is still used very successfully in hobby applicationsespecially if there are USB – RS-232 convertersThe RS-232 standard determines the plugselectrical parameters and meanings of the signals but not the protocol+Die RS-232 ist ein Standard unter den physischen Datenschnittstellen und wird zur Übertragung von Binärdaten genutztDieser Standard wird überwiegend für serielle Anschlüsse von Computern verwendetwelche gewöhnlich als "COM"-Anschlüsse bezeichnet werdenInzwischen wurden die RS-232 größtenteils durch USB-Schnittstellen ersetzt. Aufgrund ihrer Einfachheit werden sie jedoch weiterhin erfolgreich in Freizeitanwendungen verwendetinsbesondere wenn USB RS-232 Konverter vorhanden sindDer RS-232 Standard legt die Stecker, die elektronischen Parameter sowie die Bedeutung der Signale festnicht aber das Protokoll.
  
-The RS-232 interface is used mainly with UART hardware data transmission module which protocol is standardizedbut it does not determine the plugs or other thingsSo the RS-232 enhances the UART. Since the UART is usually one module of periphery of the microcontrollerwhich digital input-output does not correspond to the electrical parameters of the RS-232, they are connected together with a special leveling-converterOne best known leveling-converters between RS-232 and TLL/CMOS is MAX232.   +Die RS-232 Schnittstelle wird hauptsächlich in Verbindung mit dem UART Datenübermittlungsmodul genutzt. Diese UART-Hardware verfügt über ein standardisiertes Protokolllegt jedoch keine Stecker oder andere Dinge festDie RS-232 Schnittstelle erweitert somit das UART Modul. UART ist ein Peripheriemodul des Mikrocontrollersdessen digitaler Inund Output nicht mit den elektronischen Parametern des RS-232 korrespondiertAus diesem Grund werden die beiden über einen speziellen Pegelkonverter miteinander verbunden. Der bekannteste Pegelkonverter für RS-232 und TLL/COMS ist der MAX232.
  
-UART means universal asynchronous receiver/transmitter. USART is almost the samewith the difference that the data is sent with clock signalThe UART may be called also a serial interfaceThe serial interface is a data transferring mechanismwhere each bit is transmitted one by oneFor example, to transmit bait, 8 bits are transmitted with certain intervalThis means that on the serial interface linewhich is one pin of the microcontrollerthe value of voltage is changed after certain timeonce low and then highUsually there are two devices connected to the serial interfaceOne is transmitting the information (by changing the value of the pinand the other is receiving it (by registering the value of the pin). Transmitting pin is TX, and receiving pin is RX. The info is moving always to one direction on one lineFor sending data to the other direction an other line is usedIf data is moved on two lines at the same timeit is called full duplex bus +Die Bezeichnung UART steht für "Universal Asynchronous Receiver Transmitter"Die USART-Schnittstelle bietet ergänzend die MöglichkeitDaten synchron zum Taktsignal zu senden. UART kann auch als serielle Schnittstelle bezeichnet werdenDie serielle Schnittstelle ist ein Datentransfermechanismuswobei jedes Bit einzeln übermittelt wirdUm beispielsweise Byte zu sendenwerden Bits in einem bestimmten Intervall übermitteltDadurch wird an der seriellen Leitungsschnittstellealso an einen Pin des Mikrocontrollersder Wert der Stromspannung nach einer bestimmten Zeit verändertzunächst ist dieser niedrig und daraufhin hochNormalerweise gibt es zwei Geräte die an der seriellen Schnittstelle angeschlossen werdenDas eine dient zur Übertragung von Information (durch Veränderung des Pinwertes), das andere zum Empfang (durch Erfassung des Pinwertes). Der Übertragungspin ist mit TX, der Empfangspin mit RX gekennzeichnetAuf einer Leitung geht der Informationsfluss immer nur in eine RichtungUm Daten in die andere Richtung zu senden, muss eine andere Leitung genutzt werdenWerden Daten über zwei Leitungen gleichzeitig gesendetwird dieses "Full Duplex Bus" genannt  
  
-[{{  :examples:communication:comm_uart_frame.png?319|the frame of UART, where is start-bit , 0-7 are data-bits, P is parity-bit (if existingand is stop-bit (or 2).}}]+[{{  :examples:communication:comm_uart_frame.png?319|Der Rahmen des UART, mit als Startbit , 0-7 als Datenbits, P als Paritätsbit (falls dieses existiertund als Stopbit (oder 2).}}]
  
-Transmitting data is done by frames of the UART interfacein which is 5-data bits (depending on the configuration)Most common is bits (1 bait). In addition to the data bits also extra bits are transmitted with the framewhich are used to recognize the moments of arrival and ending of the data on the receiver’s sideThe first is called start-bit and it is always 0. The second is called stop-bit (or bits)which is always 1. Before the stop-bit also parity bit may comeIt is use to control regularityThe parity-bit shows whether in the amount of the data-bits is odd or even number of onesWhich reading it has depends on the configuration of the UART interfaceThe parity-bit is usually not used anymore and it can be banned in configurationLike the parity-bit can be configuredalso can the amount of data-bits and stop-bits.+Die Datenübertragung erfolgt über den Rahmen der UART-Schnittstellewelcher je nach Konfiguration bis Datenbits enthältAm häufigsten sind Bits (1 Byte). Zusätzlich zu den Datenbits werden durch den Rahmen weitere Bits übertragenwelche dazu genutzt werden, den Augenblick der Ankunft von Daten sowie des Abschlusses der Übertragung auf der Empfängerseite zu erkennenErsteres wird Startbit genannt und hat immer den Wert 0. Das zweite ist das Stopbitwelches immer den Wert hatVor dem Stopbit gibt es in einigen Fällen noch das ParitätsbitDieses dient zur Kontrolle der RichtigkeitDas Paritätsbit zeigt an, ob die Anzahl der Einsen in den Datenbits gerade oder ungerade istDie Art der Ablesung hängt von der Konfiguration der UART Schnittstelle abDas Paritätsbit wird aber normalerweise nicht mehr verwendet und kann im Rahmen der Konfiguration unterdrückt werdenSo wie das Paritätsbit konfiguriert werden kannkann auch die Anzahl von Datenund Stopbits variiert werden.
              
-In addition to the frame structure, there is one more important parameter – it is //baud rate//, with which the number of transmitted symbols in one second is determinedBaud shows the number of symbolsWhen we are dealing with UART then baud is 1 bit and that is why we talked about bits when we were talking about frameBasically it does not matter which baud rate is used for data transmittingbut there is a certain amount of commonly used baud rateswhich should be usedFor example: 9600 bps, 19200bps, 38400 bps, 57600 bps, 115200 bps+Zusätzlich zur Rahmenstruktur gibt es einen weiteren wichtigen Parameter - die //Baudrate//, wodurch die Anzahl der in einer Sekunde übertragenen Symbole festgelegt wirdDie Baudrate zeigt die Anzahl der Symbole anBei der Verwendung von UART entspricht Baud einem Bit, weshalb im Zusammenhang mit dem Rahmen von Bits gesprochen wurdeAllgemein ist es egalwelche Baudrate zur Datenübertragung genutzt wirdes gibt jedoch eine einige häufig verwendete Baudraten, welche verwendet werden solltenDiese sind zum Beispiel: 9600 bps, 19200bps, 38400 bps, 57600 bps, 115200 bps.
    
-Furthermoreit is worth to know that the RS-232 standard includes in addition to the data-signals  (RX, TX) also data flow control pins DTR, DCD, DSR, RI, RTS and CTSwhich are used for controlling the communication between the devicesFor example they can be used to notify whether it is ready to receive data or not Since the RS-232 interface’s original goal is to connect the computers to a modemsome signals are (wereuseful rather for showing the state of the telephone lines +Darüber hinaus ist es wichtig zu wissendass der RS-232 Standard zusätzlich zu den Datensignalen (RX, TX) auch über Datenflusskontrollpins DTR, DCD, DSR, RI, RTS undCTS verfügtwelche zur Kontrolle der Kommunikation zwischen den Geräten dienenSie können zum Beispiel genutzt werden, um festzustellen ob das Gerät zum Empfang von Daten bereit ist oder nichtDa die RS-232 Schnittstelle ursprünglich darauf abzieltComputer an ein Modem anzuschließen, können (konnteneinige Signale dazu genutzt werden, um den Status von Telefonleitungen anzuzeigen
  
-=== Practice ===+=== Praktisches Beispiel ===
  
-The Controller module board is equipped with one RS-232 type male plugThrough that can controller be connected to computer or to an other controllerFor connecting to a computer a usual not inverted cable must be usedwhich one end is male and other one is female. For connection to an other controller a cable must be used where RX and TX and current control signals are perpendicularly inverted and both plugs are female. The inverted cable is also called zero modem cable The following is an example program of using UART serial interface When the program is startedit transmits a welcome through a RS-232 interface and displays messages, which are received. LCD and USART libraries are used  +Die Platine des Controllermoduls ist mit einem RS-232 male-Stecker ausgerüstetDarüber kann der Controller an einen Computer oder einen anderen Controller angeschlossen werdenUm ihn an einen Computer anzuschließen, muss ein normales nicht invertiertes Kabel genutzt werdendessen eines Ende male und anderes Ende female istUm den Controller an einen anderen Controller anzuschließen, muss ein Kabel verwendet werden, bei dem RXTX sowie Kontrollsignale für die Stromstärke senkrecht invertiert sind und beide Stecker female sindDas invertierte Kabel wird auch Nullmodemkabel genanntNachfolgend ist ein Beispielprogramm zur Nutzung der UART Schnittstelle dargestelltWird das Programm gestartetübermittelt es ein "Willkommen" über die RS-232 Schnittstelle und zeigt empfangene Nachrichten anEs werden das LCD-Display und die USART Bibliotheken genutzt.
  
 <code c> <code c>
 // //
-// Connecting the Controller module of the HomeLab to a computer through RS-232. +// Anschluss des Controllermoduls des HomeLab an einen Computer über die RS-232 Schnittstelle
-// The example is using digital input-output module with LCD. +// Im Beispiel wird ein digitales Input-Output-Modul mit LCD Display verwendet
-// The text inserted in the terminal of the computer is displayed on the LCD.+// Der im Terminal des Computers eingegebene Text wird auf dem LCD Display angezeigt.
 // //
 #include <homelab/usart.h> #include <homelab/usart.h>
Line 4992: Line 4482:
  
 // //
-// Determining USART interface.+// Festlegung der USART Schnittstelle.
 // //
 usart port = USART(0); usart port = USART(0);
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 5004: Line 4494:
  unsigned char row = 1;  unsigned char row = 1;
  
- // The set-up of the USART interface.+ // Installation der USART Schnittstelle.
  usart_init_async(port,  usart_init_async(port,
  USART_DATABITS_8,  USART_DATABITS_8,
Line 5011: Line 4501:
  USART_BAUDRATE_ASYNC(9600));  USART_BAUDRATE_ASYNC(9600));
  
- // The set-up of the  LCD.+ // Installation des LCD.
  lcd_alpha_init(LCD_ALPHA_DISP_ON_BLINK);  lcd_alpha_init(LCD_ALPHA_DISP_ON_BLINK);
  
- // Displaying welcome message on the screen.+ // Anzeige eines Begrüßungstextes auf dem Display.
  lcd_alpha_write_string("Waiting for the message");  lcd_alpha_write_string("Waiting for the message");
  
- // Putting the cursor in the beginning of the second row.+ // Cursor an den Beginn der zweiten Reihe setzen.
  lcd_alpha_goto_xy(0, row);  lcd_alpha_goto_xy(0, row);
  
- // Saying hello to the computer.+ // "Hallo" zum Computer sagen.
  usart_send_string(port, "Hello, write something!\r\n");  usart_send_string(port, "Hello, write something!\r\n");
  
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Reading the sign from the serial interface.+ // Zeichen aus der seriellen Schnittstelle lesen.
  if (usart_try_read_char(port, &c))  if (usart_try_read_char(port, &c))
  {   {
- // Are we dealing with the sign of changing the row+ // Befassen wir uns mit dem Zeichen zur Änderung der Reihe
- if (c = '\r')+ if (c == '\r')
  {  {
- // Changing the row.+ // Änderung der Reihe.
  row = 1 - row;  row = 1 - row;
  
- // Emptying the row from the previous message.+ // Vorherige Nachricht aus der Reihe löschen.
  lcd_alpha_clear_line(row);  lcd_alpha_clear_line(row);
  }  }
  else  else
  {  {
- // Issuing the sign directly to the screen.+ // Ausgabe des Zeichens auf dem Display.
  lcd_alpha_write_char(c);  lcd_alpha_write_char(c);
  }  }
Line 5048: Line 4538:
 </code> </code>
  
-[{{  :examples:communication:comm_hyperterminal.png?250|The window of the HyperTerminal}}]+[{{  :examples:communication:comm_hyperterminal.png?250|Das Fenster des HyperTerminal}}]
  
-With Windows XP OS comes a program called HyperTerminal. It is opened from the //Start// menu by selecting //Accessories// →// Communications// → //HyperTerminal//Select 9600 bps, 1 start-bit and stop-bit without parity- and stream-control for configurationWhen the HyperTerminal is opened during the time when the microcontroller is startingthere will be a welcoming message on the display The letters inserted through the window are displayed in the alphanumerical LCD. By pressing //Enter// button the row is changed on the LCD. +Windows XP OS beinhaltet das Programm HyperTerminal. Dieses Programm kann über das //Start// Menü geöffnet werden, indem //Zubehör// →// Kommunikation// → //HyperTerminal// ausgewählt wirdWählen Sie zur Konfiguration 9600 bps aus, 1 Startbit und Stopbit ohne Paritätsund DatenstromkontrolleWenn HyperTerminal geöffnet ist, während der Mikrocontroller starteterscheint ein Begrüßungstext auf dem DisplayDie über das Fenster eingegebenen Buchstaben werden auf dem alphanumerischen LCD dargestelltDurch Betätigung der //Enter// Taste wird die Reihe auf dem LCD gewechselt
-==== Exercises  ====+==== ZigBee ====
  
-The goal is to write a program which is able to perform tasks described below. +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +==== Aufgabe ====
  
-=== Warm up exercise ===+Ziel ist es ein Programm zu schreiben, welches die folgenden Aufgaben erfüllt.
  
-  * To the computer is sent a number with grows once in a second. The number must be in a form of text and end with a row changing sign (\n).+=== Aufwärmübung ===
  
-=== For beginner ===+  * Es wird eine Nummer an den Computer gesendet, diejede Sekunde größer wird. Die Nummer muss in Textform sein und mit einem Reihenänderungszeichen enden (\n).
  
-  - For the commands (letter signs) which are coming through RS-232 interface from a computer are being waited. Command “R” lights green LED, “K” lights yellow LED and “P” red LED. “R” is switching all LEDs off. +=== Für Anfänger ===
-  - If a button is pressed, the name of the corresponding button (S1, S2, S3) is received in the computer through the RS-232 interface.+
  
-=== For advanced ===+  - Es wird auf die Befehle (in Buchstaben), welche über die RS-232 Schnittstelle von einem Computer gesendet werden, gewartet. Der Befehl "R" lässt die grüne LED leuchten, "K" die gelbe und "P" die rote. 
 +"R" schaltet alle LEDs aus. 
 +  - Wenn ein Schalter betätigt wird, wird der Name dieses Schalters (S1, S2, S3) am Computer über dieRS-232 Schnittstelle empfangen.
  
-  - The communication between two RS-232 controllers. If a button is pressed, the controller transmits to the controller the number of the button. When the number is received the status of a corresponding LED is changed. '1' → green, '2' → yellow, '3' → red. Requires two sets of controllers, but the software is identical for both controllers. +=== Für Fortgeschrittene ===
-  - Make a  “teletype” – device, which allows changing text messages between two controllers through RS-232 interface. Use LCD for displaying the messages. On the first row must be seen inserted message and on the second the last received message. For inserting the message a potentiometer and/or buttons may be used.+
  
-==== Questions ====+  - Kommunikation zwischen zwei RS-232 Controllern. Wird ein Schalter betätigt, sendet der eine Controller dem Anderen die Nummer des Schalters. Wenn die Nummer empfangen wurde, wird der Status der zugehörigen LED verändert.'1' → grün, '2' → gelb, '3' → rot.  Benötigt 2 Controller, die Software ist jedoch für beide identisch. 
 +  - Erstellen Sie ein "Teletype"Gerät, welches Änderungen von Textnachrichten zwischen zwei Controllern über die RS-232 Schnittstelle ermöglicht. Nutzen Sie das LCD um die Nachrichten anzuzeigen. In der ersten Reihe muss die eingegebene Nachricht zu sehen sein, in der zweiten Reiche die zuletzt empfangene Nachricht. Um eine Nachricht einzugeben können Potentiometer und / oder Schalter genutzt werden.
  
-  Describe the UART package+==== Fragen==== 
-  - What is the baud rate+ 
-  - What is the difference between fulland half duplexes. +  Beschreiben Sie das UART Paket
-  - Find at least different sensors which are using serial interface+  - Was ist die Baud-Rate
-  - What is the difference between UART and USART interfaces? Which is faster+  - Was ist der Unterschied zwischen Voll/Halb-Duplex? 
-  - How is the SPI interface working?  +  - Finden Sie mindestens Sensoren, welche die serielle Schnittstelle nutzen
-  - Name interfaceswhich enable connecting at least 100 devices to a single bus+  - Nennen Sie den Unterschied zwischen UART und USART Schnittstelle. Welche ist schneller
-  - Name different topologies and explain their differences+  - Wie funktioniert die SPI Schnittstelle
-  - On what voltage level are RS-232 and UART connections happening+  - Nennen Sie Schnittstellendie das Anschließen von mind. 100 Geräten an einen einzigen Bus erlauben
-  - How long time takes to transmit 1 MiB at the baud rate of 9600 bpswhen there is data-bits1 stop-bit and not parity control+  - Nennen Sie verschiedene Archtiekturen und erklären Sie ihre Unterschiede
-====== Example projects ======+  - Auf welchem Spannungslevel finden RS-232 und UART Verbindungen statt
 +  - Wie lange benötigt, es 1MiB bei einer Baud-Rate von 9600 dps mit Daten-Bitseinem Stop-Bit und ohne Paritätskontrolle, zu senden? 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +--- 
 + MISSING PAGE --- 
 +====== Beispielprojekte ======
  
 {{:examples:projects:robot:robot_project.png?580|}} {{:examples:projects:robot:robot_project.png?580|}}
  
-Some instructions on how to prepare a project documentation, what themes should be dealt with and what should be written on every theme are brought out in this example project. It is only practical to use a documentation of a typical project as an example. Unfortunatelythe documentation of the project is too voluminous due to the graphic material and would not have fit here anywayThereforeall the main points are reflected in this example project, but not in its entiretyFor example, only one detail is showed from drawings and only one PCB from electronic schemesNevertheless, in real documentation all created details should have their drawings and schemes of PCB. Hopefully this example project is helpful for teachers as well, as it is easier for them to explain what they expect from students at the end of the project and how it should be presentedHoweverfew points can be left out from the documentation depending on the level of the student and the actual situation+Das Beispielprojekt in diesem Kapitel enthält eine Anleitung zur Vorbereitung einer Projektdokumentation und erläutertwelche Themen behandelt werden sollten sowie was zu den einzelnen Themen geschrieben werden sollteEs ist sehr hilfreicheine Dokumentation eines typischen Projekts als Beispiel zu nehmenLeider ist die gesamte Projektdokumentation aufgrund des Bildmaterials zu umfangreich und würde den Rahmen dieses Buches sprengenDennoch enthält das Beispielprojekt alle wichtigen Aspekte. So werden beispielsweise nur wichtige Details einer Zeichnung oder nur ein PCB eines elektronischen Plans gezeigtDennoch sollte eine tatsächliche Dokumentation Zeichnungen und Pläne für alle erstellten Details enthaltenDas Beispielprojekt soll auch die Lehrer dahin gehend unterstützenden Schülern zu verdeutlichen, was am Ende eines Projektes erwartet wird und wie die Ergebnisse zu präsentieren sind. Je nach Situation und Lehrniveau können jedoch einige Punkte der Dokumentation ausgelassen werden
-===== Report =====+===== Bericht ===== 
 + 
 +Um ein einfaches mechatronisches Gerät herzustellen, muss man die Konstruktion und Mechanik, Elektronik und Sensoren, Kontrollsystem und Software für das Gerät entwickeln. 
 +Am Ende des Projekts soll ein Bericht erstellt werden. Es ist eine Dokumentation welche mindesten die folgenden Punkte enthalten soll: 
  
-In order to engineer a simple mechatronic device it is needed to project the construction and mechanics, electronics and sensors, control system and software for this device.  +  * **Titelseite** 
-At the end of the project a report should be compiled. It is a documentation which should at least consist following content points:  +  * **Zusammenfassung** 
-  * **Titlepage ** +  * **Zusammenfassung (in Fremdsprache / Englisch)** 
-  * **Summary** +  * **Inhaltsverzeichnis** 
-  * **Summary (in foreign language)** +    - **Ursprüngliche Aufgabe** 
-  * **Table of contents** +    - **Systemvoraussetzungen und Einschränkungen** 
-    - **Initial task** +    - **Modell des Systems** \\ Struktur und Funktionalität eines Systems als BlockdiagrammZusätzlich können eine Anleitung zur Nutzung des Anwendungsfalldiagrammsein Interfacediagramm etc. verfasst werden
-    - **System requirements and limitations** +    - **Designlösungen** \\ Mindestens drei verschiedene Konzeptlösungen für diese AufgabeGeeignet sind handgezeichnete DiagrammeZeichnungen etc. Dokumentation mit Kommentaren
-    - **The overall system model** \\ Structure and functionality of a system as block diagramsIn additioninstructions for use case diagram, interface diagram etc. can be composed+    - **Mechanik** \\ Am Besten ein 3D Modell mit Zeichnungen von wichtigen Verbindungen und BauanweisungenFalls eine Verbindung spezielle Anweisungen benötigtdann auch Bauanleitungen und Zeichnungen hinzufügenWenn möglich eine Animation der Funktionen des Systems beifügen
-    - **Design solutions** \\ At least three different conceptual solutions of how to solve the taskSuitable are manually sketched diagramssketches etc. Documentation with comments+    - **Elektronik** \\ Darstellung aller genutzten Module in einem Blockdiagramm (ControllerMotorenantriebMotorEncoder etc. und ihre Verbindungen). Falls möglich geben Sie ein Layout für den Aufbau der Leiterplatte an
-    - **Mechanics** \\ Preferably a 3D model with drawings of essential nodes and engineering instructionsIf a node requires special instructionsthen assembly drawings and instructions as wellIf possible, add an animation on functioning of the system+    - **Control System** \\ Kontrollalgorhytmus und QuellcodeFalls selbst-erstellte Funktionen genutzt werdeneine Tabelle der Funktionen und Parameterusw. angeben
-    - **Electronics** \\ Give the overall block diagram, where all the used modules are showed (controllermotor actuatormotorencoder etc. and their connections). At opportunity provide a standard electronic unit and PCB assembly layout+    - **Gebrauchsfertige Lösung** \\ Beschreibung und Bilder 
-    - **Control system** \\ Control algorithm and source codeIf self made functions are usedthen provide a table of functions and parameterstable of interruption priorities etc.  +    - **Wirtschaftliche Rechnung** \\ Auflistung von Komponenten wie Kostengeschätzte, benötigte Zeit etc. 
-    - **Ready-to-use solution** \\ Description and pictures +    - **Projektmanagement** \\ Zeitplan des Projektsdie Ressourcenbelegung die Arbeitsteilung Mitwirkung der GruppeTermine für Meetings etc. 
-    - **Economic calculation** \\ The list of components with costtime estimates etc. +    - **Zusammenfassung und Fazit** \\ Was war schwer, was würden Sie anders machenwas wurde mit dem Projekt erreicht etc. Die Zusammenfassung umfasst eine kleine Beschreibung der Arbeitaufgetretene Probleme werden genannt und das Ergebnis der Arbeit wird dargestelltDarüber hinaus ist es sinnvolldie eigene Meinung bezüglich der Notwendigkeit des Projekts hinzuzufügen. Außerdem bezüglich des Nutzens für die Projektmitgliedern bringt, dazu was in Zukunft anders gemacht werden sollte, was man gelernt hat und was den Leitern und Organisatoren des Projekts vorschlagen werden sollte
-    - **Project management** \\ The project scheduleresource allocationdivision of laborthe crew's contributionthe minutes of meetings etc. +  * **Genutzte Quellen und Materialien** 
-    - **Summary and conclusions** \\ What was difficultwhat would you do differently, what you gained from the project etc. In the summary a short description of the work doneproblems encountered and a description of the outcome should be outlinedIt is also good to add your opinion on the necessity of the projectwhat it offers to the members of the project and what should be done differently in the futurewhat was learned and what would be suggested to the supervisors and organizers of the project.  +  * **Anhang**
-  * **References and materials used** +
-  * **Annexes**+
  
-The following example project is a sample of how to compile a documentation and a report on the project.  Unfortunatelythe report is in an abbreviated form due to the limited volume of this bookbut it is aimed to show the different aspects of documentation.  +Das folgende Beispielprojekt zeigtwie eine Dokumentation und ein Bericht eines Projekts erstellt werden. Aufgrund des begrenzten Umfangs dieses Buches kann der Bericht leider nur in gekürzter Fassung dargestellt werdener stellt aber immer noch die verschiedenen Aspekte einer Dokumentation dar
-===== Mobile robot platform =====+===== Mobile Roboterplattform =====
  
-Mobile robot is one of the most popular robot for constructionVery common are sumo robotssports robots (footballvolleyball etc.), robots simulating rescue operations (firefightingperson or object finding etc.and many otherFor these kinds of robots there are many different competitions in the world and in Estoniaeven standard classes have been developed (eg sumo robots). The common feature for these types of robots is mobile platformwhich may have different construction and capabilitiesbut its main functionality remains the sameIt is controlling the motors and basic navigationwhich includes avoiding objects and travelling to the desired destinationUsually, a specific functionality is added to the main functionalitywhich is planned according to the requirements and opportunities set for the project.+Der mobile Roboter ist eine der populärsten RobotorkonstruktionenSehr verbreitet sind SumoroboterSportroboter (FußballVolleyball usw.), Roboter die Rettungsoperationen simulieren (FeuerbekämpfungPersonen- oder Objektsucheund viele andereEs gibt auf der ganzen Welt und in Estland diverse Wettbewerbe für diese Art Roboteres wurden sogar Standardklassen entwickelt (z. B. Sumoroboter). Alle diese Robotor nutzen eine mobile Plattformwelche zwar zum Teil unterschiedlich konstruiert ist oder andere Eigenschaften besitztderen Grundfunktion aber stets die gleiche istDiese umfasst die Steuerung von Motoren und einfacher Navigationinklusive dem Ausweichen vor Objekten und der Bewegung zu einem festgelegten PunktGewöhnlich wird der Hauptfunktion eine spezifische Funktion hinzugefügtdie auf die Voraussetzungen und Möglichkeiten des Projekts abgestimmt ist
  
-Here we look at the documentation of a typical mobile robot platform project and its different phases.+Nachfolgend werden eine Dokumentation eines typischen Projekts für eine mobile Roboterplattform sowie die verschiedenen Projektphasen dargestellt.
  
-=== Initial tasks ===+=== Ursprüngliche Aufgabe ===
  
-Plan and construct a multifunctional mobile robot platform with basic navigation functionality using HomeLab componentsRobot platform must have an easy-to-change operational functionalitywhen equipped with different gadgets+Planen und konstruieren Sie eine multifunktionale mobile Roboterplattform mit einfacher Navigationsfunktion unter der Verwendung von HomeLab KomponentenDie Roboterplattform muss eine einfach zu ändernde operationale Funktion besitzenwenn sie mit verschiedenen Gadgets ausgerüstet wird:
   * Manipulator   * Manipulator
   * Radar   * Radar
-  * Camera +  * Kamera 
-Robot must be able to move on a flat surface in indoors+Der Roboter muss sich in geschlossenen Räumen auf flachen Böden bewegen können.
  
-== Requirements ==+== Voraussetzungen ==
  
-  * Maximum dimensions: 20 cm x 20 cm x 20 cm +  * Maximale Abmessung: 20 cm x 20 cm x 20 cm 
-  * Maximum weight 2 kg +  * maximales Gewicht: 2 kg 
-  * Speed max. 0,2 m/s +  * Höchstgeschwindigkeit: 0,2 m/s 
-  * Full autonomy+  * volle Selbstständigkeit
  
-== Restrictions ==+== Einschränkung ==
  
-  * Must be constructed mainly from HomeLab components  +  * Muss überwiegend aus HomeLab Komponenten bestehen  
-  * Cannot exceed the cost limit 10 000 EEK+  * Kostengrenze: 10000 EEK (~630€)
  
-~~PB~~+<pagebreak>
  
-=== The overall model of the system  ===+=== Grundlegendes Modell des Systems  ===
  
-The overall model of the system is presented as a block diagramIt describes the structurebehaviour and other important aspects of the systemAs an example, an hierarchical model of the overall system is depicted below+Das grundlegende Modell des System wird mit einem Blockdiagramm dargestelltEs beschreibt die Strukturdas Verhalten und andere wichtige Aspekte des SystemsAls Beispiel ist nachfolgend das hierarchische Modell des System abgebildet.
  
-[{{  :examples:projects:robot:robot_blokk_diagramm.png?500  |Model of system structure}}]+[{{  :examples:projects:robot:robot_blokk_diagramm.png?500  |Model der Systemstruktur}}]
  
-=== Design solutions ===+=== Designlösungen ===
  
-For this task the team used a brainstorming method and generated 3 conceptually different solutionsEvaluation matrix was compiled and the most optimum construction was foundThe main differences of the solutions lay in the movement schemes.+Für diese Aufgabe hat das Team eine Brainstorming-Methode verwendet und drei vom Konzept völlig unterschiedliche Vorschläge erstelltEs wurde eine Evaluationsmatrix erstellt und so die optimale Konstruktion gefundenDer größte Unterschied der drei Lösungen liegt im Bewegungsschema.
  
-[{{  :examples:projects:robot:robot_ideekavandid.png?500  |Design solutions}}]+[{{  :examples:projects:robot:robot_ideekavandid.png?500  |Designlösungen}}]
  
-~~PB~~+<pagebreak>
  
-Simplified evaluation matrix was as following+Vereinfachte Evaluationsmatrix:
  
-Function/Solution ^ I ^ II ^ III ^ Weight factor +Funktion/Lösung ^ I ^ II ^ III ^ Gewichtungsfaktor 
-|Cost         | 3 | 4 | 6 | 0,8 | +|Kosten         | 3 | 4 | 6 | 0,8 | 
-|Complexity of building | 2 | 4 | 7 | 0,7 | +|Komplexität im Bau | 2 | 4 | 7 | 0,7 | 
-|Maneuverability | 4 | 8 | 8 | 0,5 | +|Beweglichkeit  | 4 | 8 | 8 | 0,5 | 
-|Permeability/läbitavus? | 5 | 8 | 2 | 0,3 | +|Permittivität            | 5 | 8 | 2 | 0,3 | 
-|Applicability of HomeLab | 5 | 4 | 5 | 0,9 | +|Anwendbarkeit in Homelab | 5 | 4 | 5 | 0,9 | 
-|Weight | 5 | 6 | 7 | 0,8 | +|Gewicht | 5 | 6 | 7 | 0,8 | 
-^Total (with weight factor) ^ 19^27^ 28^ ^+^Total (mit Gewichtungsfaktor) ^ 19^27^ 28^ ^
  
-Evaluation scale was 1-10 points and weight factor 0-1. Weight factors were chosen according to the requirements and restrictions set for this systemEg, although solution was significantly more capable moving on rough groundit wasn't required in the preliminary task and therefore the weight factor was low +Die Evaluationsskala umfasst Werte von bis 10 und der Gewichtungsfaktor liegt zwischen und 1. Der Gewichtungsfaktor wird nach den Anforderungen und Einschränkungen des Systems ausgewähltSo ist beispielsweise Lösung beweglicher auf unebenen Bodendieses war jedoch nicht in der ursprünglichen Aufgabe gefordert, daher ist der Gewichtungsfaktor niedrig.
  
-Based on the assessment the optimum solution for given task was proved to be a platform moving on two wheels with two separate motorsFurther work continued developing the chosen solution into a real system+Basierend auf der Auswertung, ist die optimale Lösung für die gestellte Aufgabe eine Plattform auf zwei Rädern mit zwei separaten MotorenDie weitere Arbeit besteht in der Entwicklung der gewählten Lösung in ein reales System. 
 +<pagebreak>
  
-~~PB~~+=== Mechanik ===
  
-=== Mechanics ===+Die Mechanik wurde so einfach wie möglich gehalten, wobei dem Prinzip der Modularität gefolgt wurde. Front- und Heckstossstange sind identische Module. Die Elektronik beseteht aus drei Modulen, welche übereinander platziert werden und mit einfachen Flachbandkabeln verbunden werden. Darüber hinaus wird so sicher gestellt, dass die Module relativ einfach ausgewechselt werden können. 
 +Die Motoren entstammen dem HomeLab kit: Motoren mit einem integrierten Drehzahlminderer und Coder, welche direkt mit den Antrieb des Motors verbunden sind. Es wurden Modellflugzeugräder benutzt, da diese sehr leicht und robust sind. Um die Konstruktion zu vereinfachen sind Boden und Dachplatte identisch. Die Platten haben Löcher, damit unterschiedliche Geräte an der Dachplatte angeschlossen werden können. Neben der Elektronik passt auch eine Batterie problemlos zwischen den Platten.
  
-Mechanics was tried to make as simple as possible, while following the principle of modularity. The front and the rear bumper are identical modules. Electronics have three modules, which are placed on top of each other, allowing simple **ribakaabelühendusi**, while ensuring relatively simple changeability of modules. Motors have been selected from HomeLab kitmotors with integrated reducer and coder, which are connected directly to the actuator of the motors. Model aircraft wheels have been used, because they are very light and strong enough for the robot. To simplify the construction the bottom and the top plate are identical. Plates are equipped with holes, allowing different devices to be attached on the top plate. Besides the electronic modules a battery fits between the plates as well+[{{  :examples:projects:robot:robot_3d.jpg?500  |Erstes 3D-Modell des Roboters und Anordnung seiner Komponenten}}]
  
-[{{  :examples:projects:robot:robot_3d.jpg?500  |Primary 3D model of the robot and location of its components}}]+Die Stoßstangen des Roboters werden separat geplant und sind mit Berührungs- und Linienfolgesensoren ausgestattetDie Stoßstange wird aus PCBs hergestellt und verfügt dadurch über Elektrizität. Die Linienfolgesensoren werden direkt auf die Stoßstange der Bodenplatte gelötet. Berührungssensoren (Mikroschalter) werden zwischen den Stoßstangenplatten platziert und mit einem Gummistück an der Front geschützt. Das Gummistück absorbiert den Aufprall und ermöglicht gleichzeitig zu identifizieren, woher der Aufprall kam.
  
-The bumper of the robot is projected separately and it is integrated with touch sensors and line following sensors. The bumper is made from PCBs and therefore has electricity in addition to construction. Line following sensors are soldered directly to the bumper of the bottom plate. Touch sensors (micro switches) are placed between the bumper plates and are covered by a single rubber piece at front. The rubber piece absorbs the hit and at the same time enables to identify where the hit came from+[{{  :examples:projects:robot:pamperi_joonis.jpg?500  |Zeichnung der Stoßstangenplatte}}]
  
-[{{  :examples:projects:robot:pamperi_joonis.jpg?500  |Bumper plate drawing}}]+=== Elektronik ===
  
-=== Electronics ===+Die Elektronik des Systems ist in einem Prinzipsschema und Schaltplan mit PCB-Aufbau-Plan beschrieben.
  
-The electronics of the system is described as a principle scheme and electronic scheme with PCB assembly scheme+[{{  :examples:projects:robot:robot_electronics.png?500  |Blockdiagramm der elektronischen Komponenten}}]
  
-[{{  :examples:projects:robot:robot_electronics.png?500  |Block diagram of electronic components}}]+<pagebreak>
  
-~~PB~~+Als Beispiel werden die Schaltpläne der Linienfolgesensoren sowie die dazugehörigen PCB-Aufbau Pläne der Stoßstange des Roboters gezeigt.
  
-As an example, Line following sensors electric scheme and respective PCB assembly scheme of the robot's bumper is shown.+[{{  :examples:projects:robot:robot_pumper_skeem.png?500  |Schaltplan der Stoßstangensensoren.}}]
  
-[{{  :examples:projects:robot:robot_pumper_skeem.png?500  |Electric scheme of the bumper sensors}}]+[{{  :examples:projects:robot:robot_pumper_pcb.png?500  |Aufbauplan der Stoßstange.}}]
  
-[{{  :examples:projects:robot:robot_pumper_pcb.png?500  |Assembly scheme of the bumper}}]+<pagebreak>
  
-~~PB~~+=== Kontrollsystem ===
  
-=== Control system ===+Das Kontrollsystem des Roboters, leitet sich von einem Verhaltensmodell ab und ist an Funktionalität, Anforderungen und Einschränkungen der ursprünglichen Aufgabe angepasst. 
 +Aus dem Verhaltensmodell des Systems wird ein spezifisches Kontrollprogramm entworfen, welches wiederum die Basis für den Softwareprogrammcode ist. 
 +Alle drei Ebenen (Verhaltensmodell-Algorihtmus-Quellcode) müssen miteinander vereinbar sein.
  
-The control system of the robot derives from behavioral model and is set by the functionality, requirements and restrictions of the initial task. From the behavioral model of the system a specified control program is created, which in turn is the basis for software program code. All three levels (behavioral model-algorithm-source code) must be consistent with each other. +== Algorithmus ==
  
-== Algorithm ==+Der Algorithmus beschreibt die Kontrolllogik des System und wird als Blockdiagramm dargestellt. Einige Elemente und Beschreibungen der Verhältnisse genügen, um einen einfachen Algorithmus zu erstellen. Wenn der Algorithmus für den Roboter richtig zusammengestellt ist, kann daraus sehr einfach ein Kontrollprogramm erstellt werden. 
 +Grundsätzlich werden zwei verschiedene Objekte in einem Algorithmus genutzt: ein Rechteck mit runden Ecken, zur Darstellung einer Aktivität sowie ein kleiner Diamant zur Kontrolle einer Bedingung, gefolgt von einem Start weiterer Aktivitäten, je nach Resultat der Kontrolle.
  
-Algorithm describes the control logic of the system and is depicted as a block diagram. A few elements and description of their relations is enough to create a simple algorithm. If the algorithm of the robot is composed correctly, then it is relatively easy to compose a control program for this robot.    +Bedeutung der im Algorithmus verwendeten Symbole
-Mainly two different objects are used in the algorithma rectangle with rounded corners, which marks an activity and a small diamond for controlling a condition, followed by a startup of further activities in accordance with the results of the inspection.+
  
-Meanings of the symbols used in the algorithm: +^Symbol^Bedeutung^0^1^-1^ 
 +|M1|linker Motor|Stop|rotiert im Uhrzeigersinn|rotiert gegen den Uhrzeigersinn| 
 +|M2|rechter Motor|stop|rotiert im Uhrzeigersinn|rotiert gegen den Uhrzeigersinn| 
 +|F|erster mittlerer Berührungssensor|kein Signal|Signal| | 
 +|FR|erster rechter Berührungssensor|kein signal|Signal | | 
 +|FL|erster linker Berührungssensor|kein signal|Signal | | 
 +|d|Bezug| | | |
  
-^Symbol^Meaning^0^1^-1^ +[{{  :examples:projects:robot:robot_algoritm.png?500  |Statusdiagramm eines Algorithmus}}]
-|M1|left motor|stop|rotates clockwise|rotates counter-clockwise| +
-|M2|right motor|stop|rotates clockwise|rotates counter-clockwise| +
-|F|first middle touch sensor|no signal|signal| | +
-|FR|first right touch sensor|no signal|signal | | +
-|FL|first left touch sensor|no signal|signal | | +
-|d|reference| | | |+
  
-[{{  :examples:projects:robot:robot_algoritm.png?500  |Algorithm state diagram}}]+== Quellcode  ==
  
-== Source code  == +Einfache Navigation
- +
-Simple navigation+
 <code c> <code c>
 #include <homelab/module/motors.h> #include <homelab/module/motors.h>
Line 5223: Line 4734:
 #include <homelab/delay.h> #include <homelab/delay.h>
  
-// Defining bumper pins+// Definieren der Stoßstangenpins
 pin front      = PIN(C, 0); pin front      = PIN(C, 0);
 pin frontleft  = PIN(C, 1); pin frontleft  = PIN(C, 1);
Line 5229: Line 4740:
  
 // //
-// Mainprogram+// Hauptprogramm
 // //
 int main(void) int main(void)
 { {
- // Initiating motors and + // Starten von Motor und 
  dcmotor_init(0);  dcmotor_init(0);
  dcmotor_init(1);  dcmotor_init(1);
  
- // Sensor pins as inputs+ // Sensorpins als Inputs
  pin_setup_input_with_pullup(front);  pin_setup_input_with_pullup(front);
  pin_setup_input_with_pullup(frontleft);  pin_setup_input_with_pullup(frontleft);
  pin_setup_input_with_pullup(frontright);  pin_setup_input_with_pullup(frontright);
  
- // Endless cycle+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Clockwise motor startup + // Motorstart im Uhrzeigersinn 
  dcmotor_drive(0, 1);  dcmotor_drive(0, 1);
  dcmotor_drive(1, 1);  dcmotor_drive(1, 1);
            
- // Controlling the middle sensor signal+ // Kontrolle des mittleren Sensorsignals
  if (pin_get_value(front))  if (pin_get_value(front))
  {  {
- // Reversal of the motors+ // Umkehr der Motoren
  dcmotor_drive(0, -1);  dcmotor_drive(0, -1);
  dcmotor_drive(1, -1);  dcmotor_drive(1, -1);
  
- // Paus second+ // Pause Sekunde
  sw_delay_ms(1000);  sw_delay_ms(1000);
  
- // Left motor clockwise startup  + // Start des linken Motors im Uhrzeigersinn  
  dcmotor_drive(0, 1);  dcmotor_drive(0, 1);
   
- // Paus seconds+ // Pause Sekunden
  sw_delay_ms(2000);  sw_delay_ms(2000);
  }  }
  
- // Controlling the left sensor signal+ // Kontrolle des linken Sensorsignals
  else if (pin_get_value(frontleft))  else if (pin_get_value(frontleft))
  {  {
- // Reversal of right motor+ // Umkehr des rechten Motors
  dcmotor_drive(1, -1);  dcmotor_drive(1, -1);
   
- // Paus seconds+ // Pause Sekunden
  sw_delay_ms(2000);  sw_delay_ms(2000);
  }  }
  
- // Controlling the right sensor signal+ // Kontrolle des rechten Sensorsignals
  else if (pin_get_value(frontright))  else if (pin_get_value(frontright))
  {  {
- // Reversal of left motor + // Umkehr des linken Motors 
  dcmotor_drive(0, -1);  dcmotor_drive(0, -1);
   
- // Paus seconds+ // Pause Sekunden
  sw_delay_ms(2000);  sw_delay_ms(2000);
  }  }
Line 5289: Line 4800:
 </code> </code>
  
-~~PB~~+<pagebreak>
  
-=== Ready-to-use solution ===+=== Gebrauchsfertige Lösung ===
  
-Robot platform completed under this project is largely made from plasticexcept from motor mountingswhich are made from aluminumElectronic modules are placed on top of each other and the battery is loose between the platesBumpers are made from PCB and painted blackThe top plate of the robot is completely flat, allowing to attach different desired devicesA simple radar was installed on the robotwhich consisted of a small RC servo motor and an infra red sensorAs a second solutionintelligent camera module was installed on the platform for solving machine vision problemsBoth solutions are brought out on the following picturesStandard manipulator was tested as a third devicewhich components are controlled with standard servo motors as well, using serial interface for controlling their actuator+Die in diesem Projekt gebaute Roboterplattform besteht zum größten Teil aus Plastikaußer der Motorbefestigungwelche aus Aluminium hergestellt istDie elektrischen Module wurden auf einander platziert, die Batterie liegt lose zwischen den PlattenDie Stoßstangen wurden aus PCB gebaut und schwarz gestrichenDie Dachplatte des Roboters ist flach und erlaubt das Anbringen verschiedener GerätenEs wurde ein einfaches Radar installiertwelches aus einem kleinen RC Servomotor und einem Infrarotsensor besteht. 
 +Als zweite Lösung wurde ein intelligentes Kameramodul installiertwelches beim Lösen visueller Probleme hilftBeide Lösungen werden auf den folgenden Bildern vorgestelltEin einfacher Manipulator wurde als drittes Gerät getestetdessen Komponenten mit standard Servomotoren sowie einer seriellen Schnittstelle zur Kontrolle des Antriebs betrieben werden.
  
-[{{  :examples:projects:robot:robot_radar.png?580 |Robot with infrared radar}}] +[{{  :examples:projects:robot:robot_radar.png?580 |Roboter mit Infrarotradar.}}] 
-[{{  :examples:projects:robot:robot_camera.png?580  |Robot with intelligent camera module (CMUcam3)}}]+[{{  :examples:projects:robot:robot_camera.png?580  |Roboter mit intelligentem Kameramodul (CMUcam3).}}]
  
-~~PB~~+<pagebreak>
  
-=== Economic calculation ===+=== Kostenkalkulation ===
  
-Economic calculation includes the cost of components and robot production costs+Die Kostenkalkulation enthält die Kosten für die Komponenten und die Produktion des Roboters
  
-Tabel of components cost +Tabelle der Komponentenkosten 
  
-^Component^Mark^Quantity^Price^Cost^+^Komponent^Marke^Anzahl^Preis^Kosten^
 |Motor|M LE149.6.43|2|500.-|1000.-| |Motor|M LE149.6.43|2|500.-|1000.-|
-|Microcontroller|uC ATmega128|1|900.-|900.-| +|Mikrocontroller|uC ATmega128|1|900.-|900.-| 
-|Motors actuator board|Actuator Board v1.2|1|700.-|700.-|+|Motorenantriebsplatine|Actuator Board v1.2|1|700.-|700.-|
 |Power plate|TP|1|500.-|500.-| |Power plate|TP|1|500.-|500.-|
-|Line following sensors|LFS QRD1114|8|30.-|240.-| +|Linienfolgesensoren|LFS QRD1114|8|30.-|240.-| 
-|Touch sensors|TS Microswitch|8|25.-|200.-| +|Berührungssensoren|TS Microswitch|8|25.-|200.-| 
-|Hull plate|ABS |4|50.-|200.-| +|Gehäuseblech|ABS |4|50.-|200.-| 
-|PCB blank| |2|50.-|100.-| +|PCB Rohteil| |2|50.-|100.-| 
-|Motor mountings profile|Al-L |2|10.-|20.-| +|Motorenbefestigungsprofil|Al-L |2|10.-|20.-| 
-|Wheel|60/10 mm |2|30.-|60.-| +|Reifen|60/10 mm |2|30.-|60.-| 
-|Battery|NI-MH 9,6 V|1|350.-|350.-| +|Batterie|NI-MH 9,6 V|1|350.-|350.-| 
-|Different cables| |10|20.-|200.-| +|Kabel| |10|20.-|200.-| 
-|Nuts-bolts| |1|50.-|50.-| +|Muttern| |1|50.-|50.-| 
-|Other acsessories| |1|100.-|100.-|+|Weiteres Zubehör| |1|100.-|100.-|
 ^ Total  ^ ^ ^ ^ 4620.- ^ ^ Total  ^ ^ ^ ^ 4620.- ^
 +Kosten in EEK.
  
-Estimated labor and production cost for a single copy+Geschätzte Arbeits- und Produktionskosten für ein einzelnes Modell.
  
-^Work^Time (h)^Price^Cost ^  +^Arbeit^Zeit (h)^Preis^Kosten ^  
-|Milling construction details|1|300.-|300.-| +|Fräsen der Bauteile|1|300.-|300.-| 
-|Milling PCBs (bumpers)|0,5|500.-|250.-| +|Fräsen der PCBs (Stoßstangen)|0,5|500.-|250.-| 
-|Construction of the robot|0,5|250.-|125.-| +|Bau des Roboters|0,5|250.-|125.-| 
-|Building bumpers (soldering components)|1|300.-|300.-| +|Bau der Stoßstangen (löten der Komponenten)|1|300.-|300.-| 
-|Programming|5|300.-|1500.-| +|Programmierarbeit|5|300.-|1500.-| 
-|Compiling documentation|3|250.-|750.-|+|Erstellen der Dokumentation|3|250.-|750.-|
 ^Total^ 11 ^ ^ 3225.- ^ ^Total^ 11 ^ ^ 3225.- ^
  
-Estimated cost of the robot **7845.-**+Vorraussichtliche Kosten des Roboters **7845.-**
  
-The cost calculation of the robot is estimatedsince it is an educational project, where most of the work and construction is done in significantly larger volumes, but without direct chargeTherefore, the work and the approximate time spent does not reflect the real situation.+Die Kostenkalkulation des Roboters basiert auf geschätztenda es sich um ein Lehrprojekt handelt und aus diesem Grund mehr Zeit für die Arbeit und Konstruktion verwendet wird und keine direkte Bezahlung erfolgtDaher spiegelt der berechnete Arbeitsaufwand keine reale Situationen wider.
  
-=== Project management ===+=== Projektmanagement ===
  
-Mechatronic system (Robotis created as a team work with a firm timetable and budgetthus having  most of the significant features of a projectThe key activities of the project management weretime planningteam work planning and managementbudget monitoring and obtaining suppliescurrent reporting to the supervisorpresentation and documentation of the outcomeThe project report includes working groups minutes of meetingsproject plan (preferably in Gantt diagram), resource allocation (including human resources), planned and actual budgetFor example a simple action plan is given as a Gantt diagram.+Das mechatronische System (Roboterist in Gruppenarbeit mit straffem Zeitplan und Budget entstandenund besitzt damit die wichtigsten Eigenschaften eines Projektes  
 +Die Schlüsselaktivitäten des Projekts warenErstellung des ZeitplansPlanung und Management der GruppenarbeitÜberwachung des Budgets sowie Besorgung des MaterialsWeitergabe aktueller Berichte an den LeiterPräsentation sowie Dokumentation des ErgebnissesDer Projekbericht enthält Angaben zu den ArbeitsgruppenTerminen von Meetings, dem Projektplan (am besten in einem Gantt Diagramm), der Ressourcenverteilung (inkl. Personalverteilungsowie zum geplanten und aktuellen BudgetNachfolgend wird ein einfacher Projektplan als Gantt Diagramm dargestellt.
  
-[{{  :examples:projects:robot:roboti_projekt_gantt.gif?580  |Action diagram of a project}}]+[{{  :examples:projects:robot:roboti_projekt_gantt.gif?580  |Projektplan}}]
  
-=== Summary and conclusions ===+=== Fazit ===
  
-Economic calculation showed that the production cost of the robot is quite highespecially when dealing with a single originalbut remains within a predetermined initial taskProduction costs could certainly be substantially reduced through the optimization of materials and components, and producing a larger quantity of robots at the same timeDuring this project we learned how to project a mechatronic systemhow to construct and test itwhich gave us the first time experience of this kind+Die Kostenrechnung hat gezeigtdass die Produktionkosten des Roboters sehr hoch sindbesonders wenn man nur mit einem Exemplar rechnetDie Kosten blieben jedoch im anfänglich gesetzten Rahmen. Die Prouktionskosten könnten durch Optimierung des Materials und der Komponeten sowie durch gleichzeitige Fertigung mehrerer Roboter wesentlich reduziert werden. 
 +Während des Projekts ist deutlich gewordenwie ein mechatronisches System geplantgebaut und getestet wird.
  
-At the end of the work a fact revealedinorder for the robot to function properly significantly more time should be planned for testingespecially for the software testingDifferent modules may not always work properly togetheralthough as a separate experiment it worksThis shows that the integration of the modules of the system is a serious challengeand therefore more time and resources should be planned for this+Am Ende der Arbeit ist eines klar gewordenDamit der Roboter richtig funktioniertsollte deutlich mehr Zeit zum Testen eingeplant werden, insbesondere für Softwaretests. 
 +Unterschiedliche Module funktionieren nicht immer einwandfrei zusammenauch wenn dieses in einzelnen Experimenten klapptDadurch wird deutlich, dass die Integration von Modulen in ein System eine echte Herausforderung darstelltund hierfür mehr Zeit und Ressourcen eingeplant werden sollten.
  
-In conclusionwe believe that the project was very interesting and instructive, it gave an indication how to design and construct integrated systems+Abschließend hoffen wirdass das Projekt sehr interessant und lehrreich war und einen Einblick in das Design und die Konstruktion von integrierten Systemen geben konnte.
  
-=== References and materials used ===+=== Genutzte Quellen und Materialien ===
  
-  - HomeLab generic manual http://home.roboticlab.eu +  - Allgemeines Benutzerhandbuch des HomeLab http://home.roboticlab.eu 
-  - ATmega128 datasheet+  - Datenblatt des ATmega128
   - Dudziak, R., Köhn, C., Sell, R., Integrated Systems & Design, TUT Press, 2008   - Dudziak, R., Köhn, C., Sell, R., Integrated Systems & Design, TUT Press, 2008
   - Friendenthal, S., Moore, A., Steiner, A., A Practical Guide to SysML, Elsevier, 2008   - Friendenthal, S., Moore, A., Steiner, A., A Practical Guide to SysML, Elsevier, 2008
   - Perens, A. Project Management, Külim, 1999   - Perens, A. Project Management, Külim, 1999
   - Bräunl, T. Embedded Robotics, Springer-Verlag, 2003   - Bräunl, T. Embedded Robotics, Springer-Verlag, 2003
-====== What's next? ======+====== Ausblick ======
  
-If you have reached the end of this book you have already quite a lot of knowledge and practical skills of programming the microcontroller and using different devicesIf you have used examples selectively is also OKHopefully you got help for solving the problems on the time and you got also some theoretical knowledge about the problemNext logical step would be to start building custom intelligent devices according to your interest or needsStudents should look around and participate in some robotic contestIn any case you can apply the acquired knowledge to make your everyday life easier and more funYou can build a simple security system for your summer house or garagewhich uses different sensors to detect the intruders and alarm the owner.+Wenn Sie am Ende dieses Buches angelangt sind, haben Sie einige Kenntnisse sowie praktische Fähigkeiten in Bezug auf das Programmieren von Mikrocontrollern und den Umgang mit diversen Geräten erlangt, selbst wenn Sie nicht alle Übungsbeispiele absolviert habenWir hoffen, dass dieses Buch Sie bei der Bewältigung von Problemen sowie der Erlangung theoretischen Hintergrundwissens unterstützen konnteDer nächste Schritt wäre nun, eigene intelligente Geräte zu entwickeln, die Ihren Interessen oder Bedürfnissen angepasst sindSchüler und Studenten können sich darüber hinaus nach Robotikwettbewerben umsehenAuf jeden Fall können Sie das erworbene Wissen dazu nutzen, Ihren Alltag einfacher und mit mehr Freude zu gestalten. Sie können einfache Sicherheitssysteme für Ihr Ferienhaus oder Ihre Garage entwickeln, die mit verschiedenen Sensoren arbeiten, um Einbrecher aufzuspüren und den Eigentümer zu warnen. Bei Problemen, fragen Sie um Hilfe. Dieses Buch wird sich ständig in seiner elektronischen Form weiter entwickelnEs ist Teil eines Robotik-Studienkonzepts, welches die Pflege der Webseite einschließtZusätzlich zum online verfügbaren Material existiert ein Benutzerforum, in welchem sie Antworten auf Ihre Probleme finden können. Die elektronische Version enthält zusätzliche Kapitel zu den Themen Bluetooth, Ethernet, RFIDMachine Vision für Fortgeschrittene etc.
  
-If you feel troubled, ask for help. This book is not finished and will keep on developing further in his electronic form. The book is a part of robotic study concept which includes the support website. In addition to the material the web includes a user community forum where you can find answers for your problems. The electronic version has also additional chapters like Bluetooth, Ethernet, RFID, machine vision for the advanced users etc.. +**Für Lehrer:** Registrieren Sie sich auf unserer Homepage und teilen Sie uns kurz mitdass Sie  Lehrer sind. Daraufhin werden Sie Zugriff auf die Lösungen der Übungsaufgaben sowie Antworten auf die Fragen am Ende jedes Übungsabschnittes erhalten.
- +
-**For teachers:** Register yourself in our website and send a note that you are a teacheryou will get the access to the exercise solutions and answers of the questions in the end of every lab ;)+
  
 {{  :images:book:robot_fire.jpg?250|}} {{  :images:book:robot_fire.jpg?250|}}
-Web environment: \\+Homepage: \\
 http://www.roboticlab.eu http://www.roboticlab.eu
 +
 +---
 + MISSING PAGE ---
  
de/book.1311234890.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