在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 5486|回复: 4

帮忙分析下MATLAB对ADC的FFT分析的程序

[复制链接]
发表于 2013-10-22 12:29:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
format long g;
clc;
SampleNumber=2^10;
SampleFrequency=100e6;
SingleFrequency=6.5e6;%6.5e6;
vi=load('.\data.txt');
Vin=reshape(vi,'',1)';%'
Vin=Vin-(max(Vin(70:end))+min(Vin(70:end)))/2;
figure(1);
hold on;
plot(Vin(70:SampleNumber+69));
numpt2=fix(SampleNumber/2);
Dout=Vin(70:SampleNumber+69);
Window=kaiser(SampleNumber,10)';%'
span=5;
Doutw=Dout.*Window;
DoutFFT=fft(Doutw,SampleNumber);
SumPower=(abs(DoutFFT)).*(abs(DoutFFT));
SumPower_dB=10*log10(SumPower);
[MaxdB,SingleFrequencyPoint]=max(SumPower_dB(1:numpt2));
spanh=3;
DcPower=sum(SumPower(1:span));
if SingleFrequencyPoint>span
    SinglePower=sum(SumPower(SingleFrequencyPoint-span:SingleFrequencyPoint+span));
else
    SinglePower=0;
end
SingleHarmonyNumber2=floor(SampleNumber/SingleFrequencyPoint);%或者为SampleFrequency/(SingleFrequency)
SingleHarmonyPower=zeros(SingleHarmonyNumber2);
SingleHarmonyPower(1)=SinglePower;
SingleHarmonyFrequency=zeros(SingleHarmonyNumber2);
SingleHarmonyFrequency(1)=SampleFrequency*(SingleFrequencyPoint)/SampleNumber;
SingleHarmonyStep=SingleFrequencyPoint;
for SingleHarmonyNumber=1:SingleHarmonyNumber2/2;
    if (SingleHarmonyStep<=0) break; end
    HarmonyFrequencyPoint=SingleHarmonyStep*SingleHarmonyNumber+SingleFrequencyPoint
    if (HarmonyFrequencyPoint<=numpt2)
        if SingleHarmonyNumber==1;
            BaseHarmonyFrequencyPoint=HarmonyFrequencyPoint;
        end
        SingleHarmonyPower(SingleHarmonyNumber+1)=sum(SumPower(HarmonyFrequencyPoint-spanh:HarmonyFrequencyPoint+spanh));
        SingleHarmonyFrequency(SingleHarmonyNumber+1)=(HarmonyFrequencyPoint)*SampleFrequency/SampleNumber;
    end
end
SingleFrequency=SingleHarmonyFrequency(1);
HarmonyPowerNumber=floor(SampleNumber/SingleFrequencyPoint)/2;%或者为SampleFrequency/(SingleFrequency)/2
HarmonyPower=sum(SingleHarmonyPower(1:HarmonyPowerNumber))-SingleHarmonyPower(1);
NoisePower=sum(SumPower(1:numpt2))-DcPower-SinglePower;
ss=sqrt((sum(Dout.^2)/sum(Doutw.^2))*NoisePower*2)/SampleNumber%*sqrt(12)
HarmonyRange=floor(SampleNumber/SingleFrequencyPoint)/2;%或者为SampleFrequency/(SingleFrequency)/2
SNDR=10*log10(SinglePower/NoisePower);
THD=10*log10(HarmonyPower/SingleHarmonyPower(1))
SFDR=10*log10(SingleHarmonyPower(1)/max(SingleHarmonyPower(2:HarmonyRange)));
ENOBloc=(SNDR-1.76)/6.02;
figure(2);
hold on;
semilogx([0:numpt2-1]*SampleFrequency/SampleNumber,SumPower_dB(1:numpt2),'-r');
text_handle = text(floor(SampleFrequency/3),10, sprintf('SNDR = %4.1f dB \nENOB = %2.2f bits ',SNDR,ENOBloc), ...
    'EdgeColor','red','LineWidth',3,'BackgroundColor',[1 1 1],'Margin',10);
title('FREQ DOMAIN');
xlabel('ADC FFT SPECTRUM');
ylabel('AMPLITUDE(dB)');
我论坛上下了段程序,但是看不懂,我的ADC是12位,100M采样速率,输入信号6.5M,有65个周期,我自己改了几个参数,但出来的结果不对,帮忙看看啊 QQ截图20131022122741.png 尤其是有效位数竟然有12.58
发表于 2013-10-30 19:30:12 | 显示全部楼层
请问你是用直方图测试方法获取数据的吗,你知道测DNL的程序含义不,我现在这个出问题了。
发表于 2014-6-28 15:39:19 | 显示全部楼层
any one can modify it ?!
发表于 2018-5-7 14:25:07 | 显示全部楼层
这里的SingleFrequency指的是什么啊
发表于 2018-8-31 10:17:17 | 显示全部楼层
回复 4# lonsir


    不是输入信号的频率吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条


小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-15 04:05 , Processed in 0.035432 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表