Communication Systems Laboratory Manual prepared by Muhammad Tahir Adeem Aslam S. Irfan Shah Sahar Idrees Department of Electrical Engineering University of Engineering and Technology Lahore c 2013 Department of Electrical Engineering, University of Engineering Copyright and Technology Lahore, Pakistan. Permission is granted to copy and distribute for educational purpose. However, any commercial use of the material, in any form, is not allowed. 2 Contents 1 Exponential Fourier Series 4 2 Fourier Series using Matlab 8 3 Autocorrelation and Energy Spectral Density 13 4 Amplitude Modulation 18 5 Envelope Detection 20 6 Study the Basic Operation of Phase-Lock-Loop (PLL) 22 7 FM Modultion and Demodulation using PLL 28 8 Single Transistor FM Voice Transmitter 31 9 A Simple Sampler using 555 Timer 33 10 Pulse Width Modulation 37 11 Pulse Position Modulation 39 3 Experiment 1 Exponential Fourier Series Objective The objective of this experiment is to calculate and plot exponential Fourier series coefficients. Background In mathematics, a Fourier series decomposes periodic functions or periodic signals into the sum of a (possibly infinite) set of simple oscillating functions, namely sines and cosines (or complex exponentials). The study of Fourier series is a branch of Fourier analysis. Using Eulers Equation, and a little trickery, we can convert the standard Rectangular Fourier Series into an exponential form. Even though complex numbers are a little more complicated to comprehend, we use this form for a number of reasons: 1. Only need to perform one integration 2. A single exponential can be manipulated more easily than a sum of sinusoids 3. It provides a logical transition into a further discussion of the Fourier Transform Description In this lab, you will perform the following tasks: 1. Evaluate the fourier series coefficients using π 1 π Dn = e−jn 4 sinc(n ) 4 4 (1.1) Plot the magnitude | Dn | (in volts) and phase 6 Dn (in degrees) of the first twenty-one coefficients {n = −10, −9, ..., 10} versus frequency (in rad/sec). 2. Plot two periods of g(t) , directly i.e., by creating a vector of samples of g(t) and plotting that vector. 3. Plot an approximation to g(t) using these first twenty-one terms of the exponential Fourier series. Make a function file sinc1.m using the following code listing. Listing 1.1: Sinc function 1 function y = sinc1 (x) % s i n c func tion implementation 4 5 2 3 4 5 6 7 8 9 10 k = length (x) ; for i = 1:k i f x ( i ) == 0 y( i ) = 1; else y ( i ) = s i n ( x ( i ) ) /x ( i ) ; end end end Magnitude and Phase of Fourier Series Coefficients Write the following code in Matlab and run it. You will get the output shown in Figure 1.1(a) & (b). Listing 1.2: Magnitude and Phase Response 1 2 3 4 5 6 7 8 9 10 11 12 13 n = [ −10:10]; % s e t s up t h e v e c t o r o f i n t e g e r i n d i c e s . z = n∗( pi /4) ; Dn = 0 . 2 5 ∗ exp(− i ∗ z ) . ∗ s i n c 1 ( z ) ; % s i n c 1 ( ) i s d e f i n e d above . magDn = abs (Dn) ; % magnitude o f F o u r i e r s e r i e s c o e f f i c i e n t s . argDn = a n g l e (Dn) ∗ ( 1 8 0 / p i ) ; % phase o f F o u r i e r s e r i e s c o e f f i c i e n t s . w = 0.5∗n ; stem (w, magDn) , x l a b e l ( ’ Frequency i n rad / s e c ( u n i t s o f p i ) ’ ) grid t i t l e ( ’ Magnitude o f t h e E x p o n e n t i a l F o u r i e r S e r i e s C o e f f i c i e n t s ’ ) stem (w, argDn ) , x l a b e l ( ’ Frequency i n rad / s e c ( u n i t s o f p i ) ’ ) ylabel ( ’ degrees ’ ) grid t i t l e ( ’ Phase o f t h e E x p o n e n t i a l F o u r i e r S e r i e s C o e f f i c i e n t s ’ ) (a) (b) Figure 1.1: Magnitude of the Exponential Fourier Series Coefficients 6 CHAPTER 1. EXPONENTIAL FOURIER SERIES Sum of Fourier Series Coefficients: The signal g(t) can be reconstructed by adding the Fourier coefficients. To verify this we find the sum given by g(t) ≈ n=+10 X Dn ej nwt (1.2) n=−10 The following code in Listing 1.3 is used to find the sum in (1.2). The output is shown in Figure 1.2. Listing 1.3: Approximation of g(t) 1 n = [ −10:10]; 2 z = n∗( pi /4) ; 3 Dn = 0 . 2 5 ∗ exp(− i ∗ z ) . ∗ s i n c 1 ( z ) ; % symbol . ∗ means element−by−e l e m e n t 4 5 6 7 8 9 multiplication nwo = n ∗ ( p i / 2 ) ; % d e f i n e e l e v e n f r e q u e n c i e s f o r sum t = [ 0 : 0 . 0 1 : 8 ] ; % d e f i n e time s a m p l i n g p o i n t s BIG = nwo ’ ∗ t ; % c r e a t e b i g matrix t o do matrix m u l t i p l i c a t i o n f o r sum g = Dn ∗ exp ( i ∗BIG) ; % here ’ s where t h e sum i s done p l o t ( t , r e a l ( g ) ) , g r i d , x l a b e l ( ’ Seconds ’ ) t i t l e ( ’ Approximation t o g ( t ) u s i n g t h e f i r s t t e n components o f t h e F o u r i e r series ’) Figure 1.2: Approximation to g(t) using the first ten components of the Fourier Series We can approximate g(t) using the first ten components of the Fourier series. The following code is used to generate two periods of function g(t). It uses a custom made unit step function, u(t), a copy of which is also provided below. The ability to use the unit step function to write piecewise functions proves extremely effective. Below is code lisitng. You will get the output in Figure 1.3. 7 Listing 1.4: g(t) using unit step 1 g t = ( u ( t ) − u ( t −1) ) + ( u ( t −4) − u ( t −5) ) + u ( t −8) ; 2 pl o t ( t , gt ) 3 grid , xla bel ( ’ seconds ’ ) 4 t i t l e ( ’ The r e a l g ( t ) ’ ) 5 a x i s ( [ 0 8 −0.2 1 . 2 ] ) ; Listing 1.5: u(t) Implementation 1 2 3 function [ y ] = u(x) y =0.5+0.5∗ s i g n ( x ) ; end Figure 1.3: The “real” g(t) Experiment 2 Fourier Series using Matlab Objective The purpose of this lab experiment is to: 1. use Matlab functions FFT and FFTSHIFT to find Fourier series of a periodic signal. 2. compare the Matlab results with theoretical formula. In this lab we will take the following example signal. Dn = j(−1)n n 6= 0 0 n=0 (nπ) . Background In mathematics, the discrete Fourier transform (DFT) is a specific kind of discrete transform, used in Fourier analysis. It transforms one function into another, which is called the frequency domain representation of the original function (which is often a function in the time domain). The DFT requires an input function that is discrete. Such inputs are often created by sampling a continuous function, such as a person’s voice. The discrete input function must also have a limited (finite) duration, such as one period of a periodic sequence or a windowed segment of a longer sequence. Discrete Fourier Transform(DFT) decomposes a sequence of values into components of different frequencies. This operation is useful in many fields but computing it directly from the definition is often too slow to be practical. An FFT is a way to compute the same result more quickly, computing a DFT of N points using the definition, takes O(N 2 ) arithmetical operations, while an FFT can compute the same result in only O(N log N ) operations. The difference in speed can be substantial, especially for long data sets where N may be in the thousands, the computation time can be reduced by several orders of magnitude in such cases. This huge improvement made many DFT-based algorithms practical. FFTs are of great importance to a wide variety of applications, from digital signal processing and solving partial differential equations to algorithms for quick multiplication of large integers. In particular, the DFT is widely employed in signal processing and related fields to analyze the frequencies contained in a sampled signal, to solve partial differential equations, and to perform other operations such as convolutions or multiplying large integers. A key enabling factor for these applications is the fact that the DFT can be computed efficiently in practice using a fast Fourier transform (FFT) algorithm. 8 9 Description Plotting the Signal This is the code segment for ploting the signal g(t). Vector g contains samples of function g(t), which is formed by concatenating three individual vectors g1, g2 and g3. The result in Figure 2.1 shows the plot of g(t) signal. Listing 2.1: Plotting signal g(t) 1 g1 = [ 0 : 1 / 3 2 : 1 − ( 1 / 3 2 ) ] ; 2 g2 = [ − 1 : 1 / 3 2 : 1 − ( 1 / 3 2 ) ] ; 3 g3 = [ − 1 : 1 / 3 2 : 0 − ( 1 / 3 2 ) ] ; 4 g = [ g1 , g2 , g3 ] ; 5 t = [ −1:1/64:1 −(1/64) ] ; 6 plot ( t , g) ; 7 a x i s ( [ − 1 . 5 1 . 5 −1.5 1 . 5 ] ) 8 grid Figure 2.1: Plot for the signal g(t). Discrete Fourier Series using FFT Using the following code we get the Fourier series coefficients. Listing 2.2: FFT of g(t) 1 z = fft (g) ; 2 stem ( t , z ) ; 10 CHAPTER 2. FOURIER SERIES USING MATLAB If we plot this calculated fft what we get is an arrangement of those total 128 coefficients one by one i.e. they are not arranged as a normal Fourier series spectrum. FFTSHIFT command helps us to reach there. We will get a plot using FFTSHIFT command such that DC component is at the centre, and plot gets the shape of a normal Fourier series plot. Listing 2.3: Shifted version of FFT of g(t) 1 z1 = f f t s h i f t ( z ) ; 2 n = [1:1:128]; 3 a = n−65; 4 f = 0.5∗ a ; 5 stem ( f , abs ( z1 ) ) Figure 2.2: Plot using the Matlab function ’FFTSHIFT’. The above approach uses the Matlab commands FFT and FFTSHIFT. Now by directly using the formula we can also obtain the plot with the help of following code segment. Listing 2.4: Finding spectrum of g(t) 1 m = 128; 2 a = 1; 3 f o r n = −m/ 2 : 1 :m/2−1 4 i f n == 0 5 Dn( a ) = 0 ; 6 else 7 $Dn=( i ∗(( −1) . ˆ n ) ) / ( n∗ p i ) ; $ 8 end 11 9 a = a +1; 10 end 11 n = −m/ 2 :m/2 −1; 12 stem ( n , abs (Dn) ) Magnitude and phase of Dn can also be obtained as follows. Listing 2.5: Magnitude and Phase of g(t) 1 magDn = abs (Dn) ; 2 argDn = a n g l e (Dn) ; 3 stem ( f , magDn) ; 4 stem ( f , argDn ) ; Comments 1. FFT function plot the fourier series but with the DC component. 2. FFTSHIFT shifts the DC component to the center of spectrum. 3. Magnitude of the fourier series is plotted against frequency to remove the complex part from the fourier series. Assignment Given the signal in Figure 2.3: 1. Plot the signal in MATLAB for two time periods. 2. Find its Fourier series and plot it. The plot should have DC component at the centre. 12 CHAPTER 2. FOURIER SERIES USING MATLAB Figure 2.3: Example plot for the assignment. Experiment 3 Autocorrelation and Energy Spectral Density Objective The objective of this experiment is to verify that Energy Spectral Density(ESD) of a periodic signal is equal to the Fourier Transform of Autocorrelation of the signal using Matlab. Background The correlation of a signal with itself is called the Autocorrelation. The Autocorrelation Ψ(τ ) of a real signal g(t) is defined as Z ∞ Ψg (τ ) = (g(t)g(t + τ )) dτ ) (3.1) −∞ It measures the similarity of a signal with itself. The Autocorrealtion provides valuable spectral information which is helpful in analyzing the spectral energy density. The Energy Spectral Density (ESD) is result of energies contributed by all the spectral components of the signal g(t) i.e. Ψg (f ) = |G(f )2 | (3.2) An important relationship between the Autocorrelation of a signal g(t) and Energy Spectral Density Ψg (τ ) exist that is the Energy Spectral Density(ESD) of a periodic signal is equal to the Fourier Transform of Autocorrelation of the signal i.e. Ψg (f ) = Ψg (τ ) (3.3) Description Consider the following Figure 3.1 of signal x(n) which shows a discrete time rectangular signal with length N=5. The magnitude of the Fourier Transform of this signal is given below sin wN 2 X(w) = sin w2 Plot the discrete time domain signal x(n) in Matlab using the following piece of code. 13 (3.4) 14 CHAPTER 3. AUTOCORRELATION AND ENERGY SPECTRAL DENSITY Listing 3.1: Plot of the Signal x(n) 1 n=[ −2:2]; 2 x=[1 1 1 1 1 ] ; 3 stem ( n , x ) ; 4 a x i s ([ −5 5 0 2 ] ) 5 t i t l e ( ’ D i s c r e t e Time Domain S i g n a l ’ ) The output graph produced should be similar to one in Figure 3.1. Using the signal x[n], Discrete Time Domain Signal 2 1.8 1.6 1.4 1.2 1 0.8 0.6 0.4 0.2 0 −5 −4 −3 −2 −1 0 1 2 3 4 5 Figure 3.1: Signal x(n) find out the Autocorrelation y[n] of the signal by using the Matlab function xcorr(x,x). An important point to observe here is that the first sampling instant of Autocorrelation function y[n] should be twice the first sampling instant of the signal x[n] itself. Same is true for the all the points of the Autocorrelation function y[n] . Therefore, for writing the code for Autocorrelation function y[n] we need to genrate the a timing vector twice that of the signal x[n] itself. Listing 3.2: Plot of the Autocorrelation Function y(n) 1 n=[ −2:1:2]; 2 x=[1 ,1 ,1 ,1 ,1]; 3 y=x c o r r ( x , x ) ; 4 ny = [ − 4 : 1 : 4 ] ; 5 stem ( ny , y ) 6 a x i s ([ −5 5 0 6 ] ) 7 t i t l e ( ’ A u t o c o r r e l a t i o n Function y [ n ] ’ ) The Autocorrelation function y[n] should be similar to the Figure 3.2. In order to plot the Fourier Transform F [n] of the Autocorrelation function y[n] the following piece of code is used. 15 Autocorrelation Function y[n] 6 5 4 3 2 1 0 −5 −4 −3 −2 −1 0 1 2 3 4 5 Figure 3.2: Autocorrelation y(n) of signal x(n) Listing 3.3: Plot for the Fourier Transform F(n) of the Autocorrelation Function y(n) 1 M=20; 2 k=−M/ 2 :M/ 2 ; 3 w=(2∗ p i /M) ∗k ; 4 Y=y ∗ ( exp (−2∗ i ∗ p i /M) ) . ˆ ( ny ’ ∗ k ) ; 5 stem (w,Y) 6 a x i s ([ −4 4 0 3 0 ] ) After plotting the Fourier Transform F [n] of the Autocorrelation Function y[n], find out the Energy Spectral Density E[n] of the signal x[n] using its Fourier Transform. The Energy Spectral Density E[n] of a signal is the magnitude square of its Fourier Transform. The following piece of code finds out the Energy Spectral Density E[n]. Listing 3.4: Plot for Energy Spectral Density E(n) of the signal x(n) 1 N=5; 2 M=20; 3 i =1; 4 f o r k=−M/ 2 :M/2 5 6 7 8 9 10 11 w=(2∗ p i /M) ∗k ; i f k==0 $ X( i )=N; $} else $X( i )=s i n (w∗N/ 2 ) / s i n (w/ 2 ) ; $} end i=i +1; 12 end 13 ESD=(abs (X) ) . ˆ 2 ; 14 w=(2∗ p i /M) ∗[−M/ 2 :M/ 2 ] ; 15 stem (w, ESD) 16 CHAPTER 3. AUTOCORRELATION AND ENERGY SPECTRAL DENSITY 30 25 20 15 10 5 0 −4 −3 −2 −1 0 1 2 3 4 Figure 3.3: Fourier Transform F [n] of the Autocorrelation Function y[n] 16 a x i s ([ −4 4 0 3 0 ] ) 17 t i t l e ( ’ESD o f Actual S i g n a l ’ ) Figure 3.3 representing the Fourier Transform F [n] of the Autocorrelation Function y[n] and Energy Spectral Density E[n] of the signal x[n] represented by Figure 3.4 are similar to each other thus showing that the Energy Spectral Density(ESD) of a periodic signal is equal to the Fourier Transform of Autocorrelation of the signal. Plot all the figures on the same window using the subplot command for the ease of comparison. Vary the period and range of the sampling points separately to observe their effects in Matlab. Listing 3.5: Plot for both the figures on the same window 1 n=[ −2:1:2]; 2 x=[1 ,1 ,1 ,1 ,1]; 3 figure (1) ; 4 stem ( n , x ) 5 a x i s ([ −3 3 0 1 . 5 ] ) ; 6 t i t l e ( ’ Gate Function ’ ) ; 7 y=x c o r r ( x , x ) ; 8 ny = [ − 4 : 1 : 4 ] ; 9 figure (2) ; 10 stem ( ny , y ) 11 a x i s ([ −5 5 0 6 ] ) ; 12 t i t l e ( ’ Auto C o r r e l a t i o n ’ ) ; 13 M=20; 14 k=−M/ 2 :M/ 2 ; 15 w=(2∗ p i /M) ∗k ; 16 Y=y ∗ ( exp (−2∗ j ∗ p i /M) ) . ˆ ( ny ’ ∗ k ) ; 17 f i g u r e ( 3 ) ; 17 ESD of Actual Signal 30 25 20 15 10 5 0 −4 −3 −2 −1 0 1 2 3 4 Figure 3.4: Energy Spectral Density E[n] of the signal x[n] 18 stem (w,Y) 19 t i t l e ( ’ Energy S p e c t r a l D e n s i t y ’ ) ; Assignment Experiment 4 Amplitude Modulation Objective The objective of this experiment is to build a simple unbalanced Amplitude Modulator. Background Read Sections 4.2 and 4.3 of the text [Lathi(1998)] for theory background of the experiment. Description Before you build the circuit you need to make an inductor of approximately 22uH. The Appendix at the end of this handout can be used as a guide to design your inductor. Build the circuit in Figure 4.1 to implement an unbalanced Amplitude Modulator. In the circuit shown, V1 and V2 are two sinusoidal sources for generating the message and carrier signals respectively. The R1-V1-V2 network adds the carrier and message signal. The diode D1 is the nonlinear device used to achieve modulation, while the network C1-L1-R4 is the band-pass (BP) filter. The inductor developed will not have exactly the same inductance for which it is designed and hence the resonant frequency of the BP filter will be different. Change the frequency of V2 source and find out at what frequency the signal is maximum across the BP filter. This will be the resonant frequency of the BP filter. Note that the resistor R4 is not required in the actual hardware implementation. It was used in the simulation to control the resistance of the inductor. You should be able to realize that changing R4 affects the Q-factor of the band-pass filter. Appendix: Designing an Inductor The classic equation for calculating the inductance of a given single layer coil is [Murray(1967)]: L= r 2 n2 9r + 10l In (4.1), L is inductance in micro-Henry, r is coil radius in inches (center of coil to center of conductor), n is number of turns, l is coil length in inches (center of starting turn to center of ending turn). 18 (4.1) 19 R2 10k V1 D1 SINE(0 .7 1K) R3 R1 20k 1N4148 C1 .03µ 10k L1 22µ V2 R4 .001k SINE(0 3 200K) .tran 0 1s 0 Figure 4.1: The unbalanced AM modulator. --- D:\Tahir\UET\Teaching\BSc_Courses\EE354_Communication Systems\Labs_EE354\Lab4\AM_Mod.asc --- This equation is generally accurate to around one percent for inductors of common dimensions. It is more convenient to work with coil diameter and (4.1) can be written as: L= d2 n2 18r + 40l (4.2) Experiment 5 Envelope Detection Objective To demonstrate envelope detection of AM signals. Background In an envelope detector, the output of the detector follows the envelope of the modulated signal. The simple circuit shown in figure functions as an envelope detector. On the positive cycle of the input signal, the input grows and may exceed the charged voltage on the capacity, turning on the diode and the capacitor C to charge up the peak voltage of the input signal cycle. As the input falls below this peak value, it falls quickly below the capacitor voltage(which is nearly the peak voltage),thus causing the diode to open. The capacitor now discharges through the resistor R at a slow rate(with a time constant RC ). During the next positive cycle,the same drama repeats. As the input signal rises above the capacitor voltage,the diode conducts again. The capacitor again charges to the peak value of this (new)cycle. The capacitor discharges slowly during the cutoff period. During each positive cycle,the capacitor charges up to the peak voltage of the input signal and then decays slowly until the next positive cycle. Thus,the output voltage closely follows the (rising)envelope of the input AM signal. Further knowledge about envelope detectors can be found from topic 4.3 of the text book. Figure 5.1: AM demodulation circuit. 20 21 Figure 5.2: Envelop detection of AM signal. Description 1. Generate AM signal (D1,R1,R2,C1,L1) with modulation index less than 1 i.e. µ < 1. 2. Build the envelope detector (D2,C2,R3) as shown in figure 1 below. 3. Display the demodulated output of the envelope detector on the oscilloscope. 4. Compare the message signal to the demodulated signal on the oscilloscope. 5. Draw the message, modulated and the demodulated signal on the next page. 6. Investigate the effect of variation of varying the message frequency and modulation index. Assignment Suppose that we have a Single Side Band Signal with a Carrier (SSB+C) of the form φ = Acoswt + [m(t)coswt + mh(t)sinwt] Show that the envelope of such a signal is given by e(t)=A+m(t). Experiment 6 Study the Basic Operation of PhaseLock-Loop (PLL) Objective The ojective of this experiment is to understand the basic working principle of PLL.1 Description 1. Set the values of C1 =0.03uF,R1=R2=18K Ω. 2. Find out the fmin and fmax of the VCO. To find fmin simply connect the VCO input (pin 9) to ground and to find fmax connect pin 9 to VDD . 3. Find out the free-running frequency fo of the VCO.This is the frequency of the output signal when input is not applied to phase detector. 4. Apply an incoming signal Vi from the signal generator. Adjust its frequency to approximately match the free-running frequency f0 of the VCO. When Vi is applied, the PLL should operate in the locked condition,with fo exactly equal to fi .The locked condition can be easily verified by observing Vi and Vosc simultaneously on a dual-trace oscilloscope.If fi =fosc ,stable waveforms of both Vi and Vosc can be observed.Otherwise, one of the waveforms on the scope screen is blurred or is moving with respect to the other. 5. By changing the frequency of the incoming signal,determine the actual lock range of the PLL,i,e., determine the maximum and the minimum frequency fi such that starting from the locked condition the PLL remains in the locked condition.The lock range should be equal to fmax -fmin . 6. Record the readings for the lock range and the capture range below. fmin = ............ fmax = ............ fcap1 =fo -fc = ............ fcap2 =f0 +fc = ............ Lock range=fmax -fmin = .............. Capture range=fcap2 -fcap1 = ............ 1 Refer to Appendix to understand the theory and the working principle of PLL 22 23 Appendix: Phase-Locked Loop Phase-Locked Loop is a device which is used to track the phase and frequency of an incoming signal.it uses a voltage-controlled oscillator(VCO),the output of which can be automaically synchronized (”locked”) to a periodic input signal.The locking property of the PLL has numerous applications in communication systems(such as frequency,amplitude,or phase modulation/demodulation,analog or digital),clock and data recovery ,self-tunable filters,frequency synthesis etc. Following figure represents the block diagram of PLL showing its basic function connected together in a feedback loop. Figure 6.1: Block diagram of a Phase-Locked(PLL) • Voltage-Controlled oscillator(VCO) • Phase detector(PD) • Low-pass loop filter(LPF) VCO is an oscillator of the frequency of which fosc is proportional to input voltage Vo .The input voltage to VCO determines the frequency fosc of the periodic signal Vosc at the output of the VCO. //Phase comparator is device that compares the phase of the output signal of VCO and the incoming signal and produces a signal proportional to the phase diference between the incoming signal and the VCO output signal.The output of the phase detector is filtered by a low-pass loop filter.The loop is closed by connecting the filter output to the input of the VCO.When the loop is locked on the incoming signal Vi ,the frequency of the VCO output fosc is exactly equal to the frequency fi of the periodic signal Vi fosc = fi The basic function of PLL is to maintain the frequency lock(fosc =fi ) between the input and the output signals even if the frequency fi of the incoming signal varies with time.Assuming that the PLL is in the locked condition and then if the frequency fi of the incoming signal increases slightly , the phase difference between the VCO signal and the incoming signal will begin to increase in time.As a result,the filter output voltage Vo increases, and the VCO output frequency fosc increases until it matches fi ,thus keeping the PLL in the locked condition. //The range of frequencies from fi =fmin to fi =fmax where the locked PLL remains in the locked condition 24 CHAPTER 6. STUDY THE BASIC OPERATION OF PHASE-LOCK-LOOP (PLL) is called the lock range the PLL.If the PLL is intially locked,and fi becomes smaller than the fmin ,or if fi exceeds fmax ,the PLL fails to keep fosc equal to fi ,and the PLL becomes unlocked ,i.e. fosc !=fi .When the PLL is unlocked ,the VCO oscillates at the frequency fo called the subtitle center frequency ,or the free-running frequency of the VCO .The lock can be established again if the incoming singal frequency fi gets closed enough to fo .The range of frequencies fi =fo -fc to fi =fo +fc such that the initially unlocked PLL becomes locked is called the capture range of the PLL. The lock range is wider than the capture range.So,if the VCO output frequency fosc is plotted against the incoming frequency fi ,we obtain the PLL steadystate characteristics shown in Fig 2. The characteristics simply shows that fosc =fi in the locked condition,and that fosc =fo =constant when the PLL is unlocked. A hysteresis can be observed in the fosc (fi ) characteristic because the capture range is smaller than the lock range. Figure 6.2: steady-state characteristics of the basic PLL The 4046 Phase-Locked Loop IC A diagram of the 4046 PLL is shown in Fig 3. A single positive supply voltage is needed for the chip .The positive supply voltage VDD is connected to pin 16 and the ground is connected to pin 8.In the lab we will use +VDD =+15V.The incoming signal Vi goes to the input of an internal amplifier at the pin 14 of the chip.The internal amplifier has the input biased at about +VDD /2.Therefore ,the incoming signal can be capacitively coupled to the input as shown in Fig 3.The incoming ac signal Vi of about one volt peak-to-peak is sufficient for proper operation.The output Vi 2 of the amplifier is internally connected to one of the inputs of the phase detector on the chip. Phase Detector The phase detector on the 4046 is simply an XOR logic gate,with logic low output (Vφ =0V) when the two inputs are both high or low,and the logic high output Vφ =VDD )otherwise.Following figure shows the operation of the XOR phase detector when the PLL is in the locked condition. Vi2 and Vosc are two phase-shifted periodic square-wave signals at the same frequency fosc = fi and with 50 percent duty cycle .The output of the phase detector is a periodic square- 25 Figure 6.3: Cmos 4046 PLL Figure 6.4: Operation of the phase detector with XOR gate wave signal Vφ (t) at the frequency 2fi ,and with the duty ratio Dφ that depends on the phase difference between Vi and Vosc . VDD = φ π (6.1) The periodic signal Vφ (t) at the output of the XOR phase detector can be written as the Fourier series: Vφ (t) = Vo + X Vk sin((4kπfi )t − θk ) (6.2) k=1 where Vo is the dc component of Vφ (t),and Vk is the amplitude of the kth harmonic at the frequency 2kfi .The dc component of the phase detector output can be found easily as the average of Vφ (t)over a period TI =2 Vo = VDD Φ π (6.3) 26 CHAPTER 6. STUDY THE BASIC OPERATION OF PHASE-LOCK-LOOP (PLL) Loop filter The output Vφ (t) of the phase detector is filtered by an external low-pass filter.In Fig3,the loop filter is a simple passive RC filter.The purpose of the low-pass filter is to pass the dc and low-frequency portions of Vφ (t) and to attenuate high-frequency ac component at frequencies 2kfi .The simple RC filter has the cut-off frequency: fp = 1 2πRC (6.4) The cut-off frequency should be smaller than the input frequency for the output of the filter to be approximately equal to Vo .Vo is proportional to the phase difference between the incoming signal Vi and the signal Vosc from the VCO and the constant of proportionality , KD = VDD pi (6.5) is called the gain or the sensivity of the phase detector .This expression is valid for 0≤ φ ≤ π .The filter output VO as a function of the phase differenceφ is shown in Fig 5.Note that Vo if Vi and Vosc are in phase (φ=0),and that it reaches the maximum value Vo =VDD when the two signals are exactly out of phase(φ=π).From fig4 it is easy to see that for φ <0,V0 increases and for φ > π,V0 decreases.Of course ,the characteristic is periodic in φ with period 2π.The range 0 ≤ φ ≤ π is the range where the PLL can operate in the locked condition. Figure 6.5: Characteristics of the phase detector Voltage Controlled Oscillator The voltage VO controls the charging and discharging currents through an external capacitor C1 ,and therefore determines the time needed to charge (discharge) the capacitor to a predetermined threshold level.As a result ,the frequency fosc of the VCO output is determined by VO .The VCO output Vo sc is a square wave with 50percent duty cycle and frequency fosc .As shown in Fig 3,the VCO characteristics are user-adjustable by three external components:R1,R2 and C1.When Vo is zero ,VCO operates at the minimum frequency fm in and when V0 =VD D,the 27 VCO operates at the maximum frequency fmax . The actual operating frequencies can differ significantly from the values predicted by the above equations.So,one may need to tune the component values by experiment. For fosc between the minimum fmin and the maximum fmax ,the VCO output frequency fosc is ideally a linear function of the control voltage Vo .The slope Ko = 4fosc 4VO (6.6) is called the gain or the frequency sensitivity of the VCO,in HZ V . Lock Range and Capture Range Once the PLL is in the locked condition ,it remains locked as long as the VCO output frequency fosc can be adjusted to match the incoming signal frequency fi ,i.e., as long as fmin ≤ fi ≤ fmax . When the lock is lost,the VCO operates at the free-running frequency fo ,which is between the fm in and fm ax.To establish the lock gain , i.e. to capture the incoming signal again,the incoming signal frequency fi must be close enough to fo .Here ”close enough” means that fi must be in the range from fo -fc to fo +fc ,where 2fc is called the capture range.The capture range 2fc is smaller than the lock range fmax -fmin as shown in Fig.2 .The capture range 2f − c depends on the characteristics of the loop filter .For the simple RC filter,a very crude,approximate implicit expression for the capture range can be found as: fc ≈ VDD Ko q 2 1 + ( fc )2 (6.7) fp where fp is the cut-off frequency of the filter,VDD is the supply voltage and KO is the VCO gain.Given ko and fp this relation can be solved for fc numerically which yields an approximate theoretical prediction for the capture range 2fc . If the capture range is much larger than the cut-off frequency of the filter, ffpc 1,then the expression for the capture range is simplified. 2fc ≈ q 2KO fp VDD (6.8) Note that the capture range 2fc is smaller if the cut-off frequency fp of the filter is lower.It is usually desirable to have a wider capture range,which can be accomplished by increasing the cut-off frequency of the filter.On the other hand a lower cut-off fp is desirable in order to better attenuate high frequency components of vφ at the phase detector output and improve noise rejection in general. Experiment 7 FM Modultion and Demodulation using PLL Objective In this Laboratory exercise you will generate a single-tone modulated FM signal using the Voltage-controlled Oscillator (VCO) in a Phase-locked loop (PLL) Task Build the circuit shown next. This uses the VCO portion of the 4046 PLL. Figure 7.1: First, investigate it using the ”test input” circuit that is shown in Figure 2. Find the frequency and sketch the waveform for the three VCO input voltages shown in the table below. From that information, deterine the FM constant , Kf, for your modulator. See the data analysis section below for guidence in this calculation. Second, instead of the ”test input” circuit, use, as the input, the function generator with the sinusoidal output listed as follows: Frequency = 5 kHz (fm = modulating frequency) Amplitude = 2 volts (p-p) D.C.Offset = 5V 28 29 Figure 7.2: Examine the time-domain signal at the VCO output. It should look similar to the plot of Figure 3. Essentially, this is a rectangular waveform with a varying frequency , i.e., a frequency that is modulated. The maximum and minimum frequencies, fmax and fmin, can be determined using the following formulas: f min = f max = 1 T1 1 T2 Write an expression for the time domain output, assuming that the output waveform is sinusoidal like. What is the β for your signal? Examine the spectra using the spectrum analyzer. (Make the Connection to the spectrum analyzer using a high impedence scope probe). Sketch the spectra and measure the power in signicant sidebands (powers greater than one percent of the total transmitted power). Record this data in the table shown in the ”report” section. Figure 7.3: 30 CHAPTER 7. FM MODULTION AND DEMODULATION USING PLL Data Analysis The FM constant, Kf , can be determined by plotting the VCO’s output frequency v/s the VCO’s input voltage. This should give (approximately) a straight line, its slope is Kf in hertper-volt. You will want to conver it to radians/second-per-volt in order to write the expression for the FM signal you generate. To find β , use β = [peakmodulatingtoneamplitude/modulatingtonef requency(inHz)]kf . An alternative method is given by β= fmax − fmin fm Use the following circuit for FM demodulation. It is not necessary to use the buffer and Use the following circuit for FM demodulation. It is not necessary to use the buffer and output low pass filter. . output low pass filter. +10v 0.1uF 16 digital link 16 14 10k 3 CD4046 10k 10uF Vin V1 9 11 10k 7 C=1000pF CD4046 4 5 8 VCO 6 Cx=100pF Rx=8k 5k 2 9 4 VCO 5 8 11 7 6 Cx=100pF Rx=8k Figure 4. A frequency modulation and demodulation circuit. Figure 7.4: 100pF Vout Experiment 8 Single Transistor FM Voice Transmitter Objective The objective of this experiment is to build a simple FM voice transmitter, transmit the frequency modulated voice signal and then receive it by an ordinary FM receiver. Background Read Sections 5.3 and 5.4 of the text and working of Colpitts oscillator for theory background of the experiment. Description 1. Implement the circuit as shown in Figure 8.1. 2. Between Port A and Port B Mic will be placed. 3. Leave wire hanging at the output.This will act as an antenna. 4. Place a FM receiver at some distance from the antenna and hear the signal sent from the Mic. 5. Capacitor C1 is for providing AC ground for carrier frequencies and providing high impedance at audio frequencies so that whole signal is delivered at the base of BJT . 6. C2, C3, base-emitter capacitance BEC and collector-base capacitance CBC provide the Tank circuit capacitances. 7. C2,C3 and BEC are fix capacitances while CBC is variable.This is because base-collector junction is reverse biased and any change in base voltage at low frequency will change junction capacitance and thus the oscillation frequency of the tank circuit. 8. The tank circuit oscillating frequency is found by performing AC analysis. C3 is in series with BEC giving us an equivalent capacitance CE of their series combination. This CE,CBC and C2 are in parallel and their sum is the equivalent capacitance CEQ of the tank circuit. 9. From the data sheet of 2N 2222, BEC and CBC are 25pF and 8pF (mean value) respectively.Thus CEQ comes out to be equal to 25pF . 31 32 CHAPTER 8. SINGLE TRANSISTOR FM VOICE TRANSMITTER 10. Substituting CEQ in the formula of the oscillatiob frequency of the tank circuit we can find the required inductance L1 for any oscillation frequency. 11. For oscillation frequency of F M 100 channel i.e. 100M Hz the inductance is 0.1µH. Note that the capacitor C1 is not required in the actual hardware implementation. Results Using a receiving antenna connected directly to spectrum analyzer try to locate the FM transmitter frequency of oscillation. If that frequency is in the commercial FM band of 88 MHz to 108 MHz, then the transmission of message signal from the Mic can be listened on the commercial FM receiver. Figure 8.1: Circuit diagram for the single transistor FM transmitter. Experiment 9 A Simple Sampler using 555 Timer Objective The objective of this lab session is to sample a baseband signal m(t) using transistor as a switch. The switching sequence is generated by 555 timer in ASTABLE mode. Background Go through section 6.1 of your textbook for complete theoretical background of Sampling. A brief overview is given below. In signal processing, sampling is the reduction of a continuous signal to a discrete signal. A common example is the conversion of a sound wave (a continuous signal) to a sequence of samples (a discrete-time signal). A sample refers to a value or set of values at a point in time and/or space. A sampler is a subsystem or operation that extracts samples from a continuous signal. A theoretical ideal sampler produces samples equivalent to the instantaneous value of the continuous signal at the desired points. Nyquist Sampling theorem is of great importance in sampling the signals. It states that:A signal can be completely determined from its samples if they are taken at uniform intervals each of length (less than or equal to) 1/2B where B is the bandwidth of the signal. Description The circuit used for this lab session uses 555 timer. 555 timer is an IC used in variety of applications like pulse generators and oscillators. It is called 555 because it has three resistances of 5k. It has 3 modes of operation:1. Bistable Multivibator Stable in both states 2. Monostable Multivibator Stable in only one state 3. Astable Multivibator Unstable in both states The two states are Triggered and Non-Triggered Internal circuit of 555 is shown in Figure 1.1. The trigger pin (#2) is bised at 13 V cc and the control pin (#5) is biased at 32 V cc. Vcc for 555 timer can vary from 6-18 volts depending on the operation.In Astable mode, two resistors are used as shown in the Fig 11.2. The capacitor C1 is charged through the series combination of R1 and R2 and it discharges through R2. Capacitor C2 is used for noise elimination. When the capacitor charges up to (or slightly above) 32 V cc, 33 34 CHAPTER 9. A SIMPLE SAMPLER USING 555 TIMER Figure 9.1: Internal circuit of 555. the voltage at pin #6 becomes larger than the voltage at pin #5, the reset input of SR Latch is activated and the state triggers at that point. When reset is high, the active low output of SR Latch is high and it turns on the transistor. Now, the capacitor starts to discharge through this transistor and R2 resistance. When the voltage of capacitor falls below 1 3V cc, the state triggers again. The active low output of SR Latch is disabled and transistor switches off again thus providing path for the capacitor to charge again through R1 and R2 . In this way, it creates a pulse waveform. The duty cycle of this waveform can be controlled by properly selecting the values of R1 , R2 and C1 . Experimental Tasks 1. Connect the circuit as shown in Figure 1.2. 2. 555 timer is used to generate the switching sequence for the transistor which is operated in its saturation region. 555 timer is used in its astable mode as described above. The duty cycle of the output square wave is set to be much higher than 50% to generate the sampled impulses at the output. This is in accordance with the Nyquist Sampling Theorem. 3. The input to the transistor is shown in Figure 1.3. 4. The time period of such an astable output is given by the sum of high time and low time TH =0.7(R1 + R2 ) C1 TL =0.7*R2 *C1 where TH and TL are high and low times respectively. 35 Figure 9.2: Circuit Figure 9.3: Input to the transistor 5. Design 555 timer in astable mode so that duty cycle of the output waveform is 95%. Use C1 =0.1uF. 6. The baseband signal m(t) is connected in series with the transistor. A dc component is added to m(t) to ensure that it remains positive. Negative values of m(t) cannot keep transistor in saturation mode. When transistor is OFF, m(t) appears at the output and when it is ON output voltage is zero. In this way m(t) is sampled. 7. Keep the baseband signal amplitude to 2V and dc offset to 3V. 8. Observe the sampled output on oscilloscope. 9. The sampling period in this case will be TS =TH +TL The sampling period can be changed by changing the time period of the output waveform. Change the sampling time by using different values of resistors keeping the duty cycle to 95%. 36 CHAPTER 9. A SIMPLE SAMPLER USING 555 TIMER 10. Finally, you can design a filter to obtain the signal m(t). The filter will be a simple first order RC low pass as shown in Figure 1.4. Choose the cut off frequency of your filter less than the sampling frequency to obtain m(t) at the filter output. RC < where f s = 1 2π ∗ f s 1 Ts Figure 9.4: Low pass RC filter Experiment 10 EE 354 Communication Systems Lab #11 Pulse Width Modulation Pulse Width Modulation Objective Objective Theaobjective this experiment is to build a simple Pulse Width Modulator (PWM). To build simple of pulse width modulator. Background Background Pulse width modulation has numerous applications. It is widely used in motor speed control, light dimming control applications to name a few. Pulse width modulation has numerous applications. It is widely used in motor speed conDescription trol,light dimming control applications to name a few. Using the circuit diagram below, construct an astable multi-vibrator. To check the circuit functionality you can connect a capacitor at pin 5 (labelled CV) of the chip. In this mode a Description constant width pulse train will be produced. the above mentioned step construct is validatedan experimentally, connect a sinusoidal source 1V funcUsing Once the circuit diagram below astable multivibrator. To check thewith circuit (rms), and 3.0V a DC offset added tionality you200Hz can connect capacitor at into pin it. 5 of the chip. In this mode a constant width pulse train will be produced. Figure 1: Pulse width modulation circuit diagram for sinusoidal modulation. Figure 10.1: Once the above mentioned step is validated experimentally, connect a sinusoidal source with 1V RMS, 200Hz and 3V dc offset added into it. The graph of Figure 10.2 shows the modulating and the PWM signal simultaneously. 37 38 CHAPTER 10. PULSE WIDTH MODULATION Results The graph on the next page shows the modulating and the PWM signal simultaneously. V(n004) 5.4V V(n006) 4.8V 4.2V 3.6V 3.0V 2.4V 1.8V 1.2V 0.6V 0.0V 0.0ms 0.5ms 1.0ms 1.5ms 2.0ms 2.5ms 3.0ms 3.5ms Figure 2: Modulating sinusoidal and PWM signals. Figure 10.2: 4.0ms 4.5ms 5.0ms Experiment 11 Pulse Position Modulation Objective The objective of this lab session is to build a simple pulse position modulator (PPM) using two 555 timer ICs. EE321 Communication Systems Lab session # 12 Background Pulse Position Modulation Pulse-position modulation (PPM) is widely used in optical communications including optical fiber as well as IR remote controls. It is suitable for those applications, where efficiency is more Objective important and external interference is minimal. The objective of this lab session is to build a simple pulse position modulator (PPM) using two 555 timer ICs. Description Figure 1: Pulse position modulator circuit Figure 11.1: The circuit for PPM generation. 39 40 CHAPTER 11. PULSE POSITION MODULATION V(n009) V(n006) 5.0V 4.5V 4.0V 3.5V 3.0V 2.5V 2.0V 1.5V 1.0V 0.5V 0.0V 0.0ms 0.4ms 0.8ms 1.2ms 1.6ms 2.0ms 2.4ms 2.8ms 3.2ms --- D:\UET\Teaching\BSc_Courses\EE354_Communication Systems\Labs_EE354\Lab12\PPM.raw --- 3.6ms 4.0ms Figure 11.2: The modulating signal (sine wave) and the resulting PPM output. The circuit diagram of the PPM is shown in Figure 11.1. The first 555 timer IC is used in its astable multivibrator mode to produce a square wave of 50% duty cycle. The second 555 timer IC is used in its monostable mode. To verify the operation of the circuit, connect 0.1uF capacitor at pin 5 of both ICs. Doing so should produce a constant width square wave with equal high and low times. Once, the circuit has been verified, connect a sinusoidal signal of 0.5V peak and 2.5V DC offset at pin 5 of the astable multivibrator and verify that the output is a pulse train with constant high time but varying low time (PPM) as shown in Figure 11.2. Bibliography [Lathi(1998)] B.P. Lathi. Modern Digital and Analog Communication Systems 3e Osece. Oxford University Press, 1998. [Murray(1967)] R. Murray. The Radio Amateur’s Handbook. League, Newington, Conn., 44 edition, 1967. 41 The American Radio Relay