[Simple] Generating Pulse Width Modulation using PIC Microcontroller – Mikro C & Proteus Simulation

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.

[Simple] Generating Pulse Width Modulation using PIC Microcontroller – Mikro C & Proteus SimulationThe 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.

  1. Capture mode
  2. Compare mode
  3. 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!

[Simple] Generating Pulse Width Modulation using PIC Microcontroller – Mikro C & Proteus Simulation SchematicAdd 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


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

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.