Vous êtes sur la page 1sur 28

Interfacing Stepper motor with

Microcontroller/Microprocessor

Presentation
Bilal Sarwar
Ali Rafay

By:
B-17707

What is Stepper Motor?


A stepper motor is a special type of electric motor that
moves in increments, or steps, rather than turning
smoothly as a conventional motor does.
Typical increments are 0.9 or 1.8 degrees, with 400 or 200
increments thus representing a full circle.
The speed of the motor is determined by the time delay
between each incremental movement.

Motor

Moves Each Time a Pulse is


Received

(Direction
Can

and Amount) Easily

Force Motor to Hold Position


Against an Opposing Force

How Far Does It Move?


Step Angle
Arc Through Which Motor Turns With

ONE Step Change of the Windings


Varies With Model of Stepper Motor
(Depending on the number of teeth on
stator and rotor)
Normally in Degrees
Step angle = 360/No. of Steps per
Revolution
Commonly available no. of steps per
revolution are 500, 200, 180, 144, 72,

How Fast?
60 Steps per Second
rpm
Steps per Re volution

The top electromagnet (1) is


turned
on, attracting the nearest
teeth of a
gear-shaped iron rotor. With
the
teeth aligned to
electromagnet 1,
they will be slightly offset
from

The top electromagnet


The left electromagnet (4) is enabled
(1)
is turned off, and therotating again by 3.6 (1.8).
right
When the top electromagnet (1)
electromagnet (2) is is again enabled, the teeth in the
energized, pulling thesprocket will have rotated by
nearest teeth slightly one
to tooth position
the right. This results

Types of Stepper Motors


Mainly

2 types:

Unipolar- Current can flow only in one

direction in the coils


Bipolar- Current can flow in both the
directions

Common Stepper Motor


Types

Comparison

Unipolar

Current flow in one


direction
Simple drive circuit
Less torque

Bipolar

Current flow in both


direction
Complicated drive Circuit
High Torque

Construction

Permanent Magnet Rotor


Also Called the Shaft
Stator
Surrounds the Shaft
Usually Four Stator Windings Paired with
Center-Tapped Common
Known as Four-Phase or Unipolar Stepper
Motor

Modes of Operation
Single

Coil Excitation: Only one out


of the 4 coils is excited at a given
time
Double Coil: Two adjacent coils are
excited at a given time
Single and Double: Its a hybrid of
both..(refer diagram for details)

Stepper Motor basics

The stepper motor contains a permanent


magnet which is attached to the shaft at
centre and there are 4 coils on the 4 sides

Actually the stator contains 100 teeth to


get a step angle of 360/
(2*100)=1.8degrees.

Single Coil Mode

Single coil Excitation

Note that until the next coil is switched on, the stator remains in its position only
And as we can control when to switch on a particular coil thru software, we can
rotate it by exactly the angle we wish.. Compare this with DC motor where the
shaft keeps on rotating as soon as the current is switched on

a. Single-Coil Excitation - Each


successive coil is energized in turn.

Double coil Excitation

b. Two-Coil Excitation - Each successive


pair of adjacent coils is energized in turn.

Single and Double coil


Excitation

Interleaving the two sequences


will cause the motor to half-step

Comparison
Single

coil

Low torque

Double

Consume less energy

Settling time is more

coil

High torque

Consume double
energy
Note: The advantage of hybrid mode is that the step angle gets
Settling time is less
halved.. So we can control the rotation
with double precision

Controlling DC motors by HBridge


The basic operating mode of an H-bridge is fairly
simple:
If Q1 and Q4 are turned on, the left lead of the
motor will be connected to the power supply &
motor shaft starts spinning in the forward direction.

-Continued

If Q2 and Q3 are turned on, the reverse


will happen, the motor gets energized in
the reverse direction, and the shaft will
start spinning backwards.

Implementation of H
bridge

Controlling Stepper thru


Computer
Parallel

Ports: Its the easiest way to


control the motors from computer.
No complicated intermediate circuits
are required
Serial/USB ports
Bluetooth

Male-Female D-Type
Connectors

Hardware
Implementation Using
Arduino Nano
Components

list:

H-Bridge
IR Reciever
IR Remote
Microcontroller
Stepper motor

L293D
Tsop4838
NEC Protocol
Atmega328p
ST3518

Circuit Diagram

Arduino Code

//Title: Stepper motor Control


//Author: Bilal Sarwar
//Date: 20/10/2016

#include <IRremote.h> /
int RECV_PIN = 5;
IRrecv irrecv(RECV_PIN);
decode_results results;
#include <Stepper.h>
int dir;
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); //arduino pins to h-bridge inputs
void setup() {
myStepper.setSpeed(60);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
// myStepper.step(encoderPos);
if (irrecv.decode(&results)) {
Serial.println(results.value);
irrecv.resume(); // Receive the next value
if (results.value == 1320358637)
{
myStepper.step(+1);
dir = 1;
}
else if (results.value == 4294967295 && dir == 1)
{
myStepper.step(+1);
}
else if (results.value == 1320368327)

-Continued

{
myStepper.step(-1);

dir = -1;
}
else if (results.value ==
4294967295 && dir == -1)
{
myStepper.step(-1);
}
else if (results.value ==
1320392807)
{
myStepper.step(+100);
dir = 100;
}
else if (results.value ==
4294967295 && dir == 100)
{
myStepper.step(+100);
}
else if (results.value ==
1320360167)
{
myStepper.step(-100);
dir = -100;
}
else if (results.value ==
4294967295 && dir == -100)

{
myStepper.step(-100);
}
else if (results.value == 1320401477)
{
myStepper.step(+1000);
dir = 1000;
}
else if (results.value == 4294967295 && dir == 1000)
{
myStepper.step(+1000);
}
else if (results.value == 1320417287)
{
myStepper.step(-1000);
dir = -1000;
}
else if (results.value == 4294967259 && dir == -1000)
{
myStepper.step(-1000);
}
else dir = 0;
}
delay(5);
}

Vous aimerez peut-être aussi