Download Controlling DC Motors

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Power inverter wikipedia , lookup

Switch wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Current source wikipedia , lookup

Stray voltage wikipedia , lookup

Rectifier wikipedia , lookup

Three-phase electric power wikipedia , lookup

Control system wikipedia , lookup

Mains electricity wikipedia , lookup

Brushless DC electric motor wikipedia , lookup

Electric motor wikipedia , lookup

Power electronics wikipedia , lookup

Schmitt trigger wikipedia , lookup

Alternating current wikipedia , lookup

Voltage optimisation wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Opto-isolator wikipedia , lookup

Pulse-width modulation wikipedia , lookup

AC motor wikipedia , lookup

Buck converter wikipedia , lookup

Induction motor wikipedia , lookup

Brushed DC electric motor wikipedia , lookup

Stepper motor wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Transcript
Khaled A. Al-Utaibi
[email protected]




Introduction
Direction Control
Speed Control
Design Example


A DC (direct current) motor is widely used device
that translates electrical pulses into mechanical
movement.
For example, small fans used in many motherboards to cool the CPU are run by DC motors.

In the DC motor we have positive (+) and
negative (−) leads.
−Connecting them to a DC voltage source moves the
motor in one direction.
−By reversing the polarity, the DC motor will move in the
opposite direction.

The maximum speed of a DC motor is indicated in rpm and
is given in the data sheet.
−The DC motor has 2 rpms: (1) no-load and (2) loaded.
−The no-load rpm can be from a few thousand to tens of
thousands.
−The rpm is reduced when moving a load and it decreases as the
load is increased.
−For example, a drill turning a screw has a much lower rpm speed
than when it is in the no-load situation.

DC motors also have voltage and current ratings.
−The nominal voltage is the voltage for that motor
under normal conditions, and can be from 1 to 150 V,
depending on the motor.
−As we increase the voltage, the rpm goes up.
−The current rating is the current consumption when
the nominal voltage is applied with no load and can be
from 25 mA to a few amps.
−As the load increases, the rpm is decreased, unless the
current or voltage provided to the motor is increased.

The direction of rotation of a DC motor may be
reversed by interchanging its input voltage
polarity.
−Let’s assume that initially it is rotating in clockwise
direction (a).
−Then, it would start rotating in anticlockwise direction
by the reversed polarity (b).
−The direction (polarity) of the DC motor can be
controlled using a configuration known as H-bridge.

The figure shows the connection of an H-Bridge using
simple switches. All the switches are open, which does
not allow the motor to turn.

The figure shows the switch configuration for turning
the motor in one direction. When switches 1 and 4 are
closed, current is allowed to pass through the motor.

The figure shows the switch configuration for turning
the motor in the opposite direction from the
configuration of previous figure. When switches 2 and
3 are closed, current is allowed to pass through the
motor.

The figure shows an invalid configuration. Current
flows directly to ground, creating a short circuit. The
same effect occurs when switches 1 and 3 are closed or
switches 2 and 4 are closed.


H-Bridge control can be created using relays,
transistors, or a single IC solution such as the
L293D.
The pin configuration of the L293D and its
mapping to the H-bridge configuration is shown
in the next figure.
−It contains two built-in H-bridge circuits each consisting
of two drivers OUT1+OUT2 and OUT3+OUT4.
−Each H-bridge may individually be enabled or disabled
through its enable input (EN1 or EN2).
−Vs (pin 8) is for motor power supply voltage input(5V
to 36V).
−Vss (pin 16) is for logic level input voltage (5V).


Two DC motors can be driven simultaneously, both in
forward and reverse direction as shown in the next
figure.
The operations of two motors can be controlled by
input logic at pins EN1 & EN2, IN1 & IN2 and IN3 & IN4
as shown in the following tables.

The speed of any DC motor can be controlled by
one of two approaches:
−(1) changing its input current or
−(2) changing its input voltage.

Changing input current can be implement using a
variable resistance connected in series with the
motor as shown in the following figure.

Pulse-Width Modulation (PWM) is a widely used
technique to control the input voltage (and,
therefore, the speed) of a DC motor.
−As shown in following figure, variation of duty cycle of
a square wave changes the value of average output
voltage, and the inertial force of the motor keeps it
rotating during the off stage of the square wave.
−Increasing the duty cycle increases the speed of
rotation and vice versa.
−In this case, "duty cycle" means the on-time with
respect to the time taken by one complete on-off cycle.

Design an Arduino Uno interface to control the
operation of a DC motor using 4 switches labeled
(EN, DIR, SP1 and SP2) according to the following
function table:


The schematic circuit breadboard of this design
example are shown in the next 2 figures.
The schematic consists of the following devices:
−An L293D chip interfaced to pin0, pin1, pin6 of the
Arduino Uno board.
−A DC motor interfaced to OUT1 and OUT2 of the L293D
chip.
−Four switches interfaced to pin2, pin3, pin4 and pin5 of
the Arduino Uno board.

The C code consists of the following main parts:
−Interface pins definition
−DC Motor Control
 Enable Control (Turn DC Motor ON/OFF)
 Direction Control (Forward/Reverse)
 Speed Control (25%, 50%, 75%, 100%)

The L293D inputs and switches are interfaced to
the Arduino Uno board as follows:
// pin interface
int en1 = 6;
int in1 = 0;
int in2 = 1;
int en = 2;
int dir = 3;
int sp1 = 4;
int sp2 = 5;
//
//
//
//
//
//
//
pin
pin
pin
pin
pin
pin
pin
6
0
1
2
3
4
5
public void setup(){
pinMode(en1, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(en, INPUT);
pinMode(dir, INPUT);
pinMode(sp1, INPUT);
pinMode(sp2, INPUT);
}
connected
connected
connected
connected
connected
connected
connected
to
to
to
to
to
to
to
L293D EN1 input
L239D IN1 input
L239D IN2 input
EN switch
DIR switch
SP1 switch
SP2 switch

The DC motor is turned ON/OFF based on the
value of the “EN” switch
−If EN = 0  turn OFF the DC motor
−If EN = 1  turn ON the DC motor
if (digitalRead(en) == HIGH) {
// enable DC motor
// direction control
.
.
.
// speed Control
.
.
.
}
else {
// disable DC motor
digitalWrite(en1, LOW);
analogWrite(en1, 0);
}

The direction of the DC motor can be controlled in
a very simple manner as follows:
−If DIR =1  IN1 = 1 and IN2 = 0 (DC motor will rotate
clockwise)
−If DIR =0  IN1 = 0 and IN2 = 1 (DC motor will rotate cclockwise)
// direction control
if (digitalRead(dir) == HIGH) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
}
else {
digitalWrite(in2, HIGH);
digitalWrite(in1, LOW);
}

The speed can be controlled by turning the DC
motor ON/OFF (i.e. setting EN1=0/1) for a
certain duty cycle based on the logic of the SP1
& SP2 switches:
−SP1 & SP2 = 00 (slow 25% duty cycle)
−SP1 & SP2 = 01 (moderate 50% duty cycle)
−SP1 & SP2 = 10 (fast 75% duty cycle)
−SP1 & SP2 = 11 (very fast 100% duty cycle)
// speed control
if ( (digitalRead(sp1) == LOW) && (digitalRead(sp2) == LOW) ) {
// SP1 = LOW and SP2 = LOW (slow 25% duty cycle)
digitalWrite(en1, LOW);
analogWrite(en1, 63);
}
else if ( (digitalRead(sp1) == LOW) && (digitalRead(sp2) == HIGH) ) {
// SP1 = LOW and SP2 = HIGH (moderate 50% duty cycle)
digitalWrite(en1, LOW);
analogWrite(en1, 127);
}
else if ( (digitalRead(sp1) == HIGH) && (digitalRead(sp2) == LOW) ) {
// SP1 = HIGH and SP2 = LOW (fast 75% duty cycle)
digitalWrite(en1, LOW);
analogWrite(en1, 191);
}
else if ( (digitalRead(sp1) == HIGH) && (digitalRead(sp2) == HIGH) ) {
// SP1 = HIGH and SP2 = HIGH (very fast 100% duty cycle)
digitalWrite(en1, LOW);
analogWrite(en1, 255);
}
delay(1);