0
$\begingroup$

Image and MATLAB code are below.

I am doing Complex Down Conversion (IQ Sampling) to 0 Hz and using a Low Pass Filter after it to remove an unwanted conversion product.

I start with 500-1000Hz Bandwidth signal its made from cosine waves. Its split, and both signals are multiplied by an LO of 750Hz, each LO is 90 degrees offset (one is multiplied by cosine750Hz and the other sine750Hz). This gives me two products on both signals, one at -250 to 250 (the one I want) and 1250 to 1750. I then use a Low Pass Filter (LPF) to remove the upper product on both signals. I then treat these signals as a complex signal.

When I implement my LPF via multiplication of the signals in the frequency domain I get a different spectrum compared to applying LPF in time domain via convolution. My LPF is constructed from a sinc and blackman window.

I have been staring at this for well over an hour, can anyone describe what I am seeing? Which one is right?!?

enter image description here

figure(1);cla;clf
%% Low Pass Filter
%This is a blackman window sinc LPF
K = 1; cutoff = 11; Fs=5000;
fc = 500 / Fs %Cutoff frequency of X Hz, Always fraction of Fs
b = 50/Fs ;%Transition bandwidth of X Hz, Always fraction of Fs
%M = 51 ; %Length of Filter
M = round(4/b)+1 %Length of filter based on selection of transition bandwidth
n = 0:1:M-1;

blackman_window = 0.42 - 0.50 * cos((2*pi*n)/(M-1)) + 0.08*cos( (4*pi*n) / (M-1));
blackman_window_ft = fftshift(fft(blackman_window,1024)/M); %Zero padded for higher resolution to show lobe roll off

sinc_func = sin(2*pi*fc.*(n-((M-1)/2))) ./ (2*pi*fc.* (n-((M-1)/2)));
sinc_func((M+1)/2) = 1 ;
sinc_func_ft = fftshift(fft(sinc_func,1024)/M);  %Zero padded for higher resolution to show lobe roll off

h_lpf = sinc_func .* blackman_window; %select your filter window
h_lpf = h_lpf ./ sum(h_lpf);
H_lpf = fft(h_lpf,Fs); %Make it the length of Ns (works if resolution is =1 in signal)
H_lpf = fftshift(H_lpf);

Ns=length(H_lpf);
fshift = (-Ns/2:Ns/2-1)*(Fs/Ns);

subplot(4,1,1);hold on;
plot(h_lpf);
title('Low Pass Filter Impulse Response');hold off;

subplot(4,1,2);
plot(fshift,20*log10(abs(H_lpf)));
title('Low Pass Filter Frequency Response (dB)');
ylim([-200 0])
xlabel('Frequency');ylabel('PSD');
%% Time Domain Signal
%Fs =(2^10)  
Ts = 1/Fs; 
freq_resolution = 1 
Ns = Fs/freq_resolution
n = (0:1:Ns-1)*Ts; 
fshift = (-Ns/2:Ns/2-1)*(Fs/Ns);

f=[500:1:1000];
for a=1:length(f)
    signal(a,:) =  cos(2*pi*f(a).*n ) ; ;
end
signal = sum(signal);

%% Complex Down Conversion to 0 Hz
%Two Streams of data, In-Phase and Quadrature
LO = 750
signal_cosine =sqrt(2)* signal .* cos(2*pi*LO.*n); 
signal_sine   =sqrt(2)* signal .* sin(2*pi*LO.*n);

%% Low Pass Filter via Frequency Multiplication
ft_signal_cosine = fft(signal_cosine)/Ns;
ft_signal_cosine = fftshift(ft_signal_cosine);

ft_signal_sine = fft(signal_sine)/Ns;
ft_signal_sine = fftshift(ft_signal_sine);

ft_signal_cosine = ft_signal_cosine .* H_lpf ;
ft_signal_sine = ft_signal_sine .* H_lpf ;

ft_signal_complex = ft_signal_cosine - i*ft_signal_sine;

subplot(4,1,3);
plot(fshift,20*log10(abs(ft_signal_complex)))
title('Complex Down Conversion with LPF via Frequency Multiplication');
ylim([-500 0])
xlabel('Frequency');ylabel('PSD');
%% Low Pass Filter via Time Convolution
signal_cosine = conv(signal_cosine,h_lpf);
signal_sine   = conv(signal_sine,h_lpf);
signal_complex = signal_cosine - i*signal_sine;

Ns = length(signal_cosine); %any of three above
fshift = (-Ns/2:Ns/2-1)*(Fs/Ns);

%%Final Spectrum
ft_signal_complex = fft(signal_complex)/Ns;
ft_signal_complex = fftshift(ft_signal_complex);

subplot(4,1,4);
plot(fshift,20*log10(abs(ft_signal_complex)))
title('Complex Down Conversion with LPF Via Convolution');
ylim([-500 0])
xlabel('Frequency');ylabel('PSD');
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.