This shows you the differences between two versions of the page.
de:book [2011/07/21 07:54] – angelegt seiler | de:book [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | 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 people. The book is oriented to the schools and universities, but can also be used for hobbyist and companies who are planning to use AVR microcontrollers in their projects. The target group is as well teachers as learners by helping to get fast results for both of them: for 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 helfen. Darüber hinaus soll es auch dazu beitragen, die Begeisterung für den Ingenieurberuf bei jungen Menschen zu wecken. In erster Linie richtet sich das Buch an Schulen sowie Universitäten, |
+ | |||
+ | Ziel ist es, sowohl Lehrende als auch Lernende dabei zu unterstützen, | ||
- | **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, | ||
- | 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 | + | **1.** Das erste Kapitel gibt eine kurze Einführung |
- | **3.** section introduces the hardware and software platform which is developed for the educational use and is a base platform of the next chapter examples. Special software library is developed for most common functions. The 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 gegeben. Dieses Kapitel basiert weitgehend auf dem Datenblatt des ATmega Mikrocontrollers, |
- | **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 skills. For better understanding the chapters are provided by the references to the theoretical section. | + | **3.** Dieses Kapitel führt die Hardware- und Softwareplattform ein, welche für Lehrzwecke entwickelt wurde und als Grundgerüst für weitere Beispiele |
+ | **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, | ||
- | **5.** | + | **5.** |
- | 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 Tallinn, January 2010 | + | Bochum, im Sommer 2013 |
- | Raivo Sell | + | Sven Seiler |
- | ====== | + | ====== |
- | === Microcontrollers | + | === Mikrocontroller |
[{{ : | [{{ : | ||
- | Microcontroller is basically a computer which is placed on a single integrated circuit chip. It consists of memory, processor, as well as input-output interfaces. Microcontroller is programmed to run a certain task, which means, if there is a need to change or enhance its functionality, one must install a new program on the chip. Aspects which differentiate microcontrollers from other computers | + | Mikrocontroller sind im Wesentlichen Computer, welche auf einen einzelnen Chip mit integriertem Schaltkreis positioniert werden und aus einer Speichereinheit, einem Prozessor sowie Input-Output Schnittstellen bestehen. Sie werden für eine bestimmte Aufgabe programmiert, was bedeutet, dass sobald eine Änderung oder Verbesserung der Aufgabe nötig ist, ein neues Programm auf dem Chip installiert werden muss. Eigenschaften, |
- | * 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 task, in order to change its functionality new software must be installed. | + | * Er wird zur Durchführung einer bestimmte Aufgabe programmiert, um die Funktionalität zu ändern muss neue Software installiert werden. |
- | * It consumes less power, because all physical characteristics are smaller and less energy demanding than in PC, laptop or server. Usually the developers of microcontrollers are concentrating on low energy demand, so that mobile | + | * Er verbraucht weniger Strom, da alle physischen Komponenten kleiner und energiesparender sind als die eines PC, Laptops oder Servers. Entwickler von Mikrocontrollern fokussieren einen geringen Energieverbrauch, sodass |
- | * Single purpose inputs and outputs. Microcontrollers have so called peripherals, which establish connection between microcontroller and other microcontrollers or computers | + | * In- und Outputs, die auf einen bestimmten Zweck ausgelegt sind. Mikrocontroller besitzen |
- | Microcontrollers can be found in a variety of everyday items: household appliances | + | Mikrocontroller finden sich in diversen Gegenständen des täglichen Gebrauchs: in Haushaltsgeräten |
- | === 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 | + | Robotik ist die Wissenschaft, |
+ | |||
- | 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 | + | === Mikrocontroller |
- | * Atmel AVR microcontrollers (ATmega, ATtiny, etc.) | + | Aufgrund der Weitläufigkeit der Robotik, konzentrieren wir uns in diesem Buch auf die Hobby-Robotik. Diese Systeme sind nicht allzu komplex und es ist möglich sie eigenständig zu implementieren. Hä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 before. For 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? | + | * Microchip Technology |
+ | * Mikrocontroller, | ||
- | * processor operating frequency | + | |
- | * program memory capacity | + | 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, |
- | * data memory capacity | + | 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: |
- | * number of input/output pins and their function | + | |
- | * number of timers | + | * Arbeitsgeschwindigkeit des Prozessors – legt die Arbeitsgeschwindigtkeit des Chips fest |
- | * energy consumption | + | * Speicherkapazität des Programms |
+ | * Datenspeicherkapazität | ||
+ | * Anzahl der Input- | ||
+ | * Anzahl der Timer – wichtig für das Zeitverhalten der Anwendung | ||
+ | * Energieverbrauch | ||
- | Here development environment is PC software, witch allows creating and compiling programs, uploading programs to the microcontrollers and bridging | + | In diesem Buch verwenden wir PC-Software als Entwicklungsumgebung, mit der Programme erstellt und kompiliert und auf die Mikrocontroller geladen werden können sowie Zugriff auf die laufenden Programme hergestellt werden kann, um 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, |
- | ====== AVR microcontroller | + | ====== Elektronik ====== |
+ | |||
+ | {{: | ||
+ | |||
+ | Verschiedene elektronische Schaltkreise werden so häufig | ||
+ | |||
+ | ===== Ohm' | ||
+ | |||
+ | 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, | ||
+ | |||
+ | Die Gleichung lautet wie folgt: | ||
+ | [{{ : | ||
+ | |||
+ | 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 Schaltkreis, der die Eingangsspannung teilt. Die Ausgangsspannung ist ein Teil der Eingangsspannung und der Wert ist abhängig vom Verhältnis der Widerstände im Schaltkreis. Die Abbildung rechts zeigt ein Beispiel mit zwei Widerständen. | ||
+ | |||
+ | Die Ausgangsspannung des Schaltkreises wird mit folgender Gleichung berechnet: | ||
+ | |||
+ | |||
+ | [{{ : | ||
+ | |||
+ | U< | ||
+ | |||
+ | mit: | ||
+ | |||
+ | * U< | ||
+ | * U< | ||
+ | * R< | ||
+ | |||
+ | Die Gleichung ist vom Ohm' | ||
+ | |||
+ | mit: | ||
+ | |||
+ | I = U< | ||
+ | |||
+ | und: | ||
+ | |||
+ | U< | ||
+ | |||
+ | Spannungsteiler werden häufig im Zusammenhang mit Widerstandssensoren (Fotowiderstand, temperaturgesteuerter 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, | ||
+ | ===== 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, | ||
+ | |||
+ | |||
+ | [{{ : | ||
+ | |||
+ | R = (U< | ||
+ | U< | ||
+ | P< | ||
+ | |||
+ | mit: | ||
+ | |||
+ | * R für den Widerstand. | ||
+ | * U< | ||
+ | * U< | ||
+ | * I< | ||
+ | * U< | ||
+ | * P< | ||
+ | |||
+ | Der spannungsbegrenzende Widerstand einer LED darf nicht geringer sein als R und muss mindestens die Leistung von P< | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | ====== AVR Mikrocontroller | ||
{{: | {{: | ||
- | The following chapters introduce the AVR microcontroller, which this book is based on. In spite of being so small, a microcontroller is full of features that have been documented by Atmel in a manual almost | + | Das folgende Kapitel stellt den AVR Mikrocontroller vor, auf welchem dieses Buch basiert. Trotz seiner geringen Größe besitzt der Mikrocontroller eine Vielzahl von Funktionen, welche von Atmel in einem fast 400 Seiten umfassenden Handbuch dokumentiert wurden. Darüber hinaus gibt es noch einige weitere Dokumente, die sich mit der Thematik befassen. Sämtliche Informationen werden in dem folgenden Abschnitt in komprimierter Form dargestellt, um 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 |
[{{ : | [{{ : | ||
- | AVR is a series of 8-bit RISC microcontrollers produced by Atmel. AVR follows | + | AVR ist eine Serie aus 8-bit RISC Microcontroller produziert von Atmel. AVR folgt der Harcard-Architektur und hat daher separate |
- | The production of AVR microcontrollers began in 1997 and by now AVR is one of the most popular controller with freelance electronic engineers. Thanks to cheap developing tools, the diversity of peripherals | + | Die Produktion des AVR Microcontroller begann |
- | Based on the type of the application, there are several types of AVR microcontrollers, each with a different configuration. Most of the AVRs belong to the megaAVR | + | Basierend auf den Typ der Anwendung, gibt es unterschiedliche Typen von AVR Microcontroller, jeder mit einer unterschiedlichen Konfiguration. Die meisten der AVRs gehören zur megaAVR |
- | The following text describes the main features of megaAVR | + | Der folgende Text beschreibt die Hauptfeatures der megaAVR |
+ | Der Hautunterschied liegt in den Peripherals. | ||
+ | Die Codebeispiele dieser Einführung sind mit AVR LibC in Assembler und C geschrieben | ||
- | === Physical appearance | + | |
+ | === äußerer Aufbau | ||
[{{: | [{{: | ||
- | Like all other controllers, | + | Wie alle anderen Controller ist der AVR in einer Standarthülle gepackt. Das traditionelle Gehäuse ist DIP (bzw. DIL). DIP ist eine so genannte Casing-On-Legs. Alle Pins treten wie Beine , ca 5mm in Länge, aus dem schwarzen Plastikgehäuse hervor. |
+ | DIP Gehäuse sind eine gute Wahl für Hobbyanwendungen und Prototypen, weil es dafür günstige Sockets gibt. Daher kann der Microcontroller einfach ersetzt werden sollte er Ausfallen. Die Beine sind aber auch der Nachteil des DIP Gehäuses, da man dafür Löcher | ||
- | The surface mount casings | + | Die Surface-Mount-Casings |
+ | 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 Microcontrollers, die Pins für einen Externen Oszillator sind nahe des Ground-Pins, die Bus-Pins sind durchnummeriert, | ||
+ | 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, | ||
== ATmega128 == | == ATmega128 == | ||
- | To better understand the following examples on ATmega128, there is a pinout schematic of ATmega128 (SMT package) below. Next to each pin, is a text with its number, primary function and secondary | + | Um die folgenden Beispiele am ATmega 128 besser zu verstehen, gibt es am Ende des Textes ein Pinout-Schema des ATmega128 (SMT Package). |
+ | An jedem Pin ist ein Text mit der Nummer, primären Funktion und sekundären | ||
+ | AVCC und AREG sind die analog | ||
+ | XTAL1 und XTAL2 sind für den Anschluss einen externen Schwingquarzes, Resonator oder Taktgebers. Die Pins PB0 bis PG4 markieren die Bits der Input-Output Buses. Die sekundären Funktionen werden | ||
[{{ : | [{{ : | ||
- | ===== Registers | + | ===== Register |
- | One of the toughest things for beginners to understand in a microcontroller is typically a register. When dealing with microcontrollers, it is impossible to get by without knowing what it is. This book is in no way different, as 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 terms, so that even a beginner can grasp the idea of a register. | + | Typischerweise ist das Register eines der Bestandteile eines Mikrocontrollers, die ein Anfänger nur mühsam versteht. Im 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 angehalten, sich das Konzept des Registers anzueignen. Daher wird es im nun folgenden Text auf eine möglichst verständliche Weise erklärt, sodass auch ein Anfänger ein Gespür für das Register bekommt. |
=== Essence === | === Essence === | ||
- | [{{ : | + | [{{ : |
- | A register is like a panel of buttons on a home appliance. It has switches, which can be turned on or off. One of the best examples is a simple tape player. For those, who don't remember, the tape player has (had) 6 buttons, left to right: | + | Ein Register ähnelt einem Panel von Tasten eines Haushaltsgerätes. Es verfügt über Schalter, die ein- und ausgeschaltet werden können. Das beste Beispiel hierfür ist ein Kassettenrekorder. Zur Erinnerung, ein Kassettenrekorder verfügt über 6 Tasten von links nach rechts: |
- | | + | |
- | * Rewind | + | |
- | * Play | + | * Zurückspulen |
- | * Fast forward | + | * Abspielen |
- | * Stop | + | * Vorspulen |
+ | * Stopp | ||
* Pause | * Pause | ||
- | Each button does something, but only when it is used correctly. For example, the stop button does nothing unless a tape is playing | + | Jede Taste führt eine Funktion aus, jedoch nur wenn sie auch korrekt verwendet wird. So macht die Stopp-Taste solange nichts, bis die Kassette abgespielt wird. Erst dann kann die Funktion ausgeführt werden und die Wiedergabe wird gestoppt. Dagegen können Vorlauf- und 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 nicht. Die Aufnahmetaste startet nur dann eine Aufnahme, wenn sowohl die Abspielen- als auch die Aufnahmetaste zeitgleich gedrückt werden. Eventuell hat mancher einmal versucht, mehrere 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 aus, wenn sie korrekt verwendet wird. Werden die falschen Tasten betätigt, wird der Mikrocontroller | ||
- | 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, | + | [{{ : |
- | [{{ : | + | Da der Status eines Registerschalters einfach durch eine Nummer abgebildet werden kann, lässt sich ein Register mit einem Speicher vergleichen, |
- | Since the state of a register' | ||
- | On a tape player it is possible to press each button separately, but in a register it is more difficult to change the value of one " | + | Während es bei einem Kassettenrekorder möglich ist, jeden Knopf einzeln zu betätigen, ergeben sich bei einem Register Schwierigkeiten, |
- | === Usage === | + | === Gebrauch |
- | To write to a register or read a value from it, it has to be addressed as a variable | + | Zur Programmierung eines Registers oder auch dazu, um Werte aus diesem abzulesen muss er als Variable |
<code c> | <code c> | ||
Line 135: | Line 232: | ||
</ | </ | ||
- | There is nothing difficult in writing and reading register values, but it gets a little tricky if only a single bit needs to be changed. To change bits, one needs to know how to do binary math and use different numeric systems. It isn't forbidden to deal only with binary numbers, but they can be a bit troublesome, | + | Die Schwierigkeit liegt nicht darin, Registerwerte zu schreiben und auszulesen, sondern vielmehr darin, ein einzelnes Bit zu verändern. Hierzu sind Kenntnisse der Binärmathematik sowie im Gebrauch diverser Zahlensysteme notwendig. Es ist auch möglich, nur mit Binärzahlen zu arbeiten. Da diese aufgrund ihrer Länge die Programmierarbeit jedoch erschweren können, verwenden die meisten Programmierer die kürzeren Hexadezimalzahlen. |
- | [{{ : | + | [{{ : |
- | In hexadecimal, | + | Im Hexadezimalsystem gibt es nicht nur die Ziffern |
- | To change single bits in a number | + | Um einzelne Bits innerhalb einer Zahl zu verändern |
- | [{{ : | + | [{{ : |
- | ~~PB~~ | + | < |
- | * **Negation / Inversion** \\ Negation | + | * **Negation / Inversion** \\ Eine Negation |
- | * **Logical multiplication | + | * **Logische Multiplikation |
- | * **Logical addition | + | * **Logische Addition |
- | * **Exclusive disjunction | + | * **Exklusive Disjunktion |
- | This is all one needs to know to change single bits. The theory alone is probably not enough, though, and that is why there are some typical examples with registers in the next few paragraphs. | + | Man benötigt nicht mehr als diese vier Operationen, um einzelne Bits zu ändern. Da die Theorie allein vermutlich nicht ausreichen mag, enthalten die folgenden Abschnitte einige Anwendungsbeispiele. |
~~CL~~ | ~~CL~~ | ||
- | == Setting a single bit high == | + | == Ein einzelnes Bit "high" setzen |
- | [{{ : | + | [{{ : |
- | To set one or more bits in a register | + | Um einzelne oder mehrere Bits in einem Register “high” zu setzen |
~~CL~~ | ~~CL~~ | ||
<code c> | <code c> | ||
- | // Let's suppose | + | // Annahme |
- | REG = REG | 0x11; // First method | + | REG = REG | 0x11; // Erste Methode |
- | REG |= 0x11; // Second method | + | REG |= 0x11; // Zweite Methode |
- | // Now REG = 0x1F | + | // Ergebnis |
</ | </ | ||
- | == Setting a single bit low == | + | == Ein einzelnes Bit “low” setzen |
- | [{{ : | + | [{{ : |
- | To set one or more bits in a register | + | Um einzelne oder mehrere Bits in einem Register “low“ zu setzen |
~~CL~~ | ~~CL~~ | ||
<code c> | <code c> | ||
- | // Let's suppose | + | // Annahme |
- | REG = REG & 0xFE; // First method | + | REG = REG & 0xFE; // Erste Methode |
- | REG &= 0xFE; // Second method | + | REG &= 0xFE; // Zweite Methode |
- | // Now REG = 0x0E | + | // Ergebnis |
</ | </ | ||
- | ~~PB~~ | + | < |
- | == Inverting a single bit == | + | == Ein einzelnes Bit invertieren / umkehren |
- | [{{ : | + | [{{ : |
- | To invert one or more bits in a register an exclusive disjunction operation is required. 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 inverted | + | Zum Invertieren einzelner oder mehrerer Bits eines Registers muss eine Exklusive Disjunktion angewandt werden. Hierzu ist ein Operand das Register, der andere muss eine Bitmaske sein, in der das einzige high Bit jenes ist, welches invertiert werden soll. Der C-Code für diese Operation ist unten abgebildet: |
~~CL~~ | ~~CL~~ | ||
<code c> | <code c> | ||
- | // Let's suppose | + | // Annahme |
- | REG = REG ^ 0x11; // First method | + | REG = REG ^ 0x11; // Erste Methode |
- | REG ^= 0x11; // Second method | + | REG ^= 0x11; // Zweite Methode |
- | // Now REG = 0x1E | + | // Ergebnis |
</ | </ | ||
- | == Inverting the whole register | + | == Das gesamte Register invertieren |
- | [{{ : | + | [{{ : |
+ | |||
+ | 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 | + | // Annahme |
REG = ~REG; | REG = ~REG; | ||
- | // Now REG = 0xF0 | + | // Ergebnis |
</ | </ | ||
- | == Reading the value of a single bit == | + | == Den Wert eines einzelnen Bits auslesen |
+ | |||
+ | [{{ : | ||
- | [{{ : | + | 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 | + | // Annahme |
unsigned char x = REG & 0x01; | unsigned char x = REG & 0x01; | ||
- | // Now x = 0x01 | + | // Ergebnis |
</ | </ | ||
- | ~~PB~~ | + | < |
- | == Shifting a bit == | + | == Ein Bit verschieben |
- | Many programming languages actually have a few additional bitwise operations, which make it easier for the programmers. These are bit shifting operations that shift bits left or right in a binary number. The 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 Bitoperationen, was die Programmierarbeit erleichtert. Hierzu gehören die Operationen, |
- | [{{ : | + | [{{ : |
- | The image on the right shows a shift left operation. Although bit shifting is not a logical operation and has no corresponding symbol, in C it is marked as "<<" | + | Das Bild auf der rechten Seite zeigt einen Linksshift. Auch wenn ein Bitshift keine logische Operation darstellt und kein zugehöriges Symbol hat, wird diese Operation |
~~CL~~ | ~~CL~~ | ||
Line 245: | Line 344: | ||
<code c> | <code c> | ||
REG = 0x01 << 5; | REG = 0x01 << 5; | ||
- | // Now REG = 0x20 | + | // Ergebnis |
</ | </ | ||
- | [{{ : | + | [{{ : |
- | Shift right operation works similarly to shift left operation. It is marked as ">>" | + | Der Rechtsshift funktioniert auf die gleiche Weise und wird in C durch |
~~CL~~ | ~~CL~~ | ||
<code c> | <code c> | ||
- | // Let's suppose | + | // Annahme |
unsigned char x = REG >> 5; | unsigned char x = REG >> 5; | ||
- | // Now x = 0x01 (or simply 1) | + | // Ergebnis |
</ | </ | ||
- | If a bit is shifted right from the lowest rank or left from the highest rank by the bit shifting operation, it disappears. Some programming languages also have rotating bit shift operations, where the bit doesn' | + | Wird durch diese Operationen ein Bit vom niedrigsten Rang nach rechts oder vom höchsten Rang nach links verschoben, verschwindet es. Einige Programmiersprachen verfügen jedoch über rotierende Bitshiftoperationen, bei denen ein Bit nicht verschwindet, sondern vom niedrigsten zum höchsten Rang wandert oder umgekehrt. In C gibt es diese Operationen nicht, sie können jedoch bei Bedarf vom Programmierer selbst geschrieben werden. |
- | All bit operations work with not only registers, but with variables and constants as well. The latter can of course only be used as operands and not the result. | + | Sämtliche Bitoperationen sind nicht nur mit Registern durchführbar, sondern auch mit Variablen und Konstanten. Letztere können jedoch ausschließlich als Operanden, nicht als Ergebnis genutzt werden. |
- | === AVR registers | + | === AVR Register |
- | To do anything actual with the microcontroller' | + | Um tatsächlich mit dem Register eines Mikrocontrollers zu arbeiten, ist es notwendig zu wissen, wie dieser spezielle Mikrocontroller verwendet wird. Zu jedem Mikrocontroller gibt es ein oder mehrere Datenblätter, welche seine Struktur und Funktionalität beschreiben. Dieses Datenblatt enthält auch Informationen über die Register. Der folgende Abschnitt dient dazu, die Registerbeschreibungen der AVR Datenblätter zu verstehen. |
- | [{{ : | + | [{{ : |
- | The image shows ATmega128 | + | Die Abbildung zeigt das UCSRnA Register des ATmega128. UCSRnA |
- | The content of the register is marked by an 8-slot box with a bold line around it. Each slot marks one bit. Bit ranks are marked above the box - increasing from right to left. Since AVR is an 8-bit microcontroller, most of the registers are 8-bit as well. There are some exceptions, a few registers are 16-bit, but they actually consist of two 8-bit registers. Like each register has a name, each bit in the register has also a name - just like the buttons on a tape player. Each bit is described in the datasheet. Bit names are abbreviations as well and the lower n must be substituted with the module' | + | Der Inhalt des Registers wird durch eine Box mit 8 Feldern und einem dicken schwarzen Rahmen dargestellt. Jedes Feld steht hier für ein Bit. Die Bitränge sind oberhalb der Box abgebildet – von links nach rechts ansteigend. Da der AVR ein 8-Bit Mikrocontroller ist, haben auch die meisten seiner Register |
- | Below the register' | + | Unterhalb der Bits des Registers finden sich im Datenblatt zwei Zeilen. Die erste gibt an, ob das Bit lesbar |
- | While AVR register names point to an actual memory slot address, the bit names hold the rank number of the corresponding bit. Therefore it is necessary to transform the names to bitmasks using a shift operation, in order to manipulate with bits in a register. The following code contains a few example lines for using the USART 0 module' | + | Während die AVR Registernamen auf eine tatsächliche Adresse im Speicher verweist, enthalten Bitnamen den Rang und das zugehörige Bit. Daher ist eine Transformation der Namen zu Bitmasken mit einer Shiftoperation notwendig, wenn man mit Bits in einem Register arbeiten will. Der 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 | + | // An dieser Stelle ist der Wert entweder |
- | // which enables using it in a logical operation | + | // wodurch die Nutzung |
if (u) | if (u) | ||
{ | { | ||
- | // | + | // |
| | ||
} | } | ||
- | // Sometimes it is necessary to acquire a specific 0 or 1 value, | + | // Manchmal ist es notwendig einen spezifischen |
- | // 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 | + | // Nun ist der Wert entweder |
</ | </ | ||
- | ===== Architecture | + | ===== Architektur |
- | AVR has an internal | + | Der AVR hat einen internen |
[{{ : | [{{ : | ||
- | === Instruction pipeline | + | === Befehls-Pipeline |
- | AVR has a two-stage instruction pipeline. While one instruction is executed, the next is fetched from the program memory. This is why carrying out jump instructions takes 2 cycles on fulfillment of the jump condition. Since the new instruction is always fetched from the next memory address, it is necessary to discard the previously fetched instruction and fetch a new one when jumping to another address, because it was fetched from an old, wrong location. | + | Der AVR hat eine zweistufige Befehls-Pipeline. Während ein Befehl ausgeführt wird, wird der nächste aus dem Programmspeicher geholt. Darum sind beim Ausführen einer „Jump-Instruction“ zwei Takte notwendig, um die Bedingungen des Jumps zu erfüllen. Neue Befehle werden immer von der nächsten Speicheradresse geholt. Dadurch ist es notwendig die vorherigen Befehle zu löschen und neue zu laden, wenn man zu einer neuen Adresse springt, da der Ort an dem der Befehl geholt wurde nun nicht mehr stimmt. |
- | === General purpose registers | + | === Mehrzweckregister |
- | General purpose registers | + | Mehrzweckregister |
+ | |||
+ | Wenn man in Assembler programmiert, | ||
- | 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 " | ||
- | For example: | ||
<code c> | <code c> | ||
Line 324: | Line 423: | ||
</ | </ | ||
- | === 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, | ||
<box 100% round # | <box 100% round # | ||
- | This is a piece of code written | + | Die ist ein Teil eines in Assembler |
<code asm> | <code asm> | ||
- | ldi r1, 5 ; | + | ldi r1, 5 ; |
- | lds r2, $100 ; Load the byte from the memory to register | + | lds r2, $100 ; Lädt das Byte aus dem Speicher in das Register |
- | 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 |
</ | </ | ||
</ | </ | ||
- | === Program | + | === Programmstapelspeicher (stack) === |
- | Stack is a data structure, where the last data written to the memory is read out first. AVR's stack can be used while operating with subroutines, interrupts and temporary data. Before executing a subroutine or interrupt, the address in the program counter where the program was interrupted is stored in the stack. When the subroutine or interrupt has finished its execution, this address is read back from the stack and the program continues from the address it left off before. Storing temporary data in the stack is usually used when dealing with shorter chunks of code, which do not require reserved memory throughout the execution of the program. Simpler assembler programs are usually written | + | Ein Stapelspeicher (stack) ist eine Datenstruktur, |
- | The stack of MegaAVR | + | Der Stack der MegaAVR-Serie ist physikalisch im Random-Access-Memory zu finden. Einige Modelle der tinyAVR-Serie besitzen jedoch keinen Random-Access-Memory sodass der Stack hier durch eine kleine, separate und begrenzte Speichereinheit realisiert. Normalerweise gibt es keinen Compiler für Modelle ohne Random-Access-Memory. |
- | To program | + | Um in einer hochleveligen Sprache zu programmieren |
- | ===== Clock ===== | + | ===== Taktgeber |
- | As it is with most digital electronics, an AVR also works at a constant frequency. A constant frequency assures the reliability of data exchange throughout the device. There are several methods for generating a clock signal for an AVR. | + | Wie die meiste digitale Elektronik, arbeitet auch der AVR in einer konstanten Frequenz. Eine konstante Frequenz versichert die Zuverlässigkeit von Datenaustausch im Gerät. Es gibt unterschiedliche Methoden um ein Taktsignal für den AVR zu generieren. |
- | **Internal | + | **Interner |
[{{ : | [{{ : | ||
- | This is a internal clock generator, which does not need any external components. Its main cons are low frequency and inaccuracy. | + | Dies ist ein interner Taktgeber, welcher keine externen Komponenten benötigt. Seine größten Nachteile sind niedrige Taktfrequenz und Ungenauigkeit. |
- | **External | + | **Externer |
- | 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** |
[{{ : | [{{ : | ||
- | Crystal oscillators use a crystal | + | Schwingquarze nutzen einen Kristall |
- | **Ceramic resonator** | + | **Keramische Resonatoren** |
- | Ceramic resonators are similar to crystal oscillators, but are made from cheaper piezoelectric materials. Ceramic resonators are typically smaller than crystal oscillators, but are also less precise | + | Keramische Resonatoren ähneln den Schwingquarzen, sind aber aus günstigeren piezoelektrischen Materialien gemacht. Keramische Resonatoren sind in der Regel kleiner als Schwingquarze, aber weniger genau (~0.5%) |
- | **External clock signal** | + | **Externes Taktsignal** |
[{{ : | [{{ : | ||
- | External clock signal can be generated with any device, provided that the frequency and amplitude | + | Ein Externes Taktsignal kann mit jedem Gerät erzeugt werden, solange die Frequenz und die Amplitude |
===== Interrupts ===== | ===== Interrupts ===== | ||
- | Interrupts | + | Interrupts |
- | Every interrupt in the AVR microcontroller is tied to a specific event. Each event has a flag bit in the status register, which marks the occurring of the event. Events are also tied to interrupt mask registers and the corresponding bits. If the event' | + | Jeder Interrupt des AVR Microcontrollers ist an ein bestimmtes Ereignis gebunden. Jedes Ereignis hat einen Flag-Bit im Status-Register, welcher den Eintritt des Ereignisses markiert. Ereignisse sind ebenfalls |
<box 100% round # | <box 100% round # | ||
- | To use interrupts with the AVR LibC library, it is necessary to include //interrupt.h//. The code that gets executed upon interrupt is written after the "ISR" keyword. The text between the brackets after "ISR" is the name of the interrupt. C language example: | + | Um Interrupts mit der AVR LibC Bibliothek zu nutzen, ist es notwendig |
<code c> | <code c> | ||
Line 393: | Line 491: | ||
ISR(XXX_vect) | ISR(XXX_vect) | ||
{ | { | ||
- | // Do something | + | // Anweisungen |
} | } | ||
</ | </ | ||
Line 399: | Line 497: | ||
</ | </ | ||
- | Global allowing of all interrupts is configured from the control and status register | + | Die generelle Erlaubnis sämtlicher Interrupts wird vom Control- und Statusregister |
- | ~~PB~~ | + | < |
<box 100% round # | <box 100% round # | ||
- | Let's suppose there is a 16-bit variable in use in the program, which 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 Hauptprogramm, als auch vom Interrupt geändert wird und der Wert dieser Variable wird später einer anderen Variable gegeben. |
<code c> | <code c> | ||
#include < | #include < | ||
- | // Global | + | // Globale |
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 x ä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; | ||
} | } | ||
</ | </ | ||
- | 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, | ||
- | In the following example, the value of x is given to y 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 auftritt, bekommt |
+ | |||
+ | 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(); | ||
</ | </ | ||
</ | </ | ||
- | ===== Digital inputs/outputs | + | ===== Digitale Inputs/Outputs |
- | All the buses on AVR are both readable and writable, if they are used in the default logical input/output | + | Sämtliche Busse des AVR sind sowohl lesbar als auch beschreibbar, wenn sie im normalen logischen Input/Output |
- | * 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> |
- | Task: make pins 0-3 on bus B inputs, pins 4-7 outputs, set pin 5 high and read the values of pins 0-3 to a variable. The C code for it looks like this: | + | Aufgabe: Die Pins 0-3 von Bus B sollen Input sein, die Pins 4-7 |
<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 | + | // Liest den Wert der Pins 0-3 |
x = PINB & 0x0F; | x = PINB & 0x0F; | ||
} | } | ||
Line 480: | Line 580: | ||
</ | </ | ||
- | In this example, the inputs are used in Hi-Z (high impedance) mode. In essence, the input does not put virtually any load on the source of the signal. This mode might be necessary, if the pin is used as a data bus. It is wise to use a pull-up resistor on the input, if the pin is used for a button, a switch or any other solution, where the input is connected to ground. For that, the output bit of the corresponding pin must be set high in the input mode - as a result, a resistor is placed between the supply voltage and the input, which keeps the input voltage high unless it is being pulled down by something. The goal of a pull-up resistor is to prevent floating of the input due to statical electricity and other interferences. After booting the controller, all IO buses are in the high impedance input mode by default. | + | In diesem Beispiel, wird der Input im Hi-Z (hochohmig) Modus verwendet. Im Wesentlichen liegt an diesem Input keine Ladung an. Diese Betriebsart könnte hilfreich sein, wenn der Pin als Datenbus genutzt wird. Es ist sinnvoll, einen Pull-Up-Widerstand für den Input zu nutzen, wenn der Pin als Taste, Schalter oder anderes verwendet wird wobei er mit der Masse verbunden ist. Hierfür muss das korrespondierende Output-Bit im Inputmodus „high“ gesetzt werden. Als Folge daraus muss zwischen Stromversorgung und Input ein Widerstand eingefügt werden, welcher die Inputspannung hoch hält, bis irgendetwas sie heruntersetzt. Ein solcher Pull-Up-Widerstand dient dazu, ein Floaten des Inputs aufgrund von Reibungselektrizität oder anderen Einwirkungen zu verhindern. Nachdem der Controller gebootet wurde, befinden sich sämtliche |
- | Usually, the pins on the IO bus are also used for other peripherals, aside from the logical connections. If there is a need to use the alternate function of the pin, the appropriate | + | Normalerweise werden die Pins am IO Bus, neben den logischen Anschlüssen, |
- | ===== External interrupts | + | ===== Externe Interrupts |
- | External interrups are one of the most simple peripheral functions. Typically AVRs have 1 to 8 special pins, which are used to cause interrupts in the program when their logical value changes or they are at a certain state. Since this function is usually used to monitor external logical signals, these pins are called external interrupt pins. | + | Externe Interrupts sind eine der einfachsten Funktionen der Peripheriegeräte. Normalerweise haben AVR' |
- | To use an external interrupt, the pin has to be configured as standard | + | Um einen externen Interrupt zu nutzen, muss der Pins als Standard |
- | * 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 principal, there are two types of interrupts: synchronized to the controller' | + | Der Modus „logische Null“ bewirkt, dass der Interrupt durchgehend ausgelöst wird, solange der Pin den Wert Null hat. Wä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, |
- | <box 100% round # | ||
- | Task: Make ATmega128 | + | < |
+ | |||
+ | <box 100% round # | ||
+ | |||
+ | Aufgabe: Lassen Sie ATmega128 | ||
<code c> | <code c> | ||
#include < | #include < | ||
- | // 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 7 on bus E to an input by changing bit 7 to zero | + | // Ändere Pin 7 an Bus E zu einem Inputpin, indem Bit 7 auf 0 gesetzt wird |
DDRE &= ~(1 << PIN7); | DDRE &= ~(1 << PIN7); | ||
- | // Defining a pull-up resistor to to pin 7 on bus E | + | // Definiere einen Pull-Up Widerstand für Pin 7 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 | + | // Erlaube externen Interrupt |
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: | ||
</ | </ | ||
- | 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 interrupts. These interrupts are simply called pin change | + | 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ösen. Diese Interrupts werden einfach „Pin |
- | ===== Analog-to-digital converter | + | ===== Analog-zu-Digital Konverter |
- | Analog-to-digital converter | + | Analog-zu-Digital Konverter |
- | AVR ADC works on the principal of successive approximation. In short, the measured voltage is compared to specific voltage levels and the results are reported as a bit array. This method is relatively slow, as each bit in the final result is calculated separately. AVR spends | + | Der AVR ADC arbeitet nach dem Prinzip der schrittweisen Annäherung. Kurz gesagt, die gemessene Spannung wird mit bestimmten Spannungslevels verglichen und die Ergebnisse werden als Bit-Array ausgegeben. Diese Methode ist relativ langsam, da jedes Bit im Endergebnis einzeln berechnet wird. Der AVR benötigt |
- | The measured value can be read as an 8- or 10-bit value. Since AVR itself is an 8-bit device, it has two 8-bit registers for storing the ADC values. It is possible to specify | + | Der gemessene Wert kann als 8- oder 10-Bit Wert gelesen werden. Da der AVR ein 8-Bit Mikrocontroller ist, verfügt er über zwei 8-Bit Register um ADC-Werte zu speichern. In den Einstellungen kann festgelegt werden, ob die ersten oder letzten zwei Bits in ein seperates Register sollen. Falls die zwei zuletzt ausgelesenen Bits, welche das Ergebnis weniger widergeben, separiert werden, kann das Ergebnis als 8-Bit Wert ausgelesen werden. Eine solche Kombination nennt man „left aligned result“. Darüber hinaus kennzeichnet „right aligned result“ |
- | A typical | + | Ein normaler |
- | ~~PB~~ | ||
- | <box 100% round #EEEEEE|Example> | + | < |
+ | |||
+ | <box 100% round #EEEEEE|Beispiel> | ||
- | Task: measure the voltage in ADC channel | + | Aufgabe: Messen Sie die Spannung des ADC Kanals |
<code c> | <code c> | ||
Line 564: | Line 668: | ||
unsigned char result; | unsigned char result; | ||
- | // Choose | + | // Wähle den AREF Pin zum Vergleich der Spannung |
- | // | + | // (es wird angenommen, dass AREF mit der +5V Stromversorgung verbunden ist)) |
- | // Choose channel | + | // Wähle Kanal 3 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 |
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/ | ===== Counters/ | ||
- | Counters, which in some sense can be called timers, are one of the most important sub-functions of a microcontroller. These enable to precisely time processes, generate signals and count events. A counter converts the number of input cycles to a binary value using an array of triggers. The 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 counters. If 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' | + | Counter, welche man auch in einigen Fällen Taktgeber nennen kann, sind einer der wichtigsten Unterfunktionen eines Microcontrollers. Diese ermöglichen es Prozesse exakt zu timen, Signale zu generieren und Ereignisse zu zählen. Ein Zähler konvertiert die Nummer der Inputzyklen in einen binären Wert mit Hilfe eines Arrays |
+ | Counter unterscheiden sich auch in Applikationsfällen und Arbeitsmodi. | ||
=== Counter' | === Counter' | ||
- | In the default mode, a counter does nothing more than count sequential numbers all the time. Its value can, of course, be read and changed from the program at any time. The only additional function | + | Im Default-Modus macht ein Counter nichts anderes, als 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 ist, dass er ein Interrupt beim Counter-Overflow verursacht. Der Default-Modus wird normalerweise benutzt, um eine Sektion eines Programms | ||
<box 100% round # | <box 100% round # | ||
- | Task: Make an 8 MHz ATmega128 | + | Aufgabe: Ein 8 MHz ATmega128 |
<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 | + | // dass der nächste Overflow |
- | // 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 |
- | // the counter needs to be initialized here. | + | // muss der Counter initialisiert werden. |
TCNT0 = 178; | TCNT0 = 178; | ||
- | // Prescaler | + | // Prescaler |
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; | ||
} | } | ||
</ | </ | ||
- | The counter | + | Der Counter |
+ | Um einen präzisen Intervall zwischen den Interrupts zu verwirklichen, wird sowohl der Prescaler Wert, als auch der Wert des Counter müssen | ||
</ | </ | ||
- | == External clock counter | + | == Externer Taktgeber |
- | It is also possible to use an external clock source as a counter' | + | Es ist auch möglich einen externen Taktgeber als das Taktsignals eines Counters zu nutzen. |
+ | Der AVR hat einen Pin "Tn" dafür. Das n 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 operations, more complex | + | Da die Counter zeitlich abgestimmte Operationen ermöglichen, haben komplexe |
+ | Der Teil des Counter heißt "Input Capture Unit". Es gibt eine Auswahl zwischen zwei Ereignissen: | ||
<box 100% round # | <box 100% round # | ||
- | Task: Measure the frequency of an external 122 Hz - 100 kHz logical square signal using an 8 MHz ATmega128. | + | Aufgabe: Miss die Frequenz eines Externen 122Hz - 100kHz logischen Rechtecksignals mit einem 8MHz ATmega128. |
<code c> | <code c> | ||
Line 647: | Line 759: | ||
unsigned long frequency; | unsigned long frequency; | ||
- | // Interrupt | + | // Interrupt |
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' | + | // 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, | + | // 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; | ||
} | } | ||
</ | </ | ||
- | The program fires an interrupt each time a rising front occurs in the external signal. During the interrupt, the counter is checked for overflows | + | Das Programm löst jedes mal bei einer " |
+ | Während des Interrupts, überprüft das Programm den Counter auf einen Overflow | ||
+ | </ | ||
- | </ | + | 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 signal, in addition to timing the length of one. For this purpose the counter has an output compare unit and a compare match output unit. The 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 running. An interrupt can be generated and special pins' values can be changed each time the counter' | + | Komplexere Counter können ein Taktsignal generieren, zusätzlich zum Timen eines Signals. Dafür hat der Counter eine " |
+ | Ein Interrupt kann generiert werden und spezielle Pin Werte können geändert werden wenn der Counter Wert gleich der des Compare Unit Registers ist. In diesem Moment kann ein Pin entweder High oder low gesetzt oder invertiert werden. Das Signal wird durch Änderungen im Wert des Output-Pins generiert. | ||
- | In some signal generating modes, the counter' | + | In einigen Signal-generierenden Modi, kann der maximale Wert des Counters verändert werden. |
+ | Die physikalische Größe bleibt die gleiche, aber ein Vergleichsregister wird benutzt um den Counter bei einem bestimmten Wert zu resetten. | ||
+ | Das vorherige Beispiel kann auch mit dieser Methode gelöst werden, aber die Funktion ist eher für das Ändern der Periode des Signals gedacht. Zusätzlich kann ein Counter so eingestellt werden, dass er mit auf- oder absteigenden Werten arbeitet. | ||
- | The counters and the signal generating modes using them are one of the most complex peripheral modules | + | Der Counter und die Signal-generierenden Modi die diese nutzten sind einer der komplexesten Peripheriemodule |
== Pulse Width Modulation == | == Pulse Width Modulation == | ||
- | Pulse width modulation | + | Pulsweitenmodulation |
+ | Zum Beispiel, ein Servomotor nutzt ein ein 50Hz PWM Signal und haben einen hohe Halbperiode von 1 - 2 ms. | ||
<box 100% round # | <box 100% round # | ||
- | Task: using an 8MHz ATmega128, | + | Aufgabe: Generiere mit einem 8Mhz ATmega128, |
<code c> | <code c> | ||
Line 738: | Line 855: | ||
===== USART ===== | ===== USART ===== | ||
- | USART is a universal synchronous serial interface, UART its simplified version | + | USART ist ein Universal Synchrones Serielles Interface, UART ist die vereinfachte Version |
- | Every configuration option has corresponding registers, which are quite easy to configure using the datasheet. The baud rate, though, is a bit more difficult to set. Clock signal for data transmission is generated from the controller' | + | Jede Einstellungsoption hat ein eigenes Register, welches recht einfach anhand des Datenblatts konfiguriert werden kann. Die Baud-Rate ist allerdings etwas schwieriger einzustellen. Das Taktsignal für die Datenübertragung wird vom Taktgeber des Controllers generiert und der Nutzer kann eine Zahl von 1 bis 4096 eingeben, durch welche die Taktrate dividiert wird. Das Ergebnis wird darüber hinaus, je nach Modus, durch 2, 8 oder 16 dividiert. Das Problem ist, dass nicht alle Taktfrequenzen |
- | Since data transmission takes place independently of the processor and much slower, it is necessary to confirm that the interface is ready for the next word before transmitting. This can be done by keeping an eye on the transmit buffer' | + | Da die Datenübertragung unabhängig vom Prozessor und viel langsamer geschieht, ist es nötig zu bestätigen, |
- | The arrival of a word is signified also by a special status bit. In addition to that, there are status bits to signify framing errors, parity errors and receive buffer overflows. Buffer overflow can occur, when 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 possible, for example by using an interrupt for that. There are three possible interrupt reasons: transmit buffer ready, transmit successful and receive successful. | + | Der Empfang eines Wortes ist wird durch ein spezielles Status-Bit gekennzeichnet. Zusätzlich gibt es Status-Bits, welche Rahmenfehler, Paritätsfehler und Pufferüberläufe anzeigen. Ein Pufferüberlauf tritt auf, wenn das letzte Wort noch aus dem Puffer gelesen werden muss, während ein neues ankommt. Aus 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 Interrupts: Sendepuffer bereit, Übertragung erfolgreich, Empfang erfolgreich. |
- | The transmit and receive buffers are physically separate registers, but share the same memory address and name. When writing to the shared register, the data is stored | + | Der Sende- und Empfangspuffer sind physikalisch getrennte Register, aber sie nutzen die gleiche Speicheradresse und den gleichen Namen. Während des Schreibens |
- | ~~PB~~ | ||
- | <box 100% round #EEEEEE|Example> | + | < |
+ | |||
+ | <box 100% round #EEEEEE|Beispiel> | ||
- | Task: Configure an 8 MHz ATmega128's USART0 interface to transmit | + | Aufgabe: Konfigurieren Sie die USART0 Schnittstelle eines 8 MHz ATmega128 |
<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 | + | // Faktor |
// 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 mode, set the word size to 8 bits | + | // Konfiguriere den asynchronen Modus, setze die Wortgröße auf 8 Bit, |
- | // 1 stop bit, no parity bits. | + | // 1 Stoppbit, kein 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 wait, as the first symbol is yet | + | // In diesem Beispiel ist es jedoch nicht nötig zu warten, da nur das erste Symbol |
- | // to be sent, but it should be done when transmitting more symbols. | + | // gesendet wird. Es sollte jedoch beachtet werden, wenn 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 = ' | UDR0 = ' | ||
- | // Endless loop | + | // Endlosschleife |
while (1) continue; | while (1) continue; | ||
} | } | ||
Line 786: | Line 904: | ||
</ | </ | ||
- | ====== | + | ====== |
- | {{:images:book: | + | {{: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, | ||
- | Some electronic circuits | + | Das HomeLab kit wurde von der Tallinn University of Technology sowie estnischen Unternehmen |
- | ===== Ohm's law ===== | + | Die HomeLab Basic und Advanced kits eignen sich zur Durchführung von Experimenten, |
- | Ohm's law states that the current through a conductor between two points is directly proportional to the potential difference | + | HomeLab Webseite\\ |
+ | http://home.roboticlab.eu | ||
- | The equation is as follows: | + | DistanceLab Webseite\\ |
- | [{{ | + | http:// |
- | 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, | ||
+ | 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 |
- | ===== LED resistor calculation ===== | + | |
- | If the supply voltage is higher than LEDs voltage the resistor have to be included into the circuit in series. | + | Das folgende Beispiel kann Schulen helfen Kurse zur Robotik zu starten oder einen Denkanstoß zu geben, wie man verschiedene Lernkonzepte |
- | + | ||
- | [{{ : | + | |
- | + | ||
- | R = (U< | + | |
- | U< | + | |
- | P< | + | |
- | + | ||
- | where: | + | |
- | + | ||
- | * R is resistor. | + | |
- | * U< | + | |
- | * U< | + | |
- | * I< | + | |
- | * U< | + | |
- | * P< | + | |
- | + | ||
- | The current limiting resistor of a LED has to be not smaller than R and at least with the power of P< | + | |
- | ===== 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: | + | |
- | + | ||
- | [{{ : | + | |
- | + | ||
- | U< | + | |
- | + | ||
- | where: | + | |
- | + | ||
- | * U< | + | |
- | * U< | + | |
- | * R< | + | |
- | + | ||
- | The equation is derived from Ohm's law | + | |
- | + | ||
- | where: | + | |
- | + | ||
- | I = U< | + | |
- | + | ||
- | and: | + | |
- | + | ||
- | U< | + | |
- | + | ||
- | Voltage divider is very often used together with resistive sensors (photo resistor, thermistor 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 ====== | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | 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 | + | |
- | + | ||
- | HomeLab kit has been developed by Tallinn University of Technology and the Estonian company' | + | |
- | + | ||
- | HomeLab Advanced and Basic kit can be successfully used in experiments, | + | |
- | + | ||
- | HomeLab webpage\\ | + | |
- | http:// | + | |
- | + | ||
- | DistanceLab webpage\\ | + | |
- | http:// | + | |
- | ===== Integrated Concept of Robotic Studies ===== | + | |
- | + | ||
- | Today' | + | |
- | + | ||
- | 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: | + | |
- | | + | * Praktisches Übungsbuch |
- | * Practical Hands-On Exercise book. | + | * Robotic HomeLab |
- | * Robotic HomeLab. | + | * DistanceLab |
- | * DistanceLab. | + | * Das Kompetenznetzwerk der Robotik- und Mechatronikgemeinschaft |
- | * The Network of Excellence of Robotic and Mechatronic community | + | |
- | 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, |
- | Practical part consists of Robotic HomeLab | + | Der praktische Teil besteht aus dem Robotic HomeLab |
- | The sequence of one study process/ | + | Der Ablauf von einem Lernprozess bzw. der Arbeit mit dem Lab ist auf dem nächsten Bild beschrieben. |
{{ : | {{ : | ||
- | The topic begins with introduction which can be a classical lecture, distance online lecture or video lecture. The recorded video lecture is important also on the conventional lecture case as this enables to re-watch the lecture | + | Das Thema beginnt mit einer Einführung, welche eine klassische Vorlesung, eine Onlinevorlesung oder eine Videovorlesung sein kann. Die 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 werden. Der theoretische Teil wird durch das Lehrbuch und das praktische Übungsbuch unterstützt. |
- | After the introduction lecture the individual practical work is carried out. Practical work is about running the example code solution in the beginning and later modifying the example case according to the first " | + | Nach der Einführungsvorlesung wird der praktische Arbeitsteil realisiert. Die Praktische Arbeit besteht anfangs darin, die Codebeispiele auszuführen und später darin, die Beispiele entsprechend der Übung zu verändern. Daraufhin 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 | + | Die Ergebnisse der praktischen Arbeit werden |
- | ===== 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 channels. For many young people it is very likely to get most of the information about the course material from different communication channels on the internet. Before trying to solve a problem, firstly 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 | + | Es ist allseits bekannt, dass die Informations- und Telekommunikationstechnologie (ICT) in das tägliche Leben von vielen Menschen eingetreten ist und die Art und Weise des Lernens und der Kommunikation verändert hat. Viele junge Leute sind es gewohnt Informationen über das Kursmaterial über verschiedene Kommunikationswege aus dem Internet zu bekommen. Bevor versucht wird ein Problem zu lösen wird erst eine schnelle Suche nach möglichen Lösungen, Beispielen oder Hintergrundinformationen durchgeführt. Da 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 |
- | Robotics and Mechatronics are fields of the future, where following the newest trends and technologies are especially important. At the same time the fields are very practical and lots of hands-on experience is needed to acquire the skills and knowledge. Even several virtual simulations can be performed for studying the system behavior. However the virtual simulations do not replace the hands-on experience of using the real hardware. | + | Robotik und Mechatronik sind sehr zukunftsreiche Gebiete, in denen es sehr wichtig ist den neuesten Trends und Technologien zu folgen. Gleichzeitig sind diese Gebiete sehr praktisch veranlagt und es verlangt viel manuelle Erfahrung Fähigkeiten und Wissen zu erlangen. Selbst verschiedene virtuelle Simulationen können durchgeführt werden um das Systemverhalten zu verstehen. Trotzdem 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 applied. The methodology expect that the teacher can use practical | + | Das Folgende ist eine praktische Anleitung wie ein Robotikkurs eingeführt werden kann, in dem verschiedene Lehransätze genutzt werden. Die 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** \\ |
- | | + | |
- | - **Practical work and reporting** \\ | + | - **Praktische Arbeit und Berichterstattung** \\ |
- | | + | |
- | * Lab introduction | + | * Einführung in die Übung |
- | * The teacher explains the new lab, going through the all necessary theoretical material and the example program is performed together. | + | * Der Lehrer erklärt die neue Übung, geht 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 development. It 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 soll. Das bedeutet, dass der Quellcode anhand von theoretischen Erklärungen entwickelt wird. |
- | * Individual work. This is performed according to the lab working guide where the aim, work process, requirements and reporting are defined. Learners are working individually | + | * Individuelle Arbeit. Die individuelle Arbeit erfolgt gemäß den Arbeitsanweisungen der Übungseinheit. Hier sind Ziele, Arbeitsprozesse, Anforderungen und die Berichterstattung definiert. Die Schüler lernen selbstständig |
- | * Reporting. Learners 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 teacher. Report together with a working solution | + | * Berichte. Lernende 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 gibt. Der Bericht sowie die Lösung der Aufgabe |
- | * 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, |
- | - ** Group management | + | - ** Gruppenmanagement |
- | | + | |
- | - **Evaluation** \\ | + | - **Bewertung** \\ |
- | | + | |
- | - **Debugging** \\ | + | - **Fehlerbehebung** \\ |
- | | + | |
- | - **Competition** \\ | + | - **Wettbewerb** \\ |
- | | + | |
- | ~~PB~~ | + | < |
- | The following example is a typical lab guide which can be used for practical labs. | + | Das folgende Beispiel veranschaulicht eine typische Übungsanweisung, |
- | <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 microcontroller. To study different sensors with analog output. To perform a simple analog sensor lab. | + | |
+ | - 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:// | + | - Führen Sie die Übung mit dem Potentiometer durch. \\ http:// |
- | - Perform the common " | + | - Führen Sie die allgemeine Aufwärmübung durch. \\ http:// |
- | - 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 | + | - Beantworten Sie die Fragen |
- | **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 2 and 3. \\ | + | * Ausdruck des Algorithmus und Quellcodes für die Schritte |
- | * Answer to the question | + | * Anworten auf die Fragen |
- | * Results and Comments | + | * Ergebnisse und Kommentare |
- | * Working solutions | + | * Lösungen |
- | The report has to contain the name, lab number, date and team members | + | Der Bericht muss den eigenen Namen, die Nummer des Übungsabschnitts, das Datum sowie die Namen der Gruppenmitglieder |
- | **Readings** | + | **Lektüren** |
- | - HomeLab | + | - HomeLab |
- | - ATmega128 | + | - ATmega128 |
- | - Sharp infrared sensor datasheet | + | - Sharp Infrarotsensor Datenblatt |
- http:// | - http:// | ||
</ | </ | ||
- | ===== HomeLab | + | ===== HomeLab |
- | The modules of Robotic | + | Die Module des Robotik |
- | === HomeLab Basic Kit === | + | === HomeLab Basic kit === |
- | [{{ : | + | [{{ : |
- | * AVR ATmega128 development board | + | * AVR ATmega2561 Entwicklungsplatine, |
- | * Digital i/o board (buttons, LEDs, 2 x LCD output, 7-segment indicator) | + | * Benutzerschnittstellenplatine |
- | * 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 | + | * Software |
- | * Portable case | + | * Tragbarer Koffer |
- | === Sensor and Motor Add-On | + | === Sensor and Motor Add-On |
- | == Motor module == | ||
- | [{{ : | + | == Sensormodul == |
- | * DC motor (w/ gear) | + | * Analoge Sensoren- und Tiefpassplatine mit on-board Sensoren |
- | * 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 | + | [{{ : |
- | * 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 | ||
- | [{{ : | + | == Kommunikationsmodul == |
- | Includes all modules and components from Basic Kit and Motor and Sensor Add-On Kit. In addition, following modules are included: | + | * Kommunikationsplatine, 2xRS232 |
+ | * 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) | + | {{: |
- | ==== Controller module | + | --- |
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | ===== HomeLab Bibliothek ===== | ||
- | Main module of a HomeLab | + | Die HomeLab |
- | * 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? | + | [{{ :images:homelab: |
- | Module is equipped with AC/DC rectifier circuit and LDO voltage stabilizer | + | 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, |
- | + | ||
- | 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 | + | |
- | Circuit can be equipped with external power switch by connecting it to S2 2-pin on/ | ||
- | 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, | ||
- | |||
- | Module is equipped with external memory (Atmel | ||
- | |||
- | [{{: | ||
- | |||
- | === Connector pins and functions === | ||
- | |||
- | [{{ : | ||
- | |||
- | ^Nr^Pin^Alternative function / Description^^ | ||
- | |1|PD7|T2|Timer/ | ||
- | |2|PD6|T1|Timer/ | ||
- | |3|PD5|XCK1|USART1 External Clock Input/ | ||
- | |4|PD4|IC1|Timer/ | ||
- | |5|PD3|INT3/ | ||
- | |6|PD2|INT2/ | ||
- | |7|PD1|INT1/ | ||
- | |8|PD0|INT0/ | ||
- | |9|VCC|-|+5V | | ||
- | |10|GND|-|GND | | ||
- | |11|PB7|OC2/ | ||
- | |12|PB6|OC1B|Output Compare and PWM Output B for Timer/ | ||
- | |13|PB5|OC1A|Output Compare and PWM Output A for Timer/ | ||
- | |14|PB4|OC0|Output Compare and PWM Output for Timer/ | ||
- | |15|PB3|MISO|SPI Bus Master Input/Slave Output | | ||
- | |16|PB2|MOSI|SPI Bus Master Output/ | ||
- | |17|PB1|SCK|SPI Bus Serial Clock | | ||
- | |18|PB0|SS|SPI Slave Select Input | | ||
- | |19|PE7|INT7/ | ||
- | |20|PE6|INT6/ | ||
- | |21|PE5|INT5/ | ||
- | |22|PE4|INT4/ | ||
- | |23|PE3|AIN1/ | ||
- | |24|PE2|AIN0/ | ||
- | |25|PE1|PDO/ | ||
- | |26|PE0|PDI/ | ||
- | |||
- | |||
- | [{{ : | ||
- | |||
- | ^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| | ||
- | |||
- | [{{ : | ||
- | |||
- | ^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/ | ||
- | |14|GND|-|GND | | ||
- | |15|PF5|ADC5/ | ||
- | |16|GND|-|GND | | ||
- | |17|PF6|ADC6/ | ||
- | |18|GND|-|GND | | ||
- | |19|PF7|ADC7/ | ||
- | |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). | ||
- | |||
- | [{{: | ||
- | |||
- | ==== 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. | ||
- | |||
- | {{: | ||
- | |||
- | === electrical connections === | ||
- | |||
- | [{{ : | ||
- | |||
- | 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). | ||
- | |||
- | [{{ : | ||
- | |||
- | ~~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. | ||
- | |||
- | [{{ : | ||
- | |||
- | ~~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. | ||
- | |||
- | |||
- | [{{ : | ||
- | |||
- | === 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. | ||
- | |||
- | [{{: | ||
- | ==== 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. | ||
- | |||
- | [{{: | ||
- | ==== 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) {{: | ||
- | * Infrared distance sensor Sharp GP2Y0A21YK0F (measuring distance 10-80 cm) {{: | ||
- | * Light intensity sensor (photoresistor) VT935G (resistance 18,5 kΩ on 10 lux) {{: | ||
- | * temperature sensor (thermistor NTC) (resistance 10 kΩ on 25 °C) {{: | ||
- | * Potentiometer 5 kΩ | ||
- | |||
- | {{: | ||
- | |||
- | === Electrical connections === | ||
- | |||
- | [{{ : | ||
- | |||
- | == 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, | ||
- | |||
- | [{{ : | ||
- | |||
- | == 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. | ||
- | |||
- | [{{: | ||
- | |||
- | === 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. | ||
- | |||
- | [{{: | ||
- | |||
- | ==== 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 | ||
- | |||
- | {{: | ||
- | |||
- | 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 | ||
- | | 2 | Bipolar stepper motor | up to 36 V | up to 600 mA | | ||
- | | 3 | Servo motors | ||
- | | 4 | Unipolar stepper motors | ||
- | | 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) {{: | ||
- | * Micromotors L149.6.43 (with gear) {{: | ||
- | * Micromotors LE149.6.10 (with gear + encoder) {{: | ||
- | * **RC servo motor** | ||
- | * Robbe FS 100 {{: | ||
- | * E Sky EK2-0501 {{: | ||
- | * Futaba XT-S | ||
- | * Hitec HS422 {{: | ||
- | * **Unipolar stepper motor** | ||
- | * Ming Jong ST35 {{: | ||
- | * **Bipolar stepper motor** | ||
- | * Moons 42PM {{: | ||
- | * Ming Jong ST28 {{: | ||
- | * **Piezo sound generator ** (optional) | ||
- | |||
- | [{{ : | ||
- | |||
- | ~~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. | ||
- | |||
- | [{{ : | ||
- | |||
- | == 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.) | ||
- | |||
- | [{{ : | ||
- | |||
- | ^ 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 | | ||
- | |||
- | |||
- | [{{: | ||
- | |||
- | [{{: | ||
- | |||
- | == 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). | ||
- | |||
- | ^ AVR pin ^ Control signal ^ | ||
- | | PB5(OC1A) | PWM1 | | ||
- | | PB6(OC1B) | PWM2 | | ||
- | |||
- | === 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. | ||
- | |||
- | [{{: | ||
- | ===== HomeLab library ===== | ||
- | |||
- | HomeLab library is composed of several C language header files (with " | ||
- | |||
- | [{{ : | ||
- | |||
- | 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 (" | ||
<code c> | <code c> | ||
Line 1401: | Line 1112: | ||
</ | </ | ||
- | If HomeLab | + | Falls die HomeLab |
<code c> | <code c> | ||
Line 1407: | Line 1119: | ||
</ | </ | ||
- | In the HomeLab | + | Die HomeLab |
+ | |||
+ | 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-page. Users who are interested in customizing the library can also download the source code for it. The following chapters describe the functionality of the library. | + | Die Bibliothek für bitweise Operationen beinhaltet eine Zusammenstellung von Makrofunktionen zur Durchführung von Bitmanipulationsoperationen. Sie werden von den anderen Komponenten der Bibliotheken genutzt und können überall angewandt werden. Da 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 operations. They are used by the rest of the library and can be used everythere else. As the macro functions have no type, they are compatible with any data type. | + | Der Bit-Index wird genutzt um das Bit in einer Binärzahl zu spezifizieren. Indizes werden beginnend bei Null gezählt, wobei Null das niedrigstwertige Bit (LSB) kennzeichnet. Eine 8-Bit-Zahl hat zum Beispiel Indizes von 0 bis 7, eine 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 index to bit mask converting. Parameters: | + | Bit-Index zu Bitmaske konvertieren. Parameter: |
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
- | * Returns bit mask. | + | * Gibt Bitmaske aus. |
* **// | * **// | ||
- | | + | |
* //value// - Variable. | * //value// - Variable. | ||
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
* **// | * **// | ||
- | | + | |
* //value// - Variable. | * //value// - Variable. | ||
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
* **// | * **// | ||
- | | + | |
* //value// - Variable. | * //value// - Variable. | ||
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
- | * //state// - State (//true// or //false//). | + | * //state// - Status |
* **// | * **// | ||
- | | + | |
* //value// - Variable. | * //value// - Variable. | ||
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
* **// | * **// | ||
- | | + | |
* //value// - Variable. | * //value// - Variable. | ||
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
- | * Returns boolean value // | + | * Gibt den Bool’schen Wert //true//, wenn das Bit gesetzt und // |
* **// | * **// | ||
- | | + | |
* //value// - Variable. | * //value// - Variable. | ||
- | * //bit// - Bit index. | + | * //bit// - Bit-Index. |
- | * Returns boolean value // | + | * Gibt den Bool’schen Wert //true//, wenn das Bit gelöscht wurde und// |
- | === Example | + | === Beispiel |
- | Setting up a third bit in the 8-bit variable | + | Das dritte Bit einer 8-Bit Variablen |
<code c> | <code c> | ||
Line 1472: | Line 1185: | ||
</ | </ | ||
- | === 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) | #define bit_mask(bit) | ||
Line 1489: | Line 1201: | ||
// | // | ||
- | // Functions for handling bit masks. | + | // Funktionen zur Bearbeitung von Bitmasken. |
// | // | ||
#define bitmask_set(value, | #define bitmask_set(value, | ||
Line 1500: | Line 1212: | ||
==== Pins ==== | ==== Pins ==== | ||
- | Pins library provides an easy way for operating with AVR digital input-output pins. User can create a pin related variable and do all the pin operations with that variable. This way there' | + | Die Pins-Bibliothek erleichtert die Arbeit mit digitalen |
- | === Data types === | + | === Datentypen |
- | * **// | + | * **// |
- | === Functions | + | === Funktionen |
* **//void pin_setup_output(pin pin)//** \\ | * **//void pin_setup_output(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
* **//void pin_setup_input(pin pin)//** \\ | * **//void pin_setup_input(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
* **//void pin_setup_input_with_pullup(pin pin)//** \\ | * **//void pin_setup_input_with_pullup(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
* **//void pin_set(pin pin)//** \\ | * **//void pin_set(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
* **//void pin_clear(pin pin)//** \\ | * **//void pin_clear(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
* **//void pin_toggle(pin pin)//** \\ | * **//void pin_toggle(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
* **//void pin_set_to(pin pin, bool value)//** \\ | * **//void pin_set_to(pin pin, bool value)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
- | * //value// - Desired state boolean value. | + | * //value// - Gewünschter Status als Bool' |
* **//bool pin_get_value(pin pin)//** \\ | * **//bool pin_get_value(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
- | * Return boolean | + | * Gibt Bool' |
* **//bool pin_get_debounced_value(pin pin)//** \\ | * **//bool pin_get_debounced_value(pin pin)//** \\ | ||
- | | + | |
- | * //pin// - Pin variable. | + | * //pin// - Pin Variable. |
- | * Return pin boolean value - // | + | * Gibt dem Pin den Bool' |
- | === 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, | pin_set_to(output_pin, | ||
} | } | ||
} | } | ||
</ | </ | ||
- | ==== Analog | + | ==== Analog-Digital-Wandler==== |
- | This library provides functions to use AVR analog to digital converter. All the conversion functions in library are blocking, which means the processor waits as long as it takes to get the results. The conversion time depends on the ADC clock. | + | Diese Bibliothek enthält Funktionen um den AVR Analog-Digital-Wandler zu nutzen. Sämtliche Funktionen dieser Bibliothek sind blockierend, d.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 |
- | * **// | + | * **// |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * **// | + | * **// |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | === Functions | + | === Funktionen |
* **//void adc_init(adc_reference reference, adc_prescale prescale)// | * **//void adc_init(adc_reference reference, adc_prescale prescale)// | ||
- | | + | |
- | * // | + | * // |
- | * // | + | * // |
* **// | * **// | ||
- | | + | |
- | * //channel// - ADC channel number | + | * //channel// - ADC Kanalnummer |
- | * Return | + | * Liefert einen digitalen |
* **// | * **// | ||
- | | + | |
- | * //channel// - ADC channel number | + | * //channel// - ADC Kanalnummer |
- | * // | + | * // |
- | * Return | + | * Liefert einen digitalen |
- | === 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 | + | // Initialisierung |
- | // Clock is 8 times slower than system clock. | + | // Takt ist 8 mal langsamer als der Systemtakt. |
adc_init(ADC_REF_AVCC, | adc_init(ADC_REF_AVCC, | ||
- | // Converting channel | + | // Konvertierung des Wertes von Kanal 0. |
x = adc_get_value(0); | x = adc_get_value(0); | ||
- | // Converting and averaging channel | + | // Konvertieren des Wertes von Kanal 1 und Errechnung des Durchschnitts. |
y = adc_get_average_value(1, | y = adc_get_average_value(1, | ||
} | } | ||
Line 1632: | Line 1346: | ||
- | ==== Serial interface | + | ==== Serielles Interface |
- | This library provides | + | Diese Bibliothek bietet die Funktionen für das AVR asynchrone serielle Interface |
- | === Data types === | + | === Datentypen |
- | * **// | + | * **// |
- | * **//adc_usart_databits//** \\ Data bits count enumeration data type. Options: | + | * **//usart_databits//** \\ Zählen der Datenbits, Aufzählungsdatentyp. Möglichkeiten: |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * **// | + | * **// |
- | * // | + | * // |
- | * // | + | * // |
- | * **// | + | * **// |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | === Functions | + | === Funktionen |
* **// | * **// | ||
- | | + | |
- | * //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)// | ||
- | | + | |
- | * //port// - USART interface variable. | + | * //port// - USART Schnittstellenvariable. |
- | * // | + | * // |
- | * // | + | * // |
- | * //parity// - Parity mode. | + | * //parity// - Paritätsmodus. |
- | * // | + | * // |
* **//void usart_send_char(usart port, char symbol)//** \\ | * **//void usart_send_char(usart port, char symbol)//** \\ | ||
- | | + | |
- | * //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)//** \\ | ||
- | | + | |
- | * //port// - USART interface variable. | + | * //port// - USART Schnittstellenvariable. |
- | * //text// - Pointer to strin (char array). String | + | * //text// - Zeiger auf einen String(char array). |
* **//bool usart_has_data(usart port)//** \\ | * **//bool usart_has_data(usart port)//** \\ | ||
- | | + | |
- | * //port// - USART interface variable. | + | * //port// - USART Schnittstellenvariable. |
- | * Returns | + | * Gibt // |
* **//char usart_read_char(usart port)//** \\ | * **//char usart_read_char(usart port)//** \\ | ||
- | | + | |
- | * //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)// | ||
- | | + | |
- | * //port// - USART interface variable. | + | * //port// - USART Interfacevariable. |
- | * //symbol// - Pointer to character variable. If there is a character in receive buffer, it is written to the pointed variable. | + | * //symbol// - Verweis auf die Variable des Zeichens. Wenn ein Zeichen im Empfangsspeicher vorhanden ist, wird es der betreffenden Variable zugeschrieben. |
- | * Returns | + | * Gibt // |
- | === Example | + | === Beispiel |
- | USART interface is configured to use 8 data bits, one stop bit, 9600 bps baud rate and no parity mode. Program sends a string, waits until some character is received and then reads it out. | + | Die USART Schnittstelle ist konfiguriert um 8 Datenbits, ein Stop-Bit, 9600 bps Baudrate und keinen Paritätsmodus zu nutzen. Das Programm sendet einen String, wartet bis die Zeichen empfangen wurden und ließt sie dann aus. |
<code c> | <code c> | ||
#include < | #include < | ||
- | // Use USART interface | + | // Nutze USART Schnittstelle |
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 | + | // Senden des String. |
usart_send_string(port, | usart_send_string(port, | ||
- | // 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); | ||
} | } | ||
</ | </ | ||
- | ==== Timers | + | ==== Timer ==== |
- | This library covers large part of the functionality of ATmega128 | + | Diese Bibliothek deckt einen großen Teil der Funktionen des Timers des ATmega128 |
- | === Data types === | + | === Datentypen |
- | * **// | + | * **// |
- | * // | + | * // |
* // | * // | ||
* // | * // | ||
Line 1744: | Line 1458: | ||
* // | * // | ||
- | * **// | + | * **// |
- | * // | + | * // |
* // | * // | ||
* // | * // | ||
* // | * // | ||
* // | * // | ||
- | * // | + | * // |
- | * // | + | * // |
* **// | * **// | ||
- | * **// | + | * **// |
- | * // | + | * // |
* // | * // | ||
* // | * // | ||
* // | * // | ||
* // | * // | ||
- | * // | + | * // |
- | * // | + | * // |
* **// | * **// | ||
- | * **// | + | * **// |
- | * // | + | * // |
- | * // | + | * // |
* **// | * **// | ||
* **// | * **// | ||
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
* **// | * **// | ||
- | * **//timer1_fast_pwm_output_mode//** \\ Timer 1/3 fast PWM mode outputs configuration enumeration data type. Options (" | + | * **//timer3_fast_pwm_output_mode//** \\ Timer 1/3 fast PWM mode outputs configuration enumeration data type. Options (" |
* // | * // | ||
* // | * // | ||
Line 1783: | Line 1497: | ||
* // | * // | ||
- | === Functions | + | === Funktionen |
* **//void timer0_init_normal(timer0_prescale prescale)// | * **//void timer0_init_normal(timer0_prescale prescale)// | ||
- | | + | |
* // | * // | ||
* **//void timer2_init_normal(timer2_prescale prescale)// | * **//void timer2_init_normal(timer2_prescale prescale)// | ||
- | | + | |
* // | * // | ||
* **//void timer0_stop()// | * **//void timer0_stop()// | ||
* **//void timer2_stop()// | * **//void timer2_stop()// | ||
- | | + | |
* **// | * **// | ||
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 0 is started in normal mode with overflow interrupt. | + | Im folgenden Programm wird Timer 0 im normalen Modus mit Overflowinterrupt gestartet. |
<code c> | <code c> | ||
Line 1945: | Line 1659: | ||
} | } | ||
</ | </ | ||
- | ==== Delay ==== | + | ==== Verzögerung |
- | This part of library contains functions to generate delays | + | Dieser Teil der Bibliothek enthält die benötigten Funktionen, um in einem Programm mit Hilfe von Software Algorithmen oder Hardwaretimern Verzögerungen zu generieren. Verzögerungen blocken keine Interrupts, daher werden Softwareverzögerungen durch Interrupts unterbrochen. Verzö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)//** \\ | ||
- | | + | |
- | * //count// - Delay time in milliseconds. 0 to 65535 ms. | + | * //count// - Verzögerungszeit |
* **//void sw_delay_us(unsigned short count)//** \\ | * **//void sw_delay_us(unsigned short count)//** \\ | ||
- | | + | |
- | * //count// - Delay time in microseconds. 0 to 65535 μs. | + | * //count// - Verzögerungszeit |
* **//void hw_delay_ms(unsigned short count)//** \\' | * **//void hw_delay_ms(unsigned short count)//** \\' | ||
- | | + | |
- | * //count// - Delay time in milliseconds. 0 to 65535 ms. | + | * //count// - Verzögerungszeit |
- | === Examples | + | === Beispiele |
- | Demonstration | + | Demonstration |
<code c> | <code c> | ||
Line 1972: | Line 1686: | ||
int main(void) | int main(void) | ||
{ | { | ||
- | // Software | + | // Software-basierte Verzögerung von 100 ms. |
sw_delay_ms(100); | sw_delay_ms(100); | ||
- | // Hardware | + | // Hardware- (Timer-) basierte Verzögerung von 100 ms. |
hw_delay_ms(100); | hw_delay_ms(100); | ||
} | } | ||
</ | </ | ||
- | ==== 7-segment | + | --- |
+ | | ||
+ | ==== 7-Segment | ||
- | //Related to: [HW] [[en: | + | //In Bezug auf: [HW] [[en: |
- | This library is intended to use 7-segment | + | Diese Bibliothek dient zur Nutzung des 7-Segment |
- | === Functions | + | === Funktionen |
* **//void segment_display_init(void)// | * **//void segment_display_init(void)// | ||
- | | + | |
* **//void segment_display_write(unsigned char digit)//** \\ | * **//void segment_display_write(unsigned char digit)//** \\ | ||
- | | + | |
- | * //digit// - Number value from 0 to 9. Any other case E like "error" | + | * //digit// - Zahlenwert von 0 bis 9. Ansonsten wird ein E für "Error" |
- | === Example | + | === Beispiel |
- | Number | + | Die Zahl 5 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 | + | ==== Alphanumerisches |
- | //Related to: [HW] [[en: | + | //Bezug nehmend auf: [HW] [[en: |
- | This library contains functions to use HomeLab alphanumeric | + | Diese Bibliothek enthält die Funktionen, um das alphanumerische |
- | === Data types === | + | === Datentypen |
- | * **// | + | * **// |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | * // | + | * // |
- | === Functions | + | === Funktionen |
* **//void lcd_alpha_init(lcd_alpha_mode disp_attr)// | * **//void lcd_alpha_init(lcd_alpha_mode disp_attr)// | ||
- | | + | |
- | * // | + | * // |
* **//void lcd_alpha_clear(void)// | * **//void lcd_alpha_clear(void)// | ||
- | | + | |
* **//void lcd_alpha_clear_line(unsigned char line)//** \\ | * **//void lcd_alpha_clear_line(unsigned char line)//** \\ | ||
- | | + | |
- | * //line// - Line number. | + | * //line// - Zeilennummer: |
* **//void lcd_alpha_home(void)// | * **//void lcd_alpha_home(void)// | ||
- | | + | |
* **//void lcd_alpha_goto_xy(unsigned char x, unsigned char y)//** \\ | * **//void lcd_alpha_goto_xy(unsigned char x, unsigned char y)//** \\ | ||
- | | + | |
- | * //x// - X coordinate | + | * //x// - X Koordinate |
- | * //y// - Y coordinate | + | * //y// - Y Koordinate |
* **//void lcd_alpha_write_char(char c)//** \\ | * **//void lcd_alpha_write_char(char c)//** \\ | ||
- | | + | |
- | * //c// - ASCII character. | + | * //c// - ASCII Zeichen. |
* **//void lcd_alpha_write_string(const char *s)//** \\ | * **//void lcd_alpha_write_string(const char *s)//** \\ | ||
- | | + | |
- | * //s// - Pointer to string | + | * //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)// | ||
- | | + | |
- | * // | + | Parameter: |
+ | * // | ||
- | === Example | + | === Beispiel |
- | Demonstration of how to use alphanumeric | + | Nutzung des alphanumerischen |
<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 | + | // Cursor |
lcd_alpha_goto_xy(0, | lcd_alpha_goto_xy(0, | ||
- | // Text displaying. | + | // Anzeige des Texts. |
lcd_alpha_write_string(" | lcd_alpha_write_string(" | ||
} | } | ||
</ | </ | ||
- | ==== Graphic | + | ==== Graphisches |
- | //Related to: [HW] [[en: | + | //Related to: [HW] [[en: |
- | This library contains functions to use HomeLab graphical | + | Diese Bibliothek enthält die Funktionen zur Nutzung des graphischen |
- | === Functions | + | === Funktionen |
* **//void lcd_gfx_init(void)// | * **//void lcd_gfx_init(void)// | ||
- | | + | |
* **//void lcd_gfx_backlight(bool set)//** \\ | * **//void lcd_gfx_backlight(bool set)//** \\ | ||
- | | + | |
- | * //set// - // | + | * //set// - // |
* **//void lcd_gfx_clear(void)// | * **//void lcd_gfx_clear(void)// | ||
- | | + | |
* **//void lcd_gfx_clear_line(unsigned char line)//** \\ | * **//void lcd_gfx_clear_line(unsigned char line)//** \\ | ||
- | | + | |
- | * //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)//** \\ | ||
- | | + | |
- | * //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)//** \\ | ||
- | | + | |
- | * //c// - ASCII character. | + | * //c// - ASCII Zeichen. |
* **//void lcd_gfx_write_string(char *s)//** \\ | * **//void lcd_gfx_write_string(char *s)//** \\ | ||
- | | + | |
- | * //s// - Pointer to string | + | * //s// - Zeiger auf einen String(char array). |
- | === Example | + | === Beispiel |
- | Demonstration of using a graphical | + | Nutzung des graphischen |
<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 | + | // Cursor |
lcd_gfx_goto_char_xy(5, | lcd_gfx_goto_char_xy(5, | ||
- | // Displaying a text. | + | // Anzeige eines Textes. |
lcd_gfx_write_string(" | lcd_gfx_write_string(" | ||
} | } | ||
</ | </ | ||
- | ==== Motors | + | ==== Motoren |
- | //Related to: [HW] [[en: | + | //Bezug nehmend auf: [HW] [[en: |
- | This library contains functions to control different | + | Diese Bibliothek enthält Funktionen zur Steuerung der verschiedenen |
- | === Functions | + | === Funktionen |
* **//void dcmotor_init(unsigned char index)//** \\ | * **//void dcmotor_init(unsigned char index)//** \\ | ||
- | | + | |
- | * //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)// | ||
- | | + | |
- | * //index// - Index of motor controller. 0 to 3. | + | * //index// - Index des Motorencontrollers. 0 bis 3. |
- | * // | + | * // |
* **//void unipolar_init(unsigned char index)//** \\ | * **//void unipolar_init(unsigned char index)//** \\ | ||
- | | + | |
- | * //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)//** \\ | ||
- | | + | |
- | * //index// - Index of motor controller. 0 or 1. | + | * //index// - Index des Motorencontrollers. 0 oder 1. |
- | * // | + | * // |
- | * // | + | * // |
- | * //speed// - Time of a single step in milliseconds. | + | * //speed// - Zeit eines einzelnen Schritts |
* **//void bipolar_init(void)// | * **//void bipolar_init(void)// | ||
- | | + | |
+ | |||
* **//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)//** \\ | ||
- | | + | |
- | * // | + | * // |
- | * // | + | * // |
- | * //speed// - Time of a single step in milliseconds. | + | * //speed// - Zeit eines einzelnen Schritts |
* **//void servomotor_init(unsigned char index)//** \\ | * **//void servomotor_init(unsigned char index)//** \\ | ||
- | | + | |
- | * //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)// | ||
- | | + | |
- | * //index// - Index of servo motor. 0 or 1. | + | * //index// - Index des Servomotors. 0 oder 1. |
- | * // | + | * // |
- | === 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 forward, another in backward direction. | + | // Ein DC Motor fährt vorwärts, ein anderer rückwärts. |
dcmotor_drive(0, | dcmotor_drive(0, | ||
dcmotor_drive(1, | dcmotor_drive(1, | ||
- | // Rotating the stepper motor 100 steps in one direction | + | // Bewegt den Schrittmotor |
- | // and then back with twice the speed. | + | // und daraufhin zurück mit doppelter Geschwindigkeit. |
bipolar_halfstep(1, | bipolar_halfstep(1, | ||
bipolar_halfstep(-1, | bipolar_halfstep(-1, | ||
- | // Rotating servo motors | + | // Bewegt Servomotoren |
servomotor_position(0, | servomotor_position(0, | ||
servomotor_position(1, | servomotor_position(1, | ||
} | } | ||
</ | </ | ||
- | ==== Sensors | + | ==== Sensoren |
- | //Related to: [HW] [[en: | + | //Bezug nehmend auf: [HW] [[en: |
- | 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 |
* **// | * **// | ||
- | | + | |
* //a// - Dividend. | * //a// - Dividend. | ||
- | * //b// - Non-linear constant. | + | * //b// - Nicht-lineare Konstante. |
- | * //k// - Linearizing constant. | + | * //k// - Lineare Konstante. |
- | === Constants | + | === Konstante |
* **// | * **// | ||
- | Sharp GP2Y0A21YK | + | Sharp GP2Y0A21YK |
- | === Functions | + | === Funktionen |
* **//signed short thermistor_calculate_celsius(unsigned short adc_value)// | * **//signed short thermistor_calculate_celsius(unsigned short adc_value)// | ||
- | | + | |
- | * // | + | * // |
- | * 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)// | ||
- | | + | |
- | * //sensor// - Distance sensor calculation parameters. | + | * //sensor// - Kalkulationsparameter des Distanzsensors. |
- | * // | + | * // |
- | * Returns distance | + | * Gibt die Entfernung |
* **// | * **// | ||
- | | + | |
- | * //trigger// - Trigger pin variable. | + | * //trigger// - Variable des auslösenden Pins. |
- | * //echo// - Echo pin variable. | + | * //echo// - Variable des Echo-Pin variable. |
- | * Returns distance | + | * Gibt Entfernung |
- | === Example | + | === Beispiel |
- | The following program demonstrates usage of IR and ultrasonic distance sensors. | + | Nutzung des Infrarot- und Ultraschallentfernungssensors. |
<code c> | <code c> | ||
#include < | #include < | ||
- | // 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 pin_echo | ||
Line 2273: | Line 1990: | ||
int main(void) | int main(void) | ||
{ | { | ||
- | unsigned short adc_value = 400; // random | + | unsigned short adc_value = 400; // zufälliges |
signed short distance; | signed short distance; | ||
- | // Distance calculation from IR distance sensor | + | // Entfernungsberechnung des ADC Ergebnisses des IR-Entfernungssensors. |
distance = ir_distance_calculate_cm(GP2Y0A21YK, | distance = ir_distance_calculate_cm(GP2Y0A21YK, | ||
- | // Measuring with ultrasonic distance sensor. | + | // Messung mit Ultraschallentfernungssensor. |
distance = ultrasonic_measure(pin_trigger, | distance = ultrasonic_measure(pin_trigger, | ||
} | } | ||
</ | </ | ||
- | ====== | + | --- |
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | ====== | ||
{{ : | {{ : | ||
- | Practical examples are built up in uniform style and as concrete as possible. Each example begins with a short introduction of the theory and gives necessary knowledges for completing the following practical part. Practical part contains commented example of the source code of the software. Generally the library of the HomeLab | + | Die, in diesem Kapitel vorgestellten, |
- | ~~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, |
- | There is a list of necessary knowledges to complete the example at each chapter of practical examples. In this list are references to other chapters of the book, which are marked with icons as follows: | + | * [HW] Physikalisches Modul, das im Beispiel genutzt wird. |
+ | * [LIB] Teil der Softwarebibliothek, die 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. | ||
- | | + | **Grundlegende Software für die Beispiele** |
- | | + | |
- | | + | |
- | | + | |
- | * [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 | ||
- | 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 | + | **Programmierstil |
- | **Code style of the examples** | + | Die Beispielprogramme sind in einem einheitlichen Stil geschrieben, |
- | 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 letters, the words are separated with an under-strike. | + | * Das Programm, all seine Funktionen und Variablen sind in englischer Sprache und Kleinbuchstaben geschrieben, die Wörter werden durch einen Unterstrich getrennt. |
- | * Functions are in following form: // | + | * Die Funktionen werden wie folgt gekennzeichnet: // |
- | * more important places in the program are commented. | + | * Wichtigere Teile des Programms werden kommentiert. |
- | * Every block in C-language | + | * Jeder Block in C-Code (markiert durch { und } )startet und beginnt |
- | * Blocks are tabulated with tabulator keys. Tabulator is not used inside rows. | + | * Blöcke werden mit der Tabulatortaste geordnet. Die Tabulatortaste wird nicht innerhalb einer Zeile verwendet. |
- | ===== Beginning | + | ===== Anfang |
{{ : | {{ : | ||
- | Environment for writing the code, compiler for corresponding language and software for uploading written program to the controller are needed in order to program AVR controller. The most comfortable method would be using special integrated developing environment | + | Zur Programmierung des AVR Mikrocontrollers werden eine Programmierumgebung, ein Compiler für die betreffende Sprache sowie Software zum Laden der erstellten Programme auf den Controller benötigt. Die komfortabelste Weg hierfür ist die Nutzung der speziellen DIE (Integrated Developing Environment). Der AVR Mikrocontroller kann in folgenden Programmiersprachen programmiert werden: Assembler, C, C+, Pascal, Basic, etc. In diesem Buch wird C verwendet um den Mikrocontroller zu programmieren. Die Software ist sowohl für Windows OS und Linux OS frei erhältlich. Die 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 (// | + | |
- | + | ||
- | **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", | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | 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: | + | |
- | + | ||
- | === 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 // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **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 " | + | |
- | + | ||
- | 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. | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **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 // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **4.** Now the project space is created and new window will open where you can start to write the program source code. | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **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): // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **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 // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | If object // | + | |
- | + | ||
- | === Setting' | + | |
- | + | ||
- | 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 board- see 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 < | + | |
- | #include < | + | |
- | + | ||
- | int main(void) | + | |
- | { | + | |
- | // Pin PB7 to output | + | |
- | DDRB = 0x80; | + | |
- | + | ||
- | // Endless cycle | + | |
- | while (true) | + | |
- | { | + | |
- | // Pin PB7 invertion | + | |
- | PORTB ^= 0x80; | + | |
- | hw_delay_ms(500); | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | [{{ : | + | |
- | + | ||
- | 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. | + | |
- | + | ||
- | < | + | |
- | Build succeeded with 0 Warnings... | + | |
- | </ | + | |
- | + | ||
- | **2.** Open the controller window // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | If the described window does not open and // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **3.** On the programmer window insert into //Flash//-section textbox //Input HEX File// the location of the compiled program by pressing the " | + | |
- | + | ||
- | 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! | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | === Debugger === | + | |
- | + | ||
- | [{{ : | + | |
- | + | ||
- | 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. | + | |
- | + | ||
- | 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 // | + | |
- | + | ||
- | **2.** Next, open tab //Custom Options// and chose //[All files]//. Next add lines with " | + | |
- | + | ||
- | **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 (// | + | |
- | + | ||
- | sudo dpkg -i kontrollerlab*.deb | + | |
- | + | ||
- | If you have problems with packet dependencies, | + | |
- | + | ||
- | apt-get install –f | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | === Connecting the programmer === | + | |
- | + | ||
- | Connect to programmer with computer and see if the computer recognizes it. Write the command " | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | 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 " | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | === 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 (// | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **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. | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **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 " | + | |
- | + | ||
- | NB! As the HomeLab library can not be added on the //Linker// configuration tab, the command " | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | Apply settings on the // | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **4.** Configure the programmer by opening the configurations window from the //Project -> Configure Programmer// | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **5.** At last, place the windows in the KontrollerLab as it is more convenient and get ready to write your first program. | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | === 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. | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **2.** Write the following program in the Kontrollerlab file editor window and compile it: | + | |
- | + | ||
- | <code c> | + | |
- | #include < | + | |
- | #include < | + | |
- | + | ||
- | 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); | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | [{{ : | + | |
- | + | ||
- | Make sure that the output window shows "File compiled successfully" | + | |
- | + | ||
- | **3.** To download the program into the Controller press the //Ignite// button. After the succeful download, the " | + | |
- | + | ||
- | If everything was done correctly the red LED on the Controller board should blink periodically, | + | |
- | + | ||
- | === Using floating-point numbers === | + | |
- | + | ||
- | Sometimes it is neccessary to use floating-point numbers in program. To calculate with them and use them with // | + | |
- | + | ||
- | **1.** Open the //Project Configurations// | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | **2.** Press //OK// and close the window. | + | |
- | + | ||
- | ===== Digital input/output pins ===== | + | |
{{ : | {{ : | ||
- | Following chapters are introducing digital input/output which are basic functions of microcontroller. Input/output pins are microcontroller contacts. They are so called “legs”. Digital signal is received and transmitted through them. If pin is configured as input, the status of switches or simple sensors connected to pin can be received. When pin is configured as output, it 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 Mikrocontrollerkontakte. Es sind die sogenannten " |
- | Almost all typical microcontroller pins allow executing easier input-output functions, although often these pins have alternative | + | Fast alle typischen Mikrocontroller Pins erlauben die Ausführung einfacher Input-Output Funktionen, auch wenn diese Pins häufig noch alternative |
- | ==== Light-emitting | + | ==== Light-emitting |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[de: |
- | === Theory | + | === Theorie |
[{{ : | [{{ : | ||
- | Light-emitting diode is a semiconductor which emits light when forward voltage is applied. The acronym for light-emitting diode is LED. There are different color combination of diodes and the diodes, which can also emit white light. Like a normal diode, the LED has two contacts – anode and cathode. On drawings anode is marked as “+” and cathode as “-“. | + | Leuchtdioden sind Halbleiter die Licht abstrahlen, wenn Strom in Durchlassrichtung durch die Diode fließt. Die Abkürzung LED steht für "light-emitting diode". Es gibt verschiedenfarbige Leuchtdioden, mittlerweile ist sogar weißes Licht möglich. Wie jede normale Diode auch hat die LED 2 Kontakte - Anode und Kathode. In Zeichnungen ist die Anode mit einem "+" markiert und die Kathode mit einem "-". |
- | [{{ : | + | [{{ : |
- | When forward voltage is applied, | + | Wenn Strom in Durchlassrichtung durch die LED fließt, ist die Anode mit der positiven und die Kathode mit der negativen Spannung verbunden. Die Spannung der LED hängt von der Farbe der LED ab: lange Wellenlängen |
- | If the LEDs are used specially to illuminate, it is wise to use special electronic circuits witch would regulate current and voltage suited for LEDs. However | + | Wenn die LEDs nur zur Beleuchtung verwendet werden, sollte man spezielle elektrische Schaltkreise verwenden, welche die Spannung und die Stromstärke für die LEDs regulieren. |
+ | Jedoch werden | ||
- | LEDs are produced by a variety of casings. Most common | + | LEDs werden in vielen Formen gefertigt. Die meisten |
- | [{{ : | + | [{{ : |
- | === HomeLab | + | === HomeLab |
- | HomeLab Controller | + | Das HomeLab Controller |
+ | Um die LED an- und auszuschalten muss PB7 als Output Pin definiert werden und entweder | ||
+ | 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 included, are using HomeLab’s pin’s library. Pins’ library includes data type // | + | Alle praktischen Beispiele für das HomeLab kit, inklusive LEDs schalten, nutzen die HomeLab |
- | Here are 2 example programs, which are doing exactly the same thing, but one is created on the basis of HomeLab’s library, the other is not. | + | Hier sind 2 Beispielprogramme, welche exakt das gleiche machen. Das eine Programm nutzt die HomeLab |
<code c> | <code c> | ||
// | // | ||
- | // HomeLab | + | // HomeLab |
- | // The code is base on HomeLab | + | // Der Cose basiert auf der HomeLab |
// | // | ||
#include < | #include < | ||
// | // | ||
- | // 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 | + | // konfiguriert |
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 | + | // HomeLab |
- | // The code directly accesses registers. | + | // Der Code greift direkt auf Register zu. |
// | // | ||
#include < | #include < | ||
// | // | ||
- | // Main program | + | // Hauptprogramm |
// | // | ||
int main(void) | int main(void) | ||
{ | { | ||
- | // Configuring | + | // Konfiguriert |
DDRB |= (1 << 7); | DDRB |= (1 << 7); | ||
- | // Lighting up LED | + | // Aufleuchten der LED |
PORTB &= ~(1 << 7); | PORTB &= ~(1 << 7); | ||
} | } | ||
</ | </ | ||
- | First example uses pins’ library | + | Das erste Beispiel nutzt die Pin Bibliothek |
+ | Im Hauptprogramm wird dieser Pin mit // | ||
+ | Danach wird der Pin low gesetzt: | ||
+ | Im zweiten Beispiel werden keine Variablen genutzt. Um die LED als Output zu markieren und zum Leuchten zu bringen, werden die Datenrichtung des Port B und die Output Registerwerte verändert. Der Leser, der mehr über den AVR weiß bemerkt, dass in beiden Beispielen kein Befehl nötig ist um die LED zum leuchten zu bringen, da 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 registers? The difference is in the comfort – library is easier, because you do not need to know the registers’ names and their effects. Most important benefit of library is adaptability. Using registers, you must change registers’ names and bitmasks through entire program in order to change pin. When using library, it must be done only in the beginning of the program where pin variable is initialized. Using registers has one deceptive advantage – usage of pin is direct and it is not done through program memory and time consuming functions. However, newer AVR-GCC | + | Was ist der Unterschied zwischen dem Gebrauch von Bibliothek und Register? Der Unterschied liegt im Komfort - Die Bibliothek ist einfacher, weil man die Registernamen und deren Auswirkungen nicht kennen muss. Der 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 ändern. Nutzt man die Bibliothek muss dieses nur am Anfang, bei Initialisierung der Variable erfolgen. Die Nutzung von Registern hat jedoch einen entscheidenden Vorteil: Die Nutzung eines Pins erfolgt direkt und nicht über den Programmspeicher und zeitfressenden Funktionen. Jedoch sind die neuren | ||
- | The next program code is partial pin operations library. Its purpose is to explain the procedures with pin variables. It might not be understandable for the beginners as it uses C language pointers which are not covered in this book, but 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ären. Es wird für Anfänger nicht einfach sein zu verstehen, da C-Sprache Pointer genutzt werden, die 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, | #define PIN(port_char, | ||
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: | ||
</ | </ | ||
- | === HomeLab | + | === HomeLab |
- | In addition to the Controller module, | + | Zusätzlich zum Controllermodul befinden sich LEDs auch auf der digtalen I/O Modulplatine. |
+ | Sie sind elektrisch genau so angeschlossen wie auf dem Controllerboard, die Kathode ist also am AVR Pin angeschlossen. Die rote LED ist am PC5 Pin angeschlossen, die gelbe am PC4, und die grüne am PC3. Das auf der HomeLab | ||
<code c> | <code c> | ||
// | // | ||
- | // HomeLab | + | // HomeLab |
// | // | ||
#include < | #include < | ||
// | // | ||
- | // LED's pin configuration. | + | // LED Pin Konfiguration. |
// | // | ||
pin led_red | pin led_red | ||
Line 2748: | Line 2216: | ||
// | // | ||
- | // Main program | + | // Hauptprogramm |
// | // | ||
int main(void) | int main(void) | ||
{ | { | ||
- | // Configuring | + | // Konfiguriere |
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 |
pin_clear(led_green); | pin_clear(led_green); | ||
- | // Turn off red and yellow | + | // Ausschalten der roten und gelben |
pin_set(led_red); | pin_set(led_red); | ||
pin_set(led_yellow); | pin_set(led_yellow); | ||
Line 2766: | Line 2234: | ||
</ | </ | ||
- | ~~DISCUSSION~~ | + | ~~Diskussion~~ |
- | ==== Switch | + | --- |
+ | | ||
+ | ==== Schalter | ||
- | //Neccesary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | A switch is an electromagnetic device which can connect or break an electrical circuit. There are many different types of switches; the most common mechanical switch is mechanically connectible electrical connectors. If connectors are connected, electrical circuit is closed and electricity can flow through the switch. If connectors are disconnected, electricity cannot flow through the switch. | + | Ein Schalter ist ein elektromagnetisches Gerät, welches einen elektrischen Schaltkreis verbindet oder trennt. Es 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 verbunden, wird der elektrische Schaltkreis geschlossen und Strom kann durch den Schalter fließen. Wenn die Anschlüsse nicht verbunden sind, kann keine Elektrizität fließen. | ||
- | Switches are commonly used to electrify electrical circuits, but can also be used as sensors. Switch as a sensor is also the subject of this exercise and therefore examining specific high-voltage and high-amperage switches has been excluded. Switches can be differentiated by the number of contacts and by their connection method. Different types include: two contact switches and double switches, where contact pairs are connected, but also push button, sliding, rocker and toggle switches as well as switches which disconnect instead of connect electrical circuit. | + | Schalter werden normalerweise benutzt um elektrische Schaltkreise zu schalten, sie können jedoch auch als Sensoren benutzt werden. Der Schalter als Sensor ist auch Teil dieser Übung, |
- | Different schematic symbols are used for identifying different types of switches. Below 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 identifizieren. Unterhalb sind Beispiele typischer elektrischer Schalter |
- | + | ^ Druckknopfschalter | |
- | ^ Push button switch | + | |
|{{: | |{{: | ||
| {{: | | {{: | ||
- | In order to use a switch as a sensor connected to a microcontroller, one contact of the switch is connected to the microcontrollers pin and is set as input in the program. If contact is connected to the ground or input potential, the bus’s bit rate of microcontroller’s pin is changed. It would sound logical to use toggle switch, which allows connecting one contact with desired contact | + | Um einen Schalter als Sensor mit einem Mikrocontroller zu nutzen, muss ein Kontakt des Schalters mit dem Pin des Mikrocontrollers verbunden sein und dieser muss als Input im Programm definiert werden. Wenn der Kontakt mit der Masse oder einem Inputpotential verbunden ist, wir die Bus Bitrate des Mikrocontroller-Pins geändert. Es erscheint logisch einen Wechselschalter zu nutzen, welcher es erlaubt einen Kontakt an den gewünschten Kontakt anzubringen |
+ | Auf Grund elektromagnetischer Störung | ||
- | 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. | ||
+ | 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 " | ||
- | [{{ : | ||
+ | [{{ : | ||
Line 2798: | Line 2269: | ||
- | A simple two contact switch can be used as a sensor with pull-up | + | Ein einfacher zwei-Kontakt Schalter kann als Sensor mit einen pull-up |
+ | AVR Mikrocontroller haben beispielsweise | ||
+ | Darüber hinaus muss noch erwähnt werden, dass 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 unterbrochen. Die Beispiele dieses Kapitels werden nicht durch den "switch bounce" beeinflusst, | ||
| | ||
- | === Practice | + | === Übung |
- | There are three push button-switches on the Digital i/o module. Those switches connect the pins of microcontroller to the earth, however not directly through a resistor, this is to avoid short circuiting when pressing the button while setting the pins as output. The switches have also pull-up | + | Es gibt drei Druckknopf-Schalter am digitalen I/O Modul. Diese verbinden die Pins den Mikrocontrollers mit der Erde, aber nicht direkt durch einen Widerstand. Auf diese Weise soll ein Kurzschluss vermieden werden, wenn der Knopf gedrückt wird, während der Pin als Output definiert wird. Die Schalter besitzen einen pull-up |
- | The switches are on PC0, PC1 and PC2 pins. In order to read the status of the switches, the corresponding pins of the microcontroller must be set as inputs. There is no need to put AVR internal | + | Die Schalter befinden sich an den PC0, PC1 und PC2 Pins. Um den Status der Schalter zu lesen müssen die betreffenden Pins des Mikrocontrollers als Input gesetzt werden. Man benötigt nicht die internen |
+ | Wenn der Schalter betätigt wird, hat der entsprechende Bus des Pins den Wert 0, wird er losgelassen, den 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 | + | Der Beispielcode zur Benutzung der Schalter basiert auf der HomeLab |
| | ||
Line 2816: | Line 2289: | ||
<code c> | <code c> | ||
// | // | ||
- | // Program | + | // Program |
// | // | ||
#include < | #include < | ||
// | // | ||
- | // Determining the pins of LED-d and buttons. | + | // Festlegung der Pins von LED-d sowie der Schalter. |
// | // | ||
pin leds[3] | pin leds[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 | + | // Jeder Schalter hat eine zugehörige |
- | // which lights when button is pressed. | + | // die aufleuchtet, |
for (i = 0; i < 3; i++) | for (i = 0; i < 3; i++) | ||
{ | { | ||
Line 2853: | Line 2326: | ||
</ | </ | ||
- | + | Im Beispiel werden LEDS und Knöpfe als Array definiert - das ermöglicht es Sie in einer // | |
- | In the given example LEDs and buttons are defined as array – this allows them to be use in // | + | ==== 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 exercise, the compiler does not simplify the arrays of pins. Compiled program would be more compact if all LEDs and buttons were operated individually, | + | |
- | */ | + | |
- | ==== Filtration of switch bounce | + | |
//Vajalikud teadmised: [HW] [[en: | //Vajalikud teadmised: [HW] [[en: | ||
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | As mentioned in the introductory chapter of switches, there exists an issue of bouncing or flickering when dealing with mechanical switches. Problem | + | Wie bereits im einleitenden Kapitel zu Schaltern erwähnt, gibt es im Ungang mit mechanischen Schaltern den Effekt des Prellens (ungewolltes, |
- | [{{ : | + | [{{ : |
- | Main method used for avoiding flickering caused by the bouncing of contacts is filtering. Filtering can be done electrically or by software. To 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 drawing. Filtering 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 limit, it is considered to have a steady position and hence has no flickering problem. However, with 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 Filtrierung. Dieses kann elektrisch oder durch Software erfolgen. Um elektrisch zu filtern muss der Schalter an einen Tiefpassfilter angeschlossen 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/ |
<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 < | #include < | ||
// | // | ||
- | // 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 als Output setzen. |
for (index = 0; index < 3; index++) | for (index = 0; index < 3; index++) | ||
{ | { | ||
Line 2905: | Line 2372: | ||
} | } | ||
- | // Setting button' | + | // 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); | ||
- | // Control, wether the button is pushed down, | + | // Kontolle, ob der Schalter heruntergedrückt wurde, |
- | // that means is the new state 1 and old 0. | + | // was bedeutet, dass der neue Status |
if ((new_value) && (!old_value)) | if ((new_value) && (!old_value)) | ||
{ | { | ||
- | // Enlarging the reader and taking module | + | // Erweiterung des Lesegerätes und Nutzungvon Modul 3 |
counter = (counter + 1) % 3; | counter = (counter + 1) % 3; | ||
- | // Lighting | + | // 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: | ||
</ | </ | ||
- | Several software solutions are used for filtering, this can be performed either easy or complex way both with its advantages and disadvantages. If the program is set to have only few infrequent pressings of the button, a long pause can be set to follow the pressing, this will rule out reaction to the switching caused by bounce. However, while using this solution must be considered – in case the user holds the button down for a long period of time, the program reacts also on the miss witching caused by the release of the button. A program which controls the state of the switch several times in fixed period of time is more dependable | + | Es gibt diverse Softwarelösungen zur Filtrierung. Sie können einfach oder komplex sein, wobei jede ihre Vor- und Nachteile hat. Sieht das Programm nur wenige seltene Betätigungen des Schalters vor, kann eine lange Pause als Folge der Betätigung eingefügt werden. Auf diese Weise können durch Kontaktprellung verursachte Wirkungen auf die Schaltung vermieden werden. Jedoch muss bei Anwendung dieser Lösung bedacht werden, dass, sofern der Nutzer den Schalter für eine längere Zeit gedrückt hält, das Programm ebenfalls auf die Fehlschaltung, |
<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 |
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 |
{ | { | ||
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 |
{ | { | ||
return 0; | return 0; | ||
Line 2976: | Line 2443: | ||
</ | </ | ||
- | This function generates a delay using a function which is explained | + | Diese Funktion generiert eine Verzögerung durch Nutzung einer Funktion, die in der entsprechenden Übung erläutert wurde. Zu 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önnen. Befindet sich der Schalter 8 Lesezyklen lang in der gleichen Position, |
<code c> | <code c> | ||
Line 3034: | Line 2501: | ||
</ | </ | ||
- | If we test this program now, the LEDs are lighting exactly | + | Testen wir das Programm nun, leuchten die LEDs in genau der Sequenz auf, in welcher der Nutzer den Schalter betätigt. |
- | ==== Digital i/o exercises ==== | + | === Aufgaben: Digitale I/O === |
- | 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 |
- | | + | * Durch Drücken von S1 leuchtet eine LED auf, drückt man S2 leuchten zwei und bei S3 drei LEDs. |
- | === For beginners | + | === Für Anfänger |
- | - This simulates manually operated traffic light at pedestrian crossing. Until no button is pressed a green LED is lit for the cars. After pressing a random button the green LED will start to blink for 3 seconds, this is followed by lighting the yellow | + | - Es wird eine von Hand betriebene Ampel an einer Fußgängerkreuzung simuliert. Solange kein Schalter gedrückt wird, leuchtet eine grüne |
- | - This counts how many times the button is pressed. Only the full release of the button will complete the pressing. The result is displayed in binary code on LEDs. Maximum result for three LEDs is 7(23-1). | + | - Es soll gezählt werden, wie oft ein Schalter betätigt wurde. Nur durch ein vollständiges Lösen des Schalters wird das Herunterdrücken vollendet. Das Ergebnis wird als Binärcode auf den LEDs angezeigt. Das maximale Ergebnis bei drei LEDs ist 7 (23-1). |
- | - By pressing switch S1, LED1 and LED3 are lit; pressing | + | - 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 leuchtet. Diese Operation muss unter direkter Verwendung von Registerwerten |
- | - This counts how many times the button is pressed. The result is displayed by blinking of the LEDs. After each pressing the number of blinking is increased by one. A random button can be selected. In order for the LED to blink a sub function must be used, with parameters set on the number of blinks. | + | - Es soll gezählt werden, wie oft ein Schalter gedrückt wurde. Das Ergebnis wird durch Blinken der LEDs dargestellt. Nach jeder Betätigung des Schalters wird die Anzahl der blinkenden LEDs um eins erhöht. Der Schalter kann zufällig ausgewählt werden. Damit die LED blinkt muss eine Unterfunktion genutzt werden, deren Parameter die blinkenden LEDs zählt. |
- | - When pushing button | + | - Wird S1 betätigt, sendet die rote LED durch Blinken "SOS" im Morsecode. Drü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 off, registers 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 wird. Zum an- oder ausschalten sollen Register und nur eine zuordnende Operation genutzt werden |
- | | + | - Für jede LED gibt es einen Schalter. Der Controller bringt die LEDs in zufälliger Reihenfolge zum Blinken und der Nutzer muss diese Sequenz wiederholen. Die Blinksequenz verlängert sich, nach jeder Runde kommt eine LED hinzu. Bei einem falschen Eintrag blinken alle LEDs dreimal |
- | - There is one button for each LED. The controller blinks | + | - Das Programm misst die Zeit für eine Reaktion. Eine zufällige |
- | - The program measures time for reaction. A random | + | |
- | === Questions | + | === Fragen |
- | - What is the difference between operations”=” | + | - Was ist der Unterschied zwischen den Operationen |
- | - What is the difference between operations | + | - Was ist der Unterschied zwischen den Operationen |
- | - Write an expression using the equation | + | - Schreiben Sie einen Ausdruck, welcher die Gleichung |
- | - How an endless loop is written | + | - Wie wird eine Endlosschleife |
- | - What type of a variable do you choose | + | - Welcher Variablentyp wird in C verwendet um positive |
- | - Witch register determines the direction of a port? Provide an example of configuring settings of ports’ input and output. | + | - Welches Register legt die Richtung eines Anschlusses fest? Nennen 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 flickering? Provide 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 verhindern? Geben Sie Lösungsbeispiele unter der Nutzung von Hard- und Software. |
- | - What is bit shift? Give a practical example with an explanation. | + | - Was versteht man unter einer Bitverschiebung? Nennen Sie ein praktisches Beispiel und erklären Sie dieses. |
- | - Why are pull-up | + | - Warum werden |
- | - Calculate the resistance for regulating | + | - Errechnen Sie den Widerstand für die regulierende |
- | ===== Timers and delays | + | |
+ | ===== Timer und Verzögerungen | ||
{{ : | {{ : | ||
- | This chapter introduces the possibility of co-ordinate time of the microcontrollers - timers and delays. These are helpful in applications which require time measuring, make breaks or accurately steer processes. All timers and delays are similar by their nature yet are clearly distinguishable at the same time. The timers are physical modules of microcontroller which are functioning independently from the processor of the microcontroller, delays are paragraphs of software program which are specifically designed to use working time of a processor. From the aspect of similarity both work by counting the firing strokes of the microcontroller. | + | Dieses Kapitel beschreibt die Möglichkeit, |
- | 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 | + | Beide Methoden haben ihre Vor- und Nachteile, welche |
- | Timers have evolved from being simple time counting devices to complex systems for receiving and generating signals. They modulate and demodulate signals and they are capable of multiplying and dividing (taktsignaal? | + | Timer haben sich von einfachen Zeitzählgeräten zu komplexen System entwickelt, welche Signale empfangen und generieren. Sie modulieren und demodulieren Signale und ermöglichen, |
- | ==== Software delay ==== | + | ==== Softwareverzögerungen |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | There is often a need to create delays | + | Oft ist es wichtig |
- | + | Eine Zahl von Null bis zum Wert der Taktfrequenz des Prozessors in Hz, sollte theoretisch eine Verzögerung von einer Sekunde erzeugen. Aus 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 value. In 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 | + | 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 Operation, wie z.B. 1 zu einem Wert zu addieren, durchzuführen. Soll 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 Taktfrequenz. Daher 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, | ||
- | === Practice | + | === Beispiel |
- | The following is an example of generating software delay with AVR microcontroller. A part of a program | + | Das folgende Beispiel generiert eine Softwareverzögerung im AVR Mikrocontroller. Ein Teil des in C geschriebenen Programms zählt eine Variable |
+ | In jedem Zyklus wird ein leerer "no-action empty" Befehl ausgeführt. Dieser wird benötigt, der 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 x is 100 | + | // Zyklus bis x ist 100 |
for (x = 0; x < 100; x++) | for (x = 0; x < 100; x++) | ||
{ | { | ||
- | // With empty instruction | + | // Mit "empty" |
asm volatile (" | asm volatile (" | ||
} | } | ||
</ | </ | ||
- | This is the same part of a program after compiling. 2 hexadecimal numbers on the left is machine code and on the right is the command with operand(s) | + | Dies ist der gleiche Teil des Programms nach dem Kompilieren. Die beiden Hexadezimalzahlen links geben den Maschinencode an, und rechts befindet sich der Befehl mit den Operanden |
+ | Der Maschinencode und die Assemblersprache sind konform; Assembler dient nur dazu, den Maschinencode für Menschen lesbar zu machen. Kompiliert wurde mit der Optimierungsmethode für die Länge des Programms | ||
<code asm> | <code asm> | ||
- | 80 e0 | + | 80 e0 |
- | 00 00 | + | 00 00 |
- | 8f 5f subi r24, 0xFF ; | + | 8f 5f subi r24, 0xFF ; |
- | 84 36 | + | 84 36 |
- | e1 f7 brne .-8 ; | + | e1 f7 brne .-8 ; |
</ | </ | ||
- | + | In der kompilierten Form erkennt man, was mit dem Zyklus der C-Sprache passiert und man kann berechnen wie viele Taktfrequenzen benötigt werden, um den Zyklus einer Periode zu beenden. Die Information über die Wirkung der Befehle und ihre Laufzeit findet man im AVR Datenblatt. Im vorliegenden Beispiel, braucht es 4 Taktzyklen um 4 Befehle | |
- | In the compiled form can be seen, what 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 period. The information about the effect of the instructions and operating time can be found from AVR’s instructions datasheet. In the given example, it takes 4 clock cycles to complete | + | Wenn man nun den Arbeitstakt von 14,7456 MHz annimmt, kann 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 | + | Die Verzögerung |
- | + | ||
- | The goal of this exercise is not creating precise software delay on the level of machine code, because 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 know, that regardless its basic simplicity; it is extremely inefficient method from the power consumption point of view. | + | Das Ziel dieser Übung ist es nicht präzise Softwareverzögerungen in Maschinencode zu erstellen, da 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 sind. Diese werden auch in den folgenden Beispielen genutzt. |
+ | Bei der Arbeit mit Softwareverzögerungen arbeitet, ist es wichtig zu wissen, dass diese trotz ihrer Einfachheit, | ||
+ | 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 // | ||
+ | // | ||
- | The following code of a program is about software delay function // | ||
<code c> | <code c> | ||
// | // | ||
- | // Software delay in milliseconds. | + | // Softwareverzögerung |
// | // | ||
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: | ||
</ | </ | ||
- | The following program is for using the given function, this creates two delays | + | Das folgende Programm dient dazu, die gegebene Funktion zu nutzen, es erzeugt zwei Verzögerungen |
<code c> | <code c> | ||
// | // | ||
- | // The demonstration program of the software delay of the HomeLab. | + | // Das Vorführprogramm des HomeLab |
- | // The program is blinking a LED for a moment after ~1 second. | + | // Es lässt eine LED für ~1 Sekunde aufleuchten. |
// | // | ||
#include < | #include < | ||
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: | ||
</ | </ | ||
- | Although it seems that the LED blinks in every 1 second, the time is actually a little bit longer, because 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 Sekunde, dauert es tatsächlich etwas länger, da das ansprechen der LED und die Verzögerungsfunktionen ein paar Taktfrequenzen des Mikrocontrollers benötigen. |
- | ==== Hardware delay ==== | + | ==== Hardwareverzögerung |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === 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 frequency. The clock frequency of the timer can be generated from microcontroller’s frequency or from some kind of other outside pace. In general the clock frequency can be divided with a multiplier to reach a smaller frequency - this is done with prescaler. Important fact is that the fixed clock frequency timer’s value is linearly related to the time. The 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, |
- | [{{ : | + | [{{ : |
- | AVR counters can be made to inform about overflow of the counter or achieving compare mach. Overflow 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 user. On 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 informieren. Ein Überlauf tritt auf, wenn der Timer seinen maximalen Wert erreicht hat und der Zyklus wieder bei 0 anfängt. Nach Erreichen eines vorgegebenen Wertes beginnt der Timer bei jedem Anstieg seines Wertes diesen mit einem vom Benutzer vorgegebenen Wert zu vergleichen. Daraufhin werden die Bits des AVR-Statusindexes automatisch |
- | + | ||
- | 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 generieren, muss man nur den Timer setzen und darauf warten, dass das Statusbit high wird. Im Unterschied zur Softwareverzögerung ist die Arbeit des Timers nicht vom Compiler abhängig, wodurch er zuverlässiger ist. Gleichzeitig ist die Diversität (bzw. Komplexität) der Einstellungen des AVR Timers hoch. Je nach Taktsignal des Mikrocontrollers kann es sein, dass 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 timer, which is simplified a little bit. The 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 ms. The 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 // | + | |
- | In the cycle takes place initialing of the counter and zeroing the flag of the overflow | + | === Ü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 // | ||
+ | Leider entsteht hier eine gewisse Ungenauigkeit, | ||
+ | |||
+ | In dem Zyklus wird der Timer initialisiert und die Überlauf-Flagge genullt | ||
<code c> | <code c> | ||
// | // | ||
- | // Hardware delay in milliseconds. | + | // Hardwareverzögerung |
// | // | ||
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(); | ||
} | } | ||
</ | </ | ||
- | The following is a similar program to the example of the software delay. In the shorter | + | Das folgende Programm ist ähnlich wie das für die Softwareverzögerung. In der kürzeren |
<code c> | <code c> | ||
// | // | ||
- | // Demonstration program of hardware delay of the HomeLab. | + | // Beispielprogramm für eine Hardwareverzögerung mit dem HomeLab. |
- | // The Program blinks | + | // Das Programm lässt eine LED immer nach ~1 Sekunde blinken. |
// | // | ||
#include < | #include < | ||
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 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: | ||
</ | </ | ||
- | ==== Periodic interrupt | + | ==== Periodische Interrupts |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | The goal of these practical exercises is to demonstrate the usage of the interrupts on the example of the counters. The interrupts are program parts which are reacting to the events taking place in the microcontrollers. They are usually used for quick response to an event, but they can also be used for completing several | + | Ziel dieses praktischen Beispiels ist es, die Verwendung von Interrupts an Beispiel von Timern darzustellen. Interrupts sind Programmteile welche auf Ereignisse, die in einem Mikrocontroller stattfinden, |
+ | 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 interrupt. There are 2 LEDs of the Digital i/o module in the program, the state of the red LED is changed periodically with software delay, the state of the green LED is changed when interrupts occur. There is a separate exercise for blinking LED with software delay and it is not explained here. The 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ändert, der Status der grünen | ||
- | In the beginning of the program, the 16-bit counter/ | + | Zu Beginn des Programms wird der 16-Bit Timer 1 mit der Funktion |
+ | Der Teiler des Timers ist 1024 und der Wert des ICR1 beträgt | ||
f = 14745600 Hz / 1024 / 14400 = 1 | f = 14745600 Hz / 1024 / 14400 = 1 | ||
- | After allowing the interrupt to achieve the maximum value of the counter | + | Nachdem zugelassen wurde, dass ein Interrupt den maximalen Wert von Counter |
+ | Ein Interrupt wird im Programm durch die Makrofunktion | ||
<code c> | <code c> | ||
// | // | ||
- | // The HomeLab's example of blinking | + | // HomeLab |
- | // For comparison to the LED blinking due to interrupts, | + | // Zum Vergleich blinkender LEDs aufgrund von Interrupts, |
- | // there is a software delay blinking | + | // gibt es parallel eine durch Softwareverzögerung blinkende |
// | // | ||
#include < | #include < | ||
Line 3319: | Line 2798: | ||
// | // | ||
- | // Determining the pins of the LEDs. | + | // Festlegung der Pins der LEDs. |
// | // | ||
pin led_red | pin led_red | ||
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 |
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, | + | // Maximaler Wert des Timers ist 14400, |
- | // makes the length of the period | + | // die Periode |
- | // 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 |
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: | ||
</ | </ | ||
- | At the start of the program it is seen that regardless of what the microcontroller is doing in the main program, the interrupts are taking place and the green LED is blinking. | + | Zu Beginn des Programms sieht man, dass unabhängig davon was der Mikrocontroller gerade im Hauptprogramm macht, Interrupts stattfinden und die grüne |
- | If we let the program to work for a couple of minutes, an important aspect occurs, that was not so easily noticeable during software delay exercise. Although the delay in red LED blinking is 1000 ms, the actual time for completing the full cycle is a little bit longer. This is because, the change of the LED’s state, callout of the function of the delay and completion of the cycle are demanding some clock cycles of time for the processor. As 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 deutlich, der im Rahmen der Softwareverzögerung nicht so einfach zu erkennen ist. Auch wenn die Verzögerung der blinkenden roten LED 1000 ms beträgt, ist die tatsächlich benötigte Zeit um einen Zyklus zu beenden länger. Das liegt daran, dass die Änderung vom LED-Status' |
- | ==== 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 blink. The period is 10 seconds | + | * Lassen Sie die rote LED blinken. Die Periode soll 10 Sekunden |
- | === For beginners | + | === Für Anfänger |
- | - Display on LCD screen, with the accuracy of 100 ms, time between pressing of any random two buttons. Execution 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 | + | - Wird Schalter |
- | - Display the frequency of pressing down the button | + | - zeige die Druckfrequenz von Schalter |
- | - If button | + | - Wird Schalter |
- | - Display the Time on the LCD as follows: hh: | + | - Zeigen Sie die Zeit auf dem LCD wie folgt an: hh: |
- | === For advanced | + | === Für Fortgeschrittene |
- | - Design a stopwatch, which displays hours, minutes, seconds and milliseconds on LCD screen. Button | + | - Entwickeln Sie eine Stoppuhr, die Stunden, Minuten, Sekunden, und Millisekunden auf dem LCD anzeigt. Schalter |
- | - In 2 second intervals red, yellow and green LED are smoothly lit and switched off after each other. The smooth lighting is achieved by modulating the LEDs with hundredths of hertz (by lighting and switching it off very fast) and by changing the proportions between lighted/ | + | - Die rote, gelbe und grüne |
- | - Make a part of program | + | - Erstellen Sie einen Programmteil |
- | === Questions | + | === Fragen |
- | - What are the methods for crating delay? | + | - Welche Methoden zur Erstellung von Verzögerungen gibt es? |
- | - How is software delay created? On which parameters depends the duration of the software delay? | + | - Wie wird eine Softwareverzögerung erstellt? Von 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 timer, if the clock rate is 16 MHz and frequency divider' | + | - Berechnen sie die die Überlauf-Interruptperiode für einen 8-Bit Timer, wenn Taktfrequenz 16M Hz und Frequenzteilerfaktor |
- | - What is RTC hidden | + | - Was ist ein Echtzeitgeber |
- | - 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 |
- | - What indexes can be used to set up the ATmega128 | + | - Welche Indizes können genutzt werden um den ATmega128 |
- | - Which is the longest duration of the interruptions | + | - Wie lang ist die längste Zeitspanne von Unterbrechungen |
- | - In case the processor is heavily loaded with an execution of a program (for example, it controls several motors and the values of several sensors at once), does this have an effect on the accuracy of the timer? Explain your answer. | + | - Hat es einen Effekt auf die Genauigkeit von Timern, wenn 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 |
{{ : | {{ : | ||
- | 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 activities. Quite often it is not enough, because 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 displayed. Here become handy all sorts of indicators and displays, which allow to display numbers, texts or even pictures. One of the most known information displaying devices is computer monitor and typical programmer does not see anything special about using it, but 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, |
- | The following chapters are introducing simpler types of displays and screens – indicator with LED segments and two types of monochromatic LCD. In addition to those also LED matrixes and (quite common today) organic color LED (OLED) | + | Das folgende Kapitel befasst sich mit einfachen Displays und Bildschirmen. Anzeigen mit LED-Segmenten und zwei Typen von monochromen LCD´s. Zusätzlich zu diesen werden auch LED-Matrizen und organischen Farb-LED´s(OLED) |
- | ==== 7-segment LED display ==== | ||
- | //Necessary knowledge: [HW] [[en: | + | ==== 7-Segment-LED-Anzeige ==== |
- | === Theory === | + | // |
- | 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 === |
- | [{{ : | + | Die 7-Segment-LED-Zifferanzeige ist ein Display, welches aus sieben, in Form einer Acht angeordneten, |
- | Electrically all anodes of the LEDs are connected to one anode pin //ca//. LEDs are lit by switching their cathodes | + | [{{ : |
+ | |||
+ | Elektrisch werden alle Anoden der LEDs an einer Anode am Pin // | ||
LED number-indicators are easy to use, they can be controlled directly from the pins of the microcontroller, | LED number-indicators are easy to use, they can be controlled directly from the pins of the microcontroller, | ||
- | === 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, |
+ | |||
+ | === Übung | ||
- | There is one 7-segment | + | Am digitalen I/O Modul befindet sich eine 7-Segment-LED-Zifferanzeige. Sie wird über einen Treiber mit der seriellen Schnittstelle |
- | [{{ : | + | [{{ : |
- | * Latch-signal | + | * Latch-Signal |
- | * Clock-signal | + | * Taktsignal |
- | * Data-signal | + | * Datensignal |
~~CL~~ | ~~CL~~ | ||
- | The data is delivered by bits through the data pin. Every 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 cell. By 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-index, where it remains until new loading. Each bit of the latch-index is connected through the current switching to one number-indicator’s segment. The segment is lit during the high bit-rate. | + | Die Daten werden in Form von Bits über den Datenpin gesendet. Immer, wenn das Taktsignal |
- | 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 |
<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 segments. Lower ranking is A, higher ranking is DP. | + | // Die Bits markieren Segmente. Ein 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 | + | 0b01111001 |
}; | }; | ||
// | // | ||
- | // 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 | + | // Senden von he Bits. Hö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, | pin_set_to(segment_display_data_out, | ||
- | // The clock-signal as high for a moment. | + | // Taktsignal |
pin_set(segment_display_clock); | pin_set(segment_display_clock); | ||
_delay_us(1); | _delay_us(1); | ||
- | // The clock-signal as low. | + | // Taktsignal |
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); | ||
} | } | ||
</ | </ | ||
- | For displaying numbers and the letter “E”, is created a constant array // | + | Um Ziffern und den Buchstaben "E" darzustellen, wird ein konstantes Array // |
- | + | ||
- | The following is a more concrete example of a program for using the number-indicator. | + | |
+ | 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 | + | // Das Beispielprogramm der 7-Segment-LED-Anzeige des I/O-Moduls des HomeLab |
- | // input-output module. | + | |
// | // | ||
#include < | #include < | ||
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 1 second. | + | // Verzögerung von 1 Sekunde. |
sw_delay_ms(1000); | sw_delay_ms(1000); | ||
} | } | ||
} | } | ||
</ | </ | ||
- | ==== Alphanumeric | + | ==== Alphanumerisches |
- | + | ||
- | //Necessary knowledge: [HW] [[en: | + | |
- | === Theory === | + | // |
- | Alphanumeric LCD is liquid crystal display, with the purpose of displaying letters and numbers. | + | === Theorie === |
- | Main characteristic of alphanumerical | + | Das alphanumerische |
+ | 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, | ||
- | [{{ : | + | [{{ : |
- | Besides the screen Alphanumerical | + | Neben dem Bildschirm hat das alphanumerische |
- | Alphanumerical | + | Alphanumerische |
- | === Practice | + | === Übung |
- | HomeLabs Digital i/o module connects a 2x16 symbol alphanumerical | + | Am digitalen I/O Modul des HomeLab ist ein alphanumerisches, |
- | Before using the display it is vital to adjust its settings. For this purpose is the // lcd_alpha_init// | + | Vor der Nutzung des Displays ist es notwendig, seine Einstellungen anzupassen. Hierzu dient die // |
- | The following program code demonstrates the usage of alphanumerical | + | Der folgende Programm-Code zeigt wie das alphanumerische |
<code c> | <code c> | ||
// | // | ||
- | // The example of using the alphanumerical | + | // Beispiel zur Nutzung des alphanumerischen |
- | // 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 < | #include < | ||
Line 3598: | Line 3078: | ||
// | // | ||
- | // Main program. | + | // Hauptprogramm. |
// | // | ||
int main(void) | int main(void) | ||
{ | { | ||
- | int seconds = 0; | + | |
- | char text[16]; | + | char text[16]; |
- | // Set-up of the LCD. | + | |
- | lcd_alpha_init(LCD_ALPHA_DISP_ON); | + | lcd_alpha_init(LCD_ALPHA_DISP_ON); |
- | // Cleaning of the LCD. | + | |
- | lcd_alpha_clear(); | + | lcd_alpha_clear(); |
- | // Name of the program. | + | |
- | lcd_alpha_write_string(" | + | lcd_alpha_write_string(" |
- | // Endless loop | + | |
- | 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, | + | sprintf(text, |
- | (seconds / 3600) % 24, | + | (seconds / 3600) % 24, |
- | (seconds / 60) % 60, | + | (seconds / 60) % 60, |
- | seconds % 60); | + | |
- | // Displaying the clock text in the beginning of the second row of the LCD. | + | |
- | lcd_alpha_goto_xy(0, | + | lcd_alpha_goto_xy(0, |
- | 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 |
- | hw_delay_ms(1000); | + | hw_delay_ms(1000); |
- | } | + | } |
} | } | ||
</ | </ | ||
- | ==== Graphic | + | ==== Graphisches |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | Graphical | + | Das graphische |
- | [{{ : | + | [{{ : |
- | Monochrome | + | Monochrome |
+ | |||
- | === Practice | + | === Übung |
- | In the Home-Lab set is a 84x48 pixels monochrome graphic | + | Das HomeLab Kit enthält ein 84x48 Pixel großes, monochromes, |
- | The functions of the graphic | + | Die Funktionen für das graphische |
- | The following is an example of time counter. The program counts seconds | + | Nachfolgend ist ein Beispiel des Zeitzählers dargestellt. Das Programm zählt Sekunden |
<code c> | <code c> | ||
// | // | ||
- | // Example of using the graphic | + | // Beispiel für die Nutzung des graphischen |
- | // 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 < | #include < | ||
Line 3666: | Line 3147: | ||
// | // | ||
- | // Main program. | + | // Hauptprogramm. |
// | // | ||
int main(void) | int main(void) | ||
{ | { | ||
- | int seconds = 0; | + | |
- | char text[16]; | + | char text[16]; |
- | // Set-up of the LCD. | + | |
- | lcd_gfx_init(); | + | lcd_gfx_init(); |
- | // Cleaning the screen. | + | |
- | lcd_gfx_clear(); | + | lcd_gfx_clear(); |
- | // Switching on the background light. | + | |
- | lcd_gfx_backlight(true); | + | lcd_gfx_backlight(true); |
- | // Displaying the name of the program. | + | |
- | lcd_gfx_goto_char_xy(1, | + | lcd_gfx_goto_char_xy(1, |
- | lcd_gfx_write_string(" | + | lcd_gfx_write_string(" |
- | // Endless loop. | + | |
- | 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, | + | sprintf(text, |
- | (seconds / 3600) % 24, | + | (seconds / 3600) % 24, |
- | (seconds / 60) % 60, | + | (seconds / 60) % 60, |
- | seconds % 60); | + | |
- | // Displaying the clock text. | + | |
- | lcd_gfx_goto_char_xy(3, | + | lcd_gfx_goto_char_xy(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); |
- | } | + | } |
} | } | ||
</ | </ | ||
- | ==== 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 " | ||
+ | - 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²”, | + | === 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 | + | |
- | === Questions === | + | - Stellen Sie griechische Buchstaben auf dem graphischen LCD dar. Dabei sollen folgende Zeilen angezeigt werden: “Widerstand Ω”, “∑R=∑πR²”, |
+ | - 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 " | ||
+ | - 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. | ||
- | | + | === Fragen === |
- | - What determines the brightness of the 7-segment number-indicator? How can it be adjusted if the number-indicator is controlled | + | |
- | - If the 7-segment number indicator is connected directly to the port A of the controller, so that the segment | + | |
- | - What is the difference between | + | - Was bestimmt die Helligkeit der 7-Segment Zifferanzeige? Wie kann sie angepasst werden wenn die Anzeige |
- | - Through which pins and how is the background light of the alphanumerical LCD regulated? | + | - Wenn die 7-Segment Zifferanzeige direkt an Port A des Controllers angeschlossen ist sodass das Segment |
- | - Which I/O protocol uses graphic | + | - Was ist der Unterschied zwischen alphabetischen |
- | - How can the numbers | + | - Über welche Pins und wie wird die Hintergrundbeleuchtung der alphanumerischen LCDs reguliert? |
- | - Draw the consisting layers of LCD using //twisted nematic// | + | - Welches |
- | - How are the letters formed on a graphical | + | - Wie können Dezimalzahlen |
- | - How is monochrome | + | - Zeichnen Sie die Schichten aus denen ein LCD besteht mittels der //twisted nematic// |
- | ===== Sensors | + | - Wie werden Buchstaben auf dem graphischen |
+ | - Wie unterscheidet sich ein monochromes | ||
+ | ===== Sensoren | ||
{{ : | {{ : | ||
- | Sensors are devices converting any kind of physical attributes | + | Sensoren sind Geräte welche jede Form von physikalischen Attributen |
+ | |||
+ | 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 wird. Dafür werden Analog-zu-Digital Konverter benutzt, welche normalerweise im Mikrocontroller verbaut sind. | ||
- | In analogue sensor any change in physical attributes changes one of its electrical values, usually voltage, current or resistance. Since microcontrollers are digital devices, the signal have to be converted from analogue to digital before delivering it to controller. For this purpose analogue-digital converters are used witch usually are built-in to the microcontroller. | + | Analoge Sensoren welche die Information digitalisieren, werden digitale Sensoren genannt. Digitale Sensoren können darüber hinaus Information standardisieren, Sensoren 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 Schnittstelle. Die folgenden Übungen führen aber nur einfachere und in der Robotik genutzte Sensoren ein. |
- | Analogue sensor which already includes digitizer of information, | + | ==== Potentiometer ==== |
- | ==== Potentsiometer ==== | + | // |
- | //Necessary knowledge : [HW] [[en: | + | === Theorie === |
- | === Theory === | + | [{{ : |
- | [{{ : | + | 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, |
- | 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. | ||
- | [{{ : | + | [{{ : |
- | A typical potentiometer consists of a resistor with conducting surfaces and of a sliding contact called | + | 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 ist, desto geringer ist der Widerstand zwischen Slider und Ecke des Widerstands und umgekehrt. Ein Material mit hohem Widerstand oder einer Spule aus Widerstandsdraht kann als Widerstand fungieren. Bei einigen Potentiometern sind die Beziehungen zwischen Widerstand und Sliderposition |
- | === Practice | + | === Übung |
- | On the module of the HomeLab | + | Am HomeLab |
~~CL~~ | ~~CL~~ | ||
Line 3832: | Line 3315: | ||
} | } | ||
</ | </ | ||
- | The function // | ||
- | In previously explained example program analogue-digital converter and 7 segment number indicator library are used. The 10 bit value of analogue-digital converter is multiplied by 10 and divided by 1024 to get the value between 0 and 9. The value 10 is impossible to reach because while dividing in C-language only integer value is calculated and not rounded result. Function of averaging the result of converter is used to get more accurate result. Derived from this the operating program shows the numbers 0 to 9, which correspond to the position of the potentiometer on the indicator. | + | Die Funktion // |
+ | 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 < | #include < | ||
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 | + | // Anpassung der 7-Segmentanzeige |
segment_display_init(); | segment_display_init(); | ||
- | // Adjusting | + | // Anpassung des ADC |
adc_init(ADC_REF_AVCC, | adc_init(ADC_REF_AVCC, | ||
- | // 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, | value = adc_get_average_value(ADC_CHANNEL, | ||
- | // 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: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | A thermistor is a type of resistor which resistance varies with temperature. There are two types of thermistors: | + | Ein Thermistor ist temperaturabhängiger Widerstand. Es gibt Thermistoren mit positiven und mit negativen Temperaturkoeffizienten. Der Widerstand von Thermistoren mit positiven Koeffizienten nimmt mit steigender Temperatur zu, bei Thermistoren mit negativen Koeffizienten steigt er mit sinkender Temperatur. Die dazugehörigen Abkürzungen sind PTC(// |
- | + | ||
- | The thermistors resistances' | + | |
+ | 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: | ||
{{: | {{: | ||
- | where:\\ | + | mit:\\ |
- | * T< | + | * T< |
- | * R< | + | * R< |
- | * B | + | * B |
- | Parameter B is a coefficient, which is usually given in the datasheet of the thermistor. But it is stable enough constant only in a certain ranges of temperature, for example at ranges | + | Der Parameter B ist ein Koeffizient, welcher normalerweise im Datenblatt des Thermistors vorgegeben ist. Aber er ist nur in bestimmten Temperaturbereichen ausreichend konstant, z.B. in Bereichen zwischen |
- | + | Normalerweise wird ein Spannungsteiler genutzt, um den Widerstand eines Thermistors zu messen. Dabei wird ein Widerstand durch einen Thermistor ausgetauscht wird und die Inputspannung ist konstant. Es wird die Outputspannung des Spannungsteilers gemessen, welche sich in Abhängigkeit der Widerstandsänderung des Thermistors verändert. Wenn Spannung anliegt, fließt Strom durch den Thermistor, wodurch sich dieser bedingt durch den Thermistorwiderstand aufheizt und damit den Widerstand verändert. Der durch das Aufheizen entstehende Fehler kann berechnet werden, jedoch ist es einfacher einen Thermistor zu nutzen, welcher einen hohen Widerstand hat und sich nicht so viel aufheizt. | |
- | Usually a voltage-divider is used for measuring the resistance of a thermistor, where one resistor is replaced with a thermistor and the input voltage is constant. The output voltage of the voltage-divider is measured, which changes according to the change of the resistance of the thermistor. If the voltage is applied, current goes through the thermistor which heats up the thermistor due to thermistors resistance and therefore alters again the resistance. The fault caused by heating up of the thermistor can be compensated with calculations, but it is easier to use a thermistor that has higher resistance and therefore heats up less. | + | |
- | With restricted resources and with less demands on accuracy, previously calculated charts and tables for temperatures are used. Generally the tables have ranges of temperatures and respective values of resistance, voltage or analogue-digital converters. All 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 Genauigkeit, werden zuvor errechnete Diagramme und Tabellen für die Temperaturen genutzt. Normalerweise enthalten die Tabellen Temperaturbereiche und die entsprechenden Werte für Widerstand, Spannung und ADC. Alle 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 |
- | + | Ein Pin des Thermistors ist an die +5 V Betriebsspannung angeschlossen der andere an Kanal 2 (Pin PF2). Ein typischer | |
- | The Sensor module of the HomeLab | + | |
- | + | ||
- | 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. // | + | |
+ | 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, | ||
<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 | + | // 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 |
// | // | ||
const signed short min_temp = -20; | const signed short min_temp = -20; | ||
Line 3939: | Line 3420: | ||
</ | </ | ||
- | 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 | + | // 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 |
- | // value, then the temperature is at least as high as the temperature | + | // Wert, ist 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 0 but values of the elements from -20, | + | // Da die Tabelle mit 0 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; | ||
} | } | ||
</ | </ | ||
- | 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 | + | Der Algorithmus sucht den Bereich aus der Tabelle |
+ | |||
+ | Umrechnungstabelle und Funktion sind schon in der HomeLab | ||
<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 < | #include < | ||
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(" | lcd_alpha_write_string(" | ||
- | // Setting the ADC | + | // Einrichten des ADC |
adc_init(ADC_REF_AVCC, | adc_init(ADC_REF_AVCC, | ||
- | // Endless loop | + | // Endlosschleife |
while (true) | while (true) | ||
{ | { | ||
- | // Reading the 4 times rounded values of the voltage of the thermistor | + | // Auslesen der 4-fach gerundeten Spannungswerte aus dem Thermistor |
value = adc_get_average_value(2, | value = adc_get_average_value(2, | ||
- | // 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 | + | // Konvertieren der Temperatur |
// To display the degree sign, the octal variable is 337. | // To display the degree sign, the octal variable is 337. | ||
sprintf(text, | sprintf(text, | ||
- | // 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, | lcd_alpha_goto_xy(0, | ||
lcd_alpha_write_string(text); | lcd_alpha_write_string(text); | ||
Line 4025: | Line 3507: | ||
=== Extra === | === Extra === | ||
- | * {{: | + | * {{: |
- | ==== Photoresistor | + | ==== Fotowiderstand |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | [{{ : | + | [{{ : |
- | A photoresistor is a sensor which electrical resistance is altered depending on the light intensity falling on it. The more intense is the light the more free carriers are formed and therefore the lower gets the resistance of the element. Two exterior metal contacts of the photoresistor are reaching through the ceramic base material to the light sensitive membrane, which determines the electrical resistance properties with its geometry and material properties. Since photo sensitive material itself has high resistance, with narrow, curvy track between the electrodes, low total resistance at average light intensity is gained. Similarly to the human eye, the 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 application. Following 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ändert. Je intensiver das Licht ist, desto mehr freie Ladungsträger werden gebildet, und umso geringer wird dadurch der Widerstand des Bauteils. Durch das keramische Basismaterial führen zwei externe Metallkontakte des Widerstands zur lichtempfindlichen Membran, dessen Widerstand abhängig von der Geometrie und den Materialeigenschaften ist. Da lichtempfindliches Material durch die schmale, kurvige Spur zwischen den Elektroden bereits einen hohen Widerstand hat, kann der niedrigste totale Widerstand schon bei durchschnittlichen Lichtintensitäten erreicht werden. Der Fotowiderstand reagiert ähnlich dem menschlichen Auge nur auf bestimmte Wellenlängen, was bei der Auswahl eines solchen Bauteils bedacht werden muss. Andernfalls kann es vorkommen, dass der Widerstand nicht auf die in der Anwendung genutzte Lichtquelle reagiert. Nachfolgend ist eine Tabelle abgebildet, welche vereinfacht die Wellenlängen des sichtbaren Lichts mit den entsprechenden Farben darstellt: |
- | ^ Colour | + | ^ Farbe |
- | | Purple | + | | Violett |
- | | Blue | 450 – 500 | | + | | Blau | 450 – 500 | |
- | | Green | + | | Grün | 500 – 570 | |
- | | Yellow | + | | Gelb | 570 – 590 | |
| Orange | | Orange | ||
- | | Red | 610 – 700 | | + | | Rot | 610 – 700 | |
- | A range of working temperature is set for photoresistor. Wishing the sensor to work at different temperatures, precising conversions must be executed, because the resisting properties of the sensors are depending on the temperature of the ambient. | + | Der Fotowiderstand arbeitet innerhalb eines bestimmten, festgelegten Temperaturbereichs. Soll der Sensor bei anderen Temperaturen genutzt werden, müssen präzise Umrechnungen durchgeführt werden, da die Widerstandseigenschaften des Sensors abhängig von der Umgebungstemperatur sind. |
- | For characterizing light intensiveness physical concept called light intensity | + | Zur Kennzeichnung der Lichtintensität wird die Beleuchtungsstärke |
+ | Vergleichswerte von Beleuchtungsstärken: | ||
- | Values of light intensity for comparison: | + | ^ Umgebung ^ Beleuchtungsstärke |
- | + | | Vollmond | 0,1 | | |
- | ^ Environment ^ Intensity of light (lx) ^ | + | | Abenddämmerung |
- | | Full moon | 0,1 | | + | |
- | | Dusk | + | |
| Auditorium | | Auditorium | ||
- | | Class room | 30 | | + | | Klassenraum | 30 | |
- | | Sunset or sunrise | + | | Sonnenaufgang / -untergang| 400 | |
- | | Operating room (hospital) | 500 - 1000 | | + | | OP-Saal |
- | | 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 lux. For doing this, exists | + | Das Sensormodul aus dem HomeLab verfügt über einen VT935G Fotowiderstand. Ein Pin des Widerstands ist an der +5 V Stromversorgung angeschlossen, der zweite |
+ | 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. | ||
- | [{{ : | + | 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 // |
+ | |||
+ | |||
+ | [{{ : | ||
+ | |||
+ | 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, | ||
- | 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 sensor. We have also data on one of the points on that line: | + | Die Relation wird durch den Anstieg des Y-Faktors |
log(E< | log(E< | ||
E< | E< | ||
- | This gives the formula for calculating the intensity of light when the resistance is known. The resistance can not be measured directly with microcontroller. For 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 | + | So erhält man die Formel zur Berechnung der Beleuchtungsstärke bei gegebenem Widerstand. Da der Widerstand nicht direkt von Microcontroller gemessen werden kann befindet sich der Fotowiderstand im Spannungsteiler. Die Output-Spannung des Spannungsteilers wird durch den ADC zu einer spezifischen Variable konvertiert. Zur Bestimmung des Widerstands muss diese Output-Spannung |
- | The formula is following: | + | |
U< | U< | ||
- | From the formula for voltage divider(check the chapter on voltage divider) the resistance of the upper photoresistor | + | Mit Hilfe der Formel für Spannungsteiler |
R< | R< | ||
- | In the following calculation of voltage and resistance, the known factors are replaced with numbers and indexes have been removed: | + | In der folgenden Berechnung von Spannung und Widerstand, werden 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< | E = 10< | ||
Line 4101: | Line 3583: | ||
= (18.5< | = (18.5< | ||
- | + | Durch die Berechnung der Konstante vor der Variable des Feldes | |
- | By calculating the constant in front of the variable of the field R, the expression remains follows: | + | |
E = 255,84 * R< | E = 255,84 * R< | ||
- | These formulas help only if the photoresistor on the module of sensors of the HomeLab | + | Die dargestellten Formeln sind jedoch nur im Zusammenhang mit Fotowiderständen des HomeLab |
- | + | Nachfolgend ist der Quellcode eines Beispielprogramms dargestellt, welches die Beleuchtungstärke mit Hilfe des ADC misst und berechnet und auf dem LCD darstellt. Bevor das Programm kompiliert wird, müssen die Einstellungen für die Gleitkomma-Variablen im Projekt festgelegt werden. Dieser 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, | ||
<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 < | #include < | ||
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_alpha_init(LCD_ALPHA_DISP_ON); | lcd_alpha_init(LCD_ALPHA_DISP_ON); | ||
- | // Clearing the LCD. | + | // Lösche |
lcd_alpha_clear(); | lcd_alpha_clear(); | ||
- | // Name of the program | + | // Name des Programms |
lcd_alpha_write_string(" | lcd_alpha_write_string(" | ||
- | // Setting the ADC | + | // Einrichten des ADC |
adc_init(ADC_REF_AVCC, | adc_init(ADC_REF_AVCC, | ||
- | // 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, | adc_value = adc_get_average_value(1, | ||
- | // 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 |
illuminance = 255.84 * pow(resistance, | illuminance = 255.84 * pow(resistance, | ||
- | // Converting the intensity of light to text | + | // Beleuchtungsstärke in Text konvertieren |
sprintf(text, | sprintf(text, | ||
- | // Displaying it on the LCD | + | // Darstellung auf dem LCD |
lcd_alpha_goto_xy(0, | lcd_alpha_goto_xy(0, | ||
lcd_alpha_write_string(text); | lcd_alpha_write_string(text); | ||
- | // Delay 500 ms | + | // Verzögerung |
sw_delay_ms(500); | sw_delay_ms(500); | ||
} | } | ||
Line 4171: | Line 3652: | ||
</ | </ | ||
- | ==== Infrared distance sensor | + | ==== Infrarot-Entfernungsmesser |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
[{{ : | [{{ : | ||
- | For measuring the distance to an object there are optical sensors using triangulation measuring method. Company “Sharp” produces most common infra-red (IR) wavelength using distance sensors which have analogue voltage output. The sensors made by “Sharp” have IR LED equipped with lens, which emits narrow light beam. After reflecting from the object, the beam will be directed through the second lens on a position-sensible photo detector | + | Um die Distanz zu einem Objekt zu messen, gibt es optische Sensoren, welche die Triangulation als Messmethode nutzen. Die am häufigsten verwendeten Infrarot-Entfernungsmesser werden von der Firma "Sharp" produziert und verfügen über einen analogen Spannungs-Output. Diese Sensoren besitzen eine Infrarot-LED mit einer Linse, welchen einen schmalen Lichtstrahl aussendet. Dieser wird von dem Objekt, zu welchem die Distanz gemessen werden soll, reflektiert und dann durch die zweite Linse zu einem optischen Positionssensor |
- | [{{ : | + | [{{ : |
- | [{{ : | + | [{{ : |
- | The output of distance sensors by " | + | Der Output der Infrarot-Entfernungsmesser von " |
+ | Jeder Sensor-Typ hat seinen spezifischen Messbereich, | ||
+ | Die minimale Entfernung wird durch die Besonderheit der Sharp Sensoren eingeschränkt. So fällt der Output steil ab, sobald die Entfernung einen bestimmten Punkt unterschreitet | ||
+ | Dieses Problem kann vermieden werden, indem beachtet wird, dass die Distanz zwischen Objekt und Sensor nicht zu gering ist. | ||
- | === Practice | + | === Übung |
- | The HomeLab | + | Das HomeLab |
+ | Der Messbereich dieses Sensors liegt zwischen | ||
- | On the datasheet of the GP2Y0A21YK | + | Das Datenblatt des GP2Y0A21YK |
+ | Nachfolgend ist der Graph des GP2Y0A21YK mit der Relation der korrigierten inversen Werte der Outputspannung zu den korrigierten inversen Werten der gemessenen Distanz, inklusive einer Trendlinie abgebildet. Zur Vereinfachung wurde die Output-Spannung schon in 10-Bit +5 V Werte des ADC mit Vergleichspannung konvertiert. | ||
- | [{{ : | + | [{{ : |
- | As seen on the graph, the trend-line (blue) overlaps quite precisely with the points of the graph. Such overlapping is achieved by using the help of the corrective constant. This corrective constant is discovered by using the trial-and-error | + | Wie der Graph zeigt, überschneiden sich die blaue Trendlinie und die Punkte des Graphen fast genau. Dieses wird durch die Nutzung einer Korrektur-Konstante erreicht. Diese 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 |
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 | + | Die Entfernung |
d = (1 / (a * ADC + B)) - k | d = (1 / (a * ADC + B)) - k | ||
- | Now it is basically possible to calculate the distance by using this formula, but this requires floating-point calculations, | + | Nun ist es generell möglich die Entfernung mit der Formel zu berechnen. Da jedoch Brüche dividiert werden, sind zudem Gleitkomma-Berechnungen nötig. Weiterhin muss die Formel vereinfacht und auf größere Quotienten ausgeweitet werden, da Microcontroller mit Ganzzahlen arbeiten. Durch 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 equation, the formula for calculating the distance will be: | + | Durch Aufnahme der Korrekturkonstante sowie des linearen und freien Elements der Trendlinien-Gleichung, ergibt 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 calculating, must be ensured that the value of the ADC is over 17, otherwise dividing with 0 or negative | + | Diese Formel kann mit 16-Bit Zahlen berechnet werden und ist daher vollständig für den AVR geeignet. Vor der Berechnung muss sicher gestellt sein, dass der Wert des ADC größer als 17 ist, ansonsten kann der Fall eintreten, dass durch 0 geteilt werden muss oder eine negative |
- | Following is the function for converting the values of ADC to centimeters, it is written | + | Nachfolgend ist die Funktion dargestellt, die dazu dient, ADC-Werte |
<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 | + | // Die Parametereigenschaften des GP2Y0A21YK |
// | // | ||
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 | + | // Gibt -1 aus, wenn 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: | ||
</ | </ | ||
- | To make the conversion the function | + | Zur Durchführung der Konvertierung muss die Funktion |
<code c> | <code c> | ||
// | // | ||
- | // The example program of the IR distance sensor of the HomeLab | + | // Beispielprogramm des Infrarot-Entfernungsmessers des HomeLab |
- | // Measured results | + | // Die in Centimetern gemessenen Ergebnisse werden auf dem LCD abgebildet |
// | // | ||
#include < | #include < | ||
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(" | lcd_alpha_write_string(" | ||
- | // Setup of the ADC | + | // Installation des ADC |
adc_init(ADC_REF_AVCC, | adc_init(ADC_REF_AVCC, | ||
- | // 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, | value = adc_get_average_value(0, | ||
- | // Conversing | + | // Konvertieren des ADC-Wertes in Entfernung |
distance = ir_distance_calculate_cm(GP2Y0A21YK, | distance = ir_distance_calculate_cm(GP2Y0A21YK, | ||
- | // 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, | sprintf(text, | ||
} | } | ||
else | else | ||
{ | { | ||
- | // Creating the text for unknown distance | + | // Text für eine unbekannte Entfernung erzeugen |
sprintf(text, | sprintf(text, | ||
} | } | ||
- | // 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, | lcd_alpha_goto_xy(0, | ||
lcd_alpha_write_string(text); | lcd_alpha_write_string(text); | ||
Line 4324: | Line 3814: | ||
</ | </ | ||
- | === Extra materials | + | === Zusätzliches Material |
- | * {{: | + | * {{: |
- | * [[http:// | + | * [[http:// |
- | ==== Ultrasonic distance sensor | + | ==== Ultraschall-Entfernungsmesser |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | Ultrasonic distance sensor determines the distance to an object by measuring the time taken by the sound to reflect back from that object. The frequency of the sound is somewhere in the range of ultrasound, this ensures more concentrated direction of the sound wave because sound at higher frequency dissipates less in the environment. A typical ultrasonic distance sensor consists of two membranes. One membrane produces sound, another catches reflected echo. Basically they are speaker and microphone. The sound generator generates short (the length is a couple of periods) ultrasonic impulses and triggers the timer. Second 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 sound. The 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ötigt. Die Frequenz des Geräusches liegt im Bereich des Ultraschalls. Dies garantiert, dass die Schallwelle gebündelt gelenkt wird, da sich hochfrequenter Schall weniger |
- | [{{ : | + | [{{ : |
- | The ultrasonic sensors have quite a lot of use in everyday life. They are used to replace measuring tapes in measuring devices at construction sites. Cars are equipped with ultrasonic parking sensors. Besides measuring distances, they can just register the presence of the object in the measuring range, for example | + | Der Ultraschall-Entfernungsmesser findet im täglichen Leben eine Vielzahl von Anwendungsmöglichkeiten. Er wird beispielsweise als Ersatz für Maßbänder auf Baustellen eingesetzt, Autos besitzen Ultraschall-Entfernungsmesser als Parksensoren. Neben der Entfernungsmessung dient er auch dazu, das bloße Vorhandensein eines Objekts im Messbereich zu erkennen, z. B. in der Gefahrenzone einer Arbeitsmaschine. Sind Ultraschalltransmitter und -empfänger getrennt, kann die Fließgeschwindigkeit des Materials zwischen ihnen bestimmt werden, da Schallwellen langsamer aufwärts fließen. |
- | === Practice | + | === Übung |
- | HomeLab | + | Das HomeLab |
+ | Ist der Trigger-Pin "high", generiert der Sensor eine acht Perioden lange 40 kHz Ultraschallwelle. Daraufhin wird der Echo-Pin "high" und bleibt "high", bis das Echo zurück kommt. Das Echo-Signal gibt also generell die Zeit an, die der Schall benötigt um das Objekt zu erreichen und zum Sensor zurück zu kommen. Die Entfernung zum Objekt ergibt sich daraus, dass die gemessene Zeit mit der Schallgeschwindigkeit multipliziert und dann durch zwei dividiert wird. Der folgende Graph zeigt den Zusammenhang zwischen Zeit und den Signalen des Empfängers, Triggers und des Echos: | ||
- | [{{ : | + | [{{ : |
- | To use the SRF04/ | + | Um den SRF04/ |
+ | Außerdem sollte darauf geachtet werden, dass 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 3 to normal mode | + | // Timer 3 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 | + | // Entfernung |
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: | ||
</ | </ | ||
- | Presented function allows the user to choose the echo pin and the trigger pin, so the sensor can be connected where it is more suitable or where is more space. In addition, the freedom of choosing the pins allows to use the function also elsewhere than only in the HomeLab. | + | Die gegebene Funktion erlaubt dem Nutzer den Echo-und den Trigger-Pin so zu wählen, dass der Sensor dort angeschlossen werden kann wo es am günstigesten ist und genug Platz vorhanden ist. Zusätzlich erlaubt dies, die Funktion auch außerhalb von HomeLab |
<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 < | #include < | ||
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(" | lcd_alpha_write_string(" | ||
- | // Little break | + | // Kleine Unterbrechung |
sw_delay_ms(100); | sw_delay_ms(100); | ||
- | | + | |
while (true) | while (true) | ||
{ | { | ||
- | // Measuring | + | // Messen |
distance = ultrasonic_measure(pin_trigger, | distance = ultrasonic_measure(pin_trigger, | ||
- | // 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, | sprintf(text, | ||
} | } | ||
- | // Were there errors during the measuring | + | // Sind während der Messung Fehler aufgetreten? |
else | else | ||
{ | { | ||
- | // Text of the errer. | + | // Text des Fehlers. |
sprintf(text, | sprintf(text, | ||
} | } | ||
- | // 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, | lcd_alpha_goto_xy(0, | ||
lcd_alpha_write_string(text); | lcd_alpha_write_string(text); | ||
- | // Little break. | + | // Kleine Unterbrechung. |
sw_delay_ms(500); | sw_delay_ms(500); | ||
} | } | ||
} | } | ||
</ | </ | ||
- | ==== Exercises | + | --- |
+ | | ||
+ | ==== Ü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 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 | + | === 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 |
+ | - 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 | ||
+ | - 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 === | + | < |
- | - How accurate is the digital-analogue converter of ATmega128 | + | === Fragen === |
- | - How long takes one ADC process? How is the operating frequency changed? | + | |
- | - Which is the the range of input voltage of the ADC? Is it possible to be changed? How? | + | |
- | - 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-Prozess? Wie kann die Arbeitsfrequenz geändert werden? |
- | - What is the purpose of a voltage divider | + | - Welchen Inputspannungsbereich hat der ADC? Kann dieser geändert werden? Wie? |
- | - Combine a voltage divider, which allows to use an analogue sensor with ATmega128 | + | - Was ist der Unterschied zwischen |
- | - Extra resistors were added to the potentiometer pins and voltage of 5 V were applied on them. How 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 | + | - Was ist der Grund eines Spannungsteilers |
- | - Which parameters of the surroundings have an effect on the functioning of ultrasonic distance sensor and why? | + | - Kombinieren Sie einen Spannungsteiler, welcher die Nutzung eines analogen Sensors mit dem ATmega128 |
- | - 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 angelegt. Wie groß müssen die zusätzlichen Widerstände sein, damit die Spannung vom Potentiometer zwischen |
- | - Besides trigonometrical method, how is distance determined by using light? Name at least 3 methods. | + | - Welche Umgebungsparameter haben einen Effekt auf die Funktion des Ultraschallentfernungsmessers und warum? |
- | ===== Motors | + | - Welche Lichtsensivitätssensoren können |
+ | - Wie kann, neben der trigonometrischen Methode, die Entfernung mittels Licht gemessen werden? Nennen Sie mindestens drei Methoden. | ||
+ | ===== Motoren | ||
{{ : | {{ : | ||
- | Motors are actuator devices, actually some of them are and those can also be very different, beginning with operating principles and ending with power and size. In robotics mainly electric motors are used. Electrical motor is a device which converts electrical energy to mechanical energy | + | Motoren sind Antriebsgeräte, sie können in jeder Form sehr verschieden sein, vom Arbeitsprinzip bis hin zu Kraft und Größe. In der Robotik werden hauptsächlich Elektromotoren benutzt. Diese wandeln elektrische Energie in mechanische Energie |
- | + | ||
- | There are several ways to classify electrical motors. Most important is to divide them as alternate current (AC) and direct current | + | Es gibt viele Möglichkeiten, |
- | ==== DC motor ==== | + | ==== Gleichstrommotor |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | Permanent magnet DC motors are very common in different applications, where small dimensions, high power and low price are essential. Due to their fairly high speed, they are used together with transmission | + | Ein Gleichstrommotor mit permanenten Magneten wird häufig für die verschiedensten Anwendungen genutzt, bei denen kleine Ausmaße, große Kraft und ein geringer Preis entscheidend sind. Auf Grund ihrer hohen Geschwindigkeit, werden sie oft mit einer Übersetzung genutzt. |
- | [{{ : | ||
- | Permanent magnet DC motors have quite simple construction and their controlling is quite elementary. Although controlling is easy, their speed is not precisely determined by the control signal because it depends on several factors, primarily of the torque applied on the shaft and feeding current. The relationship between torque and speed of a ideal DC motor is linear, which 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. | + | [{{ : |
- | Brushed DC motors are using DC voltage and basically do not need special control electronics because all necessary communication is done inside the motor. When the motor is operating, two 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 direction, then the current may come through relay or some other simple connection. If the motor has to revolve | + | Gleichstrommotoren mit permanenten Magneten sind vom Aufbau her sehr einfache und ihre Bedienung ist relativ einfach. Aber auch wenn die Kontrolle sehr einfach ist, wird die Geschwindigkeit nicht präzise über das Steuersignal bestimmt, weil hierauf noch viele andere Faktoren, wie das Drehmoment und der Speisestrom, |
- | + | ||
- | [{{ : | + | |
- | In the H-bridge are four transistors (or four groups) directing the current for driving the motor. The electrical scheme of the H-bridge is similar to the letter H and that is where it gets its name. The peculiarity of the H-bridge is the possibility to apply both directional polarities to the motor. Picture on the side shows the principal scheme of the H-bridge based on the example of the switches. If two diagonal switches are closed, the engine starts operating. The direction of the revolving of the motor depends on in which diagonal the switches are closed. In 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, |
+ | |||
+ | [{{ :examples:motor: | ||
- | In addition to changing direction of revolving the H-bridge allows to change the speed of revolving. To do that, the 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 power. Opened time in the whole PWM period is called duty cycle, which is marked as percents. 0% means the transistor is closed constantly – it is not conducting current. 100% 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 that, modulation 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-Bridge. Das Besondere am Vierquadrantensteller ist, dass man damit beide Polaritäten am Motor anlegen kann. Das Bild auf der Seite zeit das grundsätzliche Schema eines Vierquadrantenstellers am Beispiel der Schalter. Werden zwei diagonale Schalter geschlossen, arbeitet der Motor. Die Drehrichtung des Motors hängt davon ab welche diagonalen Schalter geschlossen werden. Im wirklichen Vierquadrantensteller sind die Schalter durch Transistoren ersetzt, welche je nach Stromstärke und Spannung des Motors gewählt werden. |
- | There exist also integrated H-bridges, for conducting smaller currents. For higher currents special power MOSFET-s are used. The H-bridge with other electronics is called motor controller or driver. The 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 | + | Zusätzlich zur Richtungsänderung kann der Vierquadrantensteller auch die Geschwindigkeit des Motors verändern. Dazu werden die Transistoren konstant durch Pulsweitenmodulation geöffnet und geschlossen. Damit ist die Energie, die der Motor erhält irgendwo zwischen vollem und keinem Stromdurchfluss. Die Zeit in der die Transitoren geöffnet sind, wird in der PWM-Periode Arbeitszyklus genannt, welche |
- | 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, | ||
+ | Beachte: Verwechslen Sie nicht RC PWM Signal und gewöhnliche PWM Signale. | ||
- | === Practice | + | === Übung |
- | The board of the motors of the HomeLab | + | Das Board der Motoren des HomeLab |
+ | Wenn beide Kontrollpins den gleichen Wert haben, wird der Motor gestoppt. Wenn verschiedene Werte vorliegen, wird der Motor in eine bestimmte Richtung gedreht. Der 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 |
- | | 1 | + | | 1 |
- | | 1 | + | | 1 |
- | | 0 | + | | 0 |
- | DC motors can be controlled by manipulating directly corresponding driver pins with microcontroller. Though, 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 werden. Die speziellen Funktionen um den Motor zu steuern sind in der HomeLab |
<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 | + | // Steuerung des gewählten |
// | // | ||
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 | + | // Festlegung der Funktion und Richtung des gewählten |
// | // | ||
void dcmotor_drive(unsigned char index, signed char direction) | void dcmotor_drive(unsigned char index, signed char direction) | ||
Line 4594: | Line 4090: | ||
</ | </ | ||
- | With the array // | + | Mit dem Array // |
- | The following is an example program which controls first and second DC motor so that they alter their revolving direction after every second. The speed could be controlled if one controlling pin were modulated with PWM signal | + | Das folgende Beispielprogramm steuert den ersten und zweiten Gleichstrommotor |
<code c> | <code c> | ||
// | // | ||
- | // Testing program of the DC motor of the motor' | + | // Testprogramm für den DC Motor aus dem DC Motorenmodul des HomeLab. |
// | // | ||
#include < | #include < | ||
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 1 and 2. | + | // Einrichtung von Motor 1 und 2. |
dcmotor_init(0); | dcmotor_init(0); | ||
dcmotor_init(1); | dcmotor_init(1); | ||
- | // Endless loop | + | // Endlosschleife |
while (true) | while (true) | ||
{ | { | ||
- | // One motor revolves | + | // Ein Motor dreht sich in die eine, der andere in die entgegengesetzte Richtung. |
dcmotor_drive(0, | dcmotor_drive(0, | ||
dcmotor_drive(1, | dcmotor_drive(1, | ||
- | // Break for 1 second. | + | // Unterbrechung für 1 Sekunde. |
sw_delay_ms(1000); | sw_delay_ms(1000); | ||
- | // Reversing the direction. | + | // Umkehr der Richtung. |
direction = -direction; | direction = -direction; | ||
} | } | ||
} | } | ||
</ | </ | ||
+ | --- | ||
+ | | ||
==== Servomotor ==== | ==== Servomotor ==== | ||
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | [{{ : | + | [{{ : |
- | Servo motors are often used in radio-controlled | + | Servomotoren werden oft in funkgesteuerten |
- | different kinds of small robotics applications because they are compact and inexpensive. | + | Ein RC-Servomotor verfügt über einen eingebauten Gleichstrommotor, ein Getriebe, einen Positionsfeedbacksensor |
- | An RC servo motor includes a built-in DC motor, gearbox, position feedback sensor | + | |
- | (usually potentiometer), and drive electronics. RC servo motors can be controlled by | + | |
- | an external pulse-width modulation (PWM) signal. If a signal meets RC servo timing | + | |
- | requirements, it usually “describes” a (target) position input for the servo drive | + | |
- | electronics. | + | |
- | position, trying to find a shaft position where they match. The position control signal | + | |
- | is a continuous square-wave signal, as depicted | + | |
- | RC (// | + | RC (// |
+ | Eine wichtige Eigenschaft des Servomotors ist das Kraft-Gewicht-Verhältnis. | ||
- | The controlling signal of servo motor is specific pulse with modulated signal | + | Das Kontrollsignal des Servomotors ist ein speziell pulsweitenmoduliertes Signal |
- | Traditional | + | Traditionelle |
~~CL~~ | ~~CL~~ | ||
- | === Practice | + | === Übung |
- | On the board of module of motors of the HomeLab | + | Auf dem Platine des HomeLab |
+ | Die PWM-Enden der Stecker sind an den Pins PB5 und PB6 am Mikrocontroller angeschlossen, dessen sekundäre Funktion das Vergleichen der Einheiten | ||
- | + | Timer 1 muss in den PWM-Produktionsmodus eingestellt werden, wobei der maximale Wert des Timers mit dem ICR Register bestimmt wird. Durch Änderung des maximales Wertes im Programm und im Taktgeber des Timers, kann die präzise | |
- | The timer 1 must be set up in PWM production mode, where the maximum value of the timer is determined with ICR register. With the maximum value changed in the program and in the pace divider of the timer, the precise | + | |
<code c> | <code c> | ||
// | // | ||
- | // The value of the timer (20 ms)for achieving the full period of PWM. | + | // Der WErt des Timers |
- | // F_CPU is the clock rate of the microcontroller which is divided with 50 Hz and 8. | + | // F_CPU ist die Taktrate des Mikrocontrollers, |
// | // | ||
// | // | ||
Line 4677: | Line 4169: | ||
// | // | ||
- | // Middle position of PWM servo (5 ms / 20 ms) | + | // Mittlere Position der PWM des Servomotors |
- | // Middle position is 15/ | + | // Mittlere Position liegt bei 15/ |
// | // | ||
#define PWM_MIDDLE_POS | #define PWM_MIDDLE_POS | ||
// | // | ||
- | // Factor for converting the percents | + | // 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, |
// | // | ||
#define PWM_RATIO | #define PWM_RATIO | ||
// | // | ||
- | // 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 | + | // Vorzähler |
- | // Fast PWM mode, where TOP = ICR | + | // Schneller |
- | // 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 |
// | // | ||
void servomotor_position(unsigned char index, signed short position) | void servomotor_position(unsigned char index, signed short position) | ||
Line 4740: | Line 4232: | ||
</ | </ | ||
- | The example program uses described functions of the library of the HomeLab. | + | Das Beispielprogramm nutzt beschriebene Funktionen der HomeLab |
<code c> | <code c> | ||
// | // | ||
- | // Testing program of the motors module of the HomeLab kit. | + | // Testprogramm des Motormoduls des HomeLab kit. |
// | // | ||
#include < | #include < | ||
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_init(ADC_REF_AVCC, | ||
- | // 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, | servomotor_position(0, | ||
} | } | ||
} | } | ||
</ | </ | ||
- | ==== Stepper motor ==== | + | ==== Schrittmotor |
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | 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 windings, which | + | Unipolare Schrittmotoren haben charakteristische Windungen welche die zwei Spulen in vier unterteilen. Schrittmotoren haben keine eingebauten Bürsten oder Elektronik, d.h. jegliche Kommunikation muss extern erfolgen. Der am meisten benutzte Kommutationstyp ist der offene-Regelkreis- ("open-loop") Modus: der Der Schrittmotortreiber lädt die Spulen nach einem bestimmten Muster, nutzt aber kein Feedback. Schritte können so verpasst werden falls die Motorwelle eine Drehmomentüberladung erfährt. Verpasste Schritte verursachen ungenaue Positionierung. Bipolare Schrittmotoren haben normalerweise vier Drähte und zwei separate |
- | divide two coils into four. Stepper motors have neither built-in brushes nor internal | + | |
- | electronics, | + | |
- | common commutation type is the open-loop | + | |
- | coils following a certain pattern, but uses no feedback. Steps can be missed in case of | + | |
- | motor shaft torque overload. Missed steps cause inaccurate positioning. Bipolar | + | |
- | stepper motors usually have four wires and two separate | + | |
- | features similar to those of unipolar steppers. Unipolar stepper motors can be run as | + | |
- | bipolar stepper motors, but not vice versa. | + | |
- | Stepper-motors are widely used in applications which demand accuracy. Unlike DC motors, stepper motors do not have brushes nor commutator – they have several independent coils, which are commutated with exterior electronics | + | Schrittmotoren werden oft in Applikationen genutzt, die Genauigkeit benötigen. Anders als Gleichstrommotoren haben Schrittmotoren weder Bürsten, noch Kommutatoren. Sie haben verschiedene unabhängige Spulen, welche durch externe Elektronik |
| | ||
- | * Variable Reluctance Stepper | + | * Reluktanzschrittmotor |
- | * Permanent Magnet Stepper | + | * Permanentmagnetschrittmotor |
- | * Hybrid Synchronous Stepper | + | * Hybrider Schrittmotor |
- | Variable reluctance stepper motors have toothed windings and toothed iron rotor. The largest pulling force is when the teeth of both sides are covering each other. In Permanent magnet stepper motor,just like the name hints, are permanent magnets which orientate according to the polarity of the windings. In hybrid synchronous steppers both technologies are used. | + | Der Reluktanzschrittmotor verfügt über gezahnte Windungen und einen gezahnten Weicheisenrotor. Die größte Zugkraft entsteht, wenn die Zähne beider Seiten sich gegenseitig abdecken. Der Permanentmagnetschrittmotor bestitz, wie der Name schon sagt, Permanentmagneten welche sich je nach Polarität der Windung orientieren. Der hybride Schrittmotor nutzt beide Techniken. |
- | Depending on the model of stepper motor, performing one full rotation | + | Je nach Modell des Schrittmotors, braucht eine vollständige Rotation |
- | ~~PB~~ | + | < |
- | **Unipolar stepper-motor | + | **Unipolare Schrittmotoren |
- | [{{ : | + | [{{ : |
- | Unipolar-stepper motor has 5 or 6 leads. According to the scheme of the motor only ¼ of the windings is activated. // | + | Unipolare Schrittmotoren haben fünf oder sechs Anschlüsse. Je nach Aufbau des Motors werden nur ¼ der Wicklungen aktiviert. // |
- | **Bipolar stepper-motor** | + | **Bipolare Schrittmotoren** |
- | [{{ : | + | [{{ : |
- | Bipolar stepper motor differs from unipolar stepper motor by having the polarity of the windings altered during the commutation. Half of the windings are activated together, this allows to gain higher efficiency than unipolar stepper motors. Bipolar stepper motors have four leads, each connected to a different half-bridge | + | Bipolare Schrittmotoren unterscheiden sich von unipolaren, da sie die Polarität ihrer Wicklungen während der Umwandlung verändern. Die Hälfte der Wicklungen wird gleichzeitig aktiviert, daher sind sie effizenter als unipolare Schrittmotoren. Bipolare Schrittmotoren haben 4 Anschlüsse, jeder wird an einen anderen Vierquadrantensteller 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, | ||
+ | |||
^ ^ | ^ ^ | ||
- | ^ Step ^ 1A ^ 2A ^ 1B ^ 2B ^ 1A ^ 2A ^ 1B ^ 2B ^ | + | ^ Schritt |
- | ^ 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 motor, which can be replaced by unipolar stepper motor using the above described method. There are drivers, on the board of motors, which must be controlled via four input pins by the microcontroller. Each 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 | + | Das Ziel dieser Aufgabe ist es, unter Anwendung der oben beschrieben Methode einen bipolaren Schrittmotor zu starten, welcher mit einem unipolaren Schrittmotor getauscht werden kann. Es gibt Treiber auf der Motorenplatine, welche vom Mikrocontroller über vier Inputpins kontrolliert werden. Jeder Pin gibt die Polarität einer Wicklung wieder. Die 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 // | + | |
+ | In der HomeLab Bibliothek gibt es die Funktion // | ||
<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; | + | |
- | 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 i; | + | |
- | unsigned char pattern, state1 = 0, state2 = 1; | + | unsigned char pattern, state1 = 0, state2 = 1; |
- | // Insuring the direction | + | |
- | dir = ((dir < 0) ? -1 : +1); | + | dir = ((dir < 0) ? -1 : +1); |
- | // Execution of half-steps. | + | |
- | 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. | + | |
- | pattern = (1 << ((state1 % 8) >> 1)) | | + | pattern = (1 << ((state1 % 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. | + | |
- | sw_delay_ms(speed); | + | sw_delay_ms(speed); |
- | } | + | } |
- | // Stopping the motor. | + | |
- | PORTB &= 0xF0; | + | PORTB &= 0xF0; |
} | } | ||
</ | </ | ||
- | Usage of the functions is demonstrated by the example program which rotates the motor alternately to one direction and then to the other direction | + | Die Funktion wird durch ein Beispielprogramm demonstriert, |
<code c> | <code c> | ||
// | // | ||
- | // The test program for the bipolar stepper motor of the motor' | + | // Das Testprogramm für den bipolaren Schrittmotor des Motormoduls |
- | //module of the HomeLab. | + | // des HomeLab. |
// | // | ||
#include < | #include < | ||
// | // | ||
- | // Main program. | + | // Hauptprogramm. |
// | // | ||
int main(void) | int main(void) | ||
{ | { | ||
- | // Set up of the motor. | + | |
- | 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 |
- | bipolar_halfstep(+1, | + | bipolar_halfstep(+1, |
- | // Turning | + | |
- | bipolar_halfstep(-1, | + | bipolar_halfstep(-1, |
- | } | + | } |
} | } | ||
</ | </ | ||
- | ==== Exercises | + | ==== Aufgaben |
- | The goal is to write a program which is able to perform tasks described below. | + | |
- | === Warm up exercise === | + | Ziel ist es, ein Programm zu schreiben, welches die folgenden Aufgaben erfüllen kann. |
- | * Controlling the DC motor using a digital board. By pressing S1 button, LED1 is lit and the motor turns clockwise. By pressing S3 button, LED3 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 |
- | - DC motor accelerates when S1 is pressed down and holds achieved speed when the button is released. By holding S2 pressed down, the motor decelerates smoothly. By pressing button | + | |
- | - Tracking an object. By using ultrasonic distance sensor, which is installed on the lever of the servo-motor, | + | |
- | - 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, | + | |
- | - 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' | + | |
- | - How is the direction of motor' | + | |
- | - 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 ===== | + | |
- | {{ | + | - Roboter: Durch 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, |
+ | - Servomotor: Der 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) | ||
+ | - Radar: Die Funktion eines Radars wird simuliert. Um ein Objekt, welches näher als 0.5 Meter ist, zu identifizieren, | ||
+ | - Schrittmotor: | ||
+ | - Alle drei Motorentypen werden angeschlossen. Durch Betätigung eines Schalters wird ein bestimmter Motor gestartet und angehalten. S1 steuert den Gleichstrommotor, | ||
- | 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 code, where the information is transmitted using peeps and pauses and varying their lengths. Digital data transmitting protocols are functioning similarly; | + | - Der Gleichstrommotor beschleunigt wenn S1 gedrückt wird und hält die momentane Geschwindigkeit, wenn der Schalter losgelassen wird. Wenn 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, | ||
+ | - der Schrittmotor hält die letzte Position des Motors nach Änderung jeder Sequenz. Wenn eine neue Sequenz aktiviert wird, nutzen Sie eine Variable, so dass die Bewegung exakt von der letzten Position des Motors fortgeführt wird. | ||
+ | - Beschleunigung: | ||
+ | - 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 ===== | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | 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 | ||
==== RS-232 ==== | ==== RS-232 ==== | ||
- | //Necessary knowledge: [HW] [[en: | + | //Notwendiges Wissen: [HW] [[en: |
- | === Theory | + | === Theorie |
- | [{{ : | + | [{{ : |
- | RS-232 | + | Die RS-232 |
- | The RS-232 | + | Die RS-232 |
- | UART means universal asynchronous receiver/ | + | Die Bezeichnung |
- | [{{ : | + | [{{ : |
- | Transmitting data is done by frames of the UART interface, in which is 5-9 data bits (depending on the configuration). Most common is 8 bits (1 bait). In addition to the data bits also extra bits are transmitted with the frame, which are used to recognize the moments of arrival and ending of the data on the receiver’s side. The first is called start-bit and it is always | + | Die Datenübertragung erfolgt über den Rahmen der UART-Schnittstelle, welcher je nach Konfiguration |
| | ||
- | In addition to the frame structure, there is one more important parameter – it is //baud rate//, with which the number of transmitted symbols | + | Zusätzlich zur Rahmenstruktur gibt es einen weiteren wichtigen Parameter - die //Baudrate//, wodurch die Anzahl der in einer Sekunde übertragenen Symbole festgelegt wird. Die Baudrate zeigt die Anzahl der Symbole an. Bei der Verwendung von UART entspricht |
- | Furthermore, it is worth to know that the RS-232 | + | Darüber hinaus ist es wichtig zu wissen, dass der RS-232 |
- | === Practice | + | === Praktisches Beispiel |
- | The Controller module board is equipped with one RS-232 | + | Die Platine des Controllermoduls ist mit einem RS-232 male-Stecker ausgerüstet. Darüber kann der Controller |
<code c> | <code c> | ||
// | // | ||
- | // Connecting the Controller module of the HomeLab | + | // Anschluss des Controllermoduls des HomeLab |
- | // 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 < | #include < | ||
Line 4992: | Line 4482: | ||
// | // | ||
- | // Determining | + | // 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 | + | // 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(" | lcd_alpha_write_string(" | ||
- | // Putting the cursor in the beginning of the second row. | + | // Cursor an den Beginn der zweiten Reihe setzen. |
lcd_alpha_goto_xy(0, | lcd_alpha_goto_xy(0, | ||
- | // Saying hello to the computer. | + | // " |
usart_send_string(port, | usart_send_string(port, | ||
- | // 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, | if (usart_try_read_char(port, | ||
{ | { | ||
- | // Are we dealing with the sign of changing the row? | + | // Befassen wir uns mit dem Zeichen zur Änderung der Reihe? |
- | if (c = ' | + | if (c == ' |
{ | { | ||
- | // | + | // |
row = 1 - row; | row = 1 - row; | ||
- | // | + | // |
lcd_alpha_clear_line(row); | lcd_alpha_clear_line(row); | ||
} | } | ||
else | else | ||
{ | { | ||
- | // | + | // |
lcd_alpha_write_char(c); | lcd_alpha_write_char(c); | ||
} | } | ||
Line 5048: | Line 4538: | ||
</ | </ | ||
- | [{{ : | + | [{{ : |
- | With Windows XP OS comes a program called | + | Windows XP OS beinhaltet das Programm |
- | ==== Exercises | + | ==== ZigBee |
- | The goal is to write a program which is able to perform tasks described below. | + | --- |
+ | | ||
+ | --- | ||
+ | | ||
+ | ==== 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), |
+ | " | ||
+ | - 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. ' | + | === 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.' |
+ | - Erstellen Sie ein " | ||
- | | + | ==== Fragen==== |
- | - What is the baud rate? | + | |
- | - What is the difference between full- and half duplexes. | + | |
- | - Find at least 5 different sensors which are using serial interface. | + | - Was ist die Baud-Rate? |
- | - What is the difference between | + | - Was ist der Unterschied zwischen Voll/Halb-Duplex? |
- | - How is the SPI interface working? | + | - Finden Sie mindestens |
- | - Name interfaces, which enable connecting at least 100 devices to a single bus. | + | - Nennen Sie den Unterschied zwischen |
- | - Name different topologies and explain their differences. | + | - Wie funktioniert die SPI Schnittstelle? |
- | - On what voltage level are RS-232 | + | - Nennen Sie Schnittstellen, die 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 bps, when there is 8 data-bits, 1 stop-bit and not parity control? | + | - Nennen Sie verschiedene Archtiekturen und erklären Sie ihre Unterschiede. |
- | ====== | + | - Auf welchem Spannungslevel finden |
+ | - Wie lange benötigt, es 1MiB bei einer Baud-Rate von 9600 dps , mit 8 Daten-Bits, einem Stop-Bit und ohne Paritätskontrolle, | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | --- | ||
+ | | ||
+ | ====== | ||
{{: | {{: | ||
- | Some instructions on how to prepare a project documentation, | + | Das Beispielprojekt |
- | ===== Report | + | ===== Bericht |
+ | |||
+ | Um ein einfaches mechatronisches Gerät herzustellen, | ||
+ | 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. | + | |
- | At the end of the project a report should be compiled. It is a documentation which should at least consist following content points: | + | * **Zusammenfassung** |
- | | + | * **Zusammenfassung |
- | * **Summary** | + | * **Inhaltsverzeichnis** |
- | * **Summary | + | - **Ursprüngliche Aufgabe** |
- | * **Table of contents** | + | - **Systemvoraussetzungen und Einschränkungen** |
- | - **Initial task** | + | - **Modell des Systems** \\ Struktur und Funktionalität eines Systems als Blockdiagramm. Zusätzlich können eine Anleitung zur Nutzung des Anwendungsfalldiagramms, ein Interfacediagramm |
- | - **System requirements and limitations** | + | - **Designlösungen** \\ Mindestens drei verschiedene Konzeptlösungen für diese Aufgabe. Geeignet sind handgezeichnete Diagramme, Zeichnungen |
- | - **The overall system model** \\ Structure and functionality of a system as block diagrams. In addition, instructions for use case diagram, interface diagram | + | - **Mechanik** \\ Am Besten ein 3D Modell mit Zeichnungen von wichtigen Verbindungen und Bauanweisungen. Falls eine Verbindung spezielle Anweisungen benötigt, dann auch Bauanleitungen und Zeichnungen hinzufügen. Wenn möglich eine Animation der Funktionen des Systems beifügen. |
- | - **Design solutions** \\ At least three different conceptual solutions of how to solve the task. Suitable are manually sketched diagrams, sketches | + | - **Elektronik** \\ Darstellung aller genutzten Module in einem Blockdiagramm |
- | - **Mechanics** \\ Preferably a 3D model with drawings of essential nodes and engineering instructions. If a node requires special instructions, then assembly drawings and instructions as well. If possible, add an animation on functioning of the system. | + | - **Control |
- | - **Electronics** \\ Give the overall block diagram, where all the used modules are showed | + | - **Gebrauchsfertige Lösung** \\ Beschreibung und Bilder |
- | - **Control | + | - **Wirtschaftliche Rechnung** \\ Auflistung von Komponenten wie Kosten, geschätzte, |
- | - **Ready-to-use solution** \\ Description and pictures | + | - **Projektmanagement** \\ Zeitplan des Projekts, die Ressourcenbelegung, die Arbeitsteilung |
- | - **Economic calculation** \\ The list of components with cost, time estimates | + | - **Zusammenfassung und Fazit** \\ Was war schwer, |
- | - **Project management** \\ The project schedule, resource allocation, division of labor, the crew's contribution, the minutes of meetings | + | * **Genutzte Quellen und Materialien** |
- | - **Summary and conclusions** \\ What was difficult, what would you do differently, | + | * **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. | + | Das folgende Beispielprojekt zeigt, wie 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 werden, er stellt aber immer noch die verschiedenen Aspekte einer Dokumentation dar. |
- | ===== Mobile | + | ===== Mobile |
- | Mobile robot is one of the most popular robot for construction. Very common are sumo robots, sports robots | + | Der mobile Roboter ist eine der populärsten Robotorkonstruktionen. Sehr verbreitet sind Sumoroboter, Sportroboter |
- | Here we look at the documentation of a typical | + | Nachfolgend werden eine Dokumentation eines typischen Projekts für eine mobile |
- | === Initial tasks === | + | === Ursprüngliche Aufgabe |
- | Plan and construct a multifunctional | + | Planen und konstruieren Sie eine multifunktionale |
* Manipulator | * Manipulator | ||
* Radar | * Radar | ||
- | * Camera | + | * Kamera |
- | Robot must be able to move on a flat surface | + | 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 | + | * maximales Gewicht: |
- | * Speed max. 0,2 m/s | + | * Höchstgeschwindigkeit: |
- | * Full autonomy | + | * volle Selbstständigkeit |
- | == Restrictions | + | == Einschränkung |
- | * Must be constructed mainly from HomeLab | + | * Muss überwiegend aus HomeLab |
- | * Cannot exceed the cost limit 10 000 EEK | + | * Kostengrenze: |
- | ~~PB~~ | + | < |
- | === The overall model of the system | + | === Grundlegendes Modell des Systems |
- | The overall model of the system is presented as a block diagram. It describes the structure, behaviour and other important aspects of the system. As an example, an hierarchical model of the overall system is depicted below. | + | Das grundlegende Modell des System wird mit einem Blockdiagramm dargestellt. Es beschreibt die Struktur, das Verhalten und andere wichtige Aspekte des Systems. Als Beispiel ist nachfolgend das hierarchische Modell des System abgebildet. |
- | [{{ : | + | [{{ : |
- | === Design solutions | + | === Designlösungen |
- | For this task the team used a brainstorming method and generated 3 conceptually different solutions. Evaluation matrix was compiled and the most optimum construction was found. The 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 erstellt. Es wurde eine Evaluationsmatrix erstellt und so die optimale Konstruktion gefunden. Der größte Unterschied der drei Lösungen liegt im Bewegungsschema. |
- | [{{ : | + | [{{ : |
- | ~~PB~~ | + | < |
- | 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 |
- | |Permeability/ | + | |Permittivität |
- | |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 | + | Die Evaluationsskala umfasst Werte von 1 bis 10 und der Gewichtungsfaktor liegt zwischen |
- | Based on the assessment the optimum solution for given task was proved to be a platform moving on two wheels with two separate motors. Further 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 Motoren. Die weitere Arbeit besteht in der Entwicklung der gewählten Lösung in ein reales System. |
+ | < | ||
- | ~~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**, | + | [{{ : |
- | [{{ : | + | Die Stoßstangen des Roboters werden separat geplant und sind mit Berührungs- und Linienfolgesensoren ausgestattet. Die 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, |
- | 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. | + | [{{ : |
- | [{{ : | + | === 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. | + | [{{ : |
- | [{{ : | + | < |
- | ~~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. | + | [{{ : |
- | [{{ : | + | [{{ : |
- | [{{ : | + | < |
- | ~~PB~~ | + | === Kontrollsystem === |
- | === Control system === | + | Das Kontrollsystem des Roboters, leitet sich von einem Verhaltensmodell ab und ist an Funktionalität, |
+ | 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, | + | == 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, | ||
- | 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 algorithm: a 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^ | + | [{{ : |
- | |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| | | | | + | |
- | [{{ : | + | == Quellcode |
- | == Source code == | + | Einfache Navigation |
- | + | ||
- | Simple navigation | + | |
<code c> | <code c> | ||
#include < | #include < | ||
Line 5223: | Line 4734: | ||
#include < | #include < | ||
- | // Defining bumper pins | + | // Definieren der Stoßstangenpins |
pin front = PIN(C, 0); | pin front = PIN(C, 0); | ||
pin frontleft | pin frontleft | ||
Line 5229: | Line 4740: | ||
// | // | ||
- | // Mainprogram | + | // Hauptprogramm |
// | // | ||
int main(void) | int main(void) | ||
{ | { | ||
- | // Initiating motors | + | // Starten von Motor 0 und 1 |
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, | dcmotor_drive(0, | ||
dcmotor_drive(1, | dcmotor_drive(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, | dcmotor_drive(0, | ||
dcmotor_drive(1, | dcmotor_drive(1, | ||
- | // Paus 1 second | + | // Pause 1 Sekunde |
sw_delay_ms(1000); | sw_delay_ms(1000); | ||
- | // Left motor clockwise startup | + | // Start des linken Motors im Uhrzeigersinn |
dcmotor_drive(0, | dcmotor_drive(0, | ||
- | // Paus 2 seconds | + | // Pause 2 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, | dcmotor_drive(1, | ||
- | // Paus 2 seconds | + | // Pause 2 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, | dcmotor_drive(0, | ||
- | // Paus 2 seconds | + | // Pause 2 Sekunden |
sw_delay_ms(2000); | sw_delay_ms(2000); | ||
} | } | ||
Line 5289: | Line 4800: | ||
</ | </ | ||
- | ~~PB~~ | + | < |
- | === Ready-to-use solution | + | === Gebrauchsfertige Lösung |
- | Robot platform completed under this project is largely made from plastic, except from motor mountings, which are made from aluminum. Electronic modules are placed on top of each other and the battery is loose between the plates. Bumpers are made from PCB and painted black. The top plate of the robot is completely flat, allowing to attach different desired devices. A simple radar was installed on the robot, which consisted of a small RC servo motor and an infra red sensor. As a second solution, intelligent camera module was installed on the platform for solving machine vision problems. Both solutions are brought out on the following pictures. Standard manipulator was tested as a third device, which components are controlled with standard | + | Die in diesem Projekt gebaute Roboterplattform besteht zum größten Teil aus Plastik, außer der Motorbefestigung, welche aus Aluminium hergestellt ist. Die elektrischen Module wurden auf einander platziert, die Batterie liegt lose zwischen den Platten. Die Stoßstangen wurden aus PCB gebaut und schwarz gestrichen. Die Dachplatte des Roboters ist flach und erlaubt das Anbringen verschiedener Geräten. Es wurde ein einfaches Radar installiert, welches aus einem kleinen |
+ | Als zweite Lösung wurde ein intelligentes Kameramodul installiert, welches beim Lösen visueller Probleme hilft. Beide Lösungen werden auf den folgenden Bildern vorgestellt. Ein einfacher Manipulator wurde als drittes Gerät getestet, dessen Komponenten mit standard | ||
- | [{{ : | + | [{{ : |
- | [{{ : | + | [{{ : |
- | ~~PB~~ | + | < |
- | === 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 | + | |Fräsen der PCBs (Stoßstangen)|0, |
- | |Construction of the robot|0, | + | |Bau des Roboters|0, |
- | |Building bumpers | + | |Bau der Stoßstangen |
- | |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 |
- | The cost calculation of the robot is estimated, since it is an educational project, where most of the work and construction is done in significantly larger volumes, but without direct charge. Therefore, the work and the approximate time spent does not reflect the real situation. | + | Die Kostenkalkulation des Roboters basiert auf geschätzten, da es sich um ein Lehrprojekt handelt und aus diesem Grund mehr Zeit für die Arbeit und Konstruktion verwendet wird und keine direkte Bezahlung erfolgt. Daher spiegelt der berechnete Arbeitsaufwand keine reale Situationen wider. |
- | === Project management | + | === Projektmanagement |
- | Mechatronic system | + | Das mechatronische System |
+ | Die Schlüsselaktivitäten des Projekts waren: Erstellung des Zeitplans, Planung und Management der Gruppenarbeit, Überwachung des Budgets sowie Besorgung des Materials, Weitergabe aktueller Berichte an den Leiter, Präsentation sowie Dokumentation des Ergebnisses. Der Projekbericht enthält Angaben zu den Arbeitsgruppen, Terminen von Meetings, dem Projektplan | ||
- | [{{ : | + | [{{ : |
- | === Summary and conclusions | + | === Fazit === |
- | Economic calculation showed that the production cost of the robot is quite high, especially when dealing with a single original, but remains within a predetermined initial task. Production costs could certainly be substantially reduced through the optimization of materials and components, and producing a larger quantity of robots at the same time. During this project we learned how to project a mechatronic system, how to construct and test it, which gave us the first time experience of this kind. | + | Die Kostenrechnung hat gezeigt, dass die Produktionkosten des Roboters sehr hoch sind, besonders wenn man nur mit einem Exemplar rechnet. Die 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 geworden, wie ein mechatronisches System geplant, gebaut und getestet wird. | ||
- | At the end of the work a fact revealed: inorder for the robot to function properly significantly more time should be planned for testing, especially for the software testing. Different modules may not always work properly together, although as a separate experiment it works. This shows that the integration of the modules of the system is a serious challenge, and therefore more time and resources should be planned for this. | + | Am Ende der Arbeit ist eines klar geworden: Damit der Roboter richtig funktioniert, sollte deutlich mehr Zeit zum Testen eingeplant werden, insbesondere für Softwaretests. |
+ | Unterschiedliche Module funktionieren nicht immer einwandfrei zusammen, auch wenn dieses in einzelnen Experimenten klappt. Dadurch wird deutlich, dass die Integration von Modulen in ein System eine echte Herausforderung darstellt, und hierfür mehr Zeit und Ressourcen eingeplant werden sollten. | ||
- | In conclusion, we believe that the project was very interesting and instructive, | + | Abschließend hoffen wir, dass 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 | + | - Allgemeines Benutzerhandbuch des HomeLab http:// |
- | - ATmega128 | + | - 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, | - Friendenthal, | ||
- Perens, A. Project Management, Külim, 1999 | - Perens, A. Project Management, Külim, 1999 | ||
- Bräunl, T. Embedded Robotics, Springer-Verlag, | - Bräunl, T. Embedded Robotics, Springer-Verlag, | ||
- | ====== | + | ====== |
- | 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 devices. If you have used examples selectively is also OK. Hopefully you got help for solving the problems on the time and you got also some theoretical knowledge about the problem. Next logical step would be to start building custom intelligent devices according to your interest or needs. Students should look around and participate | + | 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 haben. Wir hoffen, dass dieses Buch Sie bei der Bewältigung von Problemen sowie der Erlangung theoretischen Hintergrundwissens unterstützen konnte. Der nächste Schritt wäre nun, eigene intelligente Geräte zu entwickeln, die Ihren Interessen oder Bedürfnissen angepasst sind. Schüler und Studenten können sich darüber hinaus nach Robotikwettbewerben umsehen. Auf 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 |
- | 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 mit, dass 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 teacher, you will get the access to the exercise solutions and answers of the questions in the end of every lab ;) | + | |
{{ : | {{ : | ||
- | Web environment: \\ | + | Homepage: \\ |
http:// | http:// | ||
+ | |||
+ | --- | ||
+ | | ||