前面有做过ADC性能测试,测试方式是先使用ADC采集一个单频信号,然后利用matlab进行性能分析。

下面把matlab分析的代码记录下来:

 %The following program code plots the FFT spectrum of a desired test tone. Test tone based on coherent sampling criteria, and
%computes SNR, SINAD, THD and SFDR.
%This program is believed to be accurate and reliable. This program may get altered without prior notification.; %fid=fopen('F:\pelican_ADC_test\vjtag_prj\data_analysis\single_tone.txt','r');
%numpt=input('Number of Points in FFT? ');
%fclk=input('Sampling Frequency (MHz)? ');
%numbit=input('ADC Resolution (bits)? ');
close all;
clear all; numpt=;
fclk=/;
% fclk=//;
numbit=; % a=textread('dds_data_out.txt','%s')';%以字符形式打开文件
% a=dlmread('sample_data.txt','%s')';%以字符形式打开文件
a=dlmread('sample_data.txt','%s')';%以字符形式打开文件
v1=a'; %16进制转化为10进制数,存储进v1矩阵
% for i = :numpt
% v1(i) = bitxor(v1(i),);
% end %v1 is a column vector(:numpt), and count is its length
%v1=dlmread('F:\pelican_ADC_test\vjtag_prj\data_analysis\single_tone.txt','');
%fclose(fid);
%change v1 into a row vector
code=v1'; %Warning: ADC output may be clipping - reduce input amplitude
if (max(code)==2^numbit-1) | (min(code)==0)
disp('WARNING: ADC OUTPUT MAYBE CLIPPING - CHECK INPUT AMPLITUDE!');
end figure;
plot(code);
title('TIME DOMAIN')
xlabel('SAMPLES');
ylabel('DIGITAL OUTPUT CODE');
Dout=code-(2^numbit-1)/2; %Re-center the digitized sinusoidal input
Voltage=Dout./((2^numbit-1)/2)*(0.5);
figure;
plot([1:numpt],Voltage); Doutw=(Dout').*blackmanharris(numpt); %add Minimum -term Blackman-Harris window
Dout_spect=fft(Doutw);
Dout_dB=*log10(abs(Dout_spect)); figure;
maxdB=max(Dout_dB(:numpt/)); %numpt points FFT result in numpt/ points spectrum %计算距离满量程的幅度差
max_voltage=max(Voltage);
delta_amplitude=*log10(max_voltage/0.5); %full scale voltage amplitude is .5v plot([:numpt/-].*fclk/numpt,Dout_dB(:numpt/)-maxdB+delta_amplitude);
grid on;
title('SINGLE TONE FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY (MHz)');
ylabel('AMPLITUDE (dBfs)');
a1=axis; axis([a1() a1() - a1()]);
fin=find(Dout_dB(:numpt/)==maxdB); %Find the signal bin (DC represents bin=)
DC_span=; %default DC leakage bins are bins
signal_span = ; %signal leakage bins are ± bins for minumun -term black-harris window
spanh=; %%default harmonic leakage bins are ± bins
spectP=(abs(Dout_spect)).*(abs(Dout_spect));
%Determine power level
Pdc=sum(spectP(:DC_span)); %Determine DC offset power level
Ps=sum(spectP(fin-signal_span:fin+signal_span)); %Determine signal power level
Fh=[];
%Vector storing frequency and power components of signal and harmonics
Ph=[]; %HD1=signal, HD2=2nd harmonic, HD3=3rd harmonic, etc. %Find the harmonic frequencies/power within the FFT plot
for har_num=:
tone=rem((har_num*(fin- )+)/numpt,); %Note: tones > fSAMPLE are aliased back
if tone>0.5
tone=-tone;
end
Fh=[Fh tone]; %For this method to work properly, make sure that the folded back high order harmonics do not overlap with DC and signal
%components or lower order harmonics.
har_peak=max(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh));
har_bin=find(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh)==har_peak);
har_bin=har_bin+round(tone*numpt)-spanh- ; %make sure that the folded back high order harmonics do not overlap with DC and signal components or lower order harmonics
Ph=[Ph sum(spectP(har_bin-:har_bin+))];
end Pd=sum(Ph(:)); %Total distortion power level
Pn=sum(spectP(:numpt/))-Pdc-Ps-Pd; %Extract noise power level
format;
A=(max(code)-min(code))/(^numbit) %Analog input amplitude in mV
AdB=*log10(A) %Analog input amplitude in dB
SNR=*log10(Ps/Pn) %SNR in dB
SINAD=*log10(Ps/(Pn+Pd)) %SINAD in dB
disp('THD - HD2 through HD9');
THD=*log10(Pd/Ph()) %THD in dB
SFDR=*log10(Ph()/max(Ph(:))) %SFDR in dB
disp('SIGNAL AND HARMONIC POWER (dB)');
HD=*log10(Ph(:)/Ph()) hold on;
plot(Fh()*fclk,-,'bo',Fh()*fclk,-,'bx',Fh()*fclk,-,'b+',Fh()*fclk,-,'b*',Fh()*fclk,-,'bs',Fh()*fclk,-,'bd',Fh()*fclk,-,'bv',Fh()*fclk,-,'b^');
legend('SIGNAL','HD2','HD3','HD4','HD5','HD6','HD7','HD8','HD9');
hold off;

输出结果

 A =

     0.5432

 AdB =

    -5.3006

 SNR =

    54.0005

 SINAD =

    53.4240

 THD - HD2 through HD9

 THD =

   -62.4784

 SFDR =

    63.0618

 SIGNAL AND HARMONIC POWER (dB)

 HD =

            -63.0618  -78.1190  -79.6691  -82.4058  -86.1153  -90.7795  -91.1868  -89.8460  -74.6853

会标记出谐波的位置。

ADC测试matlab代码的更多相关文章

  1. 如何加速MATLAB代码运行

    学习笔记 V1.0 2015/4/17 如何加速MATLAB代码运行 概述 本文源于LDPCC的MATLAB代码,即<CCSDS标准的LDPC编译码仿真>.由于代码的问题,在信息位长度很长 ...

  2. SVM实例及Matlab代码

    ******************************************************** ***数据集下载地址 :http://pan.baidu.com/s/1geb8CQf ...

  3. 数据分析处理之PCA OLSR PCR PLSR(NIPALS)及其Matlab代码实现

    传统的OLS(普通最小二乘)方法无法解决样本数据的共线性(multicollinearity)问题,如果你的数据样本中每个特征变量具有共线性,那么使用基于PCA的PCR和PLSR方法对数据样本进行回归 ...

  4. 测试C++代码与WebBrowser HTML的互动

    testWebBrowserDlg.h // testWebBrowserDlg.h : 头文件 // #pragma once #include "explorer1.h" #i ...

  5. 多分类问题中,实现不同分类区域颜色填充的MATLAB代码(demo:Random Forest)

    之前建立了一个SVM-based Ordinal regression模型,一种特殊的多分类模型,就想通过可视化的方式展示模型分类的效果,对各个分类区域用不同颜色表示.可是,也看了很多代码,但基本都是 ...

  6. 卷积相关公式的matlab代码

    取半径=3 用matlab代码实现上式公式: length=3;for Ki = 1:length for Kj = 1:length for Kk = 1:length Ksigma(Ki,Kj,K ...

  7. 使用JUnit测试java代码

    Junit 单元测试实验报告  一.实验环境 MyEclipse2014.Junit4.10 二.实验目的 学会单元测试,在MyEclipse中进行Junit测试 三.实验步骤 1.写出要测试的类 代 ...

  8. JAVA调用matlab代码

    做实验一直用的matlab代码,需要嵌入到java项目中,matlab代码拼拼凑凑不是很了解,投机取巧采用java调用matlab的方式解决. 1.    matlab版本:matlabR2014a ...

  9. 前端测试框架Jest系列教程 -- Asynchronous(测试异步代码)

    写在前面: 在JavaScript代码中,异步运行是很常见的.当你有异步运行的代码时,Jest需要知道它测试的代码何时完成,然后才能继续进行另一个测试.Jest提供了几种方法来处理这个问题. 测试异步 ...

随机推荐

  1. 布隆过滤器的概述及Python实现

    布隆过滤器 布隆过滤器是一种概率空间高效的数据结构.它与hashmap非常相似,用于检索一个元素是否在一个集合中.它在检索元素是否存在时,能很好地取舍空间使用率与误报比例.正是由于这个特性,它被称作概 ...

  2. Socket实现粗略的Android聊天功能

    面试时写过,但是很乱,今天看到代码库里有一个,还是很规范的,贴出来. 主要用到俩类,一个是ServerSocket.class 一个是Socket.class. 记得要加权限:  <uses-p ...

  3. HTML meta 标签用法(转)

    meta主要为分HTTP标头信息(HTTP-EQUIV)和页面描述信息(NAME).标头信息包括文档类型.字符集.语言等浏览器正确显示网页的信息及处理动作:网页描述如内容的关键字.摘要.作者和定义ro ...

  4. kernel/dma.c

    /* $Id: dma.c,v 1.5 1992/11/18 02:49:05 root Exp root $ * linux/kernel/dma.c: A DMA channel allocato ...

  5. 简谈ashx

    是一般处理程序, 是asp.net web 组件的一种,ashx是其扩展名. 实现IHttpHandler接口,接收并处理http请求.这个接口有一个IsReusable成员,一个待实现的方法Proc ...

  6. Codeforces Round #379 (Div. 2) F. Anton and School

    题意: 给你n对 b[i], c[i], 让你求a[i],不存在输出-1 b[i] = (a[i] and a[1]) + (a[i] and a[2]) + (a[i] and a[3]) +... ...

  7. 初识linux端c++程序开发

    关于linux端程序开发,我以前一直不知道是做些什么,只是感觉听高端的.最近接触了一些,有了一些初步的认识. 首先,linux是一个操作系统,跟windows一样:接通电源.按下电脑开机,电脑就会自动 ...

  8. Saddest's polar bear Pizza offered new YorkShire home

    Saddest:adj,可悲的,悲哀的,polar,两级的,极地额,YorkShire,约克郡 A UK wildlife park has confirmed that it is offering ...

  9. python——socket网络编程

    一.OSI七层模型

  10. Unity3D入门

    Unity3D是一款应用广泛的3D游戏引擎,本文主要介绍unity3D的简单应用,安装过程略过. 在游戏的整个开发过程中,游戏界面设计占据非常重要的地位.因为游戏启动后,第一个映入眼帘的就是整个游戏U ...