EEE1005-Labsheet

10
Lab 1: Generation and Display of Various Signals In the first part of Lab 1, our goal is to generate five kinds of electrical signals and display them properly on a scope. These signals are as follows: 1. A rectangular pulse of amplitude 2 volts starting at time T1 = 3 sec and going back to zero at T2 = 9 sec; 2. A sine wave of amplitude 1 volt and frequency 0.1 Hz; 3. A saw-tooth wave of amplitude 1 volt and frequency 0.2 Hz; 4. A square wave oscillating between 0 and 1 volt, with frequency 0.05 Hz; 5. A noise process of power 0.05 watt and sample time Ts = 0.1 sec. For this experiment you will need the following blocks: Simulink – Commonly Used Blocks: Sum, Constant and Gain Simulink – Sources: Signal Generator, Signal Builder and Band-Limited White Noise Simulink – Sink: Scope Display these five signals on the same scope and make sure to set the X and Y scales to suitable values for proper display. You can get a copy of the scope output by pressing Alt and Prt Scrn and pasting it into a Word document. The scope should have five inputs and a time range of 100 seconds. The simulation will run from T start = 0 sec to T end = 100 sec, and will operate on a discrete and fixed time-step of 0.1 sec. The Simulink model should look like Figure 1. Figure 1: Simulink Model for Lab 1

description

EEE1005-Labsheet

Transcript of EEE1005-Labsheet

Page 1: EEE1005-Labsheet

Lab 1: Generation and Display of Various Signals In the first part of Lab 1, our goal is to generate five kinds of electrical signals and display them properly on a scope. These signals are as follows:

1. A rectangular pulse of amplitude 2 volts starting at time T1 = 3 sec and going back to zero at T2 = 9 sec;

2. A sine wave of amplitude 1 volt and frequency 0.1 Hz;

3. A saw-tooth wave of amplitude 1 volt and frequency 0.2 Hz;

4. A square wave oscillating between 0 and 1 volt, with frequency 0.05 Hz;

5. A noise process of power 0.05 watt and sample time Ts = 0.1 sec.

For this experiment you will need the following blocks: Simulink – Commonly Used Blocks: Sum, Constant and Gain Simulink – Sources: Signal Generator, Signal Builder and Band-Limited White Noise Simulink – Sink: Scope Display these five signals on the same scope and make sure to set the X and Y scales to suitable values for proper display. You can get a copy of the scope output by pressing Alt and Prt Scrn and pasting it into a Word document. The scope should have five inputs and a time range of 100 seconds. The simulation will run from Tstart = 0 sec to Tend = 100 sec, and will operate on a discrete and fixed time-step of 0.1 sec. The Simulink model should look like Figure 1.

Figure 1: Simulink Model for Lab 1

Page 2: EEE1005-Labsheet

In the second part of Lab 1, write your own MATLAB scripts to plot the periodic signals 2 to 4 from Tstart = 0 sec to Tend = 60 sec.

Lab 2: Low-Pass Digital Filter In this experiment, you will implement the low-pass digital filter in Simulink as shown in fig. 2. You will need the following blocks: Simulink – Commonly Used Blocks: Product, Sum and Constant Simulink – Sources: Sine Wave Simulink – Sink: Scope Simulink – Discrete: Unit Delay (1/z) In the ‘Sine Wave’ block, change ‘Sine type’ to ‘Sampled’, ‘Samples per Period’ to 256 and ‘Sample Time’ to 0.001. For the ‘Unit Delays’ make sure that ‘Input Processing’ is set to ‘Inherited’. 1. The discrete frequency fd of the sampled sine wave is 1/(samples/period). With the number of

samples/period equal to 256 the discrete frequency is therefore 1/256 cycles/sample. Given that the sample time is 0.001s, what is the analogue frequency of the sine wave?

2. With the number of samples per period set to 256, observe and record the input and output of the filter with the Scope. Now set the number of samples per period to 4 and observe and record the filter input and output. Explain your results.

3. You will now plot the frequency response of the low-pass filter. Record the amplitude of the filter output for several values of samples per period ranging from 256 down to 4 in a table. Plot the frequency response of the amplitude against analogue frequency. What is the -3dB bandwidth of the low-pass filter?

4. Add a second Sine Wave block to the system and change ‘Sine Type’ to sampled, ‘Samples per period’ to 4 and ‘Sample time’ to 0.001s. Change the first Sine wave block so that the ‘Samples per period’ is set to 64.

Use a ‘Sum’ block to add the two Sine Wave blocks together and connect the output to the input of the filter. Set the Scope to have 3 axes and connect it to the original signal, the summed signal and the filter output. Observe and record the signals on the Scope and explain your results.

Page 3: EEE1005-Labsheet

Figure 2: FIR Low-Pass Filter for Lab 2.

Page 4: EEE1005-Labsheet

Lab 3: Fourier Series Assume that s(t) is a periodic signal with period T. Fourier showed that such signal can be seen as an infinite sum of sine and cosine terms:

1

0 2sin2cos)(

n

nn nftbnftaatf

where

2

2

)(1

0

T

T

dttfT

a ,

2

2

2cos)(2

T

T

dtnfttfT

an ,

2

2

2sin)(2

T

T

dtnfttfT

bn .

Three examples of periodic signals and their Fourier series: 1. Square Wave

ttttts

7cos

7

15cos

5

13cos

3

1cos

4)(

Page 5: EEE1005-Labsheet

2. Triangle Wave

ttttts

7cos

49

15cos

25

13cos

9

1cos

8)(

2

3. Saw-Tooth Wave

ttttts

7sin

4

15sin

3

13sin

2

1sin

2)(

For this experiment you will need the following blocks: Simulink – Commonly Used Blocks: Sum and Gain Simulink – Sources: Sine Wave Simulink – Sink: Scope Throughout this lab, our goal is to check that any periodic signal can indeed be seen as a sum of sine waves in order to illustrate the concept of Fourier series. To this end, we consider the three periodic signals mentioned above, namely the square wave, the triangular wave, and the saw-tooth wave. For each kind of periodic signal, we use the model depicted in Figure 3 to visualize on a scope four signals composed of:

Page 6: EEE1005-Labsheet

1. The fundamental;

2. The fundamental plus the first harmonic;

3. The fundamental plus the first two harmonics;

4. The fundamental plus the first three harmonics. Design the models corresponding to the three waves in the following order: Experiment 1: Square wave. Experiment 2: Triangular wave. Experiment 3: Saw-tooth wave. Comment on the differences between the various signals displayed on the scope and the three kinds of waves we are trying to generate.

Figure 3: Simulink model to observe fundamental and first three harmonics of a square wave.

Lab 4: Amplitude Modulation and Demodulation In this lab, you will investigate amplitude modulation (AM) and two types of demodulation: the product detector and the envelope detector. A DC voltage, VDC, is added to the message, m(t), and

the sum is multiplied by a carrier signal, cos(2fct), which has a much higher frequency, fc, than the highest frequency in m(t), as shown in fig. 4a.

Sine Wave 4

Sine Wave 3

Sine Wave 2

Sine Wave 1

Scope

4/pi

Gain 8

4/pi

Gain 7

4/pi

Gain 6

4/pi

Gain 5

1/7

Gain 4

1/5

Gain 3

1/3

Gain 2

1

Gain 1

Page 7: EEE1005-Labsheet

Figure 4a: Amplitude Modulator

At the receiver, a product detector multiplies the AM carrier with a signal generated by a local

oscillator with the same frequency as the carrier frequency, fc. This will result in two copies of the

AM signal: one centred at twice the carrier frequency, 2fc, and centred at 0Hz (baseband). A low-

pass filter removes the high frequencies to leave the desired baseband signal.

Alternatively, an envelope detector can be used at the receiver, which comprises a diode followed

by a resistor and capacitor in parallel acting as a low-pass filter. Both detectors are shown in fig. 4b.

Figure 4b: Product detector and envelope detector.

In this experiment you will need the following blocks: Simulink – Commonly Used Blocks: Product, Sum, Constant, Saturation Simulink – Sources: Signal Generator Simulink – Sink: Scope Simulink – Discrete: Zero-Order Hold DSP System Toolbox – Filtering – Filtering Implementations: Analog Filter Design DSP System Toolbox – Sinks: Spectrum Scope Construct the AM communication system in fig. 4c and set the blocks as follows:

For the message ‘Signal Generator’ block set ‘Wave form’ to sine and ‘Frequency’ to 100.

For the carrier ‘Signal Generator’ block set ‘Wave form’ to sine and ‘Frequency’ to 1000.

Set the DC offset to 3

For the local oscillator ‘Signal Generator’ block set ‘Wave form’ to sine and ‘Frequency’ to 1000.

Set both low-pass filters so that ‘Filter order’ is 8 and ‘Passband edge frequency’ is 300*2*pi (300Hz*2*pi rad/s).

For the ‘Zero-Order Hold’ block connected to the AM signal set the ‘Sample time’ to 4E-4 and set the ‘Spectrum Scope’ so that ‘Spectrum units’ are dBW, ‘Spectrum type’ is one-sided, ‘Buffer input’ is ticked, ‘Buffer size’ is 8192, ‘Specify FFT length’ is ticked and ‘FFT length’ is 8192.

For the ‘Zero-Order Hold’ block connected to the AM signal set the ‘Sample time’ to 1E-4 and set the ‘Spectrum Scope’ so that ‘Spectrum units’ are dBW, ‘Spectrum type’ is one-sided, ‘Buffer input’ is ticked, ‘Buffer size’ is 2048, ‘Specify FFT length’ is ticked and ‘FFT length’ is 2048.

For the ‘Zero-Order Hold’ block connected after the low-pass filter set the ‘Sample time’ to 1E-3 and set the ‘Spectrum Scope’ so that ‘Spectrum units’ are dBW, ‘Spectrum type’

Sm(t)

VDC tfc2cos

AM carrier

tfc2cos

AM carrierLPF

m(t) R CAM

carrierm(t)

Page 8: EEE1005-Labsheet

is one-sided, ‘Buffer input’ is ticked, ‘Buffer size’ is 8192, ‘Specify FFT length’ is ticked and ‘FFT length’ is 8192.

Note: The zero-order hold blocks sample the continuous signals and the FFT (fast Fourier transform) blocks perform a discrete Fourier transform on the sampled signal to transform it to the frequency domain. The discrete Fourier transform will be introduced in Stage 2. You can get a copy of the frequency spectra by pressing Alt and Prt Scrn and pasting it into a Word document.

1. Run the model and observe and record the signals on the Scope.

2. Comment on the amplitude modulated carrier waveform with reference to the message signal

and the DC offset value. 3. Compare and discuss the demodulated signals from the product detector and envelope

detector.

4. Observe and record the frequency spectra on the three Spectrum Scopes (Click on Autoscale to obtain a good view of the spectra). Explain how each spectrum is related to its corresponding time domain signal.

5. Now change the DC offset to 0 and repeat tasks 2, 3 and 4.

Figure 4c: Amplitude Modulator and Demodulators for Lab 4.

Lab 5: Noise in a Digital Communication System The aim of this lab is to investigate the effect of additive white Gaussian noise (AWGN) on the performance of a digital communication system. The communication system is shown in fig. 5 and has a binary output generated by the ‘Bernoulli Binary Generator’, which has a bit period of 1s. The binary signal then modulates the amplitude of the carrier wave. The carrier wave is multiplied by either 0 or 1 so the modulated output will be a sine wave with amplitude 0 or 1. This is an example of a simple digital modulation scheme called On-Off Keying (OOK), which can be generated using an amplitude modulator.

Page 9: EEE1005-Labsheet

The ‘Gaussian Noise Generator’ generator generates Gaussian-distributed random noise samples that are added to each sample of the modulated signal. The demodulation of the signal is achieved by first multiplying the modulated signal with a local oscillator that has the same frequency as the carrier wave. The ‘Integrate and Dump’ block then calculates the average of this signal. This is scaled down to match the amplitude of the original binary signal. The ‘Switch’ block checks compares average value with a threshold value and outputs 0 is the average is less than 0.5 and output 1 if it is greater than or equal to 0.5, thus generating a binary signal. If the noise is not too severe then this binary signal should be the same as the original binary signal. The ‘Display’ shows, from top to bottom, the bit-error rate, the number of bit errors and the total number of bits transmitted. For this experiment you will need the following blocks: Simulink – Commonly Used Blocks: Product, Sum, Constant, Gain and Switch Simulink – Sources: Sine Wave Simulink – Sink: Scope and Display Communications System Toolbox – Comms Sources – Random Data Sources: Bernoulli Binary Generator Communications System Toolbox – Comms Sources – Noise Generators: Gaussian Noise Generator Communications System Toolbox – Comm Sinks: Error Rate Calculator Communications System Toolbox – Comm Filters: Integrate and Dump Construct the system shown in fig. 5 and set the ‘Simulation stop time’ to 1000.

Set both ‘Sine wave’ blocks so that the ‘Sine type’ is time based, ‘frequency’ is 200 and ‘Sample time’ is 0.001.

In the ‘Gaussian Noise Generator’ block set ‘Variance’ to 0 and ‘Sample time’ to 0.001.

In the ‘Integrate and Dump’ block set the ‘Integration period’ to 1000.

In the ‘Error rate calculator’ block set the ‘Receive delay’ to 1.

In the ‘Switch’ block set ‘Threshold’ to 0.5. 1. Run the system and observe and record the signals on the Scope. To see the signals more clearly

change the ‘Time range’ to 10. Notice that the demodulated signal has a delay of 1 second compared with the input signal. This delay is due to the Integrate and Dump function and is compensated for in the 'Error Rate Calculator’ by setting ‘Receive delay’ to 1.

2. Increase the values of ‘Variance’ in the ‘Gaussian Noise Generator’ block from 10 to 100 and record the corresponding number of bit errors and the bit-error rate in a table.

3. The performance of a digital communication system is evaluated by plotting the bit-error rate

against a signal-to-noise ratio. Conventionally, this is the bit energy Eb divided by the noise power spectral density N0. The bit energy is equal to the energy of the modulated carrier over a 1 second interval, which is determined by squaring each sampled value of the carrier signal and summing them. Since the bit period is 1s and the sample period is 0.001s then there are 1000 samples. As discussed in the lectures, the energy of a sampled sine wave over one period is 0.5 × no. of samples so its energy, and the bit energy, is 500. Also, from the lectures we know that N0 is two times the variance so the signal-to-noise ratio is

20 2

500

N

Eb

Page 10: EEE1005-Labsheet

Use Matlab (or another program such as Excel or Libre Office Calc) to plot the bit-error rate against Eb/N0 in decibels (dB). You need to set the y-axis so that it is logarithmic, which can be achieved in Matlab by using the command ‘semilogy’ to plot the results.

Figure 5: Digital Communication System for Lab 5.