DC motor control with PIC16F877A and L293D – Proteus simulation

DC motor interfacing with PIC16F877A and L293D

This topic shows how to control DC motor rotation direction and speed using PIC16F877A microcontroller and L293D motor driver IC.
A pot is used to control motor speed and two pushbuttons are used to control rotation direction.

Related topics:
The following topic shows how to control speed and direct of a DC motor using PIC16F877A and H-bridge circuit:
DC motor speed and direction control with PIC16F877A and H-bridge

DC motor control with PIC16F877A and L293D circuit:
PIC16F877A L293D DC motor driver circuit
In the circuit there are 3 push buttons, 2 for selecting the direction and the other one for stopping the motor. The 2 LEDs are used to indicate the motor rotation direction, if LED1 is ON that means direction 1 has been chosen and the same thing for LED 2. If both LEDs are OFF that means the motor has been stopped.

The nominal voltage of the motor is 12V as well as L293D VS input voltage. Always L293D VS voltage is the same as the DC motor voltage and L293D VSS voltage is +5V.
A pot (pin AN0) is used to change the motor speed.

The microcontroller PIC16F877A reads analog data from channel 0 and use the digital value to set the PWM duty cycle. If direction 1 button is pressed the microcontroller starts PWM1 (RC2 pin) and stops PWM2 (RC1 pin) and if direction 2 button is pressed the microcontroller stops PWM1 (RC2 pin) and starts PWM2 (RC1 pin), when the stop button is pressed the microcontroller stops PWM1 and PWM2 signals and the motor will stop.
The PWM (PWM1 & 2) frequency is 488Hz.

DC motor control with PIC16F877A and L293D CCS C code:
PIC16F877A Timer2 is configured to generate a PWM frequency of 488Hz and the microcontroller runs with 8MHz crystal oscillator.

The microcontroller PIC16F877A reads RA0 analog value and stores the digital value on variable (i), this variable is used to set duty cycle of the active PWM (PWM1 or PWM2).

DC motor control with PIC16F877A and L293D Proteus simulation video:
The following video shows the simulation using Proteus.

Proteus simulation file download:
You can download Proteus simulation file from the following link.
DOWNLOAD

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.