Uni-polar stepper motor is kind of brush-less DC motor that convert electrical pulse to mechanical movement. Comparing to bipolar stepper motor, it's easy to control but with lower torque. Stepper motor give a higher precision stepping than simple brushed DC motor. It's commonly use in photocopier machine, numerical control etc.
Different size of Uni-polar Stepper Motor |
It is made of two distinct coils. Each coil divided into two pieces by a common centered tap.
Unipolar Stepper Motor internal diagram. Two distinct coil make four coil, A1, A2, B1, B2. |
Half Stepping
Half stepping is very easy to implement. Since the motor made of four coil, we just active each coil one by one. For Example, we activate A1 Coil for a given millisecond and then turn A1 off. After that we do this to the next A2 coil.
This stepping method could be easily implemented using a synchronous digital circuit.
The timing diagram below used for stepping counter clock wise:Timing Diagram For Counter Clock Wise Half Stepping |
The time diagram below used for stepping clock wise:
Timing Diagram For Clock Wise Stepping |
The example below I use a switch to set the direction of half stepping.
ATMega32 controlling the direction of unipolar stepper motor |
#include <avr/io.h>
#define F_CPU 16000000UL
#include "util/delay.h"
#define stepTime 50
void stepBackward(){
PORTC=0x01;
_delay_ms(stepTime);
PORTC=0x02;
_delay_ms(stepTime);
PORTC=0x04;
_delay_ms(stepTime);
PORTC=0x08;
_delay_ms(stepTime);
}
void stepForward(){
PORTC=0x08;
_delay_ms(stepTime);
PORTC=0x04;
_delay_ms(stepTime);
PORTC=0x02;
_delay_ms(stepTime);
PORTC=0x01;
_delay_ms(stepTime);
}
int main(void)
{
DDRC=0x0F; //PC0.3 ARE OUTPUT
PORTC=0x00; //Clear PortC
DDRD=0x7F; //PD7 IS INPUT
PORTD=0x80; //PULLUP PD7 HIGH
while (1)
{
if(PIND&0x80) stepBackward();
else stepForward();
}
}
Full Stepping
The timing diagram below gives the full step clock wise rotation:
Full step clock wise rotation timing diagram |
The timing diagram below gives the full step counter clock wise rotation:
Full step counter clock wise rotation timing diagram |
I repeat the above example, but with full stepping. The schematic remain the same, but I modify the source code for full stepping.
Source Code for full stepping could be downloaded here:
#include <avr/io.h>#define F_CPU 16000000UL #include "util/delay.h" #define stepTime 50 void stepForward(){ PORTC=0b1001; _delay_ms(stepTime); PORTC=0x0011; _delay_ms(stepTime); PORTC=0b0110; _delay_ms(stepTime); PORTC=0b1100; _delay_ms(stepTime); } void stepBackward(){ PORTC=0b1100; _delay_ms(stepTime); PORTC=0b0110; _delay_ms(stepTime); PORTC=0b0011; _delay_ms(stepTime); PORTC=0b1001; _delay_ms(stepTime); } int main(void) { DDRC=0x0F; //PC0.3 ARE OUTPUT PORTC=0x00; //Clear PortC DDRD=0x7F; //PD7 IS INPUT PORTD=0x80; //PULLUP PD7 HIGH while (1) { if(PIND&0x80) stepBackward(); else stepForward(); } }
Back to main tutorial page ATMega32 tutorials in C with Atmel Studio 7.
No comments:
Post a Comment