0% found this document useful (0 votes)
10 views

PWMSG

The document details the design and implementation of a PWM signal generator using the PIC16F877A microcontroller, capable of producing a PWM signal with a frequency of 5 kHz and a variable duty cycle from 0% to 100%. The system utilizes an analog input from a potentiometer to adjust the duty cycle dynamically, ensuring efficient power control for various applications such as motor control and LED dimming. The project highlights the cost-effectiveness of the design, totaling 670 BDT, and emphasizes its potential for future enhancements and broader applications in power management.

Uploaded by

sudhanshuwagh007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

PWMSG

The document details the design and implementation of a PWM signal generator using the PIC16F877A microcontroller, capable of producing a PWM signal with a frequency of 5 kHz and a variable duty cycle from 0% to 100%. The system utilizes an analog input from a potentiometer to adjust the duty cycle dynamically, ensuring efficient power control for various applications such as motor control and LED dimming. The project highlights the cost-effectiveness of the design, totaling 670 BDT, and emphasizes its potential for future enhancements and broader applications in power management.

Uploaded by

sudhanshuwagh007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/384863581

Design and Implementation of PWM Signal Generator

Technical Report · October 2022


DOI: 10.5281/zenodo.13923768

CITATIONS READS

0 102

3 authors, including:

Prottay Barua Md.Imam Uddin Forkan


Chittagong University of Engineering & Technology Chittagong University of Engineering & Technology
5 PUBLICATIONS 1 CITATION 1 PUBLICATION 0 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Prottay Barua on 12 October 2024.

The user has requested enhancement of the downloaded file.


Design and Implementation of PWM
Signal Generator
Prottay Barua Md. Imam Uddin Forkan Mohammad Junaid
Dept. of Electrical and Electronic Engineering Dept. of Electrical and Electronic Engineering Dept. of Electrical and Electronic Engineering
Chittagong University of Engineering and Chittagong University of Engineering and Chittagong University of Engineering and
Technology Technology Technology
Chittagong, Bangladesh Chittagong, Bangladesh Chittagong, Bangladesh
[email protected] [email protected] [email protected]

dark to full intensity, and vice versa. Then it repeats the


Abstract— This document gives information regarding
implementation of PWM Signal Generator. The concept of the
whole cycle [3].
PWM Signal is nothing new. PWM Signal is a very commonly
used signal in digital electronics for control circuitry. The design The design of PWM Signal generator is based on
of PWM Signal Generator is based on using PIC16F877A on a microcontroller PIC16F877A IC on a breadboard. PWM
breadboard. This system will generate PWM Signal from the PIC Signal will be generated from the PIC MCU which has a
MCU which has a special module called Compare Capture special module called Compare Capture module (CCP).
module (CCP) which can be used to generate PWM signals. The This system will detect PWM signal which has many
generated PWM signal is of 5 kHz with a variable duty cycle from applications. The generated PWM Signal can be used as
0% to 100%. required. [4].

Keywords— PIC PIC16F877A, Resistor, Capacitor, II. METHODOLOGY


Breadboard, Potentiometer, CCP1CON Register.
The implementation of this project involves the use of the
PIC16F877A microcontroller IC to generate a PWM (Pulse
I. INTRODUCTION
Width Modulation) signal, with a controllable duty cycle
Some machines only require partial or variable power. Full ranging from 0% to 100% at a fixed frequency of 5 kHz. This
power is not required. Previously, controlling was done by the variable duty cycle is achieved by reading an analog input
use of a rheostat which was connected in series with the motor from a potentiometer, which is connected to the PIC’s ADC
in order to adjust amount of current flowing through the motor. (Analog-to-Digital Converter) module. The analog voltage
It was quite inefficient because power was wasted as heat in
input, which ranges from 0 to 5V, is digitized by the ADC,
the resistor element of the rheostat. It was tolerable though
yielding a mapped digital value between 0 and 1024. This
because the total power was low. The rheostat was one of
methods of controlling power but a low cost and efficient digital value is then used to modify the PWM signal’s duty
power adjustment method was needed. This mechanism also cycle dynamically, where 0 corresponds to a 0% duty cycle
required to drive motors for fans, pumps and robotic servos, and 1024 corresponds to a 100% duty cycle.
and needed to be compact enough to interface with lamp
dimmers. PWM emerged as a solution for this complicated To stabilize the PWM output, the project incorporates a
problem [1]. 20 MHz crystal oscillator in parallel resonance with two 22
PWM is often used for controlling servomechanism. In the pF capacitors. This configuration is crucial for maintaining
field of telecommunications, PWM is a form of signal optimal current at the desired frequency, ensuring stable
modulation. Here the widths of the pulses correspond to PWM signal generation. The parallel resonance setup enables
specific data values encoded and decoded at the both ends. maximum current at the resonant frequency, providing
PWM can be used to control the amount of power delivered to stability essential for applications requiring precise frequency
a load without losses which would have resulted via linear control. This arrangement supports the generation of a
power delivered by resistive means [2]. The power drawn by reliable and stable PWM output that can be adjusted in real-
the load and energy delivered to the load is discontinuous. time through the potentiometer, making the system suitable
High frequency PWM power control systems can be produced for a variety of applications, such as motor control, LED
with semiconductor switches. PWM can also be used in dimming, and other analog control scenarios. By leveraging
efficient voltage regulators. By switching voltage to the load the PIC16F877A’s capabilities and the precision provided by
with proper duty cycle, the output will approximate a voltage the crystal oscillator setup, the methodology facilitates
at the desired level. PWM techniques can be used to make accurate duty cycle modulation through simple and efficient
some indicator blink softly. The light will slowly transition analog-to-digital conversion, with real-time adjustments
from available via the potentiometer.

Resonant Frequency = ( . . . . . . . .(1)


III. CIRCUIT DESIGN B. Analog-to-Digital Conversion and Duty Cycle
The implementation of this PWM signal generator is carried Variation: The microcontroller reads an analog voltage
out on a breadboard. The core components include the (0-5V) from a potentiometer, which is then mapped to a
PIC16F877A IC, a 1k potentiometer, a 20 MHz crystal digital value range of 0-1024 via the ADC module. A
oscillator, and various supporting components like resistors PWM signal with a frequency of 5 kHz is generated, and
and capacitors. The crystal oscillator, along with 22 pF the duty cycle is adjusted based on the input voltage.
capacitors, is connected to the PIC MCU, ensuring precise Specifically, an ADC reading of 0 maps to a 0% duty
timing for PWM signal generation. The potentiometer is cycle, while 1024 maps to a 100% duty cycle. The CCP
wired to the ADC input of the PIC to read the variable module is configured as follows to enable PWM
voltage, which in turn adjusts the duty cycle. The output operation:
PWM signal can be observed on an LED, which will vary in
brightness based on the duty cycle. A 9V power supply is  The PWM period is set by writing the desired
used to power the entire circuit, and breadboard connectors value to the PR2 register.
help organize the connections on the breadboard for testing  The duty cycle is adjusted by setting the CCPR1L
and experimentation. register and the CCP1CON<5:4> bits.
 The CCP1 pin is designated as an output by
clearing the TRISC<2> bit.
 Timer2 is activated, and the TMR2 prescale value
is set in the T2CON register.
 The CCP1 module is then configured to operate
in PWM mode.

C. Frequency Setting and Duty Cycle Calculation: The


PWM frequency is established by writing an appropriate
value to the PR2 register, calculated using the formula:
The target PWM frequency is set to 5 kHz by assigning
PWM_freq = 5000. The duty cycle is determined by the
function:
𝑋𝑇𝐴𝐿_𝐹𝑅𝐸𝑄
𝑃𝑅2 = −1
𝑃𝑊𝑀_𝐹𝑅𝐸𝑄 × 4 × 𝑇𝑀𝑅2𝑃𝑅𝐸𝑆𝐶𝐴𝐿𝐸

These steps ensure the generation of a stable PWM signal,


with the duty cycle dynamically controlled by the input
from the potentiometer. Duty Cylce, D is

𝐹𝑙𝑜𝑎𝑡_ 𝐷𝑢𝑡𝑦 𝑋𝑇𝐴𝐿_𝐹𝑅𝐸𝑄


𝐷= ×
1023 𝑃𝑊𝑀_𝐹𝑅𝐸𝑄×𝑇𝑀𝑅2𝑃𝑅𝐸𝑆𝐶𝐴𝐿𝐸

Fig. 1. PWM Signal Generator circuit diagram


V. RESULT & ANALYSIS
IV. ADC MAPPING
A. PWM Signal Generation: The PWM signal is generated The design of the PWM Signal Generator is implemented
using the CCP (Compare Capture PWM) module in the using the PIC16F877A microcontroller on a breadboard.
PIC16F877A microcontroller. A 40-pin microcontroller This system generates a PWM signal utilizing the Compare
is utilized in this project, as it includes the necessary CCP Capture module integrated within the microcontroller. The
module, which is absent in the 28-pin version. The PWM frequency of the generated PWM signal is set at 5 kHz, with
signal is configured with a 10-bit resolution, where a a duty cycle ranging from 0% to 100%. Below is the
digital value of 0 corresponds to a 0% duty cycle, and a simulated circuit diagram used for generating the PWM
value of 1024 (2^10) represents a 100% duty cycle. Due signal:
to the presence of two CCP modules (CCP1 and CCP2),
two separate PWM signals can be generated
simultaneously on pins 17 and 16, respectively. In this
setup, the PWM signal is produced on pin 17 [5].
TABLE I. Cost analysis of PWM Generator

Component Description Quantity Price


name

PIC16F877A 40 pin micro 01 300 BDT


controller
Resistor 10 K ohm 01 30 BDT
Capacitor 22 pF 02 20 BDT
LED Light emitting 01 20 BDT
Diode
Breadboard Connection board 01 120 BDT
Wires Connection wires 08 60 BDT
Potentiometer 1k potentiometer 01 30 BDT
Fig. 2. Simulated Circuit diagram
Crystal 20 Mhz Crystal 01 30 BDT
Oscillator Oscillator
Battery 9V Battery 01 60 BDT
Total 670 BDT

VII. COMPETITIVE STUDY AND FUTURE SCOPE OF PWM


SYSTEMS

The project utilizes a PIC microcontroller to generate


clean PWM signals with variable duty cycles, distinguishing
it from other signal generation methods. As advanced
systems increasingly adopt PWM technology, the future
scope of this project is significant. Applications include
Fig. 3. Simulated Output of PWM signal modern computer systems, where CPU fans can use PWM to
adjust speed based on temperature. Additionally, demand for
control circuitry is rising, with recent studies indicating that
the PWM controllers market is projected to grow by 5.1%
through 2032 [6].

VIII. APPLICATIONS

PWM signals are versatile tools used in various systems for


efficient control and power management. Here are some key
applications [7]:

Fig. 4. Output for 100% pwm signal  Servomechanism Control: Frequently used for
precise movement control in servos.
VI. COST ANALYSIS  Voltage Regulation: Controls the voltage received
The total cost of the smart home project is **670 BDT**, by loads, enabling efficient power delivery with
encompassing essential components such as the PIC16F877A minimal losses.
microcontroller (300 BDT), passive components (70 BDT),  Efficient Voltage Regulators: Utilized in voltage
and infrastructure (180 BDT). This cost-effective investment regulation systems for stable output.
offers potential benefits like energy savings, increased  Soft Blinking Indicators: PWM techniques create
property value, and enhanced convenience. Overall, the smooth, soft blinking effects in indicators.
initial investment is justified by long-term financial and  Lossless Power Delivery: Ensures efficient and
functional gains. lossless power transfer.
 Fan Speed Control: Replaces DC signals to adjust
CPU and case fan speeds dynamically based on
temperature conditions.
IX. CONCLUSION [3] Electronics Projects for ECE & EEE Engineering
The PWM signal generator system was successfully Students, ElProCus, Nov. 16, 2020. [Online].
implemented using the PIC16F877A microcontroller, Available: https://www.elprocus.com/electronics-
demonstrating its effectiveness in generating PWM signals. projects-for-engineering-students/. [Accessed: Aug.
While the current design allows for adjustable duty cycles, 22, 2022].
there is significant potential for improvement, such as [4] Semiconductors: Understanding the Objects That
extending the range of the duty cycle for greater control.
Power Our Digital Lives, Investopedia, Jun. 23,
Furthermore, the system's adaptability enables it to be
connected to various applications that require PWM signals, 2021. [Online]. Available:
enhancing its utility in fields like servomechanism control https://www.investopedia.com/terms/s/semiconduct
and voltage regulation. Overall, the project lays a strong or.asp. [Accessed: Aug. 22, 2022].
foundation for future enhancements and broader applications, [5] IC Timers Selection Guide: Types, Features,
promising valuable contributions to power management and Applications,” Engineering360. [Online].
control systems.
Available:
REFERENCES https://www.globalspec.com/learnmore/semicondu
ctors/timing_circuits/ic_timers. [Accessed: Aug. 22,
[1] Using 555 Timer IC,” Elonics.org. [Online]. 2022].
Available: https://elonics.org/touch-sensor-alarm- [6] J. Smith, “Introduction to Pulse Width Modulation
using-555-timer-ic/. [Accessed: Aug. 22, 2021]. (PWM),” Electronics Tutorials. [Online]. Available:
[2] PWM Signal Generation Using Microcontrollers, https://www.electronicstutorials.com/pwm/.
Electronics Projects Hub, Jul. 10, 2022. [Online]. [Accessed: Sep. 10, 2023].
Available: [7] M. Ali, “The Use of PWM in DC Motor Control,”
https://www.electronicsprojectshub.com/pwm-
Electronics Hub, Mar. 3, 2022. [Online]. Available:
signal-generation/. [Accessed: Oct. 15, 2023].
https://www.electronicshub.org/pwm-in-dc-motor-
control/. [Accessed: Oct. 14, 2023].

View publication stats

You might also like