You are on page 1of 5

Experiment (2)

DC Motor Control (Direction and Speed)


Introduction
Controlling direction and speed of DC motor is very essential in many applications like:
1- Robotic application – to change direction and speed of moving robot.
2- Industrial application – to change direction and speed of rotating machinery.
3- Domestic application – to vary speed of portable fan.
4- Defense application – to rotate radar, automatic gun, tank gun in either direction
5- Communication application – rotate dish antenna upward – downward or clockwise –
anticlockwise.
In this experiment, we are going to build a bridge to control the direction of a DC motor, then we
will explain how to use L298N H-bridge module and Arduino to control its speed and direction.

Objectives
This experiment is to be performed in order to:
1- Learn how to build an H-bridge from discrete components.
2- Familiarize the students with the function of H-bridge module.
3- Control both the direction and speed of DC motors.
4- Illustrate the principle of pulse width modulation (PWM).

Theory
To control a DC motor in direction and speed it is required to use special drive circuits such as
H-bridge, which is an electronic circuit that enables a voltage to be applied across a load in either
direction. Figure 1 shows a simplified structure for H-Bridge connections.

Figure 1: H-bridge structure


H-bridges can be built from discrete components; transistors or relays, figure 2 shows an H-
bridge built from npn transistors and freewheeling diodes. Also, H-bridges are available as
integrated circuits (as L298N driver that will be used in this experiment).
Mechatronics Systems Design Lab

Figure 2: An H-bridge built from 4 transistors


L298N is a high voltage, high current dual- full bridge driver designed to drive various loads
such as DC motors, see figure 3.
Note: Refer to L298N datasheet for more details.

Figure 3: L298N dual motor controller module

The following list illustrates the function of each terminal in figure 3:


1. DC motor 1 "+", (connection A+).
2. DC motor 1 "-", (connection A-).
3. 12V jumper: remove this if using a supply voltage greater than 12V DC. This enables
power to the onboard 5V regulator.
4. Connect your motor supply voltage here, maximum of 35V DC. Remove 12V jumper if
>12V DC.
5. Ground (GND).

2
Mechatronics Systems Design Lab

6. 5V output if 12V jumper in place, ideal for powering your Arduino (etc.).
7. DC motor 1 enable jumper. Connect to PWM output for DC motor speed control.
8. IN1
9. IN2
10. IN3
11. IN4
12. DC motor 2 enable jumper. Connect to PWM output for DC motor speed control.
13. DC motor 2 "+", (connection B+).
14. DC motor 2 "-", (connection B-).

Pulse-width modulation (PWM) technique that controls the width (in time) of an electrical pulse,
formally the pulse's duration, based on modulator signal information. It is used when a digital
system needs to control a system that expects an analog signal of varying amplitude. A typical
example is a 24V motor, the speed of the rotor can be controlled by changing the voltage from
low (0V) to high (24V). The idea from PWM is to pass the rotor always 24V but in discrete
pulses as shown in figure 4.

Figure 4: A PWM signal with three different duty cycles


The advantage of controlling a motor with PWM instead of instead of a real analog signal is that
the full torque of the motor can be used. In DC motors, there is a linear relationship between the
voltage supplied and the torque obtained from the motor (the higher the voltage, the higher the
torque). If small motor is used for moving a loaded car and a small analog voltage is used, the
motor will not move, because of the load and friction between the wheels and the floor. If a
PWM signal is used, it will give a full kick to the motor for a short time and the motor will rotate
with its full torque. Speed is controlled by spacing as needed (by adjusting the duty cycle of the
signal). It is important here to be noticed that the PWM signal is not used to directly drive the
load (motor), it is used to control a switch, for example a power transistor that delivers the
needed power to the load.

3
Mechatronics Systems Design Lab

Equipment
1. DC Power Supplies.
2. L298N driver.
3. Wires.
4. Arduino.
5. DC motor.
6. TIP120 and TIP 125 transistors.
7. Diodes.

Procedures
 Part 1: DC motor direction control
a- Using 4 transistors:
1) Build an H-bridge using 4 transistors.
2) the base resistance (R1, R2, R3, and R4) EQUAL TO 1 KΩ.
3) Connect the DC motor as shown in figure 5.

Figure 5: H-Bridge circuit using 4 transistors


4) Connect a 5 V DC power supply to A and connect B to the ground. Notice the direction
of the motor.
5) Switch off the 5 V power supply and reverse the connection in step 4 and notice the
direction of the motor.
b- Using H-bridge module:
1) Connect the motor to the A connection on L298N module.
2) Set the power supply to 6 VDC and connect it to the module.
6) Connect a 5 V DC power supply to IN1 and connect IN2 to the ground Notice the
direction of the motor.

4
Mechatronics Systems Design Lab

7) Switch off the 5 V power supply and reverse the connection in step 6 and notice the
direction of the motor.
 Part 2: DC motor speed control using H-bridge module
1) Connect the circuit as illustrated in part 1-b.
2) Build PWM signal using Function Generator, then connect the function generator output
to the motor enable pin on the H-bridge module.
3) Set different duty cycle for the square wave on the output of the function generator and
notice the speed of the motor.

Discussion and Conclusions


1- What is the component that can be used instead of transistor in part 1-b?
2- What are diodes (D1, D2, D3 and D4) in the circuit shown in figure 5 called? Why do we
use these diodes?
3- Illustrate the principle operation of an H-bridge to control the direction of DC motors?
Hint: Use a truth table to show the possible state combinations for the switches.

You might also like