DC Motor speed control with PIC16F877A and CCS C compiler

DC motor interfacing with PIC16F877A

It is easy to control the speed of a DC motor using PIC16F877A microcontroller since this microcontroller has a CCP module to generate a PWM signal, and by varying the duty cycle of the PWM signal the power delivered to the motor will also vary which causes the speed to change. This topic shows how to make a DC motor speed controller using PIC16F877A where a potentiometer is used to control motor speed.
If you need to see how to use potentiometer with PIC16F877A visit the following topic:
PIC16F877A ADC example with CCS PIC C compiler

And if you need to see how to generate a PWM signal using PIC16F877A visit the following topic:
PIC16F877A PWM example with CCS PIC C compiler

DC Motor speed control with PIC16F877A circuit:

To control the speed of a DC motor only one transistor is needed, in this project an N-type mosfet is used as shown in the circuit schematic below:
PIC16F877A DC motor speed control circuit
The potentiometer used to control the speed of the motor, it is connected to AN0. The microcontroller reads the analog data from AN0 channel and uses the digital value (after conversion) to set the PWM duty cycle.
PIC16F877A CCP1 module is used as PWM with a frequency of 500Hz.
The MCU must be supplied with 5V between pins VDD and VSS.

DC Motor speed control with PIC16F877A CCS C code:
The code is described through comments.

DC Motor speed control with PIC16F877A video:
The following video shows a hardware circuit for this project.

2 thoughts on “DC Motor speed control with PIC16F877A and CCS C compiler”

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top