From: baobrien Date: Wed, 11 Mar 2015 22:06:01 +0000 (+0000) Subject: reverting changes to iir_duc.m X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=cd5106706cbe4bc3298c73088e05bef417f58a38;p=freetel-svn-tracking.git reverting changes to iir_duc.m git-svn-id: https://svn.code.sf.net/p/freetel/code@2068 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/dacres.m b/codec2-dev/octave/dacres.m index 34f7ee9d..a57ea309 100644 --- a/codec2-dev/octave/dacres.m +++ b/codec2-dev/octave/dacres.m @@ -19,17 +19,15 @@ pcicfb = fir1(20,.5); %Interpolation LPF Fir s1fir = filter(ciccb,1,pcicfb); %Combine compensation and LPF t = (1:fs/2); -scpin = .1*sin(t*pi*2*(3000/8000))*i; % initial complex input +scpin = e.^(i*(t*pi*2*(3000/8000))); % initial complex input scpin(1) = 1+i; intstage1 = zeros(1,2*length(scpin)); %First stage of interpolation, 2x intstage1(1:2:2*length(scpin))=scpin; -%scpin = filter(s1fir,1,scpin); scireal = int32(filter(s1fir,1,real(intstage1))*csf); %separate input into real and imiginary and apply pre-distortion sciimag = int32(filter(s1fir,1,imag(intstage1))*csf); % also convert to integer. CIC integrator needs integer to work properly - %Apply 3 stage comb to real fdin = scireal; combout1=0; @@ -74,6 +72,7 @@ end scoreal=single(fdnext/(2**20)); fdin=sciimag; + %Apply 3 stage comb to imag combout1=0; combout2=0; @@ -134,6 +133,10 @@ sducinterp = zeros(1,length(sduceq)*M); %interpolate by zero-stuffing sducinterp(1:M:length(sduceq)*M) = sduceq; sdac = filter(1,[1 b1x beta1],sducinterp); %select wanted signal +sdac = sdac + median(sdac); %Center above zero +sdac = sdac / max(sdac); %normalize +sdac = int32(sdac*2000); %integerize + figure(1) subplot(211) plot(20*log10(abs(fft(sducin)/fi))) diff --git a/codec2-dev/stm32/src/iir_duc.c b/codec2-dev/stm32/src/iir_duc.c index 4c69d0dc..25f3944a 100644 --- a/codec2-dev/stm32/src/iir_duc.c +++ b/codec2-dev/stm32/src/iir_duc.c @@ -47,7 +47,7 @@ //IIR and FIR filter states. Global for go fast. float f_1,f_2,f; -int n1_1,n1_2,n1,n2_1,n2_2,n2; +int n_1,n_2,n; /* Upconvert and bandpass filter a chunk of spectrum from Fs/M to Fs. We're going for 700khz here. @@ -64,23 +64,17 @@ void iir_upconv(float modin[], unsigned short dac_out[]){ f_2 = f_1; f_1 = modin[i]; //Scale fir output and convert to fixed. m = (int)((f/(IN_SCALE))*DAC_SCALE_2); //Scale fir output and convert to fixed - n1 = m + ((B1SMUL*n1_1)>>B1SHFT) - ((B1MUL*n1_2)>>B1SHFT); //Apply one cycle of IIR. This feeds the fir-ed sample into the output filter - n1_2 = n1_1; - n1_1 = n1; - n2 = n1 + ((B1SMUL*n2_1)>>B1SHFT) - ((B1MUL*n2_2)>>B1SHFT); - n2_2 = n2_1; - n2_1 = n2; - dac_out[k]=(unsigned short)(n2+DAC_SCALE_2); + n = m + ((B1SMUL*n_1)>>B1SHFT) - ((B1MUL*n_2)>>B1SHFT); //Apply one cycle of IIR. This feeds the fir-ed sample into the output filter + n_2 = n_1; + n_1 = n; + dac_out[k]=(unsigned short)(n+DAC_SCALE_2); k++; //now do the rest of the filtering. Because we're zero-stuffing we can neglect the sample from the fir filter. for(j=1;j>B1SHFT) - ((B1MUL*n_2)>>B1SHFT); n_2 = n_1; n_1 = n; - n2 = n1 + ((B1SMUL*n2_1)>>B1SHFT) - ((B1MUL*n2_2)>>B1SHFT); - n2_2 = n2_1; - n2_1 = n2; - dac_out[k]=(unsigned short)((n2)+DAC_SCALE_2); + dac_out[k]=(unsigned short)((n)+DAC_SCALE_2); } } }