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.

Amplitude Modulation


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.

Related Files

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.
Figure 1: Simulation Environment
Figure 1 (graphics1.jpg)

The Procedure

Building the Transmitter

The basic modulation mathematical description is given by:
TABLE 1
y(t)=[1+m(t)]cos(2πfct)
Where:
cos(2πfct)- The carrier signal
m(t)- The modulation index
Figure 2: AM Transmission Principle
Figure 2 (graphics2.jpg)
  • 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).
Figure 3: The Sine Wave Generator Block
Figure 3 (graphics3.png)
  • 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”.
Figure 4: Information Signal Configuration Parameters
Figure 4 (graphics4.png)
  • 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”
  • Add new DSP-constant to your model:
Figure 5: Adding a DSP constant
Figure 5 (graphics5.png)
  • Double-click on the constant object and set its constant value to 1.5:
Figure 6: Set a constant value
Figure 6 (graphics6.png)
  • Add a new adder object from:
Figure 7: Addes
Figure 7 (graphics7.png)
  • Add a new multiplexer from the same directory as the adder (choose “product”).
  • Add a new scope object:
Figure 8: Scope
Figure 8 (graphics8.png)
  • Set the number of frames parameter to 5. This parameter determines the horizontal scaling of the presented signal.
Figure 9: Vector Scope Configuration
Figure 9 (graphics9.png)
  • Place the objects in the following way:
Figure 10: The Transmitter Model
Figure 10 (graphics10.png)
  • Run the model, pause the simulation and activate the scope window. The modulated signal should be displayed as follows:
Figure 11: AM Modulation Signal
Figure 11 (graphics11.png)

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
Figure 12 (graphics12.jpg)
  • Add the new math function block to your model. This block can be configured to implement various mathematical functions.
Figure 13: Square Function
Figure 13 (graphics13.png)
  • Configure the block to calculate the square:
Figure 14: Select Math Function
Figure 14 (graphics14.png)
  • 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.
Figure 15: Digital Filter Design
Figure 15 (graphics15.png)
  • 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).
Figure 16: LPF Design Window
Figure 16 (graphics16.png)
  • 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:
Figure 17: Matrix Concatenate
Figure 17 (graphics17.png)
  • The blocks should be connected as shown in Figure 18.
Figure 18: AM Simulation Model
Figure 18 (graphics18.png)
  • 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
Figure 19 (graphics19.png)
You should get the signals presented bellow:
Figure 20: The Video Viewer Display
Figure 20 (graphics20.png)
  • 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.
Figure 21: Real Time Implementation Environment
Figure 21 (fig21.jpg)
Equipment Used (shown in Figure 22):
  • DSK6713
  • Dual Channel Oscilloscope
  • Signal Generator
Figure 22: Equipment Used
Figure 22 (graphics22.jpg)
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).
  • Open the Simulink library browser and add the "C6713DSK".
Figure 23: The C6713DSK Block
Figure 23 (graphics23.png)
  • Add the “Analog to Digital” and “Digital to Analog” converters (ADC and DAC) to your model:
Figure 24: A/D and D/A converters
Figure 24 (Fig24.jpg)
  • Add the multi-port selector, in order to split the stereo input.
Figure 25: Multiport Selector
Figure 25 (graphics26.png)
  • 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 26: Multiport Configuration
Figure 26 (graphics27.png)
  1. Configure the ADC and DAC blocks to a sampling rate to 96 KHZ and 16-bit samples.
Figure 27: DAC and ADC Configuration
Figure 27 (Fig27.jpg)
  • The final model should look as follows:
Figure 28: AM (SQRT) Real Time Model
Figure 28 (graphics30.png)
  • You should configure the DSP constants as shown in Figure 28. The frame period for all constants should be -1
Figure 29: Constant Value Parameters
Figure 29 (graphics31.png)
  • 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.
Figure 30: RTDX input
Figure 30 (graphics32.png)
  • Configure the RTDX input object to the values described bellow:
Figure 31: RTDX Input Configuration
Figure 31 (graphics33.png)
  • 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
Figure 32 (graphics34.png)
Figure 32 – Inserting a Configurable Carrier
Figure 33: AM (SQRT) Model with Configurable Carrier
Figure 33 (fig33.jpg)
  • 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:
Figure 34: Simulation Parameters
Figure 34 (graphics36.png)
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:
Figure 35: GUI Design Screen
Figure 35 (graphics37.png)
  • Now, double click on the list-box and change the string field:
Figure 36: List Box Configuration Screen
Figure 36 (graphics38.png)
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); 
Figure 37: AM Model Graphic User Interface
Figure 37 (graphics39.png)
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
Figure 38: Carrier Wave Generator
Figure 38 (graphics40.png)

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.
Figure 39: Coherent SQRT Demodulation Principle of Operation
Figure 39 (graphics41.jpg)
Figure 40: Amplitude Modulation Example with Coherent Detection
Figure 40 (fig40.jpg)
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.

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.

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.