IES_Lab_15_DcMotor
IES_Lab_15_DcMotor
LAB EXPERIMENT # 15
PERFORMANCE OBJECTIVE:
At the conclusion of this experiment, understudy will be able to:
• Understand the principles of DC motor control using an Arduino.
• To regulate motor speed using Pulse Width Modulation (PWM).
• Implement direction control using motor driver.
REQUIRED TOOLS:
• Arduino IDE software
• Proteus Software
• DC Motor
• Motor Driver LM293
• Arduino UNO
Introduction:
A motor converts electrical energy into mechanical energy. It's widely used due to its ability to drive
power machinery and appliances provide a constant torque and speed. There are several types of motors,
each designed for different applications. Here are the most common ones:
1. DC Motors: Operate using direct current, often controlled using PWM for speed regulation. Small DC
motors ideal for use in applications where speed control is required such as in small toys, models, robots
and other such electronics circuits.
2. AC Motors: Operate using alternating current, widely used in industrial and household applications.
3. Stepper Motors: Move in precise steps, commonly used in CNC machines and 3D printers.
4. Servo Motors: Provide precise control of position, speed, and torque, used in robotics and automation.
1
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)
+
-
In this laboratory activity, we will interface motors with the Arduino board (UNO) and drive it from
your using Arduino. Do not drive the motor directly from Arduino board pins. This may damage
the board. Use a driver circuit.
Motor Drivers: Motor drivers are important components in controlling electric motors efficiently.
They act as agents between the microcontroller and the motor, regulating power flow, direction, and
speed.
• H-Bridge Motor Drivers: Commonly used for DC motors, allowing them to move forward
and backward.
• Stepper Motor Drivers: Designed for stepper motors, providing precise control over
movement.
• Servo Motor Drivers: Used for servo motors, typically requiring pulse-width modulation
(PWM) signals.
• Brushless DC (BLDC) Motor Drivers: Used in applications requiring high efficiency and
minimal maintenance.
2
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)
PWM (Pulse Width Modulation) is a widely used technique for controlling the speed of a DC motor.
It works by driving the motor with a series of “ON-OFF” pulses (digital pulses) and varying the duty
cycle, the fraction of time that the output voltage is “ON” compared to when it is “OFF”, of the pulses
while keeping the frequency constant. The power applied to the motor can be controlled by varying the
width of these applied pulses and thereby varying the average DC voltage applied to the motor’s
terminals. By changing or modulating the timing of these pulses the speed of the motor can be
controlled, i.e., the longer the pulse is “ON”, the faster the motor will rotate and likewise, the shorter
the pulse is “ON” the slower the motor will rotate. The fraction for which the signal is ON over a period
is known as a duty cycle.
3
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)
Frequency of Signal
The frequency of a signal determines how fast the PWM completes a cycle. By repeating this ON-OFF
pattern at a fast-enough rate, and with a certain duty cycle, the output will appear to behave like a
constant voltage analog signal when providing power to devices.
Example: If we want to create a 2V analog signal for a given digital source that can be either high (on)
at 5V, or low (off) at 0V, we can use PWM with a duty cycle of 40%. It will provide output 5V for 40%
of the time. If the digital signal is cycled fast enough, then the voltage seen at the output appears to be
the average voltage. If the digital low is 0V (which is usually the case) then the average voltage can be
calculated by taking the digital high voltage multiplied by the duty cycle, or 5V x 0.4 = 2V.
4
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)
Technical Specifications:
Motor output voltage 5V – 35V
Motor output voltage (Recommended) 7V – 12V
Logic input voltage 5V – 7V
Continuous current per channel 2A
Max Power Dissipation 25W
Example 1: Write a program that move dc motor in forward direction for 2 second and vice versa.
void setup() {
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
5
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)
void loop() {
directionControl();
delay(2000);
}
Example 2: Write a program that move dc motor in both direction with accelerating and
deaccelerating manner.
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
void loop() {
speedControl();
delay(1000);
}
6
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)
Lab Tasks:
1. Write a program that control the movement of dc motor with three push buttons connected on
pin 9, 10 and 11. where first push button makes the motor rotate clockwise, second button
makes it rotate counterclockwise, and third button stop the motor. The speed of the motor should
15
be equal to X (Duty Cycle = 𝑋 = 13 (𝑟𝑜𝑙𝑙𝑛𝑢𝑚 ) + 125))
Note: - Attach either the Proteus simulation or hardware results of labs tasks. Also, attach programming
code and simulation result snapshots for exercise tasks along with the handouts.