In many applications, it is important to control the speed of DC motor where precision and protection are essence. 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 Microcontroller based system provides 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 ATmega8 controller to produce PWM wave. By varying the width of this PWM wave, we can control the speed of DC motor. In ATmega8 controller, timer1 and timer2 have PWM mode. In this article we will see how to control the speed of DC motor using timer2 PWM mode.
PWM Based DC Motor Speed Control using Microcontroller Circuit Principle:
The heart of this project is ATmega8 controller. These controllers consist of 2 PWM modes. Now we will see how to generate PWM wave using timer2 PWM mode.
Before writing the program to the PWM mode we need to know the register description of all the registers that are used for PWM mode.
OCR2 register contains an 8 bit value that is continuously compared with counter value.
PWM Program:
How to Generate PWM in 8051 Microcontroller?
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.
Read more: PWM Based DC Motor Speed Control using Microcontroller