The investigation Of Pulse Width Modulation(PWM)



Pulse width modulation(PWM) is a technique which uses a processor's digital outputs to control analog circuits. The PWM is quite widely used. For example, its applications contains measurement and communications.

PWM is a digital controller. It is much easier for implementation than using the analog electronics.

PWM is a method to encoding analog signal levels digitally in a small equipment. The duty cycle of a square wave is changed in order to encode a specific analog signal level by using high-resolution counters. Because the full DC supply is sometimes fully on, and in other cases it is fully off, the signal comes from the PWM is still digital. Through the method of supplying a voltage or current source to the analog load, the signal of PWM is digital. Thus it looks like a repeating series of on and off pulses. In this case, the period when the DC supply is turned on is called as the on-time. On the contrary, the off-time is the time during which the DC supply is not applied to the load. Any analog signal levels can be encoded by using PWM if the bandwidth is enough.


This experiment aimed at investigating the function of the Pulse width modulation(PWM).



As shown in Figure 1, there are three different PWM signals. The a indicates the signal is on at 10% and 90% off, which is called that a PWM output at a 10% duty cycle. There are 50% and 90% duty cycles output in b and c. The Figure 1 shows that there are three different PWM outputs and these outputs indicate three different analog signal values. They are 10%,50% and 90% of the full range. For example, if a is the output of an analog signal of voltage, it shows that the analog signal results are 10% of the full voltage.

A circuit which applies PWM as the signal controller is illustrated in Figure 2. As is seen below, the supply is a 9V battery, and the load is a lamp. There is a simple switch to control the circuit is on or off. If the switch is on for 50ms and turned off next 50ms. Therefore, the lamp is supplied by 6V for 50ms and 0V for next 50ms. If this cycle is repeated 20 times a second, The lamb seems to be supplied by a 3V battery. For the reason that 50% of 6V. And the duty cycle is 50%, the modulating frequency is 20Hz.

Most loads need a higher modulating frequency than 10Hz in practice whatever it is inductive or capacitive. If the example before, the on-time is changed into 5 seconds, then the off-time is also changed into 5 seconds. The duty cycle is not changed as is seen. But the bulb would not like before. It would look like that it is bright for 5 seconds and dark for the next 5 seconds. So in order to make it appear like the voltage is 4.5 volts, the period must be short to make the switch state is not changed. Thus the method can be that make the cycle period shorter than the load's response time. There is a need to increase the modulating frequency for the reason that making the lamp seems on.


The apparatus used in the experiment consisted of the following:

1 dual 4 bit counter,4520 CMOS chips;

Two 4 bit comparators; 4063 CMOS chip;

1 microcontroller PIC board;


Square wave oscillator;


An internal register


Firstly, the two 4 bit comparators, 4063 CMOS chips, 1 dual 4 bit counter,4520 CMOS chips and microcontroller PIC board are connected into the internal register as the links below. The PWM output was connected to the oscilloscope. And the voltage was set up at 5V. The CLOCK was connected to the square wave oscillator, which could be called as signal generator. And the microcontroller was connected to a 5V power supply.

The Figure 3 shows that four different Pulse Width Modulation outputs. The a indicates that the duty cycle is 20%. Then the b shows that the on-time is 40% of the period and off-time is the other 60%. In addition, the c demonstrates the signal is on for 60% of the period and off the other 40%. Finally, the d displays the PWM outputs encode analog signal value at 80%.


These four different PWM outputs are achieved by entering the switch on the microcontroller. The results before indicate the experiment is almost completed. The data is near the theoretical value. Some C code for PWM mark control of hardware via 16F84 is below. When the switches are pressed, the counter would do the addition (counter++) or the subtraction (counter--). Thus the value of counter varies every time when the switch is pressed, through the code, PORTB is varies too. So when the counter=0, the PORTB=0x33, it would send 20% MARK to PORTB, the duty cycle would be 20%. It is similar to this, counter=1, the PORTB=0x66, it would send 40% MARK to PORTB, the duty cycle would be 40%. Through this method, counter=2, 60% duty cycle; counter=3, 80% duty cycle.


The Pulse Width Modulation is really a pretty good way of digitally encoding analog signal levels. Through this method, it is much easier to complete the target of digital controlling. Through the experiment, the use of PWM and the function come to a better understanding. The code make the operation of microcontroller clear.


  1. Barr, Michael (2001) [Online] Introduction to Pulse Width Modulation (PWM) available at [Accessed 28/11/2009]

Please be aware that the free essay that you were just reading was not written by us. This essay, and all of the others available to view on the website, were provided to us by students in exchange for services that we offer. This relationship helps our students to get an even better deal while also contributing to the biggest free essay resource in the UK!