1 Brief Tutorial - New Jersey Institute of Technologymad29/Final_Project.pdf · MATLAB Final...

14
MATLAB Final Project Class: Digital Communications Dentato 2012 1 Brief Tutorial In this section we will explore how to open and navigate SIMULINK 1.1 Open Simulink 1. First open MATLAB from the install directory or desktop shortcut. 2. Once open locate the SIMULINK icon as show in Figure 1 or simply type “simulink” in the command window G j g j g 3. Once you open SIMULINK you will see the “Library Browser” as in Figure 2 Figure 2: “Library Browser” Figure 1: MATLAB

Transcript of 1 Brief Tutorial - New Jersey Institute of Technologymad29/Final_Project.pdf · MATLAB Final...

MATLAB Final Project

Class: Digital Communications Dentato 2012

1 Brief Tutorial

In this section we will explore how to open and navigate SIMULINK

1.1 Open Simulink

1. First open MATLAB from the install directory or desktop shortcut. 2. Once open locate the SIMULINK icon as show in Figure 1 or simply type “simulink” in the

command window Gjgjg

3. Once you open SIMULINK you will see the “Library Browser” as in Figure 2

Figure 2: “Library Browser”

Figure 1: MATLAB

MATLAB Final Project

Class: Digital Communications Dentato 2012

4. Highlighted in Figure 2, locate and select the new model icon and a new model shown in Figure 3 will open. Once opened SAVE your model.

Figure 3: New Model

1.2 Summary

In this section we launched SIMULINK and opened a new model. We are now ready to build simulations.

2 Adding Blocks to a New Model

In the previous section we opened a new model from the “Library Browser” we will now add some blocks and run a simulation

2.1 Adding a Sine Wave Generator

1. In Figure 4 locate the “Sine Wave” block under Simulink->Sources and drag it into your new model window as seen in Figure 5.

2. Under Simulink->Sinks locate the “Scope” Block and drag that to the new model window as well. Again, reference Figure 5.

3. By placing the mouse over the output of the “Sine Wave” the mouse cursor will change from an arrow to crosshairs. Left click and drag the wire from the “Sine Wave” block to the input of the “Scope” as seen in Figure 6.

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 4: “Sin Wave” Block Located in “Library Browser”

Figure 5: “Sine Wave” and “Scope” Block Added to Model

Output Input

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 6: “Sin Wave” Connected to Scope

4. Once the two blocks have been wired double click on the “Sin Wave” Block and make the changes as seen in Figure 7.

Note: The sample time is set to 1/10000 or 100μs which means that the highest frequency sine wave we can create is 5000Hz and still obey the Nyquist Criteria. Play with this. Change the frequency and observe the results. You will notice that the closer you get to 5000Hz the choppier the waveform will get. Try changing the sampling rate and observe the results.

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 7: Change Frequency to 200Hz and the Sample Time

5. Once we have finished click “Ok” change the simulation time to 0.01secs and run the model by clicking run as seen in Figure 8.

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 8: Click “Run”

6. Once the model has finished running double click the scope and zoom in on the plot as seen in Figure 9.

Figure 9: “Scope Plot”

2.2 Exercise

Add another “Sine Wave” block at 600MHz. Click on settings as seen in Figure 10 for the scope plot and add another axis changing the “1” to a “2”. Click “Ok”. Another input will appear on the scope. Wire the “Sine Wave” block you just added to the scope and run the simulation again. You will get two plots both containing a sine wave.

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 10: Adding Another Axis to the Scope Plot

2.3 Exercise

In this exercise sum two sin waves together and observe the output. Your model should look like that in Figure 11. Sum block can be found in Simulink->Commonly Used Bocks or Simulink->Math Operators. You need to add one more axis to the scope plot. Also, you need to tap off existing wires to create new connections. To do this, place the mouse over the wire and right-click. While right-clicking drag the wire to the new scope inputs you have created. Now try the same thing again, but this time use the “product” (multiplication) block.

Note: That “Sum” and “Add” have the same overall function the only difference is the block image that will appear when you add the block to your model

2

MATLAB Final Project

Class: Digital Communications Dentato 2012

,

Figure 11: Summation of Two Sine Waves

3 Adding a Spectrum Scope and Filters

3.1 Adding a Spectrum Scope

1. Under DSP System Toolbox->Sinks add the “Spectrum Scope” to your model as seen in Figure 12. You can also use the search option to locate the scope. Simply type “spectrum” and search in the “Library Browser”

2. Once you added the scope to your model double click on the scope and change the settings as seen in Figure 13. Make sure you click “Ok” and close the window.

3. Your model should look like that in Figure 14 with the summation output wired to the input of the spectrum scope.

Note: Simulation time was changed to “inf”. This way the model will run until you hit “Stop” which will activate once you run the model.

4. Run the Simulation and the spectrum scope will open automatically. When the scope opens go to “Axes” on the menu bar and click “Autoscale”. Notice the two peaks at 200 and 600Hz? You may have to zoom in which can be done while running or when the model is stopped. What you are looking at is the Fast Fourier Transform of the two input sine waves.

3.2 Exercise

Add another sine wave at 1000Hz. Observe that there are now three peaks. Practice zooming in and out on the scope and play with some of the features to see what they do. Once done disconnect all the inputs to the “Spectrum Scope” and apply a sine wave at 6000Hz. Observe the scope. What you will

MATLAB Final Project

Class: Digital Communications Dentato 2012

notice is a signal at 4000Hz. Wait a minute!! 4000Hz does not equal 6000Hz? What you are witnessing is the phenomena known as spectral folding. It is the direct result of not obeying the Nyquist Criteria.

Figure 12: Navigate or Search for the “Spectrum Scope”

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 13: “Spectrum Scope” Settings

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 14: New Model with “Spectrum Scope”

3.3 Adding a Filter

1. Navigate or search “Filter” to locate the “Digital Filter Design” block and add it to your model. Reference Figure 15 if need be.

2. Double click on the filter design block and make the following changes as seen in Figure 16. Click “Design Filter” when done and close the window. The settings are as follows:

a. Create a band-pass filter b. Use an IIR filter or Infinite Impulse Response filter c. Set the IIR filter type to Chebyshev Type II d. Set the sampling frequency to 10000Hz. Look familiar? e. Set the beginning of the first stop-band to 100Hz f. Begin the pass-band at 150Hz g. End the pass-band at 250Hz h. End stop-band two at 300 Hz i. The magnitude response will show you graphically the response of the filter. Notice that

600Hz is not contained in the pass-band. 3. Wire the filter as seen in Figure 17. We will be using the 200Hz and 600Hz sine waves again. You

can delete or disconnect the 6000Hz sine wave if you still have it in use. 4. Run the model and observe the output of the spectrum scope. 5. You will observe the 600Hz signal is no longer seen in the spectrum due to the filter.

Note: That you can also create a low pass or high pass filter with this tool. For our purposes we should use a Chebyshev Type II IIR filter for all filter designs.

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 15: Navigating to the “Digital Filter Design” Block

MATLAB Final Project

Class: Digital Communications Dentato 2012

Figure 16: “Digital Filter Design” Settings

Figure 17: Filtered Model

MATLAB Final Project

Class: Digital Communications Dentato 2012

1 Final Project

1. Create a DSB-SC AM modulator and demodulator. The communication network will have the following parameters. Use a sampling rate 1000x larger than the maximum Nyquist bandwidth.

a. 𝑚(𝑡) = cos (2𝜋100𝑡) b. 𝑓𝑐 = 600𝐻𝑧

For Credit show a scope with the signal 𝑚(𝑡) before and after modulation and demodulation. One Scope Only!

2. Extra Credit (5pts): Create a DSB+C AM communication network plus a simulated envelope detector with the following parameters. See page 196-197 of the text book for a reference. Use a sampling rate 1000x larger than the maximum Nyquist bandwidth.

a. 𝑚(𝑡) = cos (2𝜋100𝑡) b. 𝑓𝑐 = 6000𝐻𝑧

For Credit show a scope with the signal 𝑚(𝑡) before and after modulation and demodulation. One Scope Only!

3. Extra Credit (5pts): Create a QAM communication network with the following parameters. Use a sampling rate 1000x larger than the maximum Nyquist bandwidth.

a. 𝑚1(𝑡) = cos (2𝜋100𝑡) b. 𝑚2(𝑡) = cos (2𝜋300𝑡) c. 𝑓𝑐 = 800𝐻𝑧

For Credit show a scope with the signal 𝑚1(𝑡) and 𝑚2(𝑡) before and after modulation and demodulation. Two Scopes Only!

4. Extra Credit (10pts): Create a 16- QAM communication network with the following parameters. Use a bit rate of 100bit/s. Select your sample rate accordingly.

a. 𝑚1(𝑡) = √𝑀-ary data b. 𝑚2(𝑡) = √𝑀-ary data c. 𝑓𝑐 = 100𝑘𝐻𝑧

Construct two channels one with “AWGN” and one without

For Credit show a scope with the signal 𝑚1(𝑡) and 𝑚2(𝑡) before and after modulation and demodulation. Two Scopes Only (only plot channel without noise)! Also include a constellation plot for each channel (“AWGN” and no noise).

For Credit: Please prepare a quick write up for each of the problems above. Should include how it works and what the purpose of communication system is.