# Connexions

You are here: Home » Content » From MATLAB and Simulink to Real-Time with TI DSP's » Amplitude Modulation

### Lenses

What is a lens?

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

#### Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
• TI DSP

This module and collection are included inLens: Texas Instruments DSP Lens
By: Texas Instruments

Click the "TI DSP" link to see all content affiliated with them.

Click the tag icon to display tags associated with this content.

#### Also in these lenses

• Lens for Engineering

This module and collection are included inLens: Lens for Engineering
By: Sidney Burrus

Click the "Lens for Engineering" link to see all content selected in this lens.

### Recently Viewed

This feature requires Javascript to be enabled.

### Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Inside Collection (Report):

Report by: Jacob Fainguelernt. E-mail the author

# Amplitude Modulation

Module by: Jacob Fainguelernt. E-mail the author

Summary: 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 the AM detector as well as the transmission and reception parameters (modulation index and carrier frequency).

## 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πf c t ) y ( t ) = [ 1 + m ( t ) ] cos ( 2πf c t ) size 12{y $$t$$ = $1+m $$t$$$ "cos" $$2πf rSub { size 8{c} } t$$ } {} Where: cos ( 2πf c t ) cos ( 2πf c t ) size 12{"cos" $$2πf rSub { size 8{c} } t$$ } {} - The carrier signal m ( t ) m ( t ) size 12{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
% 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
%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';
switch m
case 1
model='AM_Coherent';
case 2
model='AM_Sqrt';
end
CodegenDir = fullfile(pwd, [model '_c6000_rtw']);
OutFile = fullfile(CodegenDir, [model '.out']);
% 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 (y<last_y,y>last_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 (y<last_y,y>last_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 ω c t = Re e c t cos ω c t = Re e c t size 12{"cos"ω rSub { size 8{c} } t="Re" left [e rSup { size 8{jω rSub { size 6{c} } t} } right ]} {}
(1)

In the discrete case the following relationship applies:

cos ω c nT s = cos f c f s n = Re e j2π f c f s n cos ω c nT s = cos f c f s n = Re e j2π f c f s n size 12{"cos"ω rSub { size 8{c} } ital "nT" rSub { size 8{s} } ="cos"2π { {f rSub { size 8{c} } } over {f rSub { size 8{s} } } } n="Re" left [e rSup { size 8{j2π { {f rSub { size 6{c} } } over {f rSub { size 6{s} } } } n} } right ]} {}
(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.

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

#### Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

#### Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks