Forum Discussion
Altera_Forum
Honored Contributor
13 years agoIt looks ok to me.
Can you do describe what wrong is? do you have a model to check against or do you do that manually. above all is your adc data correctly entering the filters. here is a model for running average
%(n) stage running average, implementation model
%delay input n stages,
%subtract last stage from current input
%accumulate result and discard LSBs
clear all;
v = 2^16; %vector length
n = 256; %filter stages
data = round(2^10*randn(1,v));
data2 = data - ;
data3 = cumsum();
result = floor(data3/n);
%test it using direct computation of mean of every n samples
data = ;
avg = zeros(1,v);
for i = 1:v
avg(i) = floor(mean(data(i:i+n-1)));
end
figure;hold;
plot(result);
plot(avg,'r--');
figure; plot(result(1:end-1) - avg);