<< Chapter < Page Chapter >> Page >
function DTMF_OpeningFcn(hObject, eventdata, handles, varargin) modelName = gcs;CCS_Obj = connectToCCS(modelName); % Identify RTDX channel names/modeschan_struct(1).name = 'OutputDigit'; chan_struct(1).mode = 'r';handles.RTDX_chan1=chan_struct(1); % Identify RTDX host buffer parameters RTDX_config_struct.Buffsize= 32768;RTDX_config_struct.Nbuffers = 4; RTDX_config_struct.Mode = 'continuous';CodegenDir = fullfile(pwd, ['DTMF_RT' '_c6000_rtw']);OutFile = fullfile(CodegenDir, ['DTMF_RT' '.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;handles.output = hObject; CCS_Obj.run;% Enable all RTDX channels r.enable('all');%The buffer that stores the user input digits A=[]; handles.A=A;% flag that tells if the gui needs to clear the dialed string or %the next digit joins the previous string:handles.initFlag=0; handles.maxSize=11;handles.freqTable=generateTable(); % Update handles structureguidata(hObject, handles);

This function will run after activating the GUI. It will then load the DSK, initialize the RTDX interface, and initialize a table of samples for each digit, by calling the generateTable auxiliary function:

function res=generateTable() t=(1:256*6)/8192;res(1,:)=sin(2*pi*697*t)+sin(2*pi*1209*t); res(2,:)=sin(2*pi*697*t)+sin(2*pi*1336*t);res(3,:)=sin(2*pi*697*t)+sin(2*pi*1477*t); res(4,:)=sin(2*pi*770*t)+sin(2*pi*1209*t);res(5,:)=sin(2*pi*770*t)+sin(2*pi*1336*t); res(6,:)=sin(2*pi*770*t)+sin(2*pi*1477*t);res(7,:)=sin(2*pi*852*t)+sin(2*pi*1209*t); res(8,:)=sin(2*pi*852*t)+sin(2*pi*1336*t);res(9,:)=sin(2*pi*852*t)+sin(2*pi*1477*t); res(10,:)=sin(2*pi*941*t)+sin(2*pi*1209*t);res(11,:)=sin(2*pi*941*t)+sin(2*pi*1336*t); res(12,:)=sin(2*pi*941*t)+sin(2*pi*1477*t);
  • Enter the handle Button function:
function handleButton(hObject,handles,k) %get the digits bufferA=handles.A; %if we have to erase so we are doing it here:if handles.initFlag==1 handles.initFlag=0;A=[];end %check if the string is too long with the new digit:if length(A)==handles.maxSize fprintf('Error: too many digits\n');return; end%concatenate the new digit to the existing buffer A=[A k]; handles.A=A;set(handles.text1, 'String', strrep(strrep(strrep(int2str(A),'10','*'),'11','0'),'12','#')); guidata(hObject,handles);% invoked when the user dials '1':function pushbutton1_Callback(hObject, eventdata, handles) handleButton(hObject,handles,1);% invoked when the user dials '2': function pushbutton2_Callback(hObject, eventdata, handles)handleButton(hObject,handles,2); . . .

This function will be activated, every time the user pushes a digit button in the keypad. The digit will be displayed under the “Dialed Digits” label.

  • The following function will be activated by the “Send” button:
%input: digits and handle to the signals table %output: buffer that contains the DTMF samples for the digits.function res=buildXmt(handles,A) res=[]; for k=1 : length(A)freqTable=handles.freqTable; %place the next digit and then zeros (space)res=[res freqTable(A(k),:) zeros(1,256*6);];end%The Send Button Handler: function pushbutton13_Callback(hObject, eventdata, handles)r=handles.pipe; A=handles.A;padding=0; if length(A)==0return end% if dialed less than 11 digits pad to 11 digits if length(A)<11 padding=11-length(A);A=[A ones(1,11-length(A))];end %build the Send Bufferxmt=0.5*buildXmt(handles,A); %Transmit DTMF signals buffersound(xmt,8192) %Wait for end of detectionpause(4) %read the digits from the rtdx:num_of_msgs = msgcount(r,'OutputDigit'); r.flush('OutputDigit',num_of_msgs-1);y=r.readmsg(handles.rtdx_chan1.name, 'double',1); y=y(1:end-padding);%Update the upper label with the digits read from dsk estimationset(handles.text4, 'String', strrep(strrep(strrep(int2str(y),'10','*'),'11','#'),'20','*')); handles.initFlag=1;guidata(hObject, handles);

It will generate the DTMF samples Buffer, based on the “User Dialed” information. The samples will be sent to the sound-card. The program will then monitor the RTDX channel to receive the digits reported by the DSK.

  • Enter the functions activated by the “Clear” and “delete” push buttons:
% Delete one digit. function pushbutton14_Callback(hObject, eventdata, handles)A=handles.A; if length(A)==0return endA=A(1:end-1); set(handles.text1, 'String', strrep(strrep(strrep(int2str(A),'10','*'),'11','0'),'12','#'));handles.A=A; guidata(hObject, handles);%Clear all the dialed digits. function pushbutton15_Callback(hObject, eventdata, handles)A=handles.A; A=[]; set(handles.text1, 'String',strrep(strrep(strrep(int2str(A),'10','*'),'11','0'),'12','#')); handles.A=A;guidata(hObject, handles);

Running the example

The system used to run this example is shown in Figure 7.

Activate the GUI (DTMF.fig). Enter an array of digits and compare them to those detected by the DSK.

Things to try

The original algorithm (simulation) runs in a "noiseless" environment. You are invited to check the performance of the real-time model, and eventually change the algorithm to reduce its sensitivity to noise.

You may also add new buttons for DTMF parameters (level, frequency deviation, etc …), and test the DTMF receiver performance against these parameters.

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

if three forces F1.f2 .f3 act at a point on a Cartesian plane in the daigram .....so if the question says write down the x and y components ..... I really don't understand
Syamthanda Reply
hey , can you please explain oxidation reaction & redox ?
Boitumelo Reply
hey , can you please explain oxidation reaction and redox ?
Boitumelo
for grade 12 or grade 11?
Sibulele
the value of V1 and V2
Tumelo Reply
advantages of electrons in a circuit
Rethabile Reply
we're do you find electromagnetism past papers
Ntombifuthi
what a normal force
Tholulwazi Reply
it is the force or component of the force that the surface exert on an object incontact with it and which acts perpendicular to the surface
Sihle
what is physics?
Petrus Reply
what is the half reaction of Potassium and chlorine
Anna Reply
how to calculate coefficient of static friction
Lisa Reply
how to calculate static friction
Lisa
How to calculate a current
Tumelo
how to calculate the magnitude of horizontal component of the applied force
Mogano
How to calculate force
Monambi
a structure of a thermocouple used to measure inner temperature
Anna Reply
a fixed gas of a mass is held at standard pressure temperature of 15 degrees Celsius .Calculate the temperature of the gas in Celsius if the pressure is changed to 2×10 to the power 4
Amahle Reply
How is energy being used in bonding?
Raymond Reply
what is acceleration
Syamthanda Reply
a rate of change in velocity of an object whith respect to time
Khuthadzo
how can we find the moment of torque of a circular object
Kidist
Acceleration is a rate of change in velocity.
Justice
t =r×f
Khuthadzo
how to calculate tension by substitution
Precious Reply
hi
Shongi
hi
Leago
use fnet method. how many obects are being calculated ?
Khuthadzo
khuthadzo hii
Hulisani
how to calculate acceleration and tension force
Lungile Reply
you use Fnet equals ma , newtoms second law formula
Masego
please help me with vectors in two dimensions
Mulaudzi Reply
how to calculate normal force
Mulaudzi
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