一个one-bit delta-sigma ADC的估计过程
作者:互联网
#include <stdio.h>
int main(void){
int N=1; //N是信号个数,以一个信号为例
double transmitted_signal[N];
double estimated_signal[N];
transmitted_signal[0]=1.678; //要估计的信号值,此处为任意值
for (int i = 0; i < N; i++)
{
ADC(transmitted_signal[i], estimated_signal[i]);
}
}
void ADC(double(transmitted_signal), double(estimated_signal)) {
double Vref = 2.5; //|Vref|>transmitted_signal[0]信号值即可,也为任意值
int adcN = 50; //取样次数
double delta;
double sumOfDelta;
int bitStream[adcN];
double DACoutput = Vref; //+ or -Vref
//对于每一个信号都取adcN次平均值
for (int j = 0; j < adcN; j++)
{
//初始化
bitStream[j]=0;
//comparator(&transmitted_signal, &DACoutput, &delta);
//integrator(&delta, &sumOfDelta);
delta = transmitted_signal - DACoutput;
sumOfDelta += delta;
printf("delta = %f\n", delta);
printf("sumOfDelta = %lf\n", sumOfDelta);
if (sumOfDelta>=0)
{
bitStream[j] = 1;
DACoutput = Vref;
}
else
{
bitStream[j] = 0;
DACoutput = -Vref;
}
printf("%d\n", bitStream[j]);
printf("DACoutput_signal = %lf\n", DACoutput);
estimated_signal += DACoutput;
}
//求平均
estimated_signal /= adcN;
printf("estimated_signal = %lf\n", estimated_signal);
//随着循环次数增加,能输出一个收敛于transmitted_signal[0]的值
}
标签:double,signal,DACoutput,transmitted,ADC,delta,bit,estimated 来源: https://blog.csdn.net/Fky_mie/article/details/115793297