C114门户论坛百科APPEN| 举报 切换到宽版

亚星游戏官网

 找回密码
 注册

只需一步,快速开始

短信验证,便捷登录

搜索
查看: 10149|回复: 2

[固网终端] FSK解码原理及实现方法 [复制链接]

军衔等级:

亚星游戏官网-yaxin222  特邀版主

注册:2007-12-4
发表于 2007-12-6 14:13:00 |显示全部楼层
<p>FSK解码原理及实现方法</p><p>1.解码数学原理<br/>条件:<br/>&nbsp;&nbsp;&nbsp; FSK的频率为:1200/2200--&gt;1/0;<br/>&nbsp;&nbsp;&nbsp; wc = 1700,即(1200+2200)/2,设delta = +500/-500;<br/>&nbsp;&nbsp;&nbsp; T是采样周期<br/>&nbsp;&nbsp;&nbsp; 则:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1200 可表示为cos((wc-delta)*t);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2200 可表示为cos((wc+delta)*t);<br/>设第n次采样值为cos((wc+/-delta)*(t-T)),第n+1采样值为cos((wc+/-delta)*t).<br/>有:<br/>Value(n)*Value(n+1) =<br/>cos((wc+/-delta)*t)*cos((wc+/-delta)*(t-T))&nbsp; <br/>= [cos((wc+/-delta)*t+(wc+/-delta)*(t-T))+cos((wc+/-delta)*t-(wc+/-delta)*(t-<br/>T))]/2<br/>= [cos(2*(wc+/-delta)*t-(wc+/-delta)*T) + cos((wc+/-delta)*T)]/2&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (H)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (L)<br/>将(1)式通过一个低通滤波器,则(1)式的(H)项即2位频率被滤掉,只剩下(L)项:<br/>(1)---&gt;Lowpass filter---&gt;cos((wc+/-delta)*T)<br/>再看:<br/>&nbsp;&nbsp;&nbsp; cos((wc+/-delta)*T) = cos(wc*T+/-delta*T)&nbsp;&nbsp;&nbsp; (2)<br/>&nbsp;&nbsp;&nbsp; IF:&nbsp;&nbsp;&nbsp; wc*T = PI/2&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; 则 cos(wc*T+/-delta*T) = cos(PI/2+/-delta*T)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = -/+sin(delta*T)&nbsp;&nbsp;&nbsp; (3)<br/>(3)式则是FSK的值,<br/>2.滤波器.<br/>&nbsp;&nbsp;&nbsp; 对于来电显示,下面这段程序可以达到解码的要求<br/>&nbsp;&nbsp;&nbsp; 定义:<br/>&nbsp;&nbsp;&nbsp; #define&nbsp;&nbsp;&nbsp; FSKBUF 4<br/>&nbsp;&nbsp;&nbsp; byte&nbsp;&nbsp;&nbsp; g_cADCResult;//A/D的采样值<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; currentx,currenty,lastx,last_sample;<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; g_iFSKBuf[FSKBUF];<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; g_iFSKAvg;<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; g_iFSKBuf1[FSKBUF];<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; g_iFSKAvg1;<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; g_iFSKBuf2[FSKBUF];<br/>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; g_iFSKAvg2;<br/>&nbsp;&nbsp;&nbsp; byte&nbsp;&nbsp;&nbsp; g_cFSKBufPoint;<br/>&nbsp;&nbsp;&nbsp; //在滤波之前将变量初化为0<br/>&nbsp;&nbsp;&nbsp; 程序实现亚星游戏官网-yaxin222每次采样要做以下工作,注意采样频率和CID的波特率不是倍数关系<br/>&nbsp;&nbsp;&nbsp; currentx = g_cADCResult;<br/>&nbsp;&nbsp;&nbsp; currenty = last_sample;<br/>&nbsp;&nbsp;&nbsp; last_sample = currentx;<br/>&nbsp;&nbsp;&nbsp; //last sample in currenty,now sample in currenx;<br/>&nbsp;&nbsp;&nbsp; currenty&nbsp; *= currentx;//cos(t)*cos(t-T) = -/+sin(delta*T);<br/>&nbsp;&nbsp;&nbsp; //------avg--lowpass filter;<br/>&nbsp;&nbsp;&nbsp; g_iFSKAvg -= g_iFSKBuf[g_cFSKBufPoint];<br/>&nbsp;&nbsp;&nbsp; g_iFSKBuf[g_cFSKBufPoint] = currenty;<br/>&nbsp;&nbsp;&nbsp; g_iFSKAvg += currenty;<br/>&nbsp;&nbsp;&nbsp; currenty = g_iFSKAvg;<br/>&nbsp;&nbsp;&nbsp; //---------end filter;<br/>&nbsp;&nbsp;&nbsp; g_iFSKAvg1 -= g_iFSKBuf1[g_cFSKBufPoint];<br/>&nbsp;&nbsp;&nbsp; g_iFSKBuf1[g_cFSKBufPoint] = currenty;<br/>&nbsp;&nbsp;&nbsp; g_iFSKAvg1 += currenty;<br/>&nbsp;&nbsp;&nbsp; currenty = g_iFSKAvg1;<br/>&nbsp;&nbsp;&nbsp; //second filter over<br/>&nbsp;&nbsp;&nbsp; g_iFSKAvg2 -= g_iFSKBuf2[g_cFSKBufPoint];<br/>&nbsp;&nbsp;&nbsp; g_iFSKBuf2[g_cFSKBufPoint] = currenty;<br/>&nbsp;&nbsp;&nbsp; g_iFSKAvg2 += currenty;<br/>&nbsp;&nbsp;&nbsp; currenty = g_iFSKAvg2;<br/>&nbsp;&nbsp;&nbsp; //third filter over<br/>&nbsp;&nbsp;&nbsp; g_cFSKBufPoint++;<br/>&nbsp;&nbsp;&nbsp; g_cFSKBufPoint %= FSKBUF;<br/>&nbsp;&nbsp;&nbsp; if(currenty&gt;0)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //接收到bit 1<br/>&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp; else<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //接收到bit 0<br/>&nbsp;&nbsp;&nbsp; } <br/></p>
[此贴子已经被编辑于2007-12-7 18:48:50编辑过]

举报本楼

本帖有 2 个回帖,您需要登录后才能浏览 登录 | 注册
您需要登录后才可以回帖 登录 | 注册 |

手机版|C114 ( 沪ICP备12002291号-1 )|联系大家 |网站地图  

GMT+8, 2024-11-26 11:59 , Processed in 0.145550 second(s), 15 queries , Gzip On.

Copyright © 1999-2023 C114 All Rights Reserved

Discuz Licensed

回顶部
XML 地图 | Sitemap 地图