[go: up one dir, main page]

0% found this document useful (0 votes)
30 views7 pages

IES_Lab_15_DcMotor

This document outlines a lab experiment for electrical engineering students at Mehran University, focusing on interfacing and controlling a DC motor using an Arduino. It covers the principles of DC motor control, speed regulation through Pulse Width Modulation (PWM), and direction control using motor drivers. The document includes required tools, technical specifications, example programs, and lab tasks for students to complete.

Uploaded by

Mahnoor Channar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

IES_Lab_15_DcMotor

This document outlines a lab experiment for electrical engineering students at Mehran University, focusing on interfacing and controlling a DC motor using an Arduino. It covers the principles of DC motor control, speed regulation through Pulse Width Modulation (PWM), and direction control using motor drivers. The document includes required tools, technical specifications, example programs, and lab tasks for students to complete.

Uploaded by

Mahnoor Channar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DEPARTMENT OF ELECTRICAL ENGINEERING

MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO


Introduction to Embedded Systems (4th Semester)

LAB EXPERIMENT # 15

Roll No. ________________ Signature of Instructor: _______________________ Submission Date: _______________

INTERFACING AND CONTROL OF DC MOTOR WITH ARDUINO

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.

• Brushed DC Motor: Uses brushes for commutation, simple and inexpensive.


• Brushless DC Motor: More efficient and durable, commonly used in drones and electric vehicles.

2. AC Motors: Operate using alternating current, widely used in industrial and household applications.

• Induction Motor: Works on electromagnetic induction, found in fans and refrigerators.


• Synchronous Motor: Runs at a constant speed synchronized with the power supply frequency.

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.

DC Motor: A DC motor (Direct Current motor) is the most common type of


motor; this is illustrated in Figure 1. DC motors normally have just two leads, one
positive and one negative. If you connect these two leads directly to a battery, the
motor will rotate. If you switch the leads, the motor will rotate in the opposite
direction. A common method of controlling direction of a DC motor is to use an
“H-Bridge”. This type of controller allows you to change the polarity of the
current sent to the motor.

1
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)

+
-

Figure 15.1: (a) DC Motor (b) DC Motor with Gear Box

Figure 15.2: DC Motor in a wheelchair

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.

There are several types of motor drivers, including:

• 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)

Figure 15.3: Motors Drivers

Speed Control of DC Motor:


DC motor speed can be controlled using several techniques, depending on the type of motor and the
application. Here are the three main methods:
1. Armature Voltage Control – By varying the voltage supplied to the motor’s armature, speed
can be controlled effectively. This method is common in industrial applications and offers
smooth control.
2. Field Flux Control – Adjusting the current in the field winding changes the magnetic flux,
which affects the speed. Increasing the field current slows down the motor; while decreasing it
increases the speed.
3. Pulse Width Modulation (PWM) Control – Used in modern electronics, PWM controls speed
by rapidly switching the power supply on and off, adjusting the effective voltage and current
delivered to the motor.

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.

Figure 15.4: Variable duty cycle PWM signals

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.

PWM Pins of Arduino Uno


Arduino Uno has 6 8-bit PWM channels. The pins with
symbol ‘~’ represent that it has PWM support. These PWM
pins are shown in below image.

Interfacing of Motor with Arduino

Interfacing of Motor with Arduino using LM293 IC

4
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
Introduction to Embedded Systems (4th Semester)

L298N Dual H-Bridge Motor Driver


The L298 motor driver module is a useful component
for controlling DC and stepper motors. This module
is based on the H-bridge configuration, which allows
you to control the direction and speed of motors
efficiently. It is ideal for robotic applications and well
Arduino Functions for PWM

suited for connection to a microcontroller requiring


just a couple of control lines per motor. The L298N
module has 11 pins that allow it to communicate with
the microcontroller. The pinout is as follows:

• IN1 & IN2: Input pins for Motor A to


control its spinning direction.
• IN3 & IN4: Input pins for Motor B to
control its spinning direction.
• ENA & ENB: Enable pins for PWM signals to control the speed of Motor A and Motor B.
• OUT1 & OUT2: Output pins for Motor A.
• OUT3 & OUT4: Output pins for Motor B.
• 12V: Power input for the motors.
• 5V: Supplies power for the internal logic circuitry.
• GND: Ground pin.

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

Arduino Analog Pin Function:


✓ analogWrite (pin, duty cycle)
It is used to generate PWM or output analog value to a specified PWM channel.
pin – pin on which we want to generate pwm or analog signal.
duty cycle – it lies in between 0 (0%, always off) – 255 (100%, always on).

e.g. analogWrite (3, 127) //generates pwm of 50% duty cycle

Example 1: Write a program that move dc motor in forward direction for 2 second and vice versa.

int enA = 3; //Out 1 PWM signal pin


int in1 = 4;
int in2 = 5;

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)

// Turn off motors - Initial state


digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}

void loop() {
directionControl();
delay(2000);
}

// This function lets you control spinning direction of motors


void directionControl() {
// Set motors to maximum speed
// For PWM maximum possible values are 0 to 255
analogWrite(enA, 255);
analogWrite(enB, 255);

// Turn on motor A in forward direction


digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
delay(2000);

// Now change motor directions


digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
delay(2000);

// Turn off motors


digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}

Example 2: Write a program that move dc motor in both direction with accelerating and
deaccelerating manner.

int enA = 3; //Out 1 PWM signal pin


int in1 = 4;
int in2 = 5;
void setup() {
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);

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)

// This function lets you control speed of the motors


void speedControl() {
// Turn on motors
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

// Accelerate from zero to maximum speed


for (int i = 0; i < 256; i++) {
analogWrite(enA, i);
analogWrite(enB, i);
delay(50);
}

// Decelerate from maximum speed to zero


for (int i = 255; i >= 0; --i) {
analogWrite(enA, i);
analogWrite(enB, i);
delay(20);
}

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.

You might also like