Interfacing stepper motor with PIC microcontroller

///Interfacing stepper motor with PIC microcontroller
  • Interfacing of stepper motor with PIC microcontroller

Interfacing stepper motor with PIC microcontroller

Operation of a stepper motor is similar to that of a dc motor. The myriad applications of a stepper motor include precise motion control systems such as those found in industrial automation, a wide variety of robotic applications like arm movement controllers and systems like 3D printers etc. Interfacing a stepper motor with a microcontroller is, therefore, more of a requirement. Here in this chapter how a stepper motor is interfaced with a PIC microcontroller is discussed in detail.

Stepper motor

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.

stepper-motor

Mainly there are four types of stepper motors:

  • Permanent magnet stepper
  • Hybrid synchronous stepper
  • Variable reluctance stepper
  • Lavet type stepping motor

PRINCIPLE OF OPERATION AND WORKING

The basic principle behind the working of a stepper motor is electromagnetism. Since stepper motors are working under the same principle of a dc motor, they are normally regarded as dc motors. But unlike dc motors they have multiple stator coils which are called phases. By energizing each phase in a controlled manner or with a predetermined pulse sequence, the motor completes its full revolution with one step at a time. We can achieve motion in more precise and controlled manner with the help of a control circuitry.

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.

Unipolar and Bipolar stepper motors

According to the winding arrangements of the electromagnetic coils in a two-phase stepper motor, they are classified as unipolar and bipolar stepper motors. In the unipolar stepper motor which works with one winding with a center tap per phase, each section of the phase winding is turned on for each of the magnetic field direction. Since unipolar stepper motors are quite easy to operate, these are highly preferred among hobbyists.

stepper-motor-unipolar

Unipolar stepper motor

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.

stepper-motor-bipolar

Bipolar stepper motor

STEPPING MODES – Unipolar stepper motors

A unipolar stepper motor works only in positive voltage. That means it has only one polarity. The upper and lower voltage levels are positive. For example, upper voltage level 5V and lower voltage level 0V. A unipolar stepper motor requires a wire in the middle of each coil to allow current to flow through.

Mainly there are 3 types of stepping modes in Unipolar stepper motors

  • 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.

There are two types of full step mode:

  • One step mode/wave step
  • Dual-phase mode

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.

table-wave-step - Interfacing stepper motor with PIC microcontroller

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.

table-full-step - Interfacing stepper motor with PIC microcontroller

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.

table-half-step - Interfacing stepper motor with PIC microcontroller

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.

Stepper motor driver

The stepper motor phases are completely controlled by the microcontroller. But it cannot be controlled directly because the controller is not capable of supplying that much amount of current directly. So it can be achieved using a driver circuitry. Commonly ULN2003 and L293D are widely used for simple stepper motor driving applications and there are specialized ICs for driving large and complex applications.

Circuit diagram – interfacing stepper motor with PIC Microcontroller

Below is the circuit diagram for the Bipolar stepper motor. Here we used a ULN2003 driver to interface it with PIC18F4550.

Interfacing stepper motor with PIC microcontroller - unipolar stepper motor using uln2003

Interfacing unipolar stepper motor with PIC18F4550

Bipolar stepper motor interfacing with PIC18F4550

Bipolar stepper motor contains two coils without a center tap. The driving method is different from Unipolar, it needs the current reversed to change the direction of rotation. So we can use an H-bridge for driving Bipolar stepper motors. L293D is a commonly used H-Bridge motor driver.

Interfacing stepper motor with PIC microcontroller - bipolar stepper motor and l293d

Bipolar stepper motor interfacing with PIC

Sample Firmware for full step sequence

Below is a sample firmware for generating step sequence. For full step sequence, there are four steps. Refer the table provided in the above section.

The same idea can be used to generate other step sequences for both unipolar and bipolar stepper motors.

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
Spread the love, share this

Leave A Comment

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
close-link
25% OFF - OpenLabPro Course
Use Coupon: CRS25UL

 
PIC Microcontroller Primer
Want to learn indepth programming, peripheral interfacing and driver development?
close-link
Launched: IoT online Course - 25% Off when you complete your order today.
Checkout Now
close-image

Subscribe To our Email Newsletter

Be the first to get latest updates and exclusive content straight to your email inbox.
Send me Tutorials and Guides
close-link