最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

DTMF信号的产生与解码

来源:动视网 责编:小OO 时间:2025-09-30 22:28:37
文档

DTMF信号的产生与解码

一、课程设计的目的和任务“数字信号处理”课程是信息和通信工程专业必修的专业技术基础课程。课程以信号与系统作为研究对象,研究对信号进行各种处理和利用的技术。通过该课程的学习,学生应牢固掌握确定性信号和系统的分析方法、相关算法、系统实现等的相关知识的,借助于数字滤波器的设计及实现,学生可掌握数字系统的分析以及设计方法。数字信号处理是理论性和工程性都很强的学科,本课程设计的目的就是使该课程的理论与工程应用的紧密结合,使学生深入理解信号处理的内涵和实质。本课程设计要求学生在理解信号处理的数学原理的基础
推荐度:
导读一、课程设计的目的和任务“数字信号处理”课程是信息和通信工程专业必修的专业技术基础课程。课程以信号与系统作为研究对象,研究对信号进行各种处理和利用的技术。通过该课程的学习,学生应牢固掌握确定性信号和系统的分析方法、相关算法、系统实现等的相关知识的,借助于数字滤波器的设计及实现,学生可掌握数字系统的分析以及设计方法。数字信号处理是理论性和工程性都很强的学科,本课程设计的目的就是使该课程的理论与工程应用的紧密结合,使学生深入理解信号处理的内涵和实质。本课程设计要求学生在理解信号处理的数学原理的基础
一、课程设计的目的和任务

“数字信号处理”课程是信息和通信工程专业必修的专业技术基础课程。课程以信号与系统作为研究对象,研究对信号进行各种处理和利用的技术。通过该课程的学习,学生应牢固掌握确定性信号和系统的分析方法、相关算法、系统实现等的相关知识的,借助于数字滤波器的设计及实现,学生可掌握数字系统的分析以及设计方法。 数字信号处理是理论性和工程性都很强的学科,本课程设计的目的就是使该课程的理论与工程应用的紧密结合, 使学生深入理解信号处理的内涵和实质。 

本课程设计要求学生在理解信号处理的数学原理的基础上,应用计算机编程手段,实现一种信号分析或处理的设计,达到对所学内容融会贯通,综合各部分知识,按照题目要求设计完成。

二、课程设计的题目和要求

1.课程设计题目:DTMF信号的产生与解码

DTMF编解码广泛应用于数字电话拨号,简单通信协议等领域。目前所有的电话和传真机按键都是采用DTMF信号进行编码和传输的,该方案实际是利用模拟信号对数字符号进行编码。

该编码方案共使用8个模拟频率对16个符号进行编码,这16个频率分为2个群:高音群和低音群。所以称为双音多频(Dual-Tone Multiple-Frequency)编码,其编码方案如图1。由图可知每个符号由一个高音频率和一个低音频率唯一确定。

图1  DTMF信号编码方案

对于该信号的产生,我们可以利用数字振荡器来完成。

而对这些信号的检测,则可以利用DFT来完成。要注意的是,这里只需要计算16个频点的FFT输出,因此课本上介绍基2或基4算法并不是最优的,这时我们需要采用Goerzel算法完成所需的DFT。当然我们也可以用16个窄带带通滤波器完成,窄带带通滤波器的中心频率就是上述各频率。对窄带滤波器输出信号的输出做判决就可以得到解码的结果。

2.设计要求

编制程序生成并显示各符号的时域信号和对应的幅频曲线。

编程模拟电话拨号过程:输入电话号码,生成各号码的时域信号,给时域信号加噪声,编程对含噪声的电话拨号信号进行解码。编制程序测试编解码程序的正确性。要列出表格,统计拨出的符号的解码成功率。

完成设计,选择自己熟悉的编程语言编写程序,最好能给出图形界面。

三、设计过程与结果

1.在MATLAB中建立一个GUI图形界面,将本课程设计所要实现的功能的一些工具拖进GUI界面,并根据需要修改各个工具的属性,建立的初始界面如图2所示。

 图2  GUI图形设计的初始界面

2.打开jink.fig界面所对应的源程序编辑窗口,其中MATLAB会自动生成界面的初始化程序代码以及1——D、“解码检测”和“退出”共18个按钮各按钮的函数名和参数功能解释。在这里,我们需要对每个按钮要实现的具体功能编写程序,由于按钮函数较多,且1——D数字按钮的功能相似,故可以编写函数供每个这样的函数调用,从而避免程序的繁杂冗余。例如对于点击数字键“1”时要实现的功能的函数可以为如下代码:

set(handles.DecodeText,'string',''); %清空解码显示文本框

 Signal = PressKeyDown(handles,'1');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'1');

% Update handles structure

guidata(hObject, handles);

set(handles.CodeText,'string',handles.TelNumber);

当运行程序后点击数字键“1”时,pushbutton1_Callback函数会调用PressKeyDown函数,从而完成发出相应的声音、在text1文本框中显示出点击的数字、在axes1和axes2画出对应的图形等功能。

点击几个数字或字母键后,在界面中运行的结果如图3所示。

 图3 拨号时界面的显示结果

3.在拨号后,要对所接收的拨号信号进行解码检测,检测两个正弦波的频率分别是多少,以判断所对应的十进制数字或字母符号。检测方法有两种,一是用一组滤波器提取所关心的频率,根据两个滤波器的输出信号判断相应的数字或符号,另一是用DFT(FFT)对双音多频信号进行频谱分析,由信号幅度谱判断信号的两个频率,最后确定相应的数字或符号。本设计所编写的相应的解码部分程序代码如下:

function pushbutton17_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton17 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

handles.DecodeTelNumber='';  %清空解码字符串变量,开始新一轮解码。

keys = ['1','2','3','A';'4','5','6','B';'7','8','9','C';'*','0','#','D'];

for i=1 : length(handles.TelNumber)

  Signal = dtmf(handles.TelNumber(i));

  RowNumber = FindLowerFreq(Signal);

  ColumnNumber = FindHigherFreq(Signal);

  ResultKey = keys(RowNumber,ColumnNumber);

  handles.DecodeTelNumber=strcat(handles.DecodeTelNumber,ResultKey);

  set(handles.DecodeText,'string',handles.DecodeTelNumber);

end

handles.TelNumber=''; %解码完成后,拨号变量清空,方便下一次拨号。

点击“解码检测”按钮,进行解码的运行结果如图4所示。

                             图4  解码后的结果

由图4可以看出,在解码的文本框中显示出正确的拨号,表示解码正确。点“退出”键后界面关闭退出。

四、课程设计总结

      经过几天的努力,我终于完成了基于MATLAB的DTMF信号的产生与解码课程设计,由于刚上完数字信号处理这门课程,对相关的知识还是比较熟悉,但是对于数字信号处理的实质的理解还是不够深刻,因此刚开始不知如何下手,觉得困难比较多,不过最后经过多次修改和整理,还是完成了。受到自己知识水平的,此次课程设计还有很多不足的地方。通过这次课程设计,我发现自己以前关于数字信号处理这门课的看法太片面,课程设计不仅仅是对所学知识的一种检验,更是对自己能力的一种提高,这次课程设计使我明白前面所学的那点知识是非常欠缺的,要学的东西还很多。比如在使用MATLAB制作图形界面上,以前上过这个课程,但没有学其中GUI界面设计部分,这就要求我们去自学。

在这次课程设计中,我遇到过很多问题,发现我所学的知识实在有限,好在同学之间可以相互讨论,还可以充分利用网络去查阅相关资料。在整理与修改的过程中,我学到了很多新的知识,也培养了思考和设计的能力,树立了对知识应用的信心,相信会对以后的学习工作都有很大的帮助,并且提高了自己的动手实践能力。

在这次课程设计的过程中,我得到了许多人的帮助,感谢指导老师耐心的讲解,也感谢在一起讨论的同学,从中我得到了很多好的建议和方法。总之,本次课程设计的过程虽然曲折,但是收获还是蛮大的,这不是对知识的终结,而是我学习更多知识的一个平台。

五、参考文献

1.程耕国,信号与系统,北京:机械工业出版社,2009.4

2.高西全、丁玉美,数字信号处理(第三版),西安:西安电子科技大学出版社,2008.8

3.李正周,MATLAB数字信号处理与应用,北京:清华大学出版社,2008

4.徐明远、刘增力,MATLAB仿真在信号处理中的应用,西安:电子科技大学出版社,2007

5.李显宏,MTALAB7.x界面设计与编译技巧,北京:电子工业出版社,2006

六、附录

源程序代码:

function varargout = jink(varargin)

% JINK MATLAB code for jink.fig

%      JINK, by itself, creates a new JINK or raises the existing

%      singleton*.

%

%      H = JINK returns the handle to a new JINK or the handle to

%      the existing singleton*.

%

%      JINK('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in JINK.M with the given input arguments.

%

%      JINK('Property','Value',...) creates a new JINK or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before jink_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to jink_OpeningFcn via varargin.

%

%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one

%      instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

 

% Edit the above text to modify the response to help jink

 

% Last Modified by GUIDE v2.5 01-Jan-2012 13:20:27

 

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @jink_OpeningFcn, ...

                   'gui_OutputFcn',  @jink_OutputFcn, ...

                   'gui_LayoutFcn',  [] , ...

                   'gui_Callback',   []);

if nargin && ischar(varargin{1})

    gui_State.gui_Callback = str2func(varargin{1});

end

 

if nargout

    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

    gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

 

 

% --- Executes just before jink is made visible.

function jink_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% varargin   command line arguments to jink (see VARARGIN)

 

% Choose default command line output for jink

handles.output = hObject;

handles.DTMFSignal = [];

 

handles.TelNumber='';

handles.DecodeTelNumber='';%保存解码字符串 变量

 

set(gcf,'CurrentAxes',handles.axes1);

xlabel('单位:(s)');

 

set(gcf,'CurrentAxes',handles.axes2);

xlabel('单位:(Hz)');

 

% Update handles structure

guidata(hObject, handles);

 

% UIWAIT makes jink wait for user response (see UIRESUME)

% uiwait(handles.figure1);

 

% --- Outputs from this function are returned to the command line.

function varargout = jink_OutputFcn(hObject, eventdata, handles) 

% varargout  cell array for returning output args (see VARARGOUT);

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 

% Get default command line output from handles structure

varargout{1} = handles.output;

 

 

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'1');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'1');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'2');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'2');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'3');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'3');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton4.

function pushbutton4_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton4 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'4');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'4');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton5.

function pushbutton5_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'5');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'5');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton6 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'6');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'6');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton7.

function pushbutton7_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton7 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'7');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'7');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton8.

function pushbutton8_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton8 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'8');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'8');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton9.

function pushbutton9_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton9 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'9');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'9');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton10.

function pushbutton10_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton10 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'*');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'*');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton11.

function pushbutton11_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton11 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'0');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'0');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton12.

function pushbutton12_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton12 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'#');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'#');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton13.

function pushbutton13_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton13 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'A');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'A');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton14.

function pushbutton14_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton14 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'B');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'B');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton15.

function pushbutton15_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton15 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'C');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'C');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton16.

function pushbutton16_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton16 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.DecodeText,'string',''); %清空解码显示文本框

 

Signal = PressKeyDown(handles,'D');

handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'D');

% Update handles structure

guidata(hObject, handles);

 

set(handles.CodeText,'string',handles.TelNumber);

 

% --- Executes on button press in pushbutton17.

function pushbutton17_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton17 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

handles.DecodeTelNumber='';  %清空解码字符串变量,开始新一轮解码。

keys = ['1','2','3','A';'4','5','6','B';'7','8','9','C';'*','0','#','D'];

for i=1 : length(handles.TelNumber)

  Signal = dtmf(handles.TelNumber(i));

  RowNumber = FindLowerFreq(Signal);

  ColumnNumber = FindHigherFreq(Signal);

  ResultKey = keys(RowNumber,ColumnNumber);

  handles.DecodeTelNumber=strcat(handles.DecodeTelNumber,ResultKey);

  set(handles.DecodeText,'string',handles.DecodeTelNumber);

end

handles.TelNumber=''; %解码完成后,拨号变量清空,方便下一次拨号。

 

% Update handles structure

guidata(hObject, handles);

% RowNumber = FindLowerFreq(handles.DTMFSignal);

% ColumnNumber = FindHigherFreq(handles.DTMFSignal);

% ResultKey = keys(RowNumber,ColumnNumber);

% set(handles.DecodeText,'string',char(ResultKey));

 

% PressKeyDown.m

function Signal = PressKeyDown(handles,key)

Signal = dtmf(key);

sound(Signal,8000); % 利用声卡播放拨号音

set(gcf,'CurrentAxes',handles.axes1);

NSignal=length(Signal);

t=1/8000:1/8000:NSignal/8000;

plot(t,Signal);grid;  % 画信号的时域波形

xlabel('单位:(s)');

 

Spectrum = fft(Signal);

Spectrum = fftshift(Spectrum);  % 计算信号的频谱

N = length(Spectrum);    nStep = (2*pi)/(N-1);

w = -pi:nStep:pi;

set(gcf,'CurrentAxes',handles.axes2);

plot(w/(2*pi)*8000,abs(Spectrum));grid; %画信号的频谱图

axis([-2000,2000,0,200]);    xlabel('单位:(Hz)');

 

%dtmf.m

function x = dtmf(key);    

fs = 8000;   N = 0.1 * fs; %信号时间为100ms,N=Tpmin * Fs ;  Tpmin根据频率分辨率得到,DTMF信号的最小频率间隔为73HZ,故至少需要110点

R = 1;    fl = 0;    fh = 0;  n=0:100;

switch key

    case {'1','2','3','A'}         

        fl = 697;

    case {'4','5','6','B'}          

        fl = 770;

    case {'7','8','9','C'}         

        fl = 852;

    case {'*','0','#','D'}          

        fl = 941;

end

switch key

    case {'1','4','7','*'}       

        fh = 1209;

    case {'2','5','8','0'}      

        fh = 1336;

    case {'3','6','9','#'}       

        fh = 1477;

    case {'A','B','C','D'}       

        fh = 1633;   

end

x = wav_gener(R,2*pi*fl/fs,N) + wav_gener(R,2*pi*fh/fs,N);

 

% wav_gener.m

function h = wav_gener(R,omega,N)

% w1 = 0;    w2 = 0;    delta = zeros(1,N);  delta(1) = 1;

% k = R * cos(omega);   h = zeros(1,N);

% for n = 1:N

%     w0 = delta(n) + 2 * k * w1 -R^2 * w2;

%     h(m) = w0 - k * w1;       w2 = w1;       w1 = w0;

% end

h=zeros(1,N);

for m=1:N

   h(m)=R*cos(omega*m); 

end

 

 % FindLowerFreq.m

function number = FindLowerFreq(Signal)    

Freq = [697,770,852,941];    temp = 0;

for n = 1:length(Freq)

    Wo = Freq(n);    B = DesignLowerFilter(Wo);%设计带通滤波器,中心频率分别为697Hz,770Hz,852Hz,941Hz,当n=1时,中心频率为697Hz

    Out = filter(B,1,Signal);%将要解码的某个拨号,比如‘1’所代表的DTMF信号,通过带通滤波器(n=1时,中心频率为697Hz),输出保存在Out中

    Fout = max(abs(fft(Out))) ;    % 计算输出out幅频响应的最大值(n=1时,表示通过中心频率为697Hz的带通滤波器的最大幅频输出值)。

    %循环4次就知道,DTMF信号在经过中心频率分别为697Hz,770Hz,852Hz,941Hz的带通滤波器时,

    %最大幅频值是经过哪个带通滤波器得到的,则DTMF信号的低频值就是哪一个。

    if ( Fout > temp )

        number = n;     temp = Fout;

    end

end

 

% DesignLowerFilter.m

function  B = DesignLowerFilter(Wo)

fs = 8000;    N = 400;    k = 2*pi/fs; Bandwidth = 70;

wc1 = ( Wo - Bandwidth / 2 ) * k;

wc2 = ( Wo + Bandwidth / 2 ) * k;

B = fir2(N,[0,wc1/pi,wc2/pi,1],[0,1,1,0]);

 

% FindHigherFreq.m

function number = FindHigherFreq(Signal)    

Freq = [1209,1336,1447,1633];    temp = 0;

for n = 1:length(Freq)

    Wo = Freq(n);       B = DesignHigherFilter(Wo);

    Out = filter(B,1,Signal);

    Fout = max(abs(fft(Out)));

    if ( Fout > temp )

        number = n;       temp = Fout;

    end

end

 

% DesignHigherFilter.m

function  B = DesignHigherFilter(Wo)

fs = 8000;    N = 200;   k = 2*pi/fs;  Bandwidth = 110;

wc1 = ( Wo - Bandwidth / 2 ) * k;

wc2 = ( Wo + Bandwidth / 2 ) * k;

B = fir2(N,[0,wc1/pi,wc2/pi,1],[0,1,1,0]);

 

% --- Executes on button press in pushbutton18.

function pushbutton18_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton18 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

close(gcf);

文档

DTMF信号的产生与解码

一、课程设计的目的和任务“数字信号处理”课程是信息和通信工程专业必修的专业技术基础课程。课程以信号与系统作为研究对象,研究对信号进行各种处理和利用的技术。通过该课程的学习,学生应牢固掌握确定性信号和系统的分析方法、相关算法、系统实现等的相关知识的,借助于数字滤波器的设计及实现,学生可掌握数字系统的分析以及设计方法。数字信号处理是理论性和工程性都很强的学科,本课程设计的目的就是使该课程的理论与工程应用的紧密结合,使学生深入理解信号处理的内涵和实质。本课程设计要求学生在理解信号处理的数学原理的基础
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top