Documente Academic
Documente Profesional
Documente Cultură
Microcontroller
this project, I will show you how to generate a PWM signal using 8051 Microcontroller and also
a PWM based DC Motor Speed Control using Microcontroller.
table of Contents
Introduction
PWM Based DC Motor Speed Control using Microcontroller Circuit Principle
How to Generate PWM in 8051 Microcontroller?
Circuit Diagram of PWM Based DC Motor Speed Control using Microcontroller
o Circuit Components
o PWM based DC Motor Speed Control using Microcontroller Circuit Design
Code
How to Operate the Circuit?
Advantages
Applications
Introduction
It is important to control the speed of DC motor in many applications, where precision and
protection are essential. Here we will use a technique called PWM (Pulse Width Modulation) to
control the speed of DC motor.
We can achieve speed control of DC motor using mechanical or electrical techniques but they
require large size hardware to implement but a Microcontroller based system provides an easy
way to control the speed of DC motor.
Earlier, we have already seen how to control the speed of DC motor using PWM without
Microcontroller. Here, we do the same experiment by using a microcontroller.
For that purpose, here we will use 8051 controller to produce PWM wave. By varying the width
of this PWM wave, we can control the speed of DC motor. In 8051 microcontroller, the timers
are used to generate the PWM wave.
In this article we will see how to generate a PWM Signal using timers in 8051 Mocrocontroller
and also how to control the speed of DC motor using tthat PWM signal.
The heart of this project is the 8051 Microcontroller. If you have worked with any variant of the
8051 Microcontroller, you might remember that 8051 doesn’t have a dedicated PWM circuitry to
enable PWM Mode. So, in order to generate a PWM Signal, we have make use of Timers and
switch the I/O pins ON and OFF using the timers.
In this project, I will make use of Timer0 in 8051 Microcontroller along with Timer Interrupt to
produce the PWM Signal.
Most modern microcontrollers like AVR (Arduino, for example), ARM, PIC, etc. have a
dedicated PWM hardware and pins to activate PWM mode instantly. However, 8051
Microcontrollers do not have this provision. So, how to generate PWM in 8051 Microcontroller?
For this we have to use Timers and Interrupts in 8051 Microcontroller. The Timer0 of 8051 is
configured in Mode0. By carefully adjusting the High and Low levels, we can maintain a
constant period of the signal.
Circuit Components
8051 Microcontroller
11.0592 MHz Crystal
Capacitors – 33pF x 2, 10µF
Resistors – 1KΩ x 4, 10KΩ x 2
12V DC motor
L298N Motor Driver
Push Buttons x 5
1KΩ x 8 Pull-up Resistor Pack
Serial cable
12V battery or adaptor
Connecting wires
The circuit consists of one 8051 Microcontroller (and its supporting circuitry related to oscillator
and reset), L298N Motor Driver Module, a DC Motor and a few push buttons.
A 12V DC Motor is connected to the L298N Motor Driver Module at its OUT1 and OUT2 Pins.
The IN1 and IN2 pins of the motor driver are connected to +5V (VCC) and GND. The EN1 pin
of the Motor driver is connected to Port0 Pin P0.0.
Four Push Buttons are connected to Port0 Pins P0.4, P0.5, P0.6 and P0.7.
Generally, we can interface switches to the micro controller in two configurations; one is Pull-up
configuration and the other is pull-down configuration.
Pull-down configuration: In pull down configuration, the microcontroller pin pulled down to
LOGIC 0 and the button is connected to VCC. When button is pressed, microcontroller pin
receives LOGIC 1.
In our circuit we are using pull up configuration. So, we need to check for logic 0 in order to
know whether the button is pressed or not.
Code
#include<reg51.h>
void InitPWM_timer(void);
char a=1;
int main(void)
low=1;
medium=1;
high=1;
off=1;
PWM_Pin=0;
InitPWM_timer();
while(1)
{
if(low==0)
PWM=102;
a=0;
else if(medium==0)
PWM=153;
a=0;
else if(high==0)
PWM=255;
a=0;
else if(off==0)
a=1;
PWM_Pin=0;
}
TMOD |= 0x01;
TH0 = 0x00;
TL0 = 0x00;
ET0 = 1;
EA = 1;
TR0 = 1;
TR0 = 0;
PWM_Pin = 0;
temp = (255-PWM);
TH0 = 0xFF;
PWM_Pin = 1;
temp = PWM;
TH0 = 0xFF;
TF0 = 0;
TR0 = 1;
Advantages
Applications
Filed Under: 8051 Microcontroller, Electronics, Embedded, Free Project Circuits, Mini Projects
Leave a Reply
Your email address will not be published. Required fields are marked *