<< Chapter < Page Chapter >> Page >

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 parametersRTDX_config_struct.Buffsize= 32768; RTDX_config_struct.Nbuffers = 4;RTDX_config_struct.Mode = 'continuous'; %building the full path of the file to be loadedCodegenDir = 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 respectivelylast_x=1; last_y=15000;handles.last_x=last_x; handles.last_y=last_y;handles.output = hObject; % Enable all RTDX channelsr.enable('all'); % Update handles structureguidata(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 parametersRTDX_config_struct.Buffsize= 32768; RTDX_config_struct.Nbuffers = 4;RTDX_config_struct.Mode = 'continuous';%reload the new model switch mcase 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~=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 rtdxhandles.last_x=x; endguidata(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; endguidata(hObject, handles);
AM Model Graphic User Interface

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 size 12{"cos"ω rSub { size 8{c} } t="Re" left [e rSup { size 8{jω rSub { size 6{c} } t} } right ]} {}

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 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 ]} {}

{} The following model implements the last equation. Please note that a feedback path was included for phase continuity

Carrier Wave Generator

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.

Coherent SQRT Demodulation Principle of Operation
Amplitude Modulation Example with Coherent Detection

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.

Questions & Answers

how does the planets on our solar system orbit
cheten Reply
how many Messier objects are there in space
satish Reply
did you g8ve certificate
Richard Reply
what are astronomy
Issan Reply
Astronomy (from Ancient Greek ἀστρονομία (astronomía) 'science that studies the laws of the stars') is a natural science that studies celestial objects and phenomena. It uses mathematics, physics, and chemistry in order to explain their origin and evolution.
Rafael
vjuvu
Elgoog
what is big bang theory?
Rosemary
what type of activity astronomer do?
Rosemary
No
Richard
the big bang theory is a theory which states that all matter was compressed together in one place the matter got so unstable it exploded releasing All its contents in the form of hydrogen
Roaul
I want to be an astronomer. That's my dream
Astrit
Who named the the whole galaxy?
Shola Reply
solar Univers
GPOWER
what is space
Richard
what is the dark matter
Richard
what are the factors upon which the atmosphere is stratified
Nicholas Reply
is the big bang the sun
Folakemi Reply
no
Sokak
bigbang is the beginning of the universe
Sokak
but thats just a theory
Sokak
nothing will happen, don't worry brother.
Vansh
what does comet means
GANGAIN Reply
these are Rocky substances between mars and jupiter
GANGAIN
Comets are cosmic snowballs of frozen gases , rock and dust that orbit the sun. They are mostly found between the orbits of Venus and Mercury.
Aarya
hllo
John
hi
John
qt rrt
John
r u there
John
hey can anyone guide me abt international astronomy olympiad
sahil
how can we learn right and true ?
Govinda Reply
why the moon is always appear in an elliptical shape
Gatjuol Reply
Because when astroid hit the Earth then a piece of elliptical shape of the earth was separated which is now called moon.
Hemen
what's see level?
lidiya Reply
Did you mean eye sight or sea level
Minal
oh sorry it's sea level
lidiya
according to the theory of astronomers why the moon is always appear in an elliptical orbit?
Gatjuol
hi !!! I am new in astronomy.... I have so many questions in mind .... all of scientists of the word they just give opinion only. but they never think true or false ... i respect all of them... I believes whole universe depending on true ...থিউরি
Govinda
hello
Jackson
hi
Elyana
we're all stars and galaxies a part of sun. how can science prove thx with respect old ancient times picture or books..or anything with respect to present time .but we r a part of that universe
w astronomy and cosmology!
Michele
another theory of universe except big ban
Albash Reply
how was universe born
Asmit Reply
there many theory to born universe but what is the reality of big bang theory to born universe
Asmit
what is the exact value of π?
Nagalakshmi
by big bang
universal
there are many theories regarding this it's on you believe any theory that you think is true ex. eternal inflation theory, oscillation model theory, multiple universe theory the big bang theory etc.
Aarya
I think after Big Bang!
Michele
from where on earth could u observe all the stars during the during the course of an year
Karuna Reply
I think it couldn't possible on earth
Nagalakshmi
in this time i don't Know
Michele
is that so. the question was in the end of this chapter
Karuna
in theory, you could see them all from the equator (though over the course of a year, not at pne time). stars are measured in "declination", which is how far N or S of the equator (90* to -90*). Polaris is the North star, and is ALMOST 90* (+89*). So it would just barely creep over the horizon.
Christopher
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, From matlab and simulink to real-time with ti dsp's. OpenStax CNX. Jun 08, 2009 Download for free at http://cnx.org/content/col10713/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'From matlab and simulink to real-time with ti dsp's' conversation and receive update notifications?

Ask