[讨论] 急求:用单片机做fsk的调制和解调

iamstar   2007-7-15 09:34 楼主
如题,那位高手能帮小弟一把,不胜感激~~

回复评论 (1)

回复:急求:用单片机做fsk的调制和解调

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 }
世界是个圈,人生也是个圈。
点赞  2007-7-15 23:35
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复