Вы находитесь на странице: 1из 47

PULSE WIDTH MODULATION

(PWM)
FINAL REPORT
Class: ENEE 417
Professor: Dr. Yang

Copyright 2007
By: Long Pham
Khoa Nguyen
Travis Paul
All Rights Reserved

Table of Contents
OBJECTIVE..................................................................................................................................................................3
STAGES NEEDED.......................................................................................................................................................3
DIAGRAM OF THE ALL THE STAGES INCLUDING THE OPTICAL GROUP/LEDS ..........................................................3
BACKGROUND RESEARCH....................................................................................................................................4
WHAT IS PWM (PULSE WIDTH MODULATION METHOD)...........................................................................................4
HOW TO GENERATE A CARRIER SIGNAL (TRIANGLE WAVEFORM)...........................................................................4
HOW A COMPARATOR WORKS.....................................................................................................................................4
HOW TO DEMODULATE A PWM SIGNAL....................................................................................................................5
PARTS SPECIFICATION RESEARCH ...................................................................................................................5
PARTS NEEDED TO BUILD THE CIRCUIT..........................................................................................................7
QUICK ANALYSIS OF THE PROJECT AND HOURS SPEND...........................................................................7
PSPICE OF CIRCUIT AND SIMULATIONS..........................................................................................................8
CIRCUIT THAT REPRESENTS THE ACTUAL CIRCUIT....................................................................................................8
SIMULATE THE CIRCUIT WITH SINE AT 100HZ ........................................................................................................10
SIMULATE THE CIRCUIT WITH SINE AT 1KHZ..........................................................................................................11
SIMULATE THE CIRCUIT WITH SINE AT 10KHZ........................................................................................................12
SIMULATE THE CIRCUIT WITH SINE AT 20KHZ........................................................................................................13
SIMULATE THE CIRCUIT WITH SQUARE AT 20KHZ...................................................................................................14
CIRCUIT BUILD ON PC BOARD...........................................................................................................................15
TRANSMITTING SIDE.................................................................................................................................................15
RECEIVING SIDE........................................................................................................................................................17
TEST RESULTS.........................................................................................................................................................19
TEST THE CIRCUIT WITH SINE WAVE AT 100HZ......................................................................................................21
TEST THE CIRCUIT WITH SINE WAVE AT 1KHZ........................................................................................................24
TEST THE CIRCUIT WITH SINE WAVE AT 10KHZ......................................................................................................27
TEST THE CIRCUIT WITH SINE WAVE AT 20KHZ......................................................................................................30
FREQUENCY RESPONSE OF THE CIRCUIT BUILD.......................................................................................34
TRANSMITTING SIDE OF THE CIRCUIT......................................................................................................................34
RECEIVING SIDE OF THE CIRCUIT (2ND ORDER LPF)...............................................................................................35
CONCLUSION............................................................................................................................................................36
REFERENCES............................................................................................................................................................37
APPENDIX A CMX309...........................................................................................................................................38
APPENDIX B OP-AMP LM7171...........................................................................................................................39
APPENDIX C OP-AMP TLV2362.........................................................................................................................44

Objective
To modulate an audio signal by using the method of pulse width modulation, then
demodulate the signal to recover the audio signal. The final goal for the team is to transmit the
modulated signal optically, thus an optical group is in charge of transmitting the PWM signal by
an LED and use a photo-detector to receive the signal. Finally, there is a power amplifier to
amplify the received signal before inputting it to a speaker.

Stages Needed
1.
2.
3.
4.

To generate a carrier signal (triangle wave at 1MHz)


Use a microphone and input an audio signal
Use a comparator to produce a PWM signal
Use a low pass filter to demodulate the PWM signal into an audio signal

Diagram of the All the Stages Including the Optical Group/LEDs


Transmitting Side:

To PhotoDetector

Figure 1a
Receiving Side:

Figure 1b

Background Research
What is PWM (Pulse Width Modulation method)

PWM of a signal or power source involves the modulation of its duty cycle, to either
convey information over a communications channel or control the amount of power sent
to the load.
PWM uses a square wave whose duty cycle is modulated resulting in the variation of the
average value of the waveform.

How to Generate a Carrier Signal (Triangle Waveform)


A method of generating a triangle waveform is to first use a clock oscillator to produce a
square wave and then use an integrator (low pass filter) to integrate the square wave into a
triangle wave.
Using a Passive LPF to Integrate the Square Wave at 1Mhz:
Since the crystal oscillator is producing a 1Mhz square wave, thus using the following
calculation we can choose which RC values to use:
Calculation:
fc = 1/ (2) = 1/ (2RC) (Low Pass Filter Wikipedia)
Comment:
In this case, our cutoff frequency is 1Mhz, thus we can choose one capacitor value
that we have and solve for the resistor value. Keep in mind that in actual circuit design
the values might need to vary in order to integrate better. One method that we did was
fix the capacitor at 240pF and vary the resistor until we see a triangle wave on the
oscilloscope that is constant and stable in order for the comparator to behave properly. In
order to get a PWM signal output, the comparator needs a constant stable signal; in this
case, the triangle wave has to be constant and stable.

How a comparator works


A comparator receives two input signal and compares the signal. If the positive input voltage
is greater than the negative input voltage, then the comparator produce an output signal to its
highest rail voltage. In this case, the comparator will output the signal to 9V because we are
using +/- 9V to drive the comparator. If the negative input voltage is greater than the positive
input voltage, then the comparator will output a signal to its lowest rail voltage. In this case, the
comparator will output the signal to -9V. (Refer to figure 2 on next page) (Pulse Width
Modulation Wikipedia)

Figure 2

How to Demodulate a PWM Signal


One method to demodulate a PWM signal is to use a 2nd order low pass filter (LPF). The
LPF acts as an integrator which integrates the PWM. Since a PWM is a square wave like form,
then the LPF would integrate the PWM into a sinusoidal waveform/audio signal. Thus, the audio
signal being transmitted will be recovered by using this convention.

Parts Specification Research

Clock Oscillator (CMX 309 Series) see Appendix A for specifications


Reasons for choosing this part:
o Clock oscillator produces 1Mhz square wave which is one of our requirement
o It is low power consumption and produces a stable waveform at room temperature
o Desired low voltage value: 1.0 - 3.3V
o Embedded with heat resistant cylinder type crystal bring highly stable
characteristics
o It is suitable for various applications such as communication devices
o Price: $2.63/chip
o Amount of chips recommended: 5 (units) to test around with

Comparator (used Fast Op-Amp LM7171) see Appendix B for specifications


Reasons for choosing this part:
o It is a fast op-amp used in replacement of Comparator IC at frequency of 1Mhz
o Can support up to +/- 15 volts as supply voltage
Thus, the transmitting signal will have a large voltage swing that are set by
the rail voltage

If we use a higher voltage to transmit, the that will increase the signal to
noise ratio
Its Gain Bandwidth Product is 170 MHz at operating voltage +/-9V at room
temperature
Low offset voltage typically 0.2mV
Price: $2.88/chip
Amount of chips recommended: 5 (units) to test with

o
o
o
o

Op-Amp (not used in final design) Texas Instrument TLV2362- see Appendix C for
specifications
Reasons for not using this part in final circuit design:
o Due to lacking of understanding about op-amp specification, many features from
this op-amp is not suitable in our design
o It has a much smaller Gain Bandwidth Product than the above op-amp (6MHz
compare to 170MHz)
o High input offset voltage 6mV
o Maximum supply-voltage limits at +/- 3.50V, which will give a small output
swing that are set by the rails in comparison to the LM7171
o Price: $.57/chip
o Amount of chips recommended: 5 (units) to test with

Parts Needed to Build the Circuit


Data Table 1:
Components
CMX 309 Series- Mouser.com
LM-7171- Digikey.com
Resistor 1k - School Supplies
Resistor 680 - School Supplies
Resistor 2k - School Supplies
Capacitor 10F(Larger electrolytic)- School Supplies
Capacitor 22F(Larger electrolytic)- School Supplies
Capacitor 4.7F(Larger electrolytic)- School Supplies
Capacitor 4.7nF(Ceramic)- School Supplies
Capacitor 963pF- School Supplies
Energizer 9V Batteries Home Depot
Battery 1.5V (AA)- CVS

Price($)/Unit Quantity
2.63
1
2.88
1
.01
1
.01
1
.01
3
.20
1
.20
1
.20
1
.10
1
.10
1
.97
2
.524
1
Total Cost of Circuit

Total Cost
2.63
2.88
.01
.01
.03
.20
.20
.20
.10
.10
1.94
.52
8.83

Quick Analysis of the Project and Hours Spend


Starting from scratch, the total amount of time to assemble this circuit together took
approximately 1 semester of school hours. Each week we spend approximately 6 hours of lab
time to discuss and assemble our information, such as background research, parts research,
PSPICE simulations and etc. We spend roughly 2 months of about 8 to 10 hours a week building
the circuit on breadboard, testing it, gather data and trouble shoot any problems that we had
encounter.
The reason why this project took such a long time to accomplish was because we had to
change our circuit design due to parts constraint, meaning the parts did not work the way we had
expect it to due to poor parts research and lack of understanding about the datasheet. Another,
was troubleshooting where errors had occur within the circuit such as not measuring the DC
voltages at all nodes. This was a problem because there was a DC voltage input into the
comparator that was caused from the output of the clock oscillator, thus the comparator did not
function as we expect it to. So, the waveform did not look like a PWM. Therefore, we had to
add in a coupling capacitor to ensure that only AC signals are input into the comparator.
Another approach that we had in the beginning was to use an active LPF in order to
control the voltage swing at the output, but after many tests, we decided to have a simple passive
LPF to reduce the circuit components and that made things less complex.
As a whole, it took many hours to research, understand and assemble the project into one
final circuit. But, with proper instructions this circuit could be assembled within 10 hours for
two people to build using breadboard given all the parts are supplied. To implement the circuit
on PC board will take an extra 10 hours. So roughly 20 hours to rebuild the PWM transmitting
and receiving circuits excluding the optical parts.

PSPICE of Circuit and Simulations


Conditions:
Used Vpulse at 1.6VPP as a square wave generator
Used Vsin at 200mVPP to represent a test input to the comparator (LM7171)
Used 2nd order LPF to demodulate the PWM signal and recover the sine wave
All signals are AC signal with no bias DC voltage
Used the measured voltage of the battery to simulate the circuit. In this case it is +/9.4Vdc to drive the LM7171

Circuit that Represents the Actual Circuit


Comparator

Passive Low Pass Filter


(Demodulator)

0
V3
9 .4 V

R 2
1970

V-

L M 7 1 7 1 A IN
3
+
VO FF = 0
VAM PL = 100m V
F R EQ = 10000

V
Input

PWM Signal

R 6
1990

V+

U 1

R 3

C 4

2020

963p

O U T

C 3
4 .7 n

V2
9 .4 V

R 1

0
V 1 = .8 V
V 2 = -.8 V
T D = .1 f s
T R = .1 f s
T F = .1 f s
P W = .5 u s
PER = 1us

663

C 1
240p

Square
0
0

Figure 3a
1. 0V

0V

- 1. 0V
V( Squar e: +)
1. 0V

0V
SEL >>
- 1. 0V
10. 0us
V( R1: 2)

12. 5us

15. 0us

17. 5us

20. 0us

Ti me

Figure 3b (Blue Square Yellow - Triangle)

Simulate the Circuit with Sine at 100Hz


Sine Input to Comparator with 200mVPP:
100mV

0V

- 100mV

V( I NPUT: +)

1. 0V

0V

SEL>>
- 1. 5V
0s

V( R2: 2)

2ms

4ms

6ms

8ms

10ms

Ti me

Figure 4a (Green Input Sine to Comparator Red Output of 2nd Order LPF)
10V

0V

- 10V
100us
V( R6: 1)

110us

120us

130us

140us

150us

Ti me

Figure 4b (Output PWM Signal of Comparator at 100Hz Sine Input)

10

Simulate the Circuit with Sine at 1kHz


Sine Input to Comparator with 200mVPP:
100mV

0V

- 100mV
V( I nput : +)
1. 0V

0V

SEL >>
- 1. 5V
0s

0. 2ms

0. 4ms

0. 6ms

0. 8ms

1. 0ms

V( C4: 2)
Ti me

Figure 5a (Red Input Sine to Comparator

Blue Output of 2nd Order LPF)

10V

0V

- 10V
100us
V( R6: 1)

110us

120us

130us

140us

150us

Ti me

Figure 5b (Output PWM Signal of Comparator at 1kHz Sine Input)

11

Simulate the Circuit with Sine at 10kHz


Sine Input to Comparator with 200mVPP:
100mV

0V

- 100mV
V( I nput : +)
1. 0V

0V
SEL>>
- 1. 0V
100us
V( C4: 2)

125us

150us

175us

200us

Ti me

Figure 6a (Green Input Sine to Comparator

Red Output of 2nd Order LPF)

10V

5V

0V

- 5V

- 10V
80us

100us

120us

V( R6: 1)
Ti me

Figure 6b (Output PWM Signal of Comparator at 10kHz Sine Input)

12

Simulate the Circuit with Sine at 20kHz


Sine Input to Comparator with 200mVPP:
100mV

0V

SEL>>
- 100mV
V( I nput : +)
1. 0V

0V

- 1. 0V
50us

75us

100us

125us

V( C4: 2)
Ti me

Figure 7a (Green Input Sine to Comparator

Red Output of 2nd Order LPF)

10V

5V

0V

- 5V

- 10V
40us

50us

60us

70us

80us

V( R6: 1)
Ti me

Figure 7b (Output PWM Signal of Comparator at 20kHz Sine Input)

13

Simulate the Circuit with Square at 20kHz


Square Input to Comparator with 200mVPP:
100mV

0V

SEL>>
- 120mV
V( U1: +)
1. 0V

0V

- 1. 0V
0s

100us

200us

300us

V( C4: 2)
Ti me

Figure 8a (Blue Input Square to Comparator

Red Output of 2nd Order LPF)

10V

0V

- 10V
50us

60us

70us

80us

90us

V( R6: 1)
Ti me

Figure 8b (Output PWM Signal of Comparator at 20kHz Square Input)

14

Circuit Build on PC Board


Transmitting Side
Front View: With Batteries

Figure 9a
Front View: Closer Look at the PC Board and Circuit
Coupling
Capacitor to
get rid of DC
voltage
Capacitor to
get rid of
ripple of
square wave

Integrator
Pin 4

Pin 3

Pin 5

Pin 2

Pin 6

Clock Oscillator
CMX309

Pin 1

LM7171
Comparator
Figure 9b

15

Back View:

+9 Volt Supply
into LM7171

AA Battery
Supply into
CMX309

Input audio into


this wire

-9 Volt
Supply into
LM7171

Output of Comparator
(PWM signal)
Figure 9c

16

Receiving Side
Front View:

Pin 1 - Input to
2nd order LPF

Pin 2 - Output of
2nd order LPF

Figure 10a

17

Back View:

Pin 2 - Output of
2nd order LPF

Pin 1 - Input to
2nd order LPF

Figure 10b

18

Test Results
Conditions:
One AA battery (1.63Vdc) supply to the clock oscillator
One +9Vdc battery supply to Pin 7 of the LM7171 chip (refer to appendix B)
One -9Vdc battery supply to Pin 4 of the LM7171 chip (refer to appendix B)
Used 1x probes to measure ac signal on the oscilloscope
Measured DC Voltages:
Output of clock oscillator dc voltage
(Refer to Figure 9b Pin 2)
Clock oscillator dc voltage after coupling capacitor
(Refer to Figure 9b Pin 4)
Triangle wave dc voltage after integrator
(Refer to Figure 9b Pin 5)
PWM output dc voltage of LM7171
(Refer to Figure 9b Pin 6)

0.750Vdc
0.004Vdc
0.004Vdc
0.005Vdc

Output of the Clock Oscillator after coupling capacitor:


Refer to Figure 4b Pin 4

Figure 11a

19

Triangle Wave After the Square Wave Has Been Integrated:


Refer to figure 9b Pin 5
This is a constant carrier signal input into the comparator (LM7171) while the
sine input signal is varied at different frequencies and the sine wave voltage peak to peak
has to be less than the triangle wave.

Figure 11b

20

Test the Circuit with Sine Wave at 100Hz


Input Signal to Comparator with Sine Wave at 100Hz:
Refer to figure 9c orange wire

Figure 12a
PWM Output Signal of the Comparator/Input Signal to the LED:
Refer to figure 9b Pin 6
- Input: Triangle Wave at 1MHz
+ Input: Sine Wave at 100Hz

Figure 12b

21

PWM Output Signal of the LED/Input Signal to the Photo-Detector:

Figure 12c
Output Signal of the Photo-Detector/Input Signal to the 2nd Order LPF:
Refer to figure 10a Pin 1(use 10X probe to measure)-Note (1)

Figure 12d

22

Output Signal of the 2nd Order LPF/Input Signal to the Power Amp:
Refer to figure 10a Pin 2

Figure 12e
Output Signal of the Power Amp/Input Signal to the Speaker:

Figure 12f

23

Test the Circuit with Sine Wave at 1kHz


Input Signal to Comparator with Sine Wave at 1kHz:
Refer to figure 9c orange wire

Figure 13a
PWM Output Signal of the Comparator/Input Signal to the LED:
Refer to figure 9b Pin 6
- Input: Triangle Wave at 1MHz
+ Input: Sine Wave at 1kHz

Figure 13b
24

PWM Output Signal of the LED/Input Signal to the Photo-Detector:

Figure 13c
Output Signal of the Photo-Detector/Input Signal to the 2nd Order LPF:
Refer to figure 10a Pin 1 (use 10X probe to measure)-Note (1)

Figure 13d

25

Output Signal of the 2nd Order LPF/Input Signal to the Power Amp:
Refer to figure 10a Pin 2

Figure 13e
Output Signal of the Power Amp/Input Signal to the Speaker:

Figure 13f

26

Test the Circuit with Sine Wave at 10kHz


Input Signal to Comparator with Sine Wave at 10kHz:
Refer to figure 9c orange wire

Figure 14a
PWM Output Signal of the Comparator/Input Signal to the LED:
Refer to figure 9b Pin 6
- Input: Triangle Wave at 1MHz
+ Input: Sine Wave at 10kHz

Figure 14b

27

PWM Output Signal of the LED/Input Signal to the Photo-Detector:

Figure 14c
Output Signal of the Photo-Detector/Input Signal to the 2nd Order LPF:
Refer to figure 10a Pin 1 (use 10X probe to measure)-Note (1)

Figure 14d

28

Output Signal of the 2nd Order LPF/Input Signal to the Power Amp:
Refer to figure 10a Pin 2

Figure 14e
Output Signal of the Power Amp/Input Signal to the Speaker:

Figure 14f

29

Test the Circuit with Sine Wave at 20kHz


Input Signal to Comparator with Sine Wave at 20kHz:
Refer to figure 9c orange wire

Figure 15a
PWM Output Signal of the Comparator/Input Signal to the LED:
Refer to figure 9b Pin 6
- Input: Triangle Wave at 1MHz
+ Input: Sine Wave at 20kHz

Figure 15b

30

PWM Output Signal of the LED/Input Signal to the Photo-Detector:

Figure 15c
Output Signal of the Photo-Detector/Input Signal to the 2nd Order LPF:
Refer to figure 10a Pin 1 (use 10X probe to measure)-Note (1)

Figure 15d

31

Output Signal of the 2nd Order LPF/Input Signal to the Power Amp:
Refer to figure 10a Pin 2

Figure 15e
Output Signal of the Power Amp/Input Signal to the Speaker:

Figure 15f

32

Data Table 2:
Input
Input Sin
Frequency Vp-p
100Hz
233mV
1KHz
221mV
10KHz
230mV
20KHz
232mV

PWM
output Vp-p
16.8 V
15.8 V
16 V
15.8 V

LED
7.52 V
7.36 V
7.4 V
7.4 V

Output
Photodiode
799mV
764mV
793mV
746mV

Output LPF Output of


Power Amp
138mV
330mV
143mV
336mV
118mV
310mV
90.4mV
384mV

Note(1): All the measurement of Photodiode was taken under dark room condition.
Measurements for output of Photodiode were captured using 10X probe.

33

Frequency Response of the Circuit Build


Transmitting Side of the Circuit
The following graph shows the frequency respond of gain and phase of the transmitting
side of the circuit in Log(gain) vs. Log() and Log(phase) vs. Log(). The gain is
approximately 11 is due to the LM7171 setting the output signal to its rails which is determined
by the batteries used to drive the IC. In this case the batteries used to drive the LM7171 is +/9V, but when measured it was approximately +/-9.6V. Thus, the gain is affected by the batteries
supplied to the LM7171. As for the phase, as frequency increases, the phase decreases possibly
because at higher frequencies, the RC time constant will increase and this will make the input
and output signal be out of phase.

Phase
Log (Gain) and
Log (Phase)

Gain

Log (Hz)
Figure 16a

34

Receiving Side of the Circuit (2nd order LPF)


The following graph shows the frequency respond of gain and phase of the receiving side
of the circuit in Log(gain) vs. Log() and Log(phase) vs. Log(). The gain is approximately 1 at
low frequencies and drops off to 0.703 at -3dB is because it is a passive low pass filter, which is
designed to have a gain of 1 and at high frequencies the gain drops due to the design of RC
values. As for the phase, as frequency increases, the input and output will be more out of phase
due to the RC time constant.

Gain

Log (Gain) and


Log (Phase)

Phase

Log (Hz)
Figure 16b

35

Conclusion
The final goal of this project is to transmit a modulated audio signal optically, receive the
signal and demodulate the audio signal within several feet away is successful. The circuit build
is placed into a box which holds everything in place. According to the test result waveforms, it
corresponds with the PSPICE simulations waveforms and is as expected in terms of how the
signal behaves and its amplitude. The waveforms for the PWM and how to demodulate the
PWM signal into a sine wave are consistent with the background research.
The key point into making this project successful is to do a thorough research on the parts
such as fast comparator/op-amp, clock oscillator and troubleshooting the circuit. Also, one thing
to keep in mind is that there should not be any DC voltage being input into the comparator thus
that is the reason why there is a coupling capacitor to bias out DC components. Basically, only
AC signal can be input into the comparator. Also, in order to produce a clean PWM signal is to
first produce a stable carrier signal as a reference signal at desired frequency. This carrier signal
has to be greater in AC voltage than the audio signal at all times or else it will be cut off.
If we were to redo this project, we would research for a fast comparator that can compare
frequencies of over 1MHz, build an active LPF for integration as well as demodulation and
search for parts which uses higher power to give a high voltage swing of the AC signal. This
will be sufficient for transmitting the signal optically.
From this course, weve learn important issues such as how a background research can
save time from trouble shooting the circuit. If a thorough research is done and the circuit is well
understood, then there should not be much to troubleshoot besides wiring errors. Another
important issue is to have a good PSPICE simulation of what the ideal circuit may be to have an
understanding of how the waveforms may change under different constraint. Lastly, teamwork
is rather important in order to get the task complete in the end because if one group delays, then
the other group has to wait in order to proceed. For example, if the optical group was finished
early, but the PWM or FM was not ready to transmit the signal, then the task will be delay.

36

References
Sedra and Smith. Microelectronic Circuit. 5th Edition. Oxford University Press, 2003.
Wikipedia, The Free Encyclopedia. 18 Dec. 2007.
<http://en.wikipedia.org/wiki/Lowpass_filter>

37

Appendix A CMX309

38

Appendix B OP-AMP LM7171

39

40

41

42

43

Appendix C OP-AMP TLV2362

44

45

46

Вам также может понравиться