Summary of [Simple] Generating Pulse Width Modulation using PIC Microcontroller – Mikro C & Proteus Simulation
Summary: This article explains generating PWM using a PIC16F877A microcontroller, demonstrating PWM concepts, CCP module modes, and using MikroC PRO for PIC with its PWM library. It notes PWM applications (motor speed, LED brightness, DAC), explains enabling the PWM library in MikroC, and simulating the design with Proteus. PWM outputs appear on pins 16 and 17, and CCP supports Capture, Compare, and PWM modes, with focus on PWM mode.Parts used in the PIC PWM Generation Project:
- PIC16F877A microcontroller
- MikroC PRO for PIC (compiler/software)
- Proteus Design Suite (simulation software)
- Connections to pins 16 and 17 for PWM output
- PWM library enabled in MikroC (software library)
How to generate Pulse Width Modulation (PWM) using PIC microcontroller? This is going to be a continuation of our microcontroller online tutorial series. This article covers the detailed explanation and simulation of PWM generation using PIC16F877A microcontroller.What is a Pulse Width Modulator? A PWM has series of pulses with variable pulse width. We have used Mikro C pro for pic microcontroller programming because it has inbuilt library functions to do many operations especially in PWM, this will simplify the user headache.
The simulation is done with Proteus design suite. In my previous article we have already discussed How to Simulate PIC Microcontroller in Proteus?
PWM has wide applications in automation such as DC motor speed control circuit , generating analog signals from digital signals and LED brightness control.
PWM and PIC
Two CCP module is available with a PIC16F877A MCU. It is capable of generating PWM signals.
MikroC PRO for PIC provides library which simplifies PWM operations. The generated PWM output comes via pin No: 16 and 17 of PIC16F877A microcontroller.
As the name indicates, CCP (Capture Compare PWM) has 3 modes of operation.
- Capture mode
- Compare mode
- PWM mode
In PWM mode PIC can generate signals of varying frequency and duty cycle.
Other modes are beyond the scope of this article. We will discuss those modes later.
Now let’s begin PIC PWM generation!
Add PWM Library to Mikro C
Before writing the program we should add PWM library functions to our code. Otherwise you may be getting compilation errors such as ‘Undeclared identifier PWM1_Init in expression’.
So open ‘Library Manager’ tab and put a check mark on ‘PWM’ library. Then proceed to the program.
For more detail: [Simple] Generating Pulse Width Modulation using PIC Microcontroller – Mikro C & Proteus Simulation
Quick Solutions to Questions related to PIC PWM Generation Project:
- What is a Pulse Width Modulator?
A PWM is a series of pulses with variable pulse width. - Which PIC microcontroller is used in the article?
The article uses the PIC16F877A microcontroller. - Which software is used to write and compile PWM code?
MikroC PRO for PIC is used for programming and provides a PWM library. - Which pins provide the generated PWM output on PIC16F877A?
PWM output comes via pin numbers 16 and 17 of the PIC16F877A. - What are the three modes of the CCP module?
Capture mode, Compare mode, and PWM mode. - What applications of PWM are mentioned?
DC motor speed control, generating analog signals from digital signals, and LED brightness control. - What must be done in MikroC before using PWM functions?
Enable the PWM library in the Library Manager to avoid undeclared identifier errors. - Which mode of CCP is the article focused on?
The article focuses on PWM mode of the CCP module.
Related projects
PIC16F877 Driving LCD in 4-Bit Mode using PIC16F877 with Proteus Simulation
Introduction This microcontroller project shows how a PIC16F877 can drive an LCD display using 4-bit mode inside a Proteus simulation.The project demonstrates...
Programmers & ICSP · PIC16F877AEPE PIC/LCD Demo using PIC16F877 with Proteus Simulation
IntroductionThe EPE PIC/LCD Demo is a classic microcontroller project that demonstrates how a PIC16F877 can fully control a PG12864F graphical LCD.Designed as...
Motors & Robotics · PIC16F877AEfficient Sun-Following Robot: A Solar Tracker with Microcontroller Control
Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....
Motors & RoboticsReal-Time CAN-Based Vehicle Monitoring System with PIC MCU
INTRODUCTION The Controller Area Network (CAN) is a robust vehicle communication bus standard that was primarily developed for automobile applications but has...
Motors & RoboticsEasy Way to Learn Robotics Using Microcontrollers: A Beginner’s Guide
The title, "Easy Way to Learn Robotics Using Microcontrollers," promises an accessible entry point for those curious about the exciting world of...
Motors & RoboticsInnovative Robotics: A Comprehensive Project Exploration
A DC motor functions as an electromechanical device, translating electrical signals into mechanical movements. The rotation of the motor correlates directly with...