Lab-9 Stepper Motor Interfacing With PIC16F877A Microcontroller
Lab-9 Stepper Motor Interfacing With PIC16F877A Microcontroller
Theory:
Stepper motors are working on the same principle of dc motors. It is a synchronous dc motor
which moves in discrete steps to complete its rotation. Normally, each step moves 1.8 degree
and therefore a total of 200 steps for a rotor to finish a single rotation. Unlike normal dc motors,
it contains multiple stator magnets used to trigger each step. Apart from 1.8 degree, stepper
motors with step angle 30, 15.5, 2.5 and 2 are also available. The stepper motor completes it’s
each revolution with each step completely controlled by the controller which is followed by a
driver circuit. Because of the high precision properties, stepper motors are highly preferred in
motion control application such as robotics.
Similar to any other motor, a stepper motor has a rotating part which is aptly called a rotor and
a static part termed stator. The stator and rotor have magnetic poles. By energizing the stator
poles, the rotor moves in order to align with the stator. A rotor is a central gear-shaped piece
of iron. The stator is a set of toothed electromagnets arranged around the central gear.
When the phase windings of the stepper motor are provided with a current, corresponding
magnetic flux will be developed in the stator in the direction perpendicular to the direction of
current flow. Electromagnets are energized one at a time. When one electromagnet is energized
with the help of an external driver circuit or a microcontroller, the rotor shaft turns in such a
way that it aligns itself with the stator in a position which minimizes the flux opposition. That
means the electromagnet attracts the gear teeth by which the electromagnet is offset from the
rest of the electromagnets. Because of this, when the next electromagnet is turned on, the first
electromagnet gets turned off which results in the gear teeth getting attracted to the second
electromagnet. Thus the rotor is made rotating in steps which are an integer determined by the
angle of movement in each step.
In a bipolar stepper motor, there is a single winding per phase. This makes the driver circuit lot
more complicated while reversing the magnetic poles which in turn reverses the current in the
winding. Usually, an H-Bridge arrangement is used to do this task. One can also purchase
simpler driver chips to make the task less complicated.
Full step
Half step
Micro-step
Full Step
In full step operation each step has a movement of 1.8 degrees and hence it takes 200 steps to
complete a full revolution. This is made possible by energizing either single of stator winding
or two phases. Since the two phases are energized at the same time in the dual phase operation,
torque and speed are greater in this kind of operation while the single phase operation requires
a lower amount of power from the driver circuit.
In one step mode/ wave step, the motor is operated with only one phase energized at a time.
This mode of operation requires a small amount of power.
In dual phase mode, the motor operated in both phases get energized at the same time. This
mode provides more torque and high-speed performance. But this mode requires twice the
amount of power used in one step mode.
Half Step
The rotor moves through half the base angle in a single step which results in improved torque
than single phase full step operation. Also it doubles smoothness of rotation and resolution.
In half step mode, they have only half the basic step angle when compared to full step mode
which results in more precise motion control and smoother motor performance. Resolution is
also increased. But in this mode, motor produces less torque compared to other modes.
Micro step
In the micro step mode, it divides the motor steps up to 256 times which improves the low-
speed smoothness and low-speed resonance effects. But in this mode, the motor produces less
torque compared to other modes.
In micro step operation, the basic angle is divided into minute values even up to 256 times.
Micro step operation is preferred where increased smoothness of rotation is required.
Mikro C Code:
void main()
{
TRISD = 0b0000000; // PORT D as output port
PORTD = 0b1111111;
do
{
PORTD = 0b00000011; // energizing two phases at a time
Delay_ms(500); // delay of 0.5s
PORTD = 0b00000110;
Delay_ms(500);
PORTD = 0b00001100;
Delay_ms(500);
PORTD = 0b00001001;
Delay_ms(500);
}while(1); // loop executed infinite times
}
Circuit Diagram: