This shows you the differences between two versions of the page.
| de:examples:motors:dc [2009/04/23 17:48] – angelegt nierhoff | de:examples:motors:dc [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Gleichstrommotor ===== | ||
| + | der Betrieb eines Gleichstrommotors (DC Motor) basiert, wie alle elektrischen Motoren, auf Elektromagnetismus. | ||
| + | The operation of direct current (DC) motors, like all other electric motors, is based on | ||
| + | simple electromagnetism. Gleichstrommotoren mit Bürsten haben zwei Kabelverbindungen, | ||
| + | |||
| + | Steuern des Gleichstrommotors: | ||
| + | |||
| + | Eine H-Brücke oder zwei Halbbrückentreiber können eingesetzt werden um einen Gleichstrommotor vorwärts und rückwärts laufen zu lassen. Als Schaltung können fertige Anwendungsspezifische Integrierte Schaltungen (engl. application specific integrated circuit, ASIC) genutzt werden, oder eine aus einzelnen Komponenten, | ||
| + | |||
| + | |||
| + | ===== Einfaches Testprogramm ===== | ||
| + | Mit diesem kompilierten Programm lässt sich das Set-Up der Geräte testen. Der Gleichstrommotor ist an DC1 Port 2 und der Servomotor an PWM1 angeschlossen. | ||
| + | {{: | ||
| + | |||
| + | ===== Schaltplan ===== | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Steuersignale vom ATmega128 zum Actuator-Board | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Verbinden der Komponenten ===== | ||
| + | Elektrische Verbindungen | ||
| + | - Strom abschalten | ||
| + | - Verbinde das Actuator-Board und das Main-Board mit einem 26-pin Kabel. | ||
| + | - Verbinde die Gleichstrommotoren mit dem Actuator-Board (siehe Bild). | ||
| + | - Verbinde den JTAG Converter mit dem ATmega128 Main-Board und dem PC. | ||
| + | - Schließe Strom an das Main- und Actuator-Board an. | ||
| + | |||
| + | {{: | ||
| + | {{: | ||
| + | |||
| + | ===== Example code ===== | ||
| + | <code c> | ||
| + | / | ||
| + | Title: DC motor with Actuator Board | ||
| + | Date: 080424 | ||
| + | Ver.: 1.2 | ||
| + | Compiler: AVR-GCC | ||
| + | Target: ATmega128 | ||
| + | Hardware: ATmega128 controller board, Actuator board, DC motor | ||
| + | Author: Raivo Sell 2008 | ||
| + | Notes: in1 PD7 in2 PD6 | ||
| + | Optimization: | ||
| + | Description: | ||
| + | Motor is connected to the DC1 pins 3 | ||
| + | ---------------------------------------------------------------*/ | ||
| + | #define SET(x) |= (1<< | ||
| + | #define CLR(x) & | ||
| + | #define MS (100) //defines delay | ||
| + | #define F_CPU 14745600UL //CPU Frequency (influences delay function) | ||
| + | #include < | ||
| + | ///////////////// | ||
| + | void dc_drive(int pin, int op){ // DC motor control function | ||
| + | if (op==1) PORTD SET(pin); | ||
| + | else PORTD CLR(pin); | ||
| + | } | ||
| + | |||
| + | void _delay_ms(int t){ // Delay function | ||
| + | int i,j; | ||
| + | for (i=0; | ||
| + | for (j=0; | ||
| + | } | ||
| + | } | ||
| + | ///////////////// | ||
| + | int main (void){ | ||
| + | DDRD = 0xFF;// set port direction (output) | ||
| + | PORTD = 0x00;// initialize port | ||
| + | while(1){ | ||
| + | dc_drive(6, | ||
| + | dc_drive(7, | ||
| + | _delay_ms(MS); | ||
| + | dc_drive(6, | ||
| + | dc_drive(7, | ||
| + | _delay_ms(MS); | ||
| + | dc_drive(6, | ||
| + | dc_drive(7, | ||
| + | _delay_ms(MS); | ||
| + | } | ||
| + | } | ||
| + | </ | ||