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