amplitude modulation - openstax cnx2.pdf... · powerpoint presentation - amplitude modulation.ppt 1...
TRANSCRIPT
![Page 1: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/1.jpg)
OpenStax-CNX module: m22187 1
Amplitude Modulation*
Jacob Fainguelernt
This work is produced by OpenStax-CNX and licensed under the
Creative Commons Attribution License 2.0�
Abstract
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 AMdetector as well as the transmission and reception parameters (modulation index and carrier frequency).
1 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 algorithm2. 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 Model3. Building a Graphic Users Interface (GUI) to operate the real-time implementation.
1.1 Related Files
• Powerpoint Presentation - Amplitude Modulation.ppt1
• Simulink Model for Simulation - AM_Simulation.mdl2
• MATLAB GUI for Real-Time - AM.�g3
• GUI m-�leAM.m4
• m-�le for Selection of AM Reception ChangeModel.m5
• Simulink Model for Coherent Detection AM_Coherent.mdl6
• Simulink Model for Square Root (SQRT) Detection AM_Sqrt.mdl7
• Con�gurable Carrier Simulink Model Con�gurable_Carrier.mdl8
*Version 1.2: Apr 20, 2009 11:18 am -0500�http://creativecommons.org/licenses/by/2.0/1See the �le at <http://cnx.org/content/m22187/latest/Amplitude Modulation.ppt>2See the �le at <http://cnx.org/content/m22187/latest/AM_Simulation.mdl>3See the �le at <http://cnx.org/content/m22187/latest/AM.�g>4See the �le at <http://cnx.org/content/m22187/latest/AM.m>5See the �le at <http://cnx.org/content/m22187/latest/ChangeModel.m>6See the �le at <http://cnx.org/content/m22187/latest/AM_Coherent.mdl>7See the �le at <http://cnx.org/content/m22187/latest/AM_Sqrt.mdl>8See the �le at <http://cnx.org/content/m22187/latest/Con�gurable_Carrier.mdl>
http://cnx.org/content/m22187/1.2/
![Page 2: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/2.jpg)
OpenStax-CNX module: m22187 2
2 Simulation
2.1 The Environment
Figure 1 shows the data �ow for the AM modulation simulation. The AM modulation model receives aninput signal from an external signal generator, modulates it and displays the modulation on the scope.
Figure 1: Simulation Environment
2.2 The Procedure
2.2.1 Building the Transmitter
The basic modulation mathematical description is given by:
y (t) = [1 +m (t)] cos (2πf ct)
Where:
cos (2πf ct) - The carrier signal
m (t) - The modulation index
Table 1
http://cnx.org/content/m22187/1.2/
![Page 3: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/3.jpg)
OpenStax-CNX module: m22187 3
Figure 2: AM Transmission Principle
• 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).
http://cnx.org/content/m22187/1.2/
![Page 4: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/4.jpg)
OpenStax-CNX module: m22187 4
Figure 3: The Sine Wave Generator Block
• Con�gure the Sine Wave Generator Block (Double click on the DSP sine object). Set the sine frequencyto 1000 Hz, sample time to 1/96000, samples per frame to 64 and close the box, and change its labelto �information�.
http://cnx.org/content/m22187/1.2/
![Page 5: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/5.jpg)
OpenStax-CNX module: m22187 5
Figure 4: Information Signal Con�guration Parameters
• Use the same block to create the carrier signal. You may copy the block already created or selectit form the Simulink library. Set the carrier frequency to 15,000 Hz. The remaining parameters are
http://cnx.org/content/m22187/1.2/
![Page 6: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/6.jpg)
OpenStax-CNX module: m22187 6
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
• Double-click on the constant object and set its constant value to 1.5:
http://cnx.org/content/m22187/1.2/
![Page 7: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/7.jpg)
OpenStax-CNX module: m22187 7
Figure 6: Set a constant value
• Add a new adder object from:
http://cnx.org/content/m22187/1.2/
![Page 8: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/8.jpg)
OpenStax-CNX module: m22187 8
Figure 7: Addes
• Add a new multiplexer from the same directory as the adder (choose �product�).• Add a new scope object:
http://cnx.org/content/m22187/1.2/
![Page 9: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/9.jpg)
OpenStax-CNX module: m22187 9
Figure 8: Scope
• Set the number of frames parameter to 5. This parameter determines the horizontal scaling of thepresented signal.
http://cnx.org/content/m22187/1.2/
![Page 10: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/10.jpg)
OpenStax-CNX module: m22187 10
Figure 9: Vector Scope Con�guration
• Place the objects in the following way:
http://cnx.org/content/m22187/1.2/
![Page 11: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/11.jpg)
OpenStax-CNX module: m22187 11
Figure 10: The Transmitter Model
• Run the model, pause the simulation and activate the scope window. The modulated signal should bedisplayed as follows:
http://cnx.org/content/m22187/1.2/
![Page 12: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/12.jpg)
OpenStax-CNX module: m22187 12
Figure 11: AM Modulation Signal
2.2.2 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.
http://cnx.org/content/m22187/1.2/
![Page 13: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/13.jpg)
OpenStax-CNX module: m22187 13
Figure 12: SQRT Demodulation Principle of Operation
• Add the new math function block to your model. This block can be con�gured to implement variousmathematical functions.
http://cnx.org/content/m22187/1.2/
![Page 14: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/14.jpg)
OpenStax-CNX module: m22187 14
Figure 13: Square Function
• Con�gure the block to calculate the square:
http://cnx.org/content/m22187/1.2/
![Page 15: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/15.jpg)
OpenStax-CNX module: m22187 15
Figure 14: Select Math Function
• Use the math function block to create the Square root function. You may retrieve it from the libraryor copy the �square� block.
• Add a digital �lter design block. This block enables you to design �lters using the MATLAB®FDATool.
http://cnx.org/content/m22187/1.2/
![Page 16: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/16.jpg)
OpenStax-CNX module: m22187 16
Figure 15: Digital Filter Design
• Con�gure the �lter to be Low-Pass Filter. Since the carrier frequency (fc) is 15 KHz and the maximalfrequency of the information is 1 KHz, the �lter will be designed to pass frequencies below 5 KHz, andrejects frequencies higher than 10 KHz (please refer to Figure 16).
http://cnx.org/content/m22187/1.2/
![Page 17: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/17.jpg)
OpenStax-CNX module: m22187 17
Figure 16: LPF Design Window
• Add a "Multiplier" and a "Subtract"9 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:
9The subtraction is created by recon�guring the adder block, and choosing �+-� instead of: �++�
http://cnx.org/content/m22187/1.2/
![Page 18: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/18.jpg)
OpenStax-CNX module: m22187 18
Figure 17: Matrix Concatenate
• The blocks should be connected as shown in Figure 18.
http://cnx.org/content/m22187/1.2/
![Page 19: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/19.jpg)
OpenStax-CNX module: m22187 19
Figure 18: AM Simulation Model
• Run the simulation (push the �play� button). Double click on the scope. Scale the display to �t thescope window (Choose from the menus: Axes=>Autoscale). Choose a di�erent color for each signal(Please refer to Figure 19).
http://cnx.org/content/m22187/1.2/
![Page 20: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/20.jpg)
OpenStax-CNX module: m22187 20
Figure 19: Displaying the Modulated and Demodulated Signals
You should get the signals presented bellow:
http://cnx.org/content/m22187/1.2/
![Page 21: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/21.jpg)
OpenStax-CNX module: m22187 21
Figure 20: The Video Viewer Display
• You may change the simulation parameters, and check their in�uence.
3 Real Time Implementation
3.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 de�nition block (DSK6713) will be added.
Figure 21 shows the block-diagram for the real time implementation.
http://cnx.org/content/m22187/1.2/
![Page 22: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/22.jpg)
OpenStax-CNX module: m22187 22
Figure 21: Real Time Implementation Environment
Equipment Used (shown in Figure 22):
• DSK6713• Dual Channel Oscilloscope• Signal Generator
http://cnx.org/content/m22187/1.2/
![Page 23: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/23.jpg)
OpenStax-CNX module: m22187 23
Figure 22: Equipment Used
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 modulatedsignal that is broadcasted by the transmitter and used as input for the receiver.
• Demodulated- the signal that the receiver outputs after the demodulation process.
http://cnx.org/content/m22187/1.2/
![Page 24: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/24.jpg)
OpenStax-CNX module: m22187 24
3.2 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
• Add the �Analog to Digital� and �Digital to Analog� converters (ADC and DAC) to your model:
http://cnx.org/content/m22187/1.2/
![Page 25: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/25.jpg)
OpenStax-CNX module: m22187 25
Figure 24: A/D and D/A converters
• Add the multi-port selector, in order to split the stereo input.
http://cnx.org/content/m22187/1.2/
![Page 26: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/26.jpg)
OpenStax-CNX module: m22187 26
Figure 25: Multiport Selector
• 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.
http://cnx.org/content/m22187/1.2/
![Page 27: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/27.jpg)
OpenStax-CNX module: m22187 27
Figure 26: Multiport Con�guration
1. Con�gure the ADC and DAC blocks to a sampling rate to 96 KHZ and 16-bit samples.
http://cnx.org/content/m22187/1.2/
![Page 28: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/28.jpg)
OpenStax-CNX module: m22187 28
Figure 27: DAC and ADC Con�guration
• The �nal model should look as follows:
http://cnx.org/content/m22187/1.2/
![Page 29: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/29.jpg)
OpenStax-CNX module: m22187 29
Figure 28: AM (SQRT) Real Time Model
• You should con�gure the DSP constants as shown in Figure 28. The frame period for all constantsshould be -1
http://cnx.org/content/m22187/1.2/
![Page 30: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/30.jpg)
OpenStax-CNX module: m22187 30
Figure 29: Constant Value Parameters
• 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.
4 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 Con�gurable Carrier Wave Generator"in the Appendix)
• An additional model for AM detection (Please refer to secion "The Coherent Detector (in brief)" inthe 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.
http://cnx.org/content/m22187/1.2/
![Page 31: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/31.jpg)
OpenStax-CNX module: m22187 31
• 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
• Con�gure the RTDX input object to the values described bellow:
http://cnx.org/content/m22187/1.2/
![Page 32: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/32.jpg)
OpenStax-CNX module: m22187 32
Figure 31: RTDX Input Con�guration
• Replace the sine wave block used for the carrier by the con�gurable carrier blocks (you may �nd them
http://cnx.org/content/m22187/1.2/
![Page 33: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/33.jpg)
OpenStax-CNX module: m22187 33
in the Con�gurable_Carrier.mdl10 �le)11, and create a subsystem for the carrier generator as shownin Figure 32.
Your model should look as shown in Figure 33.
10See the �le at <http://cnx.org/content/m22187/latest/Con�gurable_Carrier.mdl>11The principle of operation of the Con�gurable Carrier Module is described in the Appendix.
http://cnx.org/content/m22187/1.2/
![Page 34: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/34.jpg)
OpenStax-CNX module: m22187 34
Figure 32: Inserting a Con�gurable Carrier
Figure 32 � Inserting a Con�gurable Carrier
http://cnx.org/content/m22187/1.2/
![Page 35: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/35.jpg)
OpenStax-CNX module: m22187 35
Figure 33: AM (SQRT) Model with Con�gurable Carrier
• Enter the Con�guration Parameters menu (ctrl+E). Choose Real-Time Workshop=>TIC6000 Code-Generator, In The Run-Time box change the Build Action to �Build�12:
12The models will be loaded by the GUI script.
http://cnx.org/content/m22187/1.2/
![Page 36: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/36.jpg)
OpenStax-CNX module: m22187 36
Figure 34: Simulation Parameters
Push the OK button and close the �Con�guration Parameters� window.Rebuild *.out �le using ctrl+B.
• Open the AM_Coherent.mdl13 �le, and repeat step for this �le.
You now have two load �les each one corresponding to a di�erent AM scheme.
4.1 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:
13See the �le at <http://cnx.org/content/m22187/latest/AM_Coherent.mdl>
http://cnx.org/content/m22187/1.2/
![Page 37: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/37.jpg)
OpenStax-CNX module: m22187 37
Figure 35: GUI Design Screen
• Now, double click on the list-box and change the string �eld:
http://cnx.org/content/m22187/1.2/
![Page 38: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/38.jpg)
OpenStax-CNX module: m22187 38
Figure 36: List Box Con�guration Screen
Change the string �eld to:CoherentSQRT
• 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-�le.
4.2 The script �le
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 �le should be loaded to the DSP.
http://cnx.org/content/m22187/1.2/
![Page 39: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/39.jpg)
OpenStax-CNX module: m22187 39
• When the modulation index is changed, its new value should be written to the DSP through thecorrespondent RTDX channel.
• When the carrier frequency modulation index is changed, its new value should be written to the DSPthrough 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);
http://cnx.org/content/m22187/1.2/
![Page 40: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/40.jpg)
OpenStax-CNX module: m22187 40
)
• 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 �le) 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']);
http://cnx.org/content/m22187/1.2/
![Page 41: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/41.jpg)
OpenStax-CNX module: m22187 41
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∼=1r.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);
http://cnx.org/content/m22187/1.2/
![Page 42: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/42.jpg)
OpenStax-CNX module: m22187 42
Figure 37: AM Model Graphic User Interface
You may change the modulation index and frequency for both models, and observe its in�uence on themodulated and demodulated signals.
5 Appendix
5.1 A Con�gurable Carrier Wave Generator
The Simulink sine wave block cannot be con�gured during run-time; its frequency is a parameter that shouldbe set in advance. We will introduce the implementation of a block where the frequency is a variable thatcan be set in real-time (In this case using RTDX). The block is based on the following relationship:
cosωct = Re[ejωct
](37)
In the discrete case the following relationship applies:
cosωcnTs = cos2πfcfsn = Re
[ej2π
fcfsn]
(37)
http://cnx.org/content/m22187/1.2/
![Page 43: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/43.jpg)
OpenStax-CNX module: m22187 43
The following model implements the last equation. Please note that a feedback path was included for phasecontinuity
Figure 38: Carrier Wave Generator
5.2 The Coherent Detector (in brief)
The coherent detector principle of operation is in Figure 39. The AM example model (AM_Coherent.mdl14)is shown in Figure 40.
14See the �le at <http://cnx.org/content/m22187/latest/AM_Coherent.mdl>
http://cnx.org/content/m22187/1.2/
![Page 44: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/44.jpg)
OpenStax-CNX module: m22187 44
Figure 39: Coherent SQRT Demodulation Principle of Operation
http://cnx.org/content/m22187/1.2/
![Page 45: Amplitude Modulation - OpenStax CNX2.pdf... · Powerpoint Presentation - Amplitude Modulation.ppt 1 Simulink Model for Simulation - AM_Simulation.mdl 2 MATLAB GUI for Real-Time -](https://reader030.vdocuments.site/reader030/viewer/2022040410/5ecd101d2b8a7e25b34f8c40/html5/thumbnails/45.jpg)
OpenStax-CNX module: m22187 45
Figure 40: Amplitude Modulation Example with Coherent Detection
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarksfor a list of additional trademarks. Other product or brand names may be trademarks or registered trade-marks of their respective holders.
http://cnx.org/content/m22187/1.2/