This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| de:examples:motors:stepper [2009/04/22 17:38] – angelegt nierhoff | de:examples:motors:stepper [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Schrittmotor ====== | ||
| + | Schrittmotoren werden entweder unipolar und bipolar angesteuert. Der bipolare Motor besitzt zwei Spulen, und da jede Spule nun mal zwei Enden hat, also 4 Anschlüsse. Der unipolare Motor ist ebenfalls so aufgebaut, jedoch wird hier noch jede Spule in der Mitte durch eine Anschlussleitung angezapft. Schrittmotoren verfügen über keine integrierte Elektronik, weshalb sämtliche Kommutierungen extern erfolgen. Die geläufigste Art der Kommutation ist der | ||
| + | Open-Loop-Betrieb: | ||
| + | Unipolare Schrittmotoren können als bipolare Motoren eingesetzt werden, aber nicht anders herum. | ||
| + | |||
| + | ===== Elektrische Verbindungen ===== | ||
| + | |||
| + | Tabelle: Schrittmotor-Wicklungen (windings) | ||
| + | |||
| + | ^ Pin ^ Unipolar winding ^ UP PORT ^ Bipolar winding ^BP PORT ^ | ||
| + | | 1 | a | ||
| + | | 2 | b | ||
| + | | 3 | 1a | PE0/ | ||
| + | | 4 | 2a | PE1/ | ||
| + | | 5 | 1b | PE2/ | ||
| + | | 6 | 2b | PE3/ | ||
| + | |||
| + | |||
| + | - Versichere dich, dass der Strom ausgeschaltet ist | ||
| + | - Verbinde das Actuator-Board und das Main-Board mit einem 26-pin Kabel. | ||
| + | - Verbinde den Schrittmotor mit dem Actuator-Board (siehe Bild) Anmerkung: Das unipolare Motor-Kabel muss korrekt angeschlossen sein (Kabel a und b stecken auf Pin 1 und 2 auf Connector UNI1 oder UNI2). | ||
| + | - Verbinde den JTAG converter mit dem ATmega128 Main-Board und dem PC. | ||
| + | - Schließe zum Schluss Strom an das Main- und Actuator-Board an. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Test Programme ===== | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Beispiel Code ===== | ||
| + | |||
| + | <code c> | ||
| + | / | ||
| + | Title: | ||
| + | Date: | ||
| + | Ver.: 1.1 | ||
| + | Compiler: | ||
| + | Target: | ||
| + | Hardware: | ||
| + | Author: Maido Hiiemaa / Raivo Sell 2008 | ||
| + | |||
| + | Notes: | ||
| + | Description: | ||
| + | ---------------------------------------------------------------*/ | ||
| + | #define STEPDELAY (50) // one step delay | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | //global variables to store commutation patterns | ||
| + | static unsigned char bipolar_pattern; | ||
| + | |||
| + | //Function prototypes | ||
| + | void bipolar_clockwise(int number_of_steps); | ||
| + | void bipolar_counter_clockwise(int number_of_steps); | ||
| + | |||
| + | ///////////////// | ||
| + | void bipolar_clockwise(int number_of_steps){ | ||
| + | int i; | ||
| + | for (i=0; i< | ||
| + | bipolar_pattern = bipolar_pattern << 1; | ||
| + | //shift pattern to the left | ||
| + | if (bipolar_pattern> | ||
| + | // alter b' | ||
| + | PORTB &= 0xF0; //zero last output (low bits) | ||
| + | PORTB |= bipolar_pattern; | ||
| + | _delay_ms (STEPDELAY); | ||
| + | } | ||
| + | PORTB &= 0xF0; //turn off motor | ||
| + | } | ||
| + | |||
| + | void bipolar_counter_clockwise(int number_of_steps){ | ||
| + | int i; | ||
| + | for (i=0; i< | ||
| + | //shift pattern to the right | ||
| + | bipolar_pattern = bipolar_pattern >> 1; | ||
| + | if (bipolar_pattern==0) { bipolar_pattern=8; | ||
| + | //alter b' | ||
| + | PORTB &= 0xF0; //clear low bits | ||
| + | PORTB |= bipolar_pattern; | ||
| + | _delay_ms (STEPDELAY); | ||
| + | } | ||
| + | PORTB &= 0xF0;//turn off motor | ||
| + | } | ||
| + | ///////////////// | ||
| + | int main(void){ | ||
| + | //output ports initialization | ||
| + | DDRB=0xFF; //output port for bipolar stepper drive signals | ||
| + | PORTB=0; //initial PORTB output | ||
| + | bipolar_pattern=0x01; | ||
| + | |||
| + | while(1){ | ||
| + | bipolar_clockwise(100); | ||
| + | bipolar_counter_clockwise(100); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | </ | ||