Sunteți pe pagina 1din 9

 Simple Projects 

October 16, 2018 • 4 Comments

Arduino Bipolar Stepper Motor Control

 Share  Tweet  Pin  Mail  SMS

This small post shows how to control speed and direction of rotation of bipolar stepper motor
using Arduino UNO board and L293D motor driver chip.
The stepper motor used in this example is just a PC CD-ROM (or DVD-ROM) drive which has 4
wires.
Proteus simulation of the example is provided at the end of the topic.

Basically there are two types of stepper motors: bipolar and unipolar. The bipolar stepper
motor is a two-phase brushless motor which has two coils (windings), this motor has 4 wires
(2 wires for each coil).
The other type is the unipolar stepper motor, it is 4-phase brushless motor which has 5 or 6
wires.

The popular controlling modes of of the stepper motor are: full step and half step. The full
step can be divided into 2 types: one-phase and two-phase.

In full step one-phase mode the driver energizes one coil at a time. This type of
controlling requires the least amount of power but provides the least torque.

In full step two-phase mode the driver energizes the two coils at the same time. This mode
provides the highest torque but it requires twice as much power as one-phase mode.

Half step mode is a combination of the two full step modes (one-phase and two-phase). This
mode increases accuracy by dividing each step by 2. it requires power in-between one-phase
and two-phase modes, torque also is in-between.

There is another controlling type called microstepping, this type is more accurate than the
half step mode, it requires two sinusoidal current sources with 90° shift.

In this example I’m going to use the full step two-phase mode for controlling the bipolar
stepper motor.

The following image shows a simple schematic of the bipolar stepper motor:

To be able to control the bipolar stepper motor, two H-bridge circuits are required. In this
example I’m going to use L293D quadruple half-H driver which can work as dual H-bridge
driver. This chip is small, low cost and easy to use, these make it a good choice for students
p y g
and hobbyists, in this blog, I used it in some DC motor control projects.

In the full step control mode always both windings are energized at the same time according
to the following two tables where rst table shows the driving sequence for one rotation
direction and second table for the other direction:

Related Projects:
Arduino Unipolar Stepper Motor Control

Hardware Required:
Arduino UNO board

Bipolar stepper motor


L293D motor driver chip   —-> datasheet

10k ohm potentiometer

Pushbutton

Power source with voltage equal to motor nominal voltage

Bread board

Jumper wires

Arduino bipolar stepper motor control circuit:


Example circuit diagram is shown below.
All grounded terminals are connected together.

The L293D chip has 16 pins with 4 inputs (IN1, IN2, IN3 and IN4) and 4 outputs (OUT1, OUT2,
OUT3 and OUT4). The 4 outputs are connected to the bipolar stepper motor as shown in the
circuit diagram.

The 4 inputs are connected as follows:


IN1 to Arduino pin 8
IN2 to Arduino pin 9
IN3 to Arduino pin 10
IN4 to Arduino pin 11

The L293D has 2 VCC pins: VCC1 (pin #16) and VCC2 (pin #8). VCC1 is connected to Arduino
+5V pin. VCC2 is connected to another power source (positive terminal) with voltage equal to
motor nominal voltage, it’s labeled in the circuit diagram as V_Motor (V_Motor = motor
voltage). So if we have a stepper motor with nominal voltage of 5V we’ve to connect VCC2 to
+5V (Arduino 5V output shouldn’t be used) and if the stepper motor nominal voltage is 12V
we’ve to connect VCC2 to +12V (negative terminal of this source is connected to circuit
ground)…

The 10k ohm potentiometer is used to control the speed of the stepper motor, its output pin
is connected to Arduino analog pin 0.

The push button which is connected to Arduino pin 4 is used to change the rotation direction
of the stepper motor.

Arduino bipolar stepper motor control code:


In this example I used Arduino stepper motor library (built-in) which simpli es the code, it is
included in the code using the following line:

C
1 #include <Stepper.h>

The stepper motor which I used in this project has 20 steps per one revolution, it is de ned in
the code as shown below:
C
1 #define STEPS 20

and the connection of the control lines of the stepper motor are de ned as:

C
1 Stepper stepper(STEPS, 8, 9, 10, 11);

Using the function stepper.step(direction_) the stepper motor moves according to the variable
direction_, in this example this variable may be 1 or -1. If direction_ = 1 the motor will move in
the rst direction and if direction_ = -1 the motor will move in the other direction.

When ever the pushbutton is pressed, the variable direction_ will be inverted (1 or -1).

Rest of code is described through comments.

C
39    ead a a og a ue o t e pote t o ete
40   int val = analogRead(pot);
41  
42   // map digital value from [0, 1023] to [5, 100]
43   // ===> min speed = 5 and max speed = 100 rpm
44   if ( speed_ != map(val, 0, 1023, 5, 100) )
45   { // if the speed was changed
46     speed_ = map(val, 0, 1023, 5, 100);
47     // set the speed of the motor
48     stepper.setSpeed(speed_);
49   }
50  
51   // move the stepper motor
52   stepper.step(direction_);
53  
54 }
55  
56 // a small function for button debounce
57 bool debounce()
58 {
59   byte count = 0;
60   for(byte i = 0; i < 5; i++) {
61     if (digitalRead(button) == 0)
62       count++;
63     delay(10);
64   }
65   if(count > 2)  return 1;
66   else           return 0;
The following video shows a simple hardware circuit of the project:

Arduino bipolar stepper motor speed and direction control

and this video shows Proteus simulation

Arduino bipolar stepper motor control - Proteus simulation

Arduino + stepper motor Proteus simulation:


Simulation le download link is below.
Arduino + Bipolar stepper motor
du o p pp
po a steppe oto

Share this:

  
Categories: Arduino Projects
Tags: Stepper Motor

Previous Post Next Post


 PIC12F1822 MCU With DS1307/DS3231 And I2C Arduino Unipolar Stepper Motor Control 
LCD | MPLAB Projects

4 responses
Wen
March 31, 2019

Hi, could you send me the le of protues simulation for Arduino + Bipolar stepper motor please?
i cant download it.

Reply
Simple Projects
March 31, 2019

Download link is working well!


Unzip it to get Proteus simulation le.
https://drive.google.com/open?id=1awcsyLfZkcnqw9PVLplKRvV71Rjt947O

Reply

Mukesh L V
June 24, 2019

not working
ISIS Release 8.09.00 (Build 27865) (C) Labcenter Electronics 1990- 2019.
Compiling design ‘C:\Users\DELL\Desktop\Arduino + Bipolar stepper motor.pdsprj’.
Netlist compilation completed OK.
Netlist linking completed OK.
Partition analysis completed OK.
Simulating partition 1
PROSPICE 8.08.00 (Build 27367) (C) Labcenter Electronics 1993-2019.
mixed model AVR2.DLL failed to authorize – Missing or invalid Customer Key.. [AU1]
Loaded netlist ‘C:\Users\DELL\AppData\Local\Temp\LISA9501.SDF’ for design ‘Arduino + Bipolar
stepper motor.pdsprj’
Real Time Simulation failed to start.
Simulation FAILED due to fatal simulator errors.

this much error is coming

Reply

Simple Projects
June 24, 2019

Try with newer version of Proteus ISIS (for example version 8.6 or higher)!

Reply

Leave a Reply
Enter your comment here...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

S-ar putea să vă placă și