专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
TI
matlab生成的滤波器系数怎么样才能在dsp上面用呢?
2019-07-22 15:01
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
TI MCU
11832
11
978
matlab生成的fir滤波器系数,保存之后,要怎么样才能在编写的dsp 滤波器程序中使用啊
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
11条回答
zhangmangui
2019-07-22 15:23
1. 参数计算窗函数选定:阻带衰减75dB,选择blackman窗;截止频率:2pi*(10+(22-10)/2)/50=0.64pi;窗函数长度:blackman窗的过渡带宽为5.98,单位为2pi/N,而要设计的低通滤波器的过度带宽为2pi*12/50=0.48pi,两者相等,得N=24.9,取25。2. 滤波器的脉冲响应理想低通滤波器脉冲响应:h1[n]= sin(nΩ1)/n/pi = sin(0.64pi*n)/n/pi窗函数为:w[n] = 0.42 -0.5cos(2pi*n/24) + 0.8cos(4pi*n/24)则滤波器脉冲响应为:h[n] =h1*w[n] |n|<=12h[n] =0 |n|>123. 滤波器的差分方程根据滤波器的脉冲响应计算出h[n],然后将脉冲响应值移位为因果序列,下面将利用matlab计算h[n]的值,具体如下:>>Window=blackman(25);>>b=fir1(24,0.64,Window);>>freqz(b,1)>>b=roundn(b,-3) %任意位四舍五入b= Columns 1 through 8 0 0 0.0010 -0.0020 -0.0020 0.0100 -0.0090 -0.0180 Columns 9 through 16 0.0490 -0.0200 -0.1100 0.2800 0.6400 0.2800 -0.1100 -0.0200 Columns 17 through 24 0.0490 -0.0180 -0.0090 0.0100 -0.0020 -0.0020 0.0010 0 Column 25 0最后得到滤波器的差分方程为:y[n]= 0.001x[n-2] - 0.002x[n-3] - 0.002x[n-4] + 0.01x[n-5] -0.009x[n-6] - 0.018[n-7] + 0.049x[n-8] -0.02x[n-9] - 0.11x[n-10] + 0.28x[n-11] +0.64x[n-12] + 0.28x[n-13] - 0.11[n-14] - 0.02x[n-15] + 0.049x[n-16] -0.018x[n-17] - 0.009x[n-18] + 0.1x[n-19] - 0.002x[n-20] - 0.002x[n-21] +0.001x[n-22]
#include "fpga_offset_addr.h"
#include <math.h>
#include <csl.h>
#define FIRNUMBER 25
#define SIGNAL1F 1000
#define SIGNAL2F 4500
#define SAMPLEF 10000
#define PI 3.1415926
float InputWave();
float FIR();
void Show_wave1(Uint16 x,Uint16 y);
void Show_wave2(Uint16 x,Uint16 y);
float fHn[FIRNUMBER]={ 0.0,0.0,0.001,-0.002,-0.002,0.01,-0.009,
-0.018,0.049,-0.02,0.11,0.28,0.64,0.28,
-0.11,-0.02,0.049,-0.018,-0.009,0.01,
-0.002,-0.002,0.001,0.0,0.0
};
float fXn[FIRNUMBER]={ 0.0 };
float fInput,fOutput;
float fSignal1,fSignal2;
float fStepSignal1,fStepSignal2;
float f2PI;
int i;
float fIn[256],fOut[256];
int nIn,nOut;
Uint16 show_x1=0,show_x2=0,show_y=0;
Uint16 last_x1=0,now_x1=0;
Uint16 last_x2=0,now_x2=0;
void main()
{
nIn=0; nOut=0;
f2PI=2*PI;
fSignal1=0.0;
fSignal2=PI*0.1;
fStepSignal1=2*PI/30;
fStepSignal2=2*PI*1.4;
Sys_Init();
while ( 1 )
{
fInput=InputWave();
fIn[nIn]=fInput;
nIn++; nIn%=256;
fOutput=FIR();
fOut[nOut]=fOutput;
nOut++; /* break point */
if ( nOut>=256 )
{
nOut=0;
}
show_x1=(Uint16)(240+fInput*50);
show_x2=(Uint16)(80 +fOutput*50);
Show_wave1(show_x1,show_y);
Show_wave2(show_x2,show_y);
if(show_y < 480)
show_y=show_y + 1;
else
{
show_y=0;
Show_Init();
}
ddelay(1);
}
}
float InputWave()
{
for ( i=FIRNUMBER-1;i>0;i-- )
fXn
=fXn[i-1];
fXn[0]=sin((double)fSignal1)+cos((double)fSignal2)/6.0;
fSignal1+=fStepSignal1;
if ( fSignal1>=f2PI ) fSignal1-=f2PI;
fSignal2+=fStepSignal2;
if ( fSignal2>=f2PI ) fSignal2-=f2PI;
return(fXn[0]);
}
float FIR()
{
float fSum;
fSum=0;
for ( i=0;i<FIRNUMBER;i++ )
{
fSum+=(fXn
*fHn
);
}
return(fSum);
}
void Show_wave1(Uint16 x,Uint16 y)
{
Uint8 i = 0;
last_x1 = now_x1;
now_x1 = x;
if(last_x1 < now_x1)
{
for(i=last_x1;i<now_x1;i++)
{
DrawPixel(i, y);
}
}
else
{
for(i=last_x1;i>now_x1;i--)
{
DrawPixel(i, y);
}
}
}
void Show_wave2(Uint16 x,Uint16 y)
{
Uint8 i = 0;
last_x2 = now_x2;
now_x2 = x;
if(last_x2 < now_x2)
{
for(i=last_x2;i<now_x2;i++)
{
DrawPixel(i, y);
}
}
else
{
for(i=last_x2;i>now_x2;i--)
{
DrawPixel(i, y);
}
}
}
举例而已
加载中...
查看其它11个回答
一周热门
更多
>
相关问题
CPLD的方波输出
4 个回答
11个版本Quartus II 软件下载,安装包网盘合集,附教程,47G!
20 个回答
请大家帮忙到21IC发展大家谈支持我申请新版面
20 个回答
【通知】21ic中国电子网服务条款 (所有人员必读)
1 个回答
满载而归乙亥年,大展鸿途庚子年---集签赢好礼
20 个回答
相关文章
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
TI
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
#include "fpga_offset_addr.h"
#include <math.h>
#include <csl.h>
#define FIRNUMBER 25
#define SIGNAL1F 1000
#define SIGNAL2F 4500
#define SAMPLEF 10000
#define PI 3.1415926
float InputWave();
float FIR();
void Show_wave1(Uint16 x,Uint16 y);
void Show_wave2(Uint16 x,Uint16 y);
float fHn[FIRNUMBER]={ 0.0,0.0,0.001,-0.002,-0.002,0.01,-0.009,
-0.018,0.049,-0.02,0.11,0.28,0.64,0.28,
-0.11,-0.02,0.049,-0.018,-0.009,0.01,
-0.002,-0.002,0.001,0.0,0.0
};
float fXn[FIRNUMBER]={ 0.0 };
float fInput,fOutput;
float fSignal1,fSignal2;
float fStepSignal1,fStepSignal2;
float f2PI;
int i;
float fIn[256],fOut[256];
int nIn,nOut;
Uint16 show_x1=0,show_x2=0,show_y=0;
Uint16 last_x1=0,now_x1=0;
Uint16 last_x2=0,now_x2=0;
void main()
{
nIn=0; nOut=0;
f2PI=2*PI;
fSignal1=0.0;
fSignal2=PI*0.1;
fStepSignal1=2*PI/30;
fStepSignal2=2*PI*1.4;
Sys_Init();
while ( 1 )
{
fInput=InputWave();
fIn[nIn]=fInput;
nIn++; nIn%=256;
fOutput=FIR();
fOut[nOut]=fOutput;
nOut++; /* break point */
if ( nOut>=256 )
{
nOut=0;
}
show_x1=(Uint16)(240+fInput*50);
show_x2=(Uint16)(80 +fOutput*50);
Show_wave1(show_x1,show_y);
Show_wave2(show_x2,show_y);
if(show_y < 480)
show_y=show_y + 1;
else
{
show_y=0;
Show_Init();
}
ddelay(1);
}
}
float InputWave()
{
for ( i=FIRNUMBER-1;i>0;i-- )
fXn=fXn[i-1];
fXn[0]=sin((double)fSignal1)+cos((double)fSignal2)/6.0;
fSignal1+=fStepSignal1;
if ( fSignal1>=f2PI ) fSignal1-=f2PI;
fSignal2+=fStepSignal2;
if ( fSignal2>=f2PI ) fSignal2-=f2PI;
return(fXn[0]);
}
float FIR()
{
float fSum;
fSum=0;
for ( i=0;i<FIRNUMBER;i++ )
{
fSum+=(fXn*fHn);
}
return(fSum);
}
void Show_wave1(Uint16 x,Uint16 y)
{
Uint8 i = 0;
last_x1 = now_x1;
now_x1 = x;
if(last_x1 < now_x1)
{
for(i=last_x1;i<now_x1;i++)
{
DrawPixel(i, y);
}
}
else
{
for(i=last_x1;i>now_x1;i--)
{
DrawPixel(i, y);
}
}
}
void Show_wave2(Uint16 x,Uint16 y)
{
Uint8 i = 0;
last_x2 = now_x2;
now_x2 = x;
if(last_x2 < now_x2)
{
for(i=last_x2;i<now_x2;i++)
{
DrawPixel(i, y);
}
}
else
{
for(i=last_x2;i>now_x2;i--)
{
DrawPixel(i, y);
}
}
}
举例而已
一周热门 更多>