0% found this document useful (0 votes)
8 views30 pages

Lecture 4

This document is a lecture on DC motor driver circuits within the Microcontrollers course at Menoufia University. It discusses the importance of using driver circuits to interface microcontrollers with DC motors, methods for connecting loads to transistors, and how to select appropriate transistors for motor control. Additionally, it includes programming examples for controlling a tank and an automatic gate using PIC microcontrollers.

Uploaded by

slamhayman209
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)
8 views30 pages

Lecture 4

This document is a lecture on DC motor driver circuits within the Microcontrollers course at Menoufia University. It discusses the importance of using driver circuits to interface microcontrollers with DC motors, methods for connecting loads to transistors, and how to select appropriate transistors for motor control. Additionally, it includes programming examples for controlling a tank and an automatic gate using PIC microcontrollers.

Uploaded by

slamhayman209
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/ 30

Menoufia University

Faculty of Electronic Engineering


Industrial Electronics and Control Engineering program

Microcontrollers– ACE 225


Lecture 4

Course Lecturer

Spring 2025
Sessions policy

‫تذكر دائما‬

3
CHAPTER 3 7Segments and
DC Motors
DC Motor Driver Circuits

What is the importance of a DC motor driver circuit?


• DC motors need currents greater than the current can supply from controller such as
Microcontrollers, Arduino, … .

• DC motor driver circuit acts as interface circuit between controllers with small current
and DC motors with high currents.

Note: If we directly connect motors to the microcontrollers, they can be damaged.

➢ DC motor driver circuit can be

• Using transistors or using ICs such as L293D or L298

• Using Relays.
Single direction transistor motor driver

• When input signal= 5V,


the motor is turned on.
NPN

Input Signal

• When input signal=0V,


the motor is turned off.
➢ How to connect the loads to transistors?

Must be 5V
Positive voltage value >0.7

Desired circuit

0V ON
5V
OFF
➢ The ratings of the transistor must be
known to a void the problems which
can be occurred. Hence, the
transistor current must be greater
than the maximum current drawn
by the motor.
Datasheet for some DC motor

Direct connection
If the datasheet is not
available how to measure
the maximum current of
the DC motor ?

1- Measure the DC Motor Resistance


𝑹=𝟖𝜴
2- The DC Motor Supply Voltage
𝑽 = 𝟏𝟐 𝒗𝒐𝒍𝒕
3- Calculate the Max Motor current
𝑽 𝟏𝟐
𝑰𝒎 = 𝑰𝒄 = = = 𝟏. 𝟓 𝑨
𝑹 𝟖
How to choose the best transistor for your DC motor ?

Some examples for NPN transistor


If we have DC motor with
Voltage 12V
Maximum current 1.5 A

What is the appropriate


transistor ?

Now, we want to calculate


the resistance must be
connected to BASE of the
transistor.
1- Calculate 𝑰𝑩
𝑰𝒄 𝟏. 𝟓
𝑰𝑩 = = = 𝟏. 𝟓 𝒎𝑨
𝑯𝒇𝒆 𝟏𝟎𝟎𝟎

DESIRED to be 5 to 10 times hence,


𝑰𝑩 = 𝟓 ∗ 𝑰 = 𝟓 ∗ 𝟏. 𝟓 = 𝟕. 𝟓 𝒎𝑨
R
TIP 120
maximum rating base current ‫ ال يتعدى قيمة‬base ‫هنا البد أن تضمن ان تيار‬

2- Calculate 𝑹𝑩
𝑽𝒊𝒏 − 𝑽𝑩 𝒔𝒂𝒕 𝟓 − 𝟏. 𝟓
𝑹𝑩 = = = 𝟒𝟔𝟔 𝛀
𝑰𝑩 𝟕. 𝟓

Real
𝑹𝑩 = 𝟏 𝐭𝐨 𝟒. 𝟕 𝒌𝛀 𝐟𝐨𝐫 𝐓𝐈𝐏𝟏𝟐𝟎
Program 1
Design an embedded system using PIC 16F877A to control the following tank. As soon as the
low-level sensor indicates that the tank is empty, the pump is ON until the high-level sensor
indicates that the tank is full. Then the valve is ON until the low-level sensor indicates that the
tank is empty and repeat the operation.
#define start_switch portb.f0
#define LL portb.f1
#define HL portb.f2
#define pump portd.f2
#define valve portd.f3
void main()
{
trisd=0; //define portd as output
trisb=0b00000111; //define RB0,RB1and RB2 as input
portd=0;portb=0; // initialization
while(start_switch==0); //check the start switch
for(;;)
if(LL==1)
{pump=1;valve=0;}
if(HL==1)
{pump=0;valve=1;}
}
}
Two direction transistor motor driver (H-bridge)

H-bridge using
4 NPN transistors
Single direction transistor/relay motor driver
Two direction transistor/relay motor driver
Program 2
Write a PIC 16f877A program to control automatic gate application in the following Figure. The gate
as shown in the following figure has:

1. Two sensors s1 and s2 for entry and exit, respectively.


2. Two limit switches LS1 and LS2 to know the end of opening and closing the gate.
3. Dc motor to open and close the gate.
4. Start and stop pushbutton.
S2

S1
#define s1 PORTB.F7
#define s2 PORTB.F6 check: if(ls2==1)
#define ls1 PORTB.F5 {
#define ls2 PORTB.F4 close=0;
#define open PORTd.F1 delay_ms(5);
#define close PORTd.F2 goto test;
void main() }
{ if(s1==1||s2==1)
TRISD=0; //Define for d1, d2 as output {
TRISB=0b11110000; //Define b7,b6,b5,b4 as close=0; delay_ms(2000);
input goto op;
open=0; }
close=0; goto check;
test: if(s1==1 || s2==1) }
{ goto test;
op: open=1; }
while(ls1==0);
open=0; delay_ms(10000);close=1;
Using L293D or L298
➢L293D and L298 are dual H-bridge motor driver ICs.

• By this IC motor driver, we


control the rotation of two
motors in both clockwise and
anti-clockwise direction.

• Pin no. 1 is used to enable H-


bridge driver 1 (on LEFT side).

• Pin no. 9 is used to enable H-


bridge driver 2 (on RIGHT side).
• The concept of enable bits, if you want to
use a particular H bridge you must give a high
logic to corresponding enable pins along with
the power supply to the IC.

• The enable pin can also be used to control

13
speed of the motor using PWM module.

• Pin 16: VCC1 Power supply pin for L293D (5V)

• Pin 8: VCC2 Power supply for motor


(i.e., If your motor is operated by 12V, apply 12V on this pin)

• Pins 4,5,12,13: Connect them to GND

• Pins 2,7,10,15: These are the input pins which


receive the signals from microcontroller or other
circuits to control the direction of the motor.
The hardware interface using L293D IC to control the direction of the DC motor as shown in
the following figure:
Optocoupler / Optoisolator
Thank You

32

You might also like