This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:examples:motor:stepper [2013/03/26 21:15] – external edit 127.0.0.1 | en:examples:motor:stepper [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Stepper motor ====== | ====== Stepper motor ====== | ||
- | //Necessary knowledge: [HW] [[en: | + | //Necessary knowledge: |
+ | [HW] [[en: | ||
+ | [AVR] [[en: | ||
+ | [LIB] [[en: | ||
+ | [LIB] [[en: | ||
===== Theory ===== | ===== Theory ===== | ||
[{{ : | [{{ : | ||
- | |||
- | Stepper motors can generally be divided into unipolar and bipolar steppers. | ||
- | Unipolar stepper motors are characterized by their centre-tapped windings, which | ||
- | divide two coils into four. Stepper motors have neither built-in brushes nor internal | ||
- | electronics, | ||
- | common commutation type is the open-loop mode: the motor driver energizes the | ||
- | 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 coils inside; they have many | ||
- | 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 (drivers). Rotating the rotor is done by commutating coils step by step, without feedback. This is one of the faults in stepper motors – in case of mechanical overloading, | 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 (drivers). Rotating the rotor is done by commutating coils step by step, without feedback. This is one of the faults in stepper motors – in case of mechanical overloading, | ||
Line 26: | Line 19: | ||
Depending on the model of stepper motor, performing one full rotation (360 degrees) of the rotor, demands hundredths of steps of commutations. For stable and smooth movement, appropriate control electronics are used which control the motor according to its parameters (inertia of the rotor, torque, resonance etc.). In addition to control electronics different commutating methods may be applied. | Depending on the model of stepper motor, performing one full rotation (360 degrees) of the rotor, demands hundredths of steps of commutations. For stable and smooth movement, appropriate control electronics are used which control the motor according to its parameters (inertia of the rotor, torque, resonance etc.). In addition to control electronics different commutating methods may be applied. | ||
- | |||
- | |||
- | ~~PB~~ | ||
**Unipolar stepper-motor ** | **Unipolar stepper-motor ** | ||
- | [{{ : | + | Unipolar-stepper motor has 5 or 6 leads. According to the scheme of the motor only ¼ of the windings is activated. //Vcc// lines are usually connected to the positive power supply. During commutation the ends of windings 1a, 1b, 2a and 2b are connected through transistors only to the ground and that makes their control electronics fairly simple. |
- | + | ||
- | Unipolar-stepper motor has 5 or 6 leads. According to the scheme of the motor only ¼ of the windings is activated. //Vcc// lines are usually connected to the positive power supply. During commutation the ends of windings 1a, 1b, 2a and 2b are connected through transistors | + | |
**Bipolar stepper-motor** | **Bipolar stepper-motor** | ||
+ | [{{ : | ||
[{{ : | [{{ : | ||
- | 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 | + | 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. During commutation half-bridges are applying either positive or negative voltage to the ends of the windings. Unipolar motors can be started using bipolar driver: just connect lines 1a, 1b, 2a and 2b of the windings (//Vcc// will be not connected). |
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: | 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: | ||
Line 63: | Line 52: | ||
===== Practice ===== | ===== Practice ===== | ||
+ | The Combo Module has a H-bridges to control bipolar stepper motors and the transistor matrix for unipolar stepper motor. | ||
- | 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 functions // |
- | + | ||
- | There is function | + | |
<code c> | <code c> | ||
- | // | + | // Preparing for controlling the bipolar stepper motor |
- | // Preparing for controlling the bipolar stepper motor. | + | |
- | // | + | |
void bipolar_init(void) | void bipolar_init(void) | ||
{ | { | ||
Line 79: | Line 64: | ||
} | } | ||
- | // | + | // Moving the bipolar stepper motor by half steps |
- | // Moving the bipolar stepper motor by half steps. | + | |
- | // | + | |
void bipolar_halfstep(signed char dir, | void bipolar_halfstep(signed char dir, | ||
unsigned short num_steps, unsigned char speed) | unsigned short num_steps, unsigned char speed) | ||
Line 97: | Line 80: | ||
state2 += dir; | state2 += dir; | ||
- | // Creating the pattern. | + | // Creating the pattern |
pattern = (1 << ( (state1 % 8) >> 1) ) | | pattern = (1 << ( (state1 % 8) >> 1) ) | | ||
(1 << ( (state2 % 8) >> 1) ); | (1 << ( (state2 % 8) >> 1) ); | ||
Line 104: | Line 87: | ||
PORTB = (PORTB & 0xF0) | (pattern & 0x0F); | PORTB = (PORTB & 0xF0) | (pattern & 0x0F); | ||
- | // Taking a break to wait for executing the step. | + | // Taking a break to wait for executing the step |
sw_delay_ms(speed); | sw_delay_ms(speed); | ||
} | } | ||
- | // Stopping the motor. | + | // Stopping the motor |
PORTB &= 0xF0; | PORTB &= 0xF0; | ||
} | } | ||
Line 116: | Line 99: | ||
<code c> | <code c> | ||
- | // | + | // The test program for the stepper motor of the HomeLab |
- | // The test program for the bipolar | + | |
- | // | + | |
- | // | + | |
#include < | #include < | ||
Line 125: | Line 105: | ||
int main(void) | int main(void) | ||
{ | { | ||
- | // Set up of the motor. | + | // Set up of the motor |
- | bipolar_init(); | + | unipolar_init(0); |
- | // Endless loop. | + | // Endless loop |
while (true) | while (true) | ||
{ | { | ||
// Turning the rotor 200 half steps to one direction | // Turning the rotor 200 half steps to one direction | ||
// at speed of 30 ms/step. | // at speed of 30 ms/step. | ||
- | bipolar_halfstep(+1, 200, 30); | + | unipolar_halfstep(0,+1, 2000, 30); |
// Turning 200 half steps to the other direction | // Turning 200 half steps to the other direction | ||
// at speed 30 ms/step. | // at speed 30 ms/step. | ||
- | bipolar_halfstep(-1, 200, 30); | + | unipolar_halfstep(0,-1, 2000, 30); |
} | } | ||
} | } | ||
</ | </ |