Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

## Introduction

This chapter presents the use of the DSK6713 to demonstrate the features of Amplitude Modulation (AM) transmission and reception. The model runs in real-time and enables the use to select:
1. The AM algorithm
2. The transmission and reception parameters (modulation index and carrier frequency).
The process comprises:
1. Creating a simulation model (not R-T) for the AM transmitter/receiver.
2. Migration to Real-time of the Simulation Model
3. Building a Graphic Users Interface (GUI) to operate the real-time implementation.

## 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.

### The Procedure

#### Building the Transmitter

The basic modulation mathematical description is given by:
 y(t)=[1+m(t)]cos(2πfct) Where: cos(2πfct) - The carrier signal m(t) - The modulation index
• Start by creating a new model in Simulink ®
• Open the Simulink library browser and add the DSP sine-wave to your model. This blocks will represent the information signal m(t).
• 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 its label to “information”.
• 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”
• Double-click on the constant object and set its constant value to 1.5:
• Add a new multiplexer from the same directory as the adder (choose “product”).
• Add a new scope object:
• Set the number of frames parameter to 5. This parameter determines the horizontal scaling of the presented signal.
• Place the objects in the following way:
• Run the model, pause the simulation and activate the scope window. The modulated signal should be displayed as follows:

#### 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.
• Add the new math function block to your model. This block can be configured to implement various mathematical functions.
• Configure the block to calculate the square:
• Use the math function block to create the Square root function. You may retrieve it from the library or copy the “square” block.
• Add a digital filter design block. This block enables you to design filters using the MATLAB® FDATool.
• 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 pass frequencies below 5 KHz, and rejects frequencies higher than 10 KHz (please refer to Figure 16).
• Add a "Multiplier" and a "Subtract"1 block.
• Add two "DSP Constant" blocks.
• Add the matrices concatenation object. This object will enable the modulated and the de-modulated signals to be displayed simultaneously in the scope:
• The blocks should be connected as shown in Figure 18.
• 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).
You should get the signals presented bellow:
• You may change the simulation parameters, and check their influence.

## Real Time Implementation

### 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.
Equipment Used (shown in Figure 22):
• DSK6713
• Dual Channel Oscilloscope
• Signal Generator
We have 4 signals (4 cables):
• Information- the signal to be modulated
• Modulated- the DSK creates a modulation of the given information
• 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.

### The Procedure

• Open the model created in the previous chapter
• Remove the scope and the “information” signal (the 1,000 Hz).
• Add the “Analog to Digital” and “Digital to Analog” converters (ADC and DAC) to your model:
• Add the multi-port selector, in order to split the stereo input.
• 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.
1. Configure the ADC and DAC blocks to a sampling rate to 96 KHZ and 16-bit samples.
• The final model should look as follows:
• You should configure the DSP constants as shown in Figure 28. The frame period for all constants should be -1
• Build the project and load the program to the DSK memory using ctrl+B.
• Make sure that the signals generator amplitude is set to 1 Volt and frequency of [0.1,5] kHz.
• Display the modulated and demodulated signals in the scope.

## Model Extensions

In this section we will extend the functionality of the example. Adding two more features:
• A variable frequency carrier generator (Please refer to secion "A Configurable Carrier Wave Generator" in the Appendix)
• An additional model for AM detection (Please refer to secion "The Coherent Detector (in brief)" in the Appendix).
• Build GUI that we will enable:
• Changing the modulation index
• Changing the carrier frequency
• Selecting the detection scheme
The modulation index and carrier frequency will be changed through RTDX.
• Open the model created in the previous section
• Replace the constant modulation index by an RTDX input (Please refer to Figure 30), and name it InputModulation.
• Configure the RTDX input object to the values described bellow:
• Replace the sine wave block used for the carrier by the configurable carrier blocks (you may find them in the Configurable_Carrier.mdl file)2, and create a subsystem for the carrier generator as shown in Figure 32.
Your model should look as shown in Figure 33.
Figure 32 – Inserting a Configurable Carrier
• 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”3:
Push the OK button and close the “Configuration Parameters” window.
Rebuild *.out file using ctrl+B.
You now have two load files each one corresponding to a different AM scheme.

### Creating the GUI

• Open a new GUI (Enter GUIDE in the MATLAB command line)
• Add 2 sliders and one list box to the GUI, so it would look like:
• Now, double click on the list-box and change the string field:
Change the string field to:
Coherent
SQRT
• In the Modulation index slider set: Min=0.75, Max=1.5.
• In the Carrier Frequency slider set: Min=1, Max=4.
• Press the “play” button so you can save your GUI and open the GUI script m-file.

### The script file

In the script we have to perform the following tasks:
• When the GUI is launched the DSK should be loaded with a default model (SQRT)
• When the user selects a new model> Its correspondent *.out file should be loaded to the DSP.
• When the modulation index is changed, its new value should be written to the DSP through the correspondent RTDX channel.
• When the carrier frequency modulation index is changed, its new value should be written to the DSP through the correspondent RTDX channel.
The following steps describe this implementation.
• The initialization routine “AM_OpeningFcn”:
`` function AM_OpeningFcn(hObject, eventdata, handles, varargin) last_model=1; handles.last_model=last_model; modelName = gcs; %connect to the board CCS_Obj = connectToCCS(modelName); % Identify RTDX channel names/modes chan_struct(1).name = 'InputModulation'; chan_struct(1).mode = 'w'; chan_struct(2).name = 'freq'; chan_struct(2).mode = 'w'; handles.rtdx_chan1=chan_struct(1); handles.rtdx_chan2=chan_struct(2); % Identify RTDX host buffer parameters RTDX_config_struct.Buffsize= 32768; RTDX_config_struct.Nbuffers = 4; RTDX_config_struct.Mode = 'continuous'; %building the full path of the file to be loaded CodegenDir = fullfile(pwd, ['AM_Coherent' '_c6000_rtw']); OutFile = fullfile(CodegenDir, ['AM_Coherent' '.out']); %Load is needed for rtdx setup CCS_Obj.load(OutFile,20); % Set up RTDX r = setupRTDX(CCS_Obj, chan_struct, RTDX_config_struct); handles.pipe=r; handles.CCS_Obj=CCS_Obj; %last_x and last_y are the initial values of %the Index and the carrier respectively  last_x=1; last_y=15000; handles.last_x=last_x; handles.last_y=last_y; handles.output = hObject; % Enable all RTDX channels r.enable('all'); % Update handles structure guidata(hObject, handles); %use the change-model function in order to load the current model. %this function loads a model to the DSK after initiallization (= the code %above) ChangeModel(handles.last_model,handles.CCS_Obj,handles.pipe,handles.last_x,handles.last_y);  ) ``
• When you select a new model, the following code is invoked:
`` function listbox1_Callback(hObject, eventdata, handles) handles.last_model=get(hObject,'Value') ; ChangeModel(handles.last_model,handles.CCS_Obj,handles.pipe,handles.last_x,handles.last_y); ``
An external function (written in the ChangeModel.m file) will be used to select the model:
`` %1. halts the current model %2. free the rtdx channel %3. redefine the rtdx channel %4. loads the current model %5. binds the rtdx to the current model %6. run the CCS and enable the rtdx. %7.writes the last given index modulation  to the rtdx  %parameters: %m - flag that tells if the model is coherential or sqrt %CCS_Obj - the target %r_old - the old  rtdx channel  %last_x - to keep the current Index %last_y - to keep the current carrier frequency function r=ChangeModel(m,CCS_Obj,r_old,last_x,last_y) %halt the current model CCS_Obj.halt; %free the curent rtdx channel cleanupRTDX(CCS_Obj,r_old); %redefine the rtdx: chan_struct(1).name = 'InputModulation'; chan_struct(1).mode = 'w'; chan_struct(2).name = 'freq'; chan_struct(2).mode = 'w'; handles.rtdx_chan1=chan_struct(1); handles.rtdx_chan2=chan_struct(2); % Identify RTDX host buffer parameters RTDX_config_struct.Buffsize= 32768; RTDX_config_struct.Nbuffers = 4; RTDX_config_struct.Mode = 'continuous'; %reload the new model switch m     case 1     model='AM_Coherent';     case 2         model='AM_Sqrt'; end          CodegenDir = fullfile(pwd, [model '_c6000_rtw']); OutFile = fullfile(CodegenDir, [model '.out']); CCS_Obj.load(OutFile,20); % set up the new rtdx channel and run the target r = setupRTDX(CCS_Obj, chan_struct, RTDX_config_struct); CCS_Obj.run;      r.enable('all'); % keep the last Index and carrier frequency: if last_x~=1 r.writemsg(chan_struct(2).name,1/last_x);   end ``
• Changing the modulation index:
`` function slider1_Callback(hObject, eventdata, handles) last_x=handles.last_x; r=handles.pipe; x=single(get(hObject,'Value'));      if or (ylast_y) %if the Index was changed:        r.writemsg(handles.rtdx_chan1.name,1/x);               %the Index increases when the added amplitude decreases         %and thats the reason that we write 1/x to the rtdx        handles.last_x=x;      end guidata(hObject, handles); ``
• Changing the carrier frequency:
`` function slider2_Callback(hObject, eventdata, handles) last_y=handles.last_y; r=handles.pipe; y=single(get(hObject,'Value'));      if or (ylast_y)        r.writemsg(handles.rtdx_chan2.name,y);               handles.last_y=y;      end guidata(hObject, handles); ``
You may change the modulation index and frequency for both models, and observe its influence on the modulated and demodulated signals.

## Appendix

### 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[ect](1)
In the discrete case the following relationship applies:
cosωcnTs=cos
 fc fs
n=Re[ej2π
 fc fs
n
]
(2)
The following model implements the last equation. Please note that a feedback path was included for phase continuity

### The Coherent Detector (in brief)

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

## FOOTNOTES

1. The subtraction is created by reconfiguring the adder block, and choosing “+-“ instead of: “++”
2. The principle of operation of the Configurable Carrier Module is described in the Appendix.
3. The models will be loaded by the GUI script.

## Sites U Missed to Visit ?

• - introSecret Knock Detecting Door Lock Protect your secret hideout from intruders with a lock that will only open when it hears the secret knock. This start...
• - *Lean Production Simplified—A Plain-Language Guide to the World's Most Powerful Production System, 2nd Edition* *DOWNLAOD*
• - *Preface* *General* NOTE: All references to ActionScript in this lesson are references to version 3 or later. This tutorial lesson is part of a series of le...
• - *Overview* Amplitude modulation (AM) is normally associated with communications systems; for example, you can find all sorts of "talk radio" stations on th...
• - Summary: Microcontroller, 8051 The 8051 Architecture The 8051 architecture consists of the following features. - Eight bit CPU with registers A(the accu...
• - Projects based on PSoC Mixed Signal Array PSC1 Light intensity based Street light automation using PSOC Mixed Signal Array PSC 2 Petrochemical level indica...
• - *Project Summary:* A closed-loop simulation of the Eagle helicopter has been developed using SIMULINK. The model incorporates realistic sensor models, sta...

## Give Support

Encourage me through Comments and by Followers