Hi, I have written a matlab code for downconverter. I have tried like this. fftsize = 1024; fi = 83; % input frequency fs = 200; % sampling frequency flo = 50; % local oscillator frequency order = 15; df = 5; % filter cutoff frequency dfactor = fs / (2 * df); % decimation factor siglen = dfactor * fftsize; sequence = 0 : (siglen - 1); X = sin(2 * pi * sequence * fi / fs); cosine = cos(2 * pi * sequence * flo / fs); sine = sin(2 * pi * sequence * flo / fs); Xc = X .* cosine; Xs = X .* sine; b = fir1(order - 1, (2 * df / fs),'low', hann(order)); Xi = filter(b, 1, Xc); Xq = filter(b, 1, Xs); I = downsample(Xi, dfactor); Q = downsample(Xq, dfactor); Z = complex(I, (-1 * Q)); Y = fft(Z, fftsize) / fftsize; f = 2 * df * linspace(0, 1, fftsize); plot(f, 2 * abs(Y(1: fftsize))) title('Amplitude Spectrum of y(t)') xlabel('Frequency (Hz)') ylabel('|Y(f)|') I observe some spurious signal in the output for any local oscillator frequecny and LPF frequecy. What am I doing wrong? Thanks... _____________________________ Posted through www.DSPRelated.com
Spurious signals in downconverter
Started by ●April 2, 2015
Reply by ●April 2, 20152015-04-02
>Hi, > >I have written a matlab code for downconverter. >I have tried like this. > >fftsize = 1024; >fi = 83; % input frequency >fs = 200; % sampling frequency >flo = 50; % local oscillator frequency >order = 15; >df = 5; % filter cutoff frequency >dfactor = fs / (2 * df); % decimation factor >siglen = dfactor * fftsize; > >sequence = 0 : (siglen - 1); >X = sin(2 * pi * sequence * fi / fs); >cosine = cos(2 * pi * sequence * flo / fs); >sine = sin(2 * pi * sequence * flo / fs); >Xc = X .* cosine; >Xs = X .* sine; > >b = fir1(order - 1, (2 * df / fs),'low', hann(order)); >Xi = filter(b, 1, Xc); >Xq = filter(b, 1, Xs); > >I = downsample(Xi, dfactor); >Q = downsample(Xq, dfactor); > >Z = complex(I, (-1 * Q)); >Y = fft(Z, fftsize) / fftsize; > >f = 2 * df * linspace(0, 1, fftsize); >plot(f, 2 * abs(Y(1: fftsize))) >title('Amplitude Spectrum of y(t)') >xlabel('Frequency (Hz)') >ylabel('|Y(f)|') > >I observe some spurious signal in the output for any local oscillator >frequecny and LPF frequecy. What am I doing wrong? > >Thanks... > > > >_____________________________ >Posted through www.DSPRelated.comyour signal @ +/- 83 single tone your osc @ +50 sin/cos so you get tone @ 33 and 67(200 - sum) so your filter is just cutting them off Kaz --------------------------------------- Posted through http://www.DSPRelated.com
Reply by ●April 2, 20152015-04-02
Kanchan, After the multiplication by sine and cosine you have _two_ replicas of the input signal, and so you may want to suppress one of those with a low-pass filter. To do that, it's essential that you (1) understand what much of a passband do you need and what level of attenuation in the stopband do you want, (2) design a low-pass filter with the desired parameters (note that for greater stopband attenuation you may need to increase the filter order), (3) display the output of your simulations in dB, rather than linear units, so that you can compare what you've got with what you've originally planned for. In your example, both replicas of the input signal are in the stopband/transition band of the low-pass filter, so you see one replica killed by your filter and the other replica not entirely killed. Hope that helps. Regards, Evgeny. On 02.04.2015 15:42, Kanchan Salvekar wrote:> Hi, > > I have written a matlab code for downconverter. > I have tried like this. > > fftsize = 1024; > fi = 83; % input frequency > fs = 200; % sampling frequency > flo = 50; % local oscillator frequency > order = 15; > df = 5; % filter cutoff frequency > dfactor = fs / (2 * df); % decimation factor > siglen = dfactor * fftsize; > > sequence = 0 : (siglen - 1); > X = sin(2 * pi * sequence * fi / fs); > cosine = cos(2 * pi * sequence * flo / fs); > sine = sin(2 * pi * sequence * flo / fs); > Xc = X .* cosine; > Xs = X .* sine; > > b = fir1(order - 1, (2 * df / fs),'low', hann(order)); > Xi = filter(b, 1, Xc); > Xq = filter(b, 1, Xs); > > I = downsample(Xi, dfactor); > Q = downsample(Xq, dfactor); > > Z = complex(I, (-1 * Q)); > Y = fft(Z, fftsize) / fftsize; > > f = 2 * df * linspace(0, 1, fftsize); > plot(f, 2 * abs(Y(1: fftsize))) > title('Amplitude Spectrum of y(t)') > xlabel('Frequency (Hz)') > ylabel('|Y(f)|') > > I observe some spurious signal in the output for any local oscillator > frequecny and LPF frequecy. What am I doing wrong? > > Thanks... > > > > _____________________________ > Posted through www.DSPRelated.com >
Reply by ●April 2, 20152015-04-02
and you are decimating down to 10 (from 200), why?? kaz --------------------------------------- Posted through http://www.DSPRelated.com