DSP Lab 7 To 12

Download as pdf or txt
Download as pdf or txt
You are on page 1of 75

Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

DIGITAL SIGNAL PROCESSING (EEE342)

Lab # 07 to 12

Name Abdul basit

Registration
FA18-BEE-002
Number

Class BEE-6A

Instructor’s Name Mam Nida Zamir

COMSATS Institute of Information Technology Page 88


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Lab # 07 Simulation of Non RT AM Tx/Rx on


Simulink

Objective:
By the end of this lab students will be able to model and simulate any type of
communications/control / DSP model on Simulink and analyze its performance.

Pre Lab Task:


We start with acquainting ourselves with SIMULINK and understanding its significance in
design of digital system. We will then try to implement signal generator in SIMULINK.

Introduction:
Simulink, developed by MathWorks©, is a commercial tool for modeling, simulating and
analyzing multi-domain dynamic systems. Its primary interface is a graphical block
diagramming tool and a customizable set of block libraries. It offers tight integration with the
rest of the MATLAB environment and can either drive MATLAB or be scripted from it.
Simulink is widely used in control theory and digital signal processing for multi-domain
simulation and Model-Based Design.

Running SIMULINK:

Simulink may be accessed in MATLAB by using the following methods:

1. Type ‘simulink’ in command window


2. Click on ‘simulink’ icon in the top
3. Click on the “MATLAB Start”, point to “Simulink” and click on “Library Browser”. As a
result ‘SIMULINK Library Browser’ will open. Click on the ‘new’ icon at top left and save
the file on your hard drive.

COMSATS Institute of Information Technology Page 89


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Given below is the interface of SIMULINK library browser:

SIMULINK Library Browser - Interface

Click on the new file icon shown at the top left corner of the above figure and set the
configuration parameters of your simulation as shown below:

Setting up simulation configuration parameters BEFORE beginning to model

COMSATS Institute of Information Technology Page 90


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Configuration Parameters Setting Window

Library Browser:

A toolbox is a collection of tools designated to perform a specific task or set of tasks. All the
toolboxes are in this window. However, we are concerned with Digital Signal Processing so we
will use the ‘Signal Processing Toolbox’. Navigate inside the blocks and right click on any
component and click on “add to <filename>” where filename is the name of your simulink model
file.

Some Useful Toolboxes

Following are some of the important toolboxes we will use in our labs:

SIMULINK
o Commonly Used Blocks
o Discontinuities
o Discrete
o Math Operations, Signal Attributes, Signal Routing, Sources, Sinks etc
Signal Processing Blockset
Embedded Target for TI C6000 DSP (for DSKs)
o DSK  DSP Starter Kits (6414, 6711, 6713 etc)
Acquaint yourselves with these toolboxes as they will be used in your subsequent labs. Consult
Google and ask your instructor in case of any queries. Build the following example model in
SIMULINK:

COMSATS Institute of Information Technology Page 91


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Example ‘.mdl’ file

Setting of Sine Wave Block

COMSATS Institute of Information Technology Page 92


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Settings of Spectrum Scope

Display Settings of Spectrum Scope

COMSATS Institute of Information Technology Page 93


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

In-Lab Task :
In this lab non R-T model for the AM transmitter/receiver is to be developed to demonstrate the
features of Amplitude Modulation (AM) transmission and reception. Amplitude Modulation is a
process where the amplitude of a carrier signal (high frequency sinusoid) is altered according to
information in a message signal. The model runs in SIMULINK and enables the user to select:

1. The AM algorithm
2. The transmission and reception parameters (modulation index and carrier frequency).

Simulation

The Environment
Figure 1 shows the data flow for the AM modulation simulation. The AM modulation model
receives an input signal from an external signal generator, modulates it and displays the
modulation on the scope.

Information
Signal

Figure 1- Simulation Environment

The Procedure

Building the Transmitter

The basic modulation mathematical description is given by:

y(t) [1 m(t)]cos(2 f c t)

Where:

COMSATS Institute of Information Technology Page 93


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

cos(2 fct) - The carrier signal

m(t) - The modulation index

Figure 2- AM Transmission Principle

1. Start by creating a new model in Simulink ®

2. Open the Simulink library browser and add the DSP sine-wave to your model. This
blocks will represent the information signal m(t).

COMSATS Institute of Information Technology Page 94


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

3. Configure the Sine Wave Generator Block (Double click on the DSP sine object). Set the
sine frequency to 1000 Hz, sample time to 1/96000, samples per frame to 64 and close
the box, and change ts label to “in

Figure 4 – Information Signal Configuration Parameters

COMSATS Institute of Information Technology Page 95


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

4. Use the same block to create the carrier signal. You may copy the block already created
or select it form the Simulink library. Set the carrier frequency to 15,000 Hz. The
remaining parameters are identical to the ones of the information signal. Change its label
to “carrier”

5. Add new DSP-constant to your model:

Figure 5 - Adding a DSP constant

COMSATS Institute of Information Technology Page 96


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

6. Double-click on the constant object and set its constant value to 1.5:

Figure 6 - Set a constant value

7. Add a new adder object from:

Figure 7- Adder

COMSATS Institute of Information Technology Page 97


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

8. Add a new multiplexer from the same directory as the adder (choose “product”).
9. Add a new scope object:

Figure 8 - Scope

10. Set the number of frames parameter to 5. This parameter determines the horizontal scaling of
the presented signal.

Figure 9 – Vector Scope Configuration

COMSATS Institute of Information Technology Page 98


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

11. Place the objects in the following way:

Figure 10- The Transmitter Model

12. Run the model, pause the simulation and activate the scope window. The modulated
signal should be displayed as follows:

Figure 11 - AM Modulation Signal

COMSATS Institute of Information Technology Page 99


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink
The AM Receiver (Square Root Demodulator)

In this section you will create the model for an AM receiver based on Square Root (SQRT)
demodulation. The principle of operation is shown Figure 1.

Figure 12 – SQRT Demodulation Principle of Operation

COMSATS Institute of Information Technology Page 100


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

13. Add the new math function block to your model. This block can be configured to
implement various mathematical functions.

Figure 13 –Square Function

14. Configure the block to calculate the square:

COMSATS Institute of Information Technology Page 101


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Figure 14 – Select Math Function

15. Use the math function block to create the Square root function. You may retrieve it
from the library or copy the “square” block.

16. Add a digital filter design block. This block enables you to design filters using the
MATLAB® FDATool.

Figure 15- Digital Filter Design

17. Configure the filter to be Low-Pass Filter. Since the carrier frequency (fc) is 15 KHz
and the maximal frequency of the information is 1 KHz, the filter will be designed to

COMSATS Institute of Information Technology Page 102


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

pass frequencies below 5 KHz, and rejects frequencies higher than 10 KHz (please refer
to Figure 16).

Figure 16 –LPF Design Window

18. Add a "Multiplier" and a "Subtract"1 block.

19. Add two "DSP Constant" blocks.

20. Add the matrices concatenation object. This object will enable the modulated and the
de-modulated signals to be displayed simultaneously in the scope:

COMSATS Institute of Information Technology Page 103


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Figure 17- Matrix Concatenate

21. The blocks should be connected as shown in Figure 18.

Figure 18 -AM Simulation Model

COMSATS Institute of Information Technology Page 104


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

22. Run the simulation (push the “play” button). Double click on the scope. Scale the display

to fit the scope window (Choose from the menus: Axes=>Autoscale). Choose a different
color for each signal (Please refer to Figure 19).

Figure 19 -Displaying the Modulated and Demodulated Signals

COMSATS Institute of Information Technology Page 105


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

You should get the signals presented bellow:

Figure 20 - The Video Viewer Display

Try to change the modulation index to 50%, 100% and 150% and comment on the
influence of changing ‘mu’ on the modulated and demodulated signals. Keep the
carrier signal frequency same as before

COMSATS Institute of Information Technology Page 106


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

In Lab Tasks:
Task 1:

Generate a sinusoid containing 5 frequency components and display these components in the
FFT-scope.

COMSATS Institute of Information Technology Page 107


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

OUTPUT GRAPH:

Task 2:

Generate DSB SC and use coherent detection to recover the message signal. Analyze the
spectra of AM and DSB-SC signals and comment on the bandwidth and transmission of both
schemes.

COMSATS Institute of Information Technology Page 108


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

OUTPUT GRAPH:

COMSATS Institute of Information Technology Page 109


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Critical Analysis / Conclusion


(By Student about Learning from the Lab)

In this lab we performed Analysis regarding simulink modeling and performance


analysis of models. Simulink, developed by Math Works, is a trading tool for modeling,
simulation and analysis of dynamic multi-domain systems. Its main interface is a
graphical block graphical tool and a customized collection of block libraries. It provides
a solid integration with the entire MATLAB environment and can call MATLAB or be
written from it. Simulink is widely used in control theory and digital signal processing
for multi-domain simulation and Model Design.

Lab Assessment

Pre Lab /5

Performance /5

Results /5 /25

Viva /5

Critical Analysis /5

Instructor Signature and Comments

COMSATS Institute of Information Technology Page 110


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Lab # 09 Filter Design through FDA Tool and its


implementation on DSP Kit

Objective:
By the end of this lab students will be able to design different types of filters using
FDA tool and implementing it on DSK 6713.

Pre Lab Task:


The filters may be broadly classified as follows:

1. Low-pass filters
2. High-pass filters
3. Band-pass filters
4. Band-stop filters
The typical responses of these filters are shown below:
Low Pass Filter (Cutoff = 4kHz)

COMSATS Institute of Information Technology Page 125


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

High Pass Filter (Cutoff = 6kHz)

Band Pass Filter (24 – 28 kHz)

COMSATS Institute of Information Technology Page 126


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Band Stop Filter (24 – 28 kHz)

Alternatively, filters may also be classified according to their response type as:

1. FIR – Response is time limited


2. IIR – Response is not limited in time

FDA tool is the filter design and analysis tool in MATLAB which is used for the design and
analysis of FIR or IIR filters. It may be opened by simply typing the following command in
MATLAB command window:

>>fdatool

Alternatively, it may also be opened by following the method given below:

1. Go to MATLAB ‘Start’
2. Point to Toolboxes
3. Point to Filter Design in the sub menu
4. Click on Filter Design & Analysis Tool (fdatool)

COMSATS Institute of Information Technology Page 127


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Following is the self-explanatory diagram of FDA tool interface:

Filter Design and Analysis Tool - Interface

Following are some of the parameters considered during filter design process in FDA tool:

• fstop – Start of stop band


• fpass – End of pass band
• Apass – Magnitude (dB) by which pass band frequencies will be attenuated
• Astop – Magnitude (dB) by which stop band frequencies will be attenuated
• fs – Sampling frequency of the filter
– Must be greater than twice the max filter frequency
• Order – Order of the filter

Think of order as the measure of how much processing power our digital filter will require to be
implemented. Hence,

1. Sharper the cutoff, higher the order


2. Higher the fs (not fstop), higher the order

FV tool is the Filter Visualization tool in MATLAB and you can use it to analyze your filter
response in details. It may be opened from FDA tool by first designing a filter and then opening
this tool from ‘ViewFilter Visualization Tool’. The interface of this tool is shown below:

COMSATS Institute of Information Technology Page 128


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

FV Tool – Interface

COMSATS Institute of Information Technology Page 129


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

In Lab Tasks:
Task 1:

Design a “minimum order” low pass filter to suppress all frequencies above 4kHz. Mention
the application of such a filter. Send this model to DSP kit and show the results in CCS.

COMSATS Institute of Information Technology Page 130


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Task 2:

Design a “minimum order” high pass filter to pass all frequencies above 6kHz. Mention the application of such a filter.
Send this model to DSP kit and show the results in CCS.

COMSATS Institute of Information Technology Page 131


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Task 3:

For a frequency range of ‘24kHz – 28kHz’, design band pass and band stop filters. Send
this model to DSP kit and show the results in CCS.

COMSATS Institute of Information Technology Page 132


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Part b:

COMSATS Institute of Information Technology Page 133


Lab # 07 Simulation of Non RT AM Tx/Rx on Simulink

Task 4:

Observe that there is a guard band of 2kHz between 4kHz and 6kHz. Exploit it.

COMSATS Institute of Information Technology Page 134


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Critical Analysis / Conclusion


(By Student about Learning from the Lab)

In this lab we learnt that how we can design different types of filters using FDA tool.
We have come to know about different kinds of filters and their applications. Filters
we studied in this lab include band pass, band stop, high pass and low pass filters and
lastly we studied guard band to get familiarized with its purpose and its applications.
A low pass filter that passes frequency below 4 kHz and stops the frequency above 4
kHz, the model was made using Simulink. A high pass filter that passes frequency
above 6 kHz and stops the frequency below 6 kHz, the model was made using
Simulink.

COMSATS Institute of Information Technology Page 135


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Lab # 10 Hardware implementation of AM


modulator and demodulator on C6713 and C6416

DSK

Objective
In this lab DSK6713 and DSK6416 will be used to demonstrate the features of Amplitude Modulation
(AM) transmission and reception. The model run is in real-time and enables the user to select:

The AM algorithm
The transmission and reception parameters (modulation index and carrier frequency). The
process comprises:

Creating a simulation model (not R-T) for the AM transmitter/receiver


(Lab 9)

Migration to Real-time of the Simulation Model

Pre-Lab Task
1. Real Time Implementation
1.1. The Environment
The real-time implementation model will be created upon the simulation model, after the following
changes:

The signal generator block will be replaced by the CODEC of the DSK6713
The virtual scope will be replaced also by the CODEC A
target definition block (DSK6713) will be added.
Figure 21 shows the block-diagram for the real time implementation.

COMSATS Institute of Information Technology Page 136


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Figure 21- Real Time Implementation Environment

Equipment Used (shown in Figure 22):

DSK6713/DSK6416
Dual Channel Oscilloscope
Signal Generator

Modulated
Signal Demodulated
Signal
Information

Figure 22- Equipment Used

We have 4 signals (4 cables):

1. Information- the signal to be modulated

2. Modulated- the DSK creates a modulation of the given information


3. Feedback- since the transmitter and the receiver are running on the same platform, we need to
perform a loopback from the transmitter to the receiver and this is exactly the feedback signal,
the modulated signal that is broadcasted by the transmitter and used as input for the receiver.

Demodulated- the signal that the receiver outputs after the demodulation process.

COMSATS Institute of Information Technology Page 137


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

In-Lab Task

Lab Task
1. Open the model created in the previous lab

2. Remove the scope and the “information” signal (the 1,000 Hz).

3. Open the Simulink library browser and add the "C6713DSK" as shown in Figure 2.

Figure 2 - The C6713DSK Block

4. Add the “Analog to Digital” and “Digital to Analog” converters (ADC and DAC) to your model
as shown in Figure 3.

Figure 3 – A/D and D/A converters

5. Add the multi-port selector, in order to split the stereo input, as shown in Figure 4.

COMSATS Institute of Information Technology Page 138


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Figure 4 – Multiport Selector

6. After placing the selector, double-click to open the dialog box and choose “columns” in the
“select” label and “{1,2}” in the “indices to output label.

Figure 5 – Multiport Configuration

7. Configure the ADC and DAC blocks to a sampling rate to 96 KHZ and 16-bit samples.

COMSATS Institute of Information Technology Page 139


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Figure 6 – DAC and ADC Configuration

8. The final model should look as follows:

Figure 7- AM (SQRT) Real Time Model

9. You should configure the DSP constants as shown in Figure . The frame period for all constants
should be -1

COMSATS Institute of Information Technology Page 140


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Figure 8- Constant Value Parameters

10. Build the project and load the program to the DSK memory using ctrl+B.

11. Make sure that the signals generator amplitude is set to 1 Volt and frequency of [0.1,5] kHz.

12. Display the modulated and demodulated signals in the scope.

Model Extensions
In this section following extensions to the model are introduced. Adding two more features:

A variable frequency carrier generator


An additional model for AM detection
The modulation index and carrier frequency will be changed through RTDX.

1. Open the model created in the previous section

2. Replace the constant modulation index by an RTDX input (Please refer to Figure ), and name it
Input Modulation.

COMSATS Institute of Information Technology Page 141


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Figure 9 - RTDX input

3. Configure the RTDX input object to the values described bellow:

Figure 10 - RTDX Input Configuration

COMSATS Institute of Information Technology Page 142


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

4. Replace the sine wave block used for the carrier by the configurable carrier blocks and create a
subsystem for the carrier generator as shown in Figure

Your model should look as shown in Figure

Figure 11 – Inserting a Configurable Carrier

COMSATS Institute of Information Technology Page 143


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Figure 12 - AM (SQRT) Model with Configurable Carrier

5. Enter the Configuration Parameters menu (ctrl+E). Choose Real-Time


Workshop=>TIC6000 Code-Generator, In The Run-Time box change the Build Action to
“Build”2:

Figure 13 – Simulation Parameters

COMSATS Institute of Information Technology Page 144


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Push the OK button and close the “Configuration Parameters” window.

Rebuild *.out file using ctrl+B.

6. Open the “AM_Coherent.mdl” file, and repeat step 0 for this file.

You now have two load files each one corresponding to a different AM scheme.

A Configurable Carrier Wave Generator


The Simulink sine wave block cannot be configured during run-time; its frequency is a parameter that
should be set in advance. We will introduce the implementation of a block where the frequency is a
variable that can be set in real-time (In this case using RTDX). The block is based on the following
relationship:

cos ct Re e j ct

In the discrete case the following relationship applies:

fc
fc j2 n
fs
cos cnTs cos2 n Re e
fs
The following model implements the last equation. Please note that a
feedback path was included for phase continuity

Figure 23 – Carrier Wave Generator

COMSATS Institute of Information Technology Page 145


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

The Coherent Detector (in brief)


The coherent detector principle of operation is in Figure 24 The AM example model
(AM_Coherent.mdl) is shown in Figure 4.0

Figure 24 – Coherent SQRT Demodulation Principle of


Operation

Figure 25 – Amplitude Modulation Example with Coherent Detection

COMSATS Institute of Information Technology Page 146


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

TASK: 01
CODE:
/*
* File: task1.c
*
* Real-Time Workshop code generated for Simulink model task1.
*
* Model version : 1.2
* Real-Time Workshop file version : 6.5 (R2006b) 03-Aug-2006
* Real-Time Workshop file generated on : Sun Dec 02 23:02:51 2018
* TLC version : 6.5 (Aug 3 2006)
* C source code generated on : Sun Dec 02 23:02:53 2018
*/
#include "task1.h"
#include "task1_private.h"

/* Block signals (auto storage) */

#pragma DATA_ALIGN(task1_B,8)

BlockIO_task1 task1_B;

/* Block states (auto storage) */


#pragma DATA_ALIGN(task1_DWork,8)

D_Work_task1 task1_DWork;

/* Real-time model */
RT_MODEL_task1 task1_M_;
RT_MODEL_task1 *task1_M = &task1_M_;

/* Model step function */


void task1_step(void)
{
/* local block i/o variables */
real_T rtb_Add2[64];
real_T rtb_Add1[64];
real32_T rtb_MultiportSelector_o1[64];
real32_T rtb_MathFunction1[64];

/* S-Function Block: <Root>/ADC (c6416dsk_adc) */


{
const real32_T ADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;

// Retrieve ADC buffer pointer and invalidate CACHE


blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
/* Left */
task1_B.ADC[i] = (real32_T)*blkAdcBuffPtr * ADCScaleFactor;

/* Right */
task1_B.ADC[i + 64] = (real32_T)*(blkAdcBuffPtr+1) * ADCScaleFactor;
blkAdcBuffPtr += 2;
}
}

/* Signal Processing Blockset Multi-port Selector (sdspmultiportsel) - '<Root>/Multiport Selector' */


{
const byte_T *u = (byte_T *)task1_B.ADC;/* input port */
const int32_T *index = (const int32_T *)&task1_P.MultiportSelector_INDEX_AR
[0];
const int32_T *length = (const int32_T *)&task1_P.MultiportSelector_LEN_ARRA

COMSATS Institute of Information Technology Page 147


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

[0];
byte_T *outPortAddr[2]; /* Local array of pointers to the output port locations */
int_T outIdx;
outPortAddr[0] = (byte_T *)rtb_MultiportSelector_o1;
outPortAddr[1] = (byte_T *)rtb_MathFunction1;

/* Loop over each output port and copy bytes */


for (outIdx = 0; outIdx < 2; outIdx++) {
const int_T numColsThisOutput = *length++;
byte_T *y = outPortAddr[outIdx];
int_T ctr;

/* Loop over each column of current output port index */


for (ctr = 0; ctr < numColsThisOutput; ctr++) {
int_T inputColIdx = *index++;

/* Copy an entire column worth of bytes


* offset input ptr to start of column index "inputColIdx"
*/
memcpy(y,
(u + inputColIdx * (64 * sizeof(real32_T))),
(64 * sizeof(real32_T)) );
y += (64 * sizeof(real32_T)); /* next output column */
} /* output column loop */
} /* output port loop */
} /* end <Root>/Multiport Selector */

{
int32_T i;
for (i = 0; i < 64; i++) {
/* Sum: '<Root>/Add2' incorporates:
* Constant: '<S2>/Constant'
*/
rtb_Add2[i] = (real_T)rtb_MultiportSelector_o1[i] + task1_P.Constant_Value;
}
}

/* Signal Processing Blockset Sine Wave (sdspsine2) - '<Root>/Sine Wave' - Output */


/* Discrete trigonometric mode: */
{
const real_T amp = task1_P.SineWave_Amplitude;
const real_T freqNrm = task1_P.SineWave_Frequency;/* normalized units */
real_T *accFrqNrm = &task1_DWork.SineWave_AccFreqNorm;
real_T *y = rtb_Add1;

/* Loop over frame */


int j;
for (j=0; j < 64; j++) {
*y++ = amp * sin((*accFrqNrm) * 6.2831853071795862E+000);

/* Update accumulated normalized freq value */


/* for next sample. Keep in range [0 1.0) */
*accFrqNrm += freqNrm;
if (*accFrqNrm >= 1.0) {
*accFrqNrm -= 1.0;
} else if (*accFrqNrm < 0.0) {
*accFrqNrm += 1.0;
}
}
}

{
int32_T i;
for (i = 0; i < 64; i++) {
/* Product: '<Root>/Product' */
task1_B.MatrixConcatenate[i] = rtb_Add2[i] * rtb_Add1[i];

COMSATS Institute of Information Technology Page 148


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

/* Math: '<Root>/Math Function' */


task1_B.MathFunction[i] = rtb_MathFunction1[i] * rtb_MathFunction1[i];
}
}

/* Signal Processing Blockset Filter Implementation (sdspfilter2) - '<S3>/Digital Filter' */


/* FIR, Direct-form */
MWDSP_FIR_DF_RR(task1_B.MathFunction, task1_B.DigitalFilter,
&task1_DWork.DigitalFilter_FILT_STATES[0],
&task1_DWork.DigitalFilter_CIRCBUFFIDX, 49, 64, 1,
&task1_P.DigitalFilter_RTP1COEFF[0], 1);

{
int32_T i;
for (i = 0; i < 64; i++) {
/* Math: '<Root>/Math Function1' */
if (task1_B.DigitalFilter[i] < 0.0F) {
rtb_MathFunction1[i] = (real32_T)-sqrt(-task1_B.DigitalFilter[i]);
} else {
rtb_MathFunction1[i] = (real32_T)sqrt(task1_B.DigitalFilter[i]);
}

/* Product: '<Root>/Product1' incorporates:


* Constant: '<Root>/Constant1'
* Constant: '<Root>/Constant2'
* Sum: '<Root>/Add1'
*/
task1_B.MatrixConcatenate[i+64] = ((real_T)rtb_MathFunction1[i] +
task1_P.Constant1_Value) * task1_P.Constant2_Value;
}
}

/* S-Function Block: <Root>/DAC (c6416dsk_dac) */


{
const real_T DACScaleFactor = 32768.0;
int_T i;
void *blkDacBuffPtr;
int16_T *outPtr;
blkDacBuffPtr = getDacBuff();
outPtr = (int16_T *) blkDacBuffPtr;
for (i = 0; i < 64; i++) {
/* Left */
*outPtr = (int16_T)(task1_B.MatrixConcatenate[i] * DACScaleFactor);

/* Right */
*(outPtr+1) = (int16_T)(task1_B.MatrixConcatenate[i + 64] * DACScaleFactor);
outPtr += 2;
}

CACHE_wbL2( (void *) blkDacBuffPtr, 256, CACHE_WAIT );


}
}

/* Model initialize function */


void task1_initialize(boolean_T firstTime)
{
(void)firstTime;

/* Registration code */

/* initialize error status */


rtmSetErrorStatus(task1_M, (const char_T *)0);

/* block I/O */
{

COMSATS Institute of Information Technology Page 149


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

int_T i;
void *pVoidBlockIORegion;
pVoidBlockIORegion = (void *)(&task1_B.MatrixConcatenate[0]);
for (i = 0; i < 128; i++) {
((real_T*)pVoidBlockIORegion)[i] = 0.0;
}

pVoidBlockIORegion = (void *)(&task1_B.ADC[0]);


for (i = 0; i < 256; i++) {
((real32_T*)pVoidBlockIORegion)[i] = 0.0F;
}
}

/* states (dwork) */
(void) memset((char_T *) &task1_DWork,0,
sizeof(D_Work_task1));
task1_DWork.SineWave_AccFreqNorm = 0.0;

{
int_T i;
real32_T *dwork_ptr = (real32_T *) &task1_DWork.DigitalFilter_FILT_STATES[0];
for (i = 0; i < 49; i++) {
dwork_ptr[i] = 0.0F;
}
}

codec_init();

/* S-Function Block: <Root>/ADC (c6416dsk_adc) */


config_codec_input();

/* Signal Processing Blockset Sine Wave (sdspsine2) - '<Root>/Sine Wave' - Start */


/* Trigonometric mode: compute initial accumulated
* normalized trig fcn argument for each channel
* NOTE: assuming model start time is ZERO
*/
{
{
/* Compute trig function argument: arg = omega * t + phi (NORMALIZED units, and t == 0) */
real_T arg = task1_P.SineWave_Phase;

/* Keep normalized value in range [0 1.0) */


while (arg >= 1.0)
arg -= 1.0;
while (arg < 0.0)
arg += 1.0;

/* Store computed value */


task1_DWork.SineWave_AccFreqNorm = arg;
}
}

/* S-Function Block: <Root>/DAC (c6416dsk_dac) */


config_codec_output();

/* Signal Processing Blockset Sine Wave (sdspsine2) - '<Root>/Sine Wave' - InitializeConditions


*
* This code only executes when block is re-enabled in an enabled subsystem
* when the enabled subsystem states on re-enabling are set to "Reset".
*/
{
/* Trigonometric mode: re-compute accumulated
* normalized trig fcn argument for each channel
*/

/* Compute trig function argument: arg = omega * t + phi (NORMALIZED units) */

COMSATS Institute of Information Technology Page 150


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

/* Reset to time zero on re-enable */


{
real_T arg = task1_P.SineWave_Phase;

/* Keep normalized value in range [0 1.0) */


while (arg >= 1.0)
arg -= 1.0;
while (arg < 0.0)
arg += 1.0;

/* Store computed value */


task1_DWork.SineWave_AccFreqNorm = arg;
}
} /* end of code for sine wave state reset upon re-enable */

/* Signal Processing Blockset Filter Implementation (sdspfilter2) - '<S3>/Digital Filter' */


/* FIR, Direct-form */
{
real32_T *statePtr = (real32_T *) &task1_DWork.DigitalFilter_FILT_STATES[0];

/* Scalar expansion of ICs with extra zero element per channel */


int_T numElems= 48;
while (numElems--) {
*statePtr++ = *(const real32_T *)&task1_P.DigitalFilter_ICRTP;
}

*statePtr++ = 0.0F;
}
}

/* Model terminate function */


void task1_terminate(void)
{
/* (no terminate code required) */
}

/* File trailer for Real-Time Workshop generated code.


*
* [EOF]
*/

BLOCK DIAGRAM:

COMSATS Institute of Information Technology Page 151


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

TASK: 02
CODE:
/*
* File: task2.c
*
* Real-Time Workshop code generated for Simulink model task2.
*
* Model version : 1.8
* Real-Time Workshop file version : 6.5 (R2006b) 03-Aug-2006
* Real-Time Workshop file generated on : Mon Dec 03 00:15:27 2018
* TLC version : 6.5 (Aug 3 2006)
* C source code generated on : Mon Dec 03 00:15:28 2018
*/
#include "task2.h"
#include "task2_private.h"

RTDX_CreateInputChannel(freq); /* Channel freq for block <Root>/From RTDX */

/* Block signals (auto storage) */


#pragma DATA_ALIGN(task2_B,8)

BlockIO_task2 task2_B;

/* Block states (auto storage) */


#pragma DATA_ALIGN(task2_DWork,8)

D_Work_task2 task2_DWork;

/* Real-time model */
RT_MODEL_task2 task2_M_;
RT_MODEL_task2 *task2_M = &task2_M_;

/* Model step function */


void task2_step(void)
{
/* local block i/o variables */
real_T rtb_Product2;
real_T rtb_Add2[64];
real_T rtb_SineWave[64];
real32_T rtb_MultiportSelector_o1[64];
real32_T rtb_MultiportSelector_o2[64];

/* S-Function Block: <Root>/From RTDX (rtdx_src) */


if (!RTDX_channelBusy(&freq)) {
RTDX_readNB( &freq, (void*) &task2_B.FromRTDX, 1*sizeof(real32_T));
}

/* Product: '<Root>/Product2' incorporates:


* Constant: '<S2>/Constant'
*/
rtb_Product2 = (real_T)task2_B.FromRTDX * task2_P.Constant_Value;

/* S-Function Block: <Root>/ADC (c6416dsk_adc) */


{
const real32_T ADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;

// Retrieve ADC buffer pointer and invalidate CACHE


blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
/* Left */
task2_B.ADC[i] = (real32_T)*blkAdcBuffPtr * ADCScaleFactor;

/* Right */

COMSATS Institute of Information Technology Page 152


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

task2_B.ADC[i + 64] = (real32_T)*(blkAdcBuffPtr+1) * ADCScaleFactor;


blkAdcBuffPtr += 2;
}
}

/* Signal Processing Blockset Multi-port Selector (sdspmultiportsel) - '<Root>/Multiport Selector' */


{
const byte_T *u = (byte_T *)task2_B.ADC;/* input port */
const int32_T *index = (const int32_T *)&task2_P.MultiportSelector_INDEX_AR
[0];
const int32_T *length = (const int32_T *)&task2_P.MultiportSelector_LEN_ARRA
[0];
byte_T *outPortAddr[2]; /* Local array of pointers to the output port locations */
int_T outIdx;
outPortAddr[0] = (byte_T *)rtb_MultiportSelector_o1;
outPortAddr[1] = (byte_T *)rtb_MultiportSelector_o2;

/* Loop over each output port and copy bytes */


for (outIdx = 0; outIdx < 2; outIdx++) {
const int_T numColsThisOutput = *length++;
byte_T *y = outPortAddr[outIdx];
int_T ctr;

/* Loop over each column of current output port index */


for (ctr = 0; ctr < numColsThisOutput; ctr++) {
int_T inputColIdx = *index++;

/* Copy an entire column worth of bytes


* offset input ptr to start of column index "inputColIdx"
*/
memcpy(y,
(u + inputColIdx * (64 * sizeof(real32_T))),
(64 * sizeof(real32_T)) );
y += (64 * sizeof(real32_T)); /* next output column */
} /* output column loop */
} /* output port loop */
} /* end <Root>/Multiport Selector */

{
int32_T i;
for (i = 0; i < 64; i++) {
/* Sum: '<Root>/Add2' */
rtb_Add2[i] = (real_T)rtb_MultiportSelector_o1[i] + rtb_Product2;
}
}

/* Signal Processing Blockset Sine Wave (sdspsine2) - '<Root>/Sine Wave' - Output */


/* Discrete trigonometric mode: */
{
const real_T amp = task2_P.SineWave_Amplitude;
const real_T freqNrm = task2_P.SineWave_Frequency;/* normalized units */
real_T *accFrqNrm = &task2_DWork.SineWave_AccFreqNorm;
real_T *y = rtb_SineWave;

/* Loop over frame */


int j;
for (j=0; j < 64; j++) {
*y++ = amp * sin((*accFrqNrm) * 6.2831853071795862E+000);

/* Update accumulated normalized freq value */


/* for next sample. Keep in range [0 1.0) */
*accFrqNrm += freqNrm;
if (*accFrqNrm >= 1.0) {
*accFrqNrm -= 1.0;
} else if (*accFrqNrm < 0.0) {
*accFrqNrm += 1.0;

COMSATS Institute of Information Technology Page 153


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

}
}
}

{
int32_T i;
for (i = 0; i < 64; i++) {
/* Product: '<Root>/Product' incorporates:
* Gain: '<Root>/Gain'
*/
task2_B.MatrixConcatenate[i] = rtb_SineWave[i] * task2_P.Gain_Gain *
rtb_Add2[i];

/* Product: '<Root>/Product1' */
task2_B.Product1[i] = (real_T)rtb_MultiportSelector_o2[i] * rtb_SineWave[i];
}
}

/* Signal Processing Blockset Filter Implementation (sdspfilter2) - '<Root>/Digital Filter' */


/* IIR, Direct-form II transposed (a0 == 1) */
MWDSP_IIR_DF2T_DD(task2_B.Product1, task2_B.DigitalFilter,
&task2_DWork.DigitalFilter_FILT_STATES[0], 2, 64, 1,
&task2_P.DigitalFilter_RTP1COEFF[0], 1,
&task2_P.DigitalFilter_RTP2COEFF[0], 1, 1);

{
int32_T i;
for (i = 0; i < 64; i++) {
/* Sum: '<Root>/Subtract' incorporates:
* Constant: '<S3>/Constant'
* Gain: '<Root>/Gain1'
*/
task2_B.MatrixConcatenate[i+64] = task2_B.DigitalFilter[i] *
task2_P.Gain1_Gain - task2_P.Constant_Value_m;
}
}

/* S-Function Block: <Root>/DAC (c6416dsk_dac) */


{
const real_T DACScaleFactor = 32768.0;
int_T i;
void *blkDacBuffPtr;
int16_T *outPtr;
blkDacBuffPtr = getDacBuff();
outPtr = (int16_T *) blkDacBuffPtr;
for (i = 0; i < 64; i++) {
/* Left */
*outPtr = (int16_T)(task2_B.MatrixConcatenate[i] * DACScaleFactor);

/* Right */
*(outPtr+1) = (int16_T)(task2_B.MatrixConcatenate[i + 64] * DACScaleFactor);
outPtr += 2;
}

CACHE_wbL2( (void *) blkDacBuffPtr, 256, CACHE_WAIT );


}
}

/* Model initialize function */


void task2_initialize(boolean_T firstTime)
{
(void)firstTime;

/* Registration code */

/* initialize error status */

COMSATS Institute of Information Technology Page 154


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

rtmSetErrorStatus(task2_M, (const char_T *)0);

/* block I/O */
{
int_T i;
void *pVoidBlockIORegion;
pVoidBlockIORegion = (void *)(&task2_B.Product1[0]);
for (i = 0; i < 256; i++) {
((real_T*)pVoidBlockIORegion)[i] = 0.0;
}

pVoidBlockIORegion = (void *)(&task2_B.FromRTDX);


for (i = 0; i < 129; i++) {
((real32_T*)pVoidBlockIORegion)[i] = 0.0F;
}
}

/* states (dwork) */
{
real_T *dwork_ptr = (real_T *) &task2_DWork.SineWave_AccFreqNorm;
dwork_ptr[0] = 0.0;
dwork_ptr[1] = 0.0;
dwork_ptr[2] = 0.0;
}

/* S-Function Block: <Root>/From RTDX (rtdx_src) */


{
RTDX_enableInput(&freq);
task2_B.FromRTDX = (real32_T) task2_P.FromRTDX_IC;
}

codec_init();

/* S-Function Block: <Root>/ADC (c6416dsk_adc) */


config_codec_input();

/* Signal Processing Blockset Sine Wave (sdspsine2) - '<Root>/Sine Wave' - Start */


/* Trigonometric mode: compute initial accumulated
* normalized trig fcn argument for each channel
* NOTE: assuming model start time is ZERO
*/
{
{
/* Compute trig function argument: arg = omega * t + phi (NORMALIZED units, and t == 0) */
real_T arg = task2_P.SineWave_Phase;

/* Keep normalized value in range [0 1.0) */


while (arg >= 1.0)
arg -= 1.0;
while (arg < 0.0)
arg += 1.0;

/* Store computed value */


task2_DWork.SineWave_AccFreqNorm = arg;
}
}

/* S-Function Block: <Root>/DAC (c6416dsk_dac) */


config_codec_output();

/* Signal Processing Blockset Sine Wave (sdspsine2) - '<Root>/Sine Wave' - InitializeConditions


*
* This code only executes when block is re-enabled in an enabled subsystem
* when the enabled subsystem states on re-enabling are set to "Reset".
*/
{

COMSATS Institute of Information Technology Page 155


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

/* Trigonometric mode: re-compute accumulated


* normalized trig fcn argument for each channel
*/

/* Compute trig function argument: arg = omega * t + phi (NORMALIZED units) */


/* Reset to time zero on re-enable */
{
real_T arg = task2_P.SineWave_Phase;

/* Keep normalized value in range [0 1.0) */


while (arg >= 1.0)
arg -= 1.0;
while (arg < 0.0)
arg += 1.0;

/* Store computed value */


task2_DWork.SineWave_AccFreqNorm = arg;
}
} /* end of code for sine wave state reset upon re-enable */

/* Signal Processing Blockset Filter Implementation (sdspfilter2) - '<Root>/Digital Filter' */


/* IIR, Direct-form II transposed (a0 == 1) */
{
real_T *statePtr = (real_T *) &task2_DWork.DigitalFilter_FILT_STATES[0];

/* Scalar expansion of ICs with extra zero element per channel */


*statePtr++ = *(const real_T *)&task2_P.DigitalFilter_ICRTP;
*statePtr++ = 0.0;
}
}

/* Model terminate function */


void task2_terminate(void)
{
RTDX_disableInput(&freq); /* S-Function Block: <Root>/From RTDX (rtdx_src) */
}

/* File trailer for Real-Time Workshop generated code.


*
* [EOF]
*/

BLOCK DIGRAM:

COMSATS Institute of Information Technology Page 156


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Conclusion:
In this lab DSK6713 and DSK6416 we used to demonstrate the features of Amplitude
Modulation (AM) transmission and reception. The model run is in real-time and enables the
user to select:
 The AM algorithm
 The transmission and reception parameters (modulation index and carrier frequency).
The process comprises:
 Creating a simulation model (not R-T) for the AM transmitter/receiver
 Migration to Real-time of the Simulation Model

Lab Assessment

Pre Lab /5

Performance /5 /25

Results /5

Viva /5

Critical Analysis /5

Instructor Signature and Comments

COMSATS Institute of Information Technology Page 157


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Lab # 11 FIR and IIR Filters

Objective:
In this lab we will learn how to implement FIR and IIR filters on different DSP kits. The basics of
FIR and IIR filters and the design and analysis of FIR and IIR filter(s) in FDA tool will also be carried
out.

Pre-Lab

IIR vs FIR Filters:


IIR filters are difficult to control and have no particular phase, whereas FIR filters make a linear phase
always possible. IIR can be unstable, whereas FIR is always stable. IIR, when compared to FIR, can
have limited cycles, but FIR has no limited cycles. IIR is derived from analog, whereas FIR has no
analog history. IIR filters make poly phase implementation possible, whereas FIR can always be made
casual. FIR filters are helpful to achieve fractional constant delays. #MAD stands for a number of
multiplications and additions, and is used as a criterion for an IIR and FIR filter comparison. IIR filters
require more #MAD when compared to FIR, because FIR is of a higher order in comparison to IIR,
which is of lower order, and uses poly phase structures.
FIR filters are dependent upon linear-phase characteristics, whereas IIR filters are used for applications
which are not linear. FIR’s delay characteristics is much better, but they require more memory. On the
other hand, IIR filters are dependent on both i/p and o/p, but FIR is dependent upon i/p only. IIR filters
consist of zeros and poles, and require less memory than FIR filters, whereas FIR only consists of zeros.
IIR filters can become difficult to implement, and also delay and distort adjustments can alter the poles
& zeroes, which make the filters unstable, whereas FIR filters remain stable. FIR filters are used for
tapping of a higher-order, and IIR filters are better for tapping of lower-orders, since IIR filters may
become unstable with tapping higher-orders. FIR stands for Finite IR filters, whereas IIR stands for
Infinite IR filters. IIR and FIR filters are utilized for filtration in digital systems. FIR filters are more
widely in use, because they differ in response. FIR filters have only numerators when compared to IIR
filters, which have both numerators and denominators.
Where the system response is infinite, we use IIR filters, and where the system response is zero, we use
FIR filters. FIR filters are also preferred over IIR filters because they have a linear phase response and
are non-recursive, whereas IIR filters are recursive, and feedback is also involved. FIR cannot simulate
analog filter responses, but IIR is designed to do that accurately. IIR’s impulse response when compared
to FIR is infinite.

In-Lab Task

Types of IIR filters:

Common types of IIR filters are as follows:


 Butterworth
 Chebyshev type

COMSATS Institute of Information Technology Page 158


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

 Chebyshev type II
 Elliptic

Butterworth filter:
The Butterworth filter is a type of signal processing filter designed to have as flat a frequency response
as possible in the passband. It is also referred to as a maximally flat magnitude filter. It was first
described in 1930 by the British engineer Stephen Butterworth in his paper entitled "On the Theory of
Filter Amplifiers"

Butterworth had a reputation for solving "impossible" mathematical problems. At the time,
filter design required a considerable amount of designer experience due to limitations of the
theory then in use. The filter was not in common use for over 30 years after its publication.
Butterworth stated that:
"An ideal electrical filter should not only completely reject the unwanted frequencies but should also
have uniform sensitivity for the wanted frequencies".

Such an ideal filter cannot be achieved but Butterworth showed that successively closer
approximations were obtained with increasing numbers of filter elements of the right values.
At the time, filters generated substantial ripple in the passband, and the choice of component
values was highly interactive. Butterworth showed that a low pass filter could be designed
whose cutoff frequency was normalized to 1 radian per second and whose frequency response
(gain) was

Where ω is the angular frequency in radians per second and n is the number of reactive elements
(poles) in the filter. If ω = 1, the amplitude response of this type of filter in the passband is 1/√2
≈ 0.707, which is half power or −3 db. Butterworth only dealt with filters with an even number
of poles in his paper

Chebyshev filter:
Chebyshev filters are analog or digital filters having a steeper roll-off and more passband ripple (type
I) or stopband ripple (type II) than Butterworth filters. Chebyshev filters have the property that they
minimize the error between the idealized and the actual filter characteristic over the range of the filter,
but with ripples in the passband. This type of filter is named in honor of Pafnuty Chebyshev because its
mathematical characteristics are derived from Chebyshev polynomials.

COMSATS Institute of Information Technology Page 159


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Type I Chebyshev filters:

The frequency response of a fourth-order type I Chebyshev low-pass filter with

These are the most common Chebyshev filters. The gain (or amplitude) response as a function
of angular frequency of the nth-order low-pass filter is

Where is the ripple factor, is the cutoff frequency and is a Chebyshev polynomial of
the th order.
The passband exhibits equiripple behavior, with the ripple determined by the ripple factor . In
the passband, the Chebyshev polynomial alternates between 0 and 1 so the filter gain will
alternate between maxima at G = 1 and minima at . At the cutoff frequency
the gain again has the value but continues to drop into the stop band as the
frequency increases. This behavior is shown in the diagram on the right. The common practice
of defining the cutoff frequency at −3 dB is usually not applied to Chebyshev filters; instead
the cutoff is taken as the point at which the gain falls to the value of the ripple for the final
time.
The order of a Chebyshev filter is equal to the number of reactive components (for example,
inductors) needed to realize the filter using analog electronics.
The ripple is often given in dB:

Ripple in dB =

So that a ripple amplitude of 3 dB results from


An even steeper roll-off can be obtained if we allow for ripple in the stop band, by allowing
zeroes on the -axis in the complex plane. This will however result in less suppression in the

COMSATS Institute of Information Technology Page 160


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

stop band. The result is called an elliptic filter, also known as Cauer filter.

Type II Chebyshev filters:

The frequency response of a fifth-order type II Chebyshev low-pass filter with

Also known as inverse Chebyshev, this type is less common because it does not roll off as fast
as type I, and requires more components. It has no ripple in the passband, but does have
equiripple in the stopband. The gain is:

In the stopband, the Chebyshev polynomial will oscillate between 0 and 1 so that the gain will
oscillate between zero and

and the smallest frequency at which this maximum is attained will be the cutoff frequency
. The parameter ε is thus related to the stopband attenuation γ in decibels by:

For a stopband attenuation of 5dB, ε = 0.6801; for an attenuation of 10dB, ε = 0.3333. The
frequency fC = ωC/2π is the cutoff frequency. The 3dB frequency fH is related to fC by:

COMSATS Institute of Information Technology Page 161


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Elliptic filter:
An elliptic filter (also known as a Cauer filter, named after Wilhelm Cauer) is a signal
processing filter with equalized ripple (equiripple) behavior in both the passband and the
stopband. The amount of ripple in each band is independently adjustable, and no other filter of
equal order can have a faster transition in gain between the passband and the stopband, for the
given values of ripple (whether the ripple is equalized or not). Alternatively, one may give up
the ability to independently adjust the passband and stopband ripple, and instead design a filter
which is maximally insensitive to component variations.

As the ripple in the stopband approaches zero, the filter becomes a type I Chebyshev filter. As
the ripple in the passband approaches zero, the filter becomes a type II Chebyshev filter and
finally, as both ripple values approach zero, the filter becomes a Butterworth filter.

The gain of a lowpass elliptic filter as a function of angular frequency ω is given by:

where Rn is the nth-order elliptic rational function (sometimes known as a Chebyshev rational
function) and
is the cutoff frequency
is the ripple factor

is the selectivity factor

The value of the ripple factor specifies the passband ripple, while the combination of the ripple
factor and the selectivity factor specify the stopband ripple

COMSATS Institute of Information Technology Page 162


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Lab Tasks
Task-1: Make a filter using following specifications:

Filter type: Low-pass


fpass = 4kHz
fstop= 6kHz
fs= 44.1kHz
Order: Minimum Order
Match exactly = Pass-band (if applicable)
Apass= 1dB
Astop= 60dB

Figure 1

COMSATS Institute of Information Technology Page 163


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Task-2: Design following high-pass filters:


1. Kaiser Window
2. Butterworth
3. Chebyshev Type-I
4. Chebyshev Type-II
5. Elliptic
With following specifications:
fpass = 6kHz
1. fstop = 4kHz
2. fs = 44.1kHz
3. Order: Minimum Order
4. Match exactly = Pass-band (if applicable)
5. Apass = 1dB
6. Astop = 60dB

1. Kaiser Window

COMSATS Institute of Information Technology Page 164


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

2. Butterworth

COMSATS Institute of Information Technology Page 165


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

3. Chebyshev Type-I

COMSATS Institute of Information Technology Page 166


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

4. Chebyshev Type-II

5. Elliptic

COMSATS Institute of Information Technology Page 167


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Create a Simulink model which generates a sinusoid with following


components:
a) Frequency = 3 kHz
b) Frequency = 8 kHz
Pass the sinusoid through your filter and send the output to output audio jacks of
the DSP kits, DSK6713.Built a table specifying which filter works on kit and
which does not.

The Simulink Model:

C6713 DSK
DAC

Filter DAC

freq 8e3

C6713DSK

TABLE:

Filter working

Kaiser No

Butterworth Yes

Chebyshev- I Yes

Chebyshev- II Yes

Elliptic Yes

COMSATS Institute of Information Technology Page 168


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

Conclusion:
In this lab the following things were observed:
The Butterworth filter is a type of signal processing filter designed to have as flat as
frequency response as possible in the passband.
Chebyshev filters are analog or digital filters having a steeper roll-off and more passband
ripple (type I) or stopband ripple (type II) than Butterworth filters.
An Elliptic filter is a signal processing filter with equalized ripple behavior in both the
passband and the stopband.

THE END

COMSATS Institute of Information Technology Page 169


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

COMSATS Institute of Information Technology Page 170


Lab # 10 Hardware implementation of AM modulator and demodulator on C6713 and C6416 DSK

COMSATS Institute of Information Technology Page 171


Lab # 11 FIR and IIR Filters

COMSATS Institute of Information Technology Page 172


Lab # 11 FIR and IIR Filters

COMSATS Institute of Information Technology Page 173


Lab # 11 FIR and IIR Filters

COMSATS Institute of Information Technology Page 174


Lab # 11 FIR and IIR Filters

COMSATS Institute of Information Technology Page 175

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy