Summary of DC motor control with PIC16F84A and L293D
This project demonstrates controlling the speed and direction of a 12V DC motor using a PIC16F84A microcontroller and an L293D motor driver IC. The circuit includes five buttons to increase/decrease speed, select motor direction, and stop the motor. Three LEDs indicate motor direction and maximum speed. Speed control is implemented via software PWM at 500Hz using the CCS PIC C compiler's PWM library. The L293D supplies motor voltage (VS=12V) and logic voltage (VSS=5V) and can drive two motors with bidirectional control.
Parts used in the DC Motor Control with PIC16F84A and L293D:
- PIC16F84A Microcontroller
- L293D Motor Driver IC
- 12V DC Motor
- 5 Push Buttons
- 3 LEDs
- Power Supply (12V for motor, 5V for logic)
- Resistors (for LEDs and buttons)
- Connecting Wires and PCB/Breadboard
Low power DC motors can be easily controlled with half H-bridge IC L293D. This IC is 16-pin IC which can control 2 motors in both directions.
This topic shows how to control DC motor speed and direction with PIC16F84A and L293D motor drive integrated circuit.
Related topics:
The following topic shows how to control a DC motor with PIC16F84A and H-bridge circuit.
DC Motor speed and direction control with PIC16F84A using H-bridge
DC motor control with PIC16F84A and L293D circuit:
Project circuit schematic is shown below
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.
In the circuit there are 5 buttons, the first button which is connected to RB0 pin is used to speed up the motor, and speed down button to decrease motor speed. Third and fourth buttons are used to choose direction rotation of the motor (direction 1 or direction 2). The last button stops the motor no matter what speed or direction.
There are 3 LEDs, LED1 and LED2 are used to indicate motor direction, and the other LED indicates maximum speed, which means when it is on the motor is running at maximum speed.
When speed up button is pressed the PWM duty cycle increases which causes the motor to increase its speed and when the duty cycle = 100 LED 3 turned on. In the other hand if speed down button is pressed the duty cycle decreases and the motor speed also decreases.
If the stop button pressed the motor stops and the 3 LEDs are off.
Software PWM is used wih frequency of 500Hz.
DC Motor control with PIC16F84A and L293D CCS C code:
The full C code is shown below. Official software PWM library which comes with CCS PIC C compiler is used, this library uses Timer0 to generate the PWM signal.
Read more: DC motor control with PIC16F84A and L293D