Motor Circuit Diagrams

# Interfacing DC Motor with 8051 Microcontroller

In this project, we will delve into the L293D and L298N motor drivers and explore how to integrate them with an 8051 microcontroller for interfacing with DC motors.

When we contemplate operating a robot, one of the first things that comes to mind is the manipulation of DC motors. In robotic applications, the connection between a DC motor and a microcontroller is a fundamental concept. By interfacing a DC motor with a microcontroller, we unlock a multitude of possibilities. This includes the ability to control both the direction and speed of the motor. This article provides a comprehensive guide on employing the AT89C51 controller for DC motor control (applicable to any variant of the 8051 Microcontroller).

### Outline

• Circuit Principle
• A Brief Note on L293D Motor Driver
• A Brief Note on L298N Motor Driver
• Circuit Diagram for Interfacing DC Motor with 8051 Microcontroller and L293D
• Components Required
• Circuit Design
• Algorithm
• Code
• Circuit Simulation Video
• Circuit Diagram for Interfacing DC Motor with 8051 Microcontroller and L298N
• Components Required
• Circuit Design
• Algorithm
• Code
• How to Operate?
• Applications

## Circuit Principle

Operating at 5V, the maximum output current of a microcontroller pin is limited to 15mA. However, most DC motors demand power levels that exceed the capabilities of the microprocessor, and even the reverse electromotive force (emf) generated by the motor has the potential to harm the microcontroller.

Due to these limitations, it is not advisable to directly connect a DC motor to a controller. Instead, a motor driver circuit is employed as an intermediary to link a DC motor to a microcontroller.

For driving DC motors, we are utilizing the L293D and L298N motor driver ICs. These ICs allow us to control two DC motors simultaneously. The L293D Motor Driver can accommodate motor supplies ranging from 4.5 to 36V, with a maximum current of 600mA. On the other hand, the L298N can handle motor supplies up to 46V and can generate a current of 3A.

## A Brief Note on L293D Motor Driver

The L293D is a motor driver IC with four H-bridge units, designed for driving DC motors, as implied by its name. This IC is built upon the H-bridge concept, which is a circuit enabling voltage control over the motor’s direction in both forward and reverse directions.

The L293D features four input pins, and the logic inputs applied to these pins determine the direction of the motors. To activate and operate the two DC motors, it is necessary to set EN1 and EN2 to a high logic level.

• IN1=0 and IN2=0 ->  Motor1 idle
• IN1=0 and IN2=1 -> Motor1 Anti-clock wise direction
• IN1=1 and IN2=0 -> Motor1 Clock wise direction
• IN1=1 and IN2=1 -> Motor1 idle
• IN3=0 and IN4=0 -> Motor2 idle
• IN3=0 and IN4=1 -> Motor2 Anti-clock wise direction
• IN3=1 and IN4=0 -> Motor2 Clock wise direction
• IN3=1 and IN4=1 -> Motor2 idle

## A Brief Note on L298N Motor Driver

The L298N Motor Driver Module is more frequently used driver IC’s now-a-days. The current and voltage ratings of L298N are higher than that of L293D Motor Driver.

## Circuit Diagram for Interfacing DC Motor with 8051 Microcontroller and L293D

### Components Required

• AT89C51 (8051 Microcontroller)
• 8051 Programmer
• programming cable
• 12V DC battery or Adaptor
• L293D motor driver
• DC motor
• Electrolytic capacitor – 10uF
• 2 Ceramic capacitors – 33pF
• 10k resistors (1/4 watt) – 4
• Push Buttons – 3
• Connecting wires.

## Circuit Design

In the aforementioned circuit design, the primary components include the AT89C51 microcontroller and the motor driver. To control the motor’s directions, the input pins IN1 and IN2 of the motor driver are connected to P3.0 and P3.1, respectively. The L293D’s output terminals are linked to a DC motor for driving purposes, with the EN1 pin connected to a 5V DC supply to power the motor.

Switches are connected to the microcontroller’s P2.0 and P2.1 pins in a pull-down configuration. The first switch facilitates clockwise motor rotation, while the second switch enables counterclockwise motor rotation. Additionally, pins 8 and 16 of the motor driver are connected to the +5V supply.

## Algorithm

1. Declare P2.0 and P2.1 as inputs and P3.0 and P3.1 as outputs.
2. Now check weather the first button is pressed or not. If pressed, then send logic one to P3.0.
3. Next check whether the second button is pressed or not. If pressed, then send logic 1 to P3.1 otherwise send 0 to port

## Circuit Diagram for Interfacing DC Motor with 8051 Microcontroller and L298N

### Components Required

• AT89C51 (8051 Microcontroller)
• 8051 Programmer
• Programming cable
• 12V DC battery or Adaptor
• L298N Motor Driver Module
• 12V DC motor
• Electrolytic capacitor – 10µF
• 2 Ceramic capacitors – 33pF
• 10KΩ Resistor (1/4 watt)
• 1KΩ Resistors (1/4 watt) – 3
•  8 x 1KΩ Resistor Pack
• Push Buttons – 4
• Connecting wires.

## Circuit Design

Similar to the previous circuit, the IN1 and IN2 pins of the L298N Motor Driver are connected to the microcontroller’s Port 0 pins, specifically P0.0 and P0.1. Additionally, the output terminals, OUT1 and OUT2, of the Motor Driver Module are connected to a 12V DC motor.

To control the motor’s rotation direction, three push buttons will be utilized, and they will be connected to Port 0 pins P0.5, P0.6, and P0.7.

## Algorithm

1. P0.5 and P0.6 should be inputs, whereas P0.0 and P0.1 should be outputs.
2. Check to see if the first button has been pressed. If the button is pressed, send logic 1 to P0.0 and logic 0 to P0.1. The motor will rotate in a forward direction as a result of this.
3. Next, look to see if the second button is pushed. If the button is pressed, send logic 1 to P0.1 and logic 0 to P0.0 to reverse the motor’s rotation.

## How to Operate?

1. The programme should be burned to the 8051 microcontroller.
2. Make the connections according to the circuit schematics.
3. Make sure there is no direct power supply from the battery to the controller while making the connections.
4. Turn on the board supply, and the motor should now be stationary.
5. When you press the first button, the motor will rotate in a clockwise manner.
6. The motor now turns in an anticlockwise direction after pressing the second button.
7. Turn off the power to the board.

## Applications

• This concept is used in robots to control the robot directions.
• Used to control the speed of the DC motor.
• It is used in the applications where we need to drive the high voltage motors.

Check Also
Close

Close
Close