TPEC - Stepper Motor
TPEC - Stepper Motor
The most common stepper motors have four windings that are paired with a center-tapped
common as shown in Figure 2.
This type of stepper motor is commonly referred to as a four-phase stepper motor. The center
tap allows a change of current direction in each of two coils when a winding is grounded,
thereby resulting in the polarity change of the stator. The stepper motor shaft moves in a
fixed repeatable increment. The direction of rotation is determined by the stator poles. As
the direction of current through the stator changes, the polarity also changes causing
the reverse motion of the rotor.
0 0 0 0 1 0 0 1 0X09
0 0 0 0 0 0 1 1 0X03
0 0 0 0 0 1 1 0 0X06
0 0 0 0 1 1 0 0 0X0C
0 0 0 0 1 1 0 0 0X0C
0 0 0 0 0 1 1 0 0X06
0 0 0 0 0 0 1 1 0X03
0 0 0 0 1 0 0 1 0X09
The stepper motor has 200 poles and is driven by ULN2003A driver IC which requires
a supply voltage of 5V
Code:
#include <reg51.h>
#define MOTORPORT P2
void main()
{
RotateClockWise(90);
while(1)
{
}
}
2. Example: Rotate stepper motor 45° in anticlockwise direction
Code:
#include <reg51.h>
#define MOTORPORT P2
unsigned char sequence[]={0x09, 0x03, 0x06, 0x0C};
void Delay(unsigned char ms)
{
unsigned char i;
unsigned int j;
for (i = 0; i < ms; i++)
for(j = 0; j < 1275; j++);
}
void main()
{
RotateAntiClockWise(45);
while(1)
{
}
}
3. Example: Rotate stepper motor 180° clockwise and anticlockwise
direction continuously
Code:
#include <reg51.h>
#define MOTORPORT P2
unsigned char sequence[]={0x09, 0x03, 0x06, 0x0C};
void Delay(unsigned char ms)
{
unsigned char i;
unsigned int j;
for (i = 0; i < ms; i++)
for(j = 0; j < 1275; j++);
}
void RotateClockWise(unsigned int angle)
{
unsigned int steps = angle/1.8f;
unsigned int i;
for(i = 0; i < steps; i++)
{
MOTORPORT = sequence[i%4];
Delay(10);
}
}
void RotateAntiClockWise(unsigned char angle)
{
unsigned int steps = angle/1.8f;
unsigned int i;
for(i = 0; i < steps; i++)
{
MOTORPORT = sequence[3 - i%4];
Delay(10);
}
}
void main()
{
while(1)
{
RotateClockWise(180);
RotateAntiClockWise(90);
}
}