Driving Stepper Motor

Posted on

Stepper motor is very useful for some robots to make their high accuracy movement. How to drive or control your stepper motor? Use this tutorial as your guide….

General Theory of Stepper Motors
An ordinary DC motor will turn around and around as long as power is supplied. No intelligent circuitry is required to drive such a motor, unless you want to slow it down or reverse direction – just apply power and it spins. A stepper motor is very different. If you just feed it power, it will stay where it is. In order to make the motor move, you have to feed it a changing signal. This is best illustrated by thinking of a magnetic compass with electromagnets around it:

Motor Stepper
Figure 2.7.1 Motor Stepper

The drawing on the bottom shows power applied to the N electromagnet, drawing the compass toward it. On the right, power is instead applied to the E electromagnet, and the needle has rotated toward that side.

motor stepper control
Figure 2.7.2. Basic Stepper Motor

Just four electromagnets would give coarse jumpy motion. Now imagine a similar arrangement with 100 electromagnets around the compass. By energizing each electromagnet in sequence, the needle takes 100 steps around the circle. But driving 100 individual electromagnets would require complex electronics. We fake it:

 

Basic Motor Stepper
Figure 2.7.3. Basic Motor Stepper with more electromagnet

In these drawing, the circled letters represent electromagnets. All the magnets with the same letter are wired together. When you energize that circuit, all of the electromagnets torn on at once. On the left, there are 8 magnets, but only 4 circuits. Sequencing through the four circuits gives half of a rotation. One more run through the sequence completes the rotation. This setup requires that both ends of the compass needle be north-seeking. On the right, the same 4 circuits energize 16 magnets. This setup requires 16 steps (4 repetitions of a 4-step cycle) to complete one rotation.

On the right, the same 4 circuits energize 16 magnets. This setup requires 16 steps (4 repetitions of a 4-step cycle) to complete one rotation. In actual practice, just four control wires can provide just about as many steps as you might want. One of the characteristics of a given stepper motor is the number of steps necessary to make a complete circle, usually expressed as number of degrees per step.

Table 2.7.1. Full Step Mode

A B C D Comment
1 0 0 0 Take a step clock wise
0 1 0 0 another step clock wise
0 0 1 0 another step clock wise
0 0 0 1 another step clock wise
0 0 0 1 No step take
0 0 1 0 Take a step back

More Complex Drive
As we have seen, it is very easy to drive a stepper motor, by simply turning one electromagnet fully on at a time. But there are other ways to drive a stepper motor.

Half Steps
By turning on two coils at once, the motor will take a position between the two steps.

 

Half STep motor Stepper
Figure 2.7.4. Half step mode

Table 2.7.2. Half Step Mode

A B C D Comment
1 0 0 0 Take a step clock wise
1 1 0 0 Half a step clock wise
0 1 0 0 The complete full step clock wise
0 1 1 0 another half step clock wise
0 0 1 0 The complete full step clock wise
0 0 1 1 Another half step clock wise
0 0 0 1 The complete full step clock wise
1 0 0 1 another half step clock wise
1 0 0 0 Start position

Get to run your stepper motor

A basic example of stepper motor driver is shown in figure 2.7.1.1 Notice the separate voltages for logic and for the stepper motor. Usually the motor will require a different voltage than the logic portion of the system. Typically logic voltage is +5 Vdc and the stepper motor voltage can range from +5 Vdc up to about +48 Vdc. The driver is also an “open collector” driver, wherein it takes its outputs to GND to activate the motor’s windings.

Figure 2.7.1.1 Driving motor stepper

Step 1st
Build the circuit as shown in figure 2.7.1.1. As you seen on figure 2.7.1.1. P0.4 trough P0.7 is connected to driver motor stepper. Remember, that all we want to do with this lesson is write data to stepper motor.

Step 2nd
In this step, you must tipe the assembly program to make your stepper motor run, we assume that you have already known the editor, we used MIDE-51 to edit the program. ( Download File : exp271.zip , Download Complete Circuit File : StepperMotor.PDF )

org 0hstart: mov P0,#11101111b; Turn on driver 1
call delay       ; call delay time
mov P0,#11011111b; Turn on driver 2
call delay       ; call delay time
mov P0,#10111111b; Turn on driver 3
call delay       ; call delay time
mov P0,#01111111b; Turn on driver 4
call delay       ; call delay time
sjmp start
;
delay: mov R0,#0
delay1:mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
end

Step 3rd
Safe your assembly program above, and name it with stepper1.asm (for example) Compile the program that you have been save by using MIDE-51, see the software instruction.

Step 4th
Download your hex file ( stepper1.hex ) into the microcontroller by using Microcontroller ATMEL ISP software, see the instruction.After download this hex file you’ll see the action of Stepper Motor ( of course if your cable connection and your program are corrected ).


Directing your step wise with push button

The other way to drive step wise of motor stepper is by using a swicht push button, for example, in this lesson we can try to rotate stepper motor in clockwise if we push the button and counter clockwise if we do not push the button.


Figure 2.7.2.1. Driving motor stepper wise step with swicht push button

Step 1st
Build the circuit as shown in figure 2.7.2.1. As you seen on figure 2.7.2.1. P0.4 trough P0.7 is connected to driver motor stepper and one push button is connected to P2.0. Remember, that all we want to do with this lesson is to drive clock wise or counter clock wise of motor stepper with push button.

Step 2nd
In this step, you must tipe the assembly program to make your stepper motor run, we assume that you have already known the editor, we used MIDE-51 to edit the program. ( Download File : exp272.zip , Download Complete Circuit File : StepperMotor.PDF )

org 0hstart: jb P2.0,CW
call StepCCW
sjmp start
CW:    call StepCW
sjmp start
;
StepCW:
mov P0,#11101111b; Turn on driver 1
call delay       ; call delay time
mov P0,#11011111b; Turn on driver 2
call delay       ; call delay time
mov P0,#10111111b; Turn on driver 3
call delay       ; call delay time
mov P0,#01111111b; Turn on driver 4
call delay       ; call delay time
ret
;
StepCCW:
mov P0,#01111111b; Turn on driver 1
call delay       ; call delay time
mov P0,#10111111b; Turn on driver 2
call delay       ; call delay time
mov P0,#11011111b; Turn on driver 3
call delay       ; call delay time
mov P0,#11101111b; Turn on driver 4
call delay       ; call delay time
ret
;
delay: mov R0,#0
delay1:mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
end

Step 3rd
Safe your assembly program above, and name it with stepper2.asm (for example) Compile the program that you have been save by using MIDE-51, see the software instruction.

Step 4th
Download your hex file ( stepper2.hex ) into the microcontroller by using Microcontroller ATMEL ISP software, see the instruction.After download this hex file you’ll see the action of Stepper Motor ( of course if your cable connection and your program are corrected ).

2.g.3. Directing your step wise with push button

With refers to lesson 2.g.2., in this lesson you can try how to drive stepper motor with two swicht, that’s mean you can direct step wise with two push button, and each push button controls one direction as shown in figure 2.23.


Figure 2.23. Driver stepper motor stepper wise with two push button

source: mytutorialcafe.com

Gravatar Image
Robotics Technology , Tutorial and News

Leave a Reply

Your email address will not be published. Required fields are marked *