FSK解码原理及实现方法
1.解码数学原理
条件:
FSK的频率为:1200/2200-->1/0;
wc = 1700,即(1200+2200)/2,设delta = +500/-500;
T是采样周期
则:
1200 可表示为cos((wc-delta)*t);
2200 可表示为cos((wc+delta)*t);
设第n次采样值为cos((wc+/-delta)*(t-T)),第n+1采样值为cos((wc+/-delta)*t).
有:
Value(n)*Value(n+1) =
cos((wc+/-delta)*t)*cos((wc+/-delta)*(t-T))
= [cos((wc+/-delta)*t+(wc+/-delta)*(t-T))+cos((wc+/-delta)*t-(wc+/-delta)*(t-
T))]/2
= [cos(2*(wc+/-delta)*t-(wc+/-delta)*T) + cos((wc+/-delta)*T)]/2
(1)
(H) (L)
将(1)式通过一个低通滤波器,则(1)式的(H)项即2位频率被滤掉,只剩下(L)项:
(1)--->Lowpass filter--->cos((wc+/-delta)*T)
再看:
cos((wc+/-delta)*T) = cos(wc*T+/-delta*T) (2)
IF: wc*T = PI/2
则 cos(wc*T+/-delta*T) = cos(PI/2+/-delta*T)
= -/+sin(delta*T) (3)
(3)式则是FSK的值,
2.滤波器.
对于来电显示,下面这段程序可以达到解码的要求
定义:
#define FSKBUF 4
byte g_cADCResult;//A/D的采样值
int currentx,currenty,lastx,last_sample;
int g_iFSKBuf[FSKBUF];
int g_iFSKAvg;
int g_iFSKBuf1[FSKBUF];
int g_iFSKAvg1;
int g_iFSKBuf2[FSKBUF];
int g_iFSKAvg2;
byte g_cFSKBufPoint;
//在滤波之前将变量初化为0
程序实现:(每次采样要做以下工作,注意采样频率和CID的波特率不是倍数关系
currentx = g_cADCResult;
currenty = last_sample;
last_sample = currentx;
//last sample in currenty,now sample in currenx;
currenty *= currentx;//cos(t)*cos(t-T) = -/+sin(delta*T);
//------avg--lowpass filter;
g_iFSKAvg -= g_iFSKBuf[g_cFSKBufPoint];
g_iFSKBuf[g_cFSKBufPoint] = currenty;
g_iFSKAvg += currenty;
currenty = g_iFSKAvg;
//---------end filter;
g_iFSKAvg1 -= g_iFSKBuf1[g_cFSKBufPoint];
g_iFSKBuf1[g_cFSKBufPoint] = currenty;
g_iFSKAvg1 += currenty;
currenty = g_iFSKAvg1;
//second filter over
g_iFSKAvg2 -= g_iFSKBuf2[g_cFSKBufPoint];
g_iFSKBuf2[g_cFSKBufPoint] = currenty;
g_iFSKAvg2 += currenty;
currenty = g_iFSKAvg2;
//third filter over
g_cFSKBufPoint++;
g_cFSKBufPoint %= FSKBUF;
if(currenty>0)
{
//接收到bit 1
}
else
{
//接收到bit 0
}
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !