Motor Circuit Diagrams

PWM Based DC Motor Speed Control using Microcontroller

In this project, I’ll teach you how to use an 8051 Microcontroller to generate a PWM signal as well as a PWM-based DC Motor Speed Control.

Outline

  • 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
    • Circuit Components
    • PWM based DC Motor Speed Control using Microcontroller Circuit Design
  • Code
  • How to Operate the Circuit?
  • Advantages
  • Applications

Introduction

In various applications demanding precision and safety, the ability to control the speed of a DC motor is of utmost importance. To achieve this speed control, we employ a method known as PWM (Pulse Width Modulation).

Controlling the speed of a DC motor can be accomplished through mechanical or electrical means, but these methods often require extensive hardware implementation. Conversely, a Microcontroller-based system offers a straightforward means of regulating DC motor speed.

PWM Based DC Motor Speed Control using Microcontroller

In a previous demonstration, we explored PWM-based DC motor speed control without involving a microcontroller. In this instance, we will revisit the experiment with the inclusion of a microcontroller.

To achieve this, we will employ an 8051 controller to produce PWM signals. By manipulating the pulse width of these PWM signals, we can effectively regulate the DC motor’s speed. The timers within the 8051 microcontroller will be harnessed to generate the PWM waveform.

This tutorial will delve into the utilization of timers within the 8051 microcontroller for PWM signal generation and demonstrate how this signal can be employed to govern the speed of a DC motor.

PWM Based DC Motor Speed Control using Microcontroller Circuit Principle

The focal component of this project is the 8051 microcontroller. If you have prior experience with the 8051 Microcontroller, you’ll recall that it does not feature dedicated PWM circuitry for enabling PWM Mode. Consequently, to create a PWM signal, we resort to employing Timers to manage the activation and deactivation of the I/O pins.

In this project, I will harness Timer0 and Timer Interrupt on an 8051 Microcontroller to generate the PWM signal.

How to Generate PWM in 8051 Microcontroller?

While modern microcontrollers like AVR (Arduino), ARM, PIC, and others come equipped with dedicated PWM hardware and pins for effortless PWM mode activation, this feature is absent in 8051 microcontrollers. So, how do you go about programming an 8051 microcontroller to generate PWM?

To accomplish this, you’ll need to make use of Timers and interrupts on the 8051 Microcontroller. Specifically, we configure the 8051’s Timer0 in Mode0. By meticulously adjusting the High and Low values, we can maintain a consistent signal period.

Circuit Diagram of PWM Based DC Motor Speed Control using Microcontroller

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

PWM based DC Motor Speed Control using Microcontroller Circuit Design

The circuit comprises one 8051 microcontroller (along with the necessary circuitry for the oscillator and reset functions), an L298N Motor Driver Module, a DC Motor, and several push buttons.

The OUT1 and OUT2 pins of the L298N Motor Driver Module are connected to a 12V DC Motor. The IN1 and IN2 pins of the motor driver are linked to +5V (VCC) and GND, respectively. Furthermore, the EN1 pin of the motor driver is connected to Port0 Pin P0.0.

Port0 Pins P0.4, P0.5, P0.6, and P0.7 are connected to four push buttons.

When connecting switches to the microcontroller, two common configurations are employed: pull-up and pull-down setups.

Pull-up setup: In a pull-up configuration, the microcontroller pin is pulled HIGH to LOGIC 1, while the button is connected to GND. When the button is pressed, a LOGIC 0 signal is sent to the microcontroller pin.

Pull-down setup: In a pull-down configuration, the microcontroller pin is pulled down to LOGIC 0, and the button is connected to VCC. When the button is pressed, a LOGIC 1 signal is sent to the microcontroller pin.

In our circuit, we have implemented a pull-up configuration. To determine whether the button is pressed or not, we need to detect a logic 0 signal.

Code

  #include<reg51.h>
   
  sbit PWM_Pin = P0^0;
  sbit low = P0^4;
  sbit medium = P0^5;
  sbit high = P0^6;
  sbit off = P0^7;
   
  void InitPWM_timer(void);
   
  unsigned char PWM = 0;
  unsigned int temp = 0;
  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;
  }
  }
  }
   
   
  void InitPWM_timer (void)
  {
  TMOD &= 0xF0;
  TMOD |= 0x01;
   
  TH0 = 0x00;
  TL0 = 0x00;
   
  ET0 = 1;
  EA = 1;
   
  TR0 = 1;
  }
   
   
  void Timer0_ISR (void) interrupt 1
  {
  TR0 = 0;
   
  if(PWM_Pin==1 && a==0)
  {
  PWM_Pin = 0;
  temp = (255-PWM);
  TH0 = 0xFF;
  TL0 = 0xFF – temp&0xFF;
  }
  else if(PWM_Pin==0 && a==0)
  {
  PWM_Pin = 1;
  temp = PWM;
  TH0 = 0xFF;
  TL0 = 0xFF – temp&0xFF;
  }
   
  TF0 = 0;
  TR0 = 1;
  }

How to Operate the Circuit?

  1. Connect the development board to a 12V battery or an adaptor.
  2. Turn on the power.
  3. With the help of a programmer, burn the hex file to the 8051 controller.
  4. As shown in the circuit diagram, make the appropriate connections.
  5. Now turn on the power and turn on switch 1. The beginnings may be seen revolving, but they are barely at 40% capacity.
  6. When switch 2 is pressed, the motor runs at a slightly higher than half-speed (60 percent duty cycle).
  7. The motor will rotate at maximum speed if switch 3 is pressed (100 percent duty cycle).
  8. Press switch 4 to turn off the motor.

Advantages

  • Using this PWM method, we can save the power.

Applications

  • Used in industries to control the speed of motors.
  • Used in shopping malls.
  • We can use this concept to control the light intensity.
Tags

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button
Close
Close