Interfacing DC Motor with 8051 Microcontroller

We’ll learn about L293D and L298N motor drivers in this project, as well as how to use them to interface a DC motor with an 8051 microcontroller.

The first thing that springs to mind when we think about operating a robot is manipulating DC motors. In robotic applications, connecting a DC motor to a microcontroller is a crucial notion. We can do a lot with a DC motor by connecting it to a microcontroller. For example, we can control the direction and speed of the motor. This article explains how to use the AT89C51 controller to control a DC motor (or any variant of 8051 Microcontroller).

Circuit Principle

At 5V, the microcontroller pin’s maximum output current is 15mA. However, the power needs of most DC motors are beyond the microprocessor’s capabilities, and even the reverse emf (electromotive force) created by the motor can harm the microcontroller.

As a result, connecting a DC motor to a controller directly is not a good idea. As a result, we employ a motor driver circuit to connect a DC motor to a microcontroller.

To drive DC motors, we’re utilizing L293D and L298N motor driver ICs. We can drive two DC motors at the same time with these ICs. The motor supply for the L293D Motor Driver is changeable between 4.5 and 36V, with a maximum current of 600mA. The motor supply of the L298N is up to 46V and can generate a current of 3A.

A Brief Note on L293D Motor Driver

The L293D is a quadruple H-bridge motor driver that is used to drive DC motors, as the name implies. This IC is based on the H-Bridge idea. The H-bridge is a circuit that permits voltage to control the motor direction in either direction.

The L293D has four input pins. The direction of the motors is determined by the logic inputs supplied to these pins. To operate the two DC motors, EN1 and EN2 must be high.

• 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 by driver IC’s nowadays. The current and voltage ratings of L298N are higher than that of the 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

The at89c51 microcontroller and motor driver are the main components in the circuit design above. To regulate the motor directions, the motor driver input pins IN1 and IN2 are linked to P3.0 and P3.1, respectively. The output terminals of the L293D are linked to a DC motor. To drive the motor, the EN1 pin is connected to a 5V DC supply.

Switches are linked to the Microcontroller’s P2.0 and P2.1 in a pull-down configuration. The first switch rotates the motor clockwise, and the second switch rotates the motor counterclockwise. The motor driver’s 8th and 16th pins 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

The IN1 and IN2 of the L298N Motor Driver are linked to the Microcontroller’s Port 0 Pins P0.0 and P0.1 in the same way as in the previous circuit. The Motor Driver Module’s OUT1 and OUT2 terminals are connected to a 12V DC motor.

I’ll use three Push Buttons linked to Port 0 Pins P0.5, P0.6, and P0.7 to control the direction of rotation of the motor.

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 program should be burned to the 8051 microcontrollers.
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’s 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