How to remove sidelobes using fdatool

I have generated an 802.11a frame using my VHDL simulation. When I analyze it in the frequency domain(cap data through iio oscilloscope), I observe sidelobes. I attempted to address this by adjusting parameters in the RF configuration, but to no avail. Now, I'm trying to remove these sidelobes using MATLAB's 'fdatool'. As I'm new to this tool, I designed a basic filter and saved its coefficients, but the resulting spectrum still appears distorted. Could you guide me on where I might be going wrong, and how I can correct this?
sampling fq=20Mhz
Filter Design
Atteched my files
matlab code :
clc;
clear;
close;
data=readmatrix("DATA1.csv"); % VHDL genarated data IQ
load('num_coef100.mat'); % fdatool genarated coefficients
LPF=(coef_100.');
real1=data(:,1);
imag1=data(:,2);
IQ_DATA= real1 + 1i*imag1 ;
iq_data = IQ_DATA;
filter_coefficients = LPF;
% Apply the filter to your IQ data
filtered_data = filter(filter_coefficients, 1, iq_data); % FIR
% Compute the FFT of the original IQ data
N = length(iq_data);
fft_original = fftshift(fft(iq_data));
fft_freq_original = (-N/2:N/2-1)*(1/N);
% Compute the FFT of the filtered data
fft_filtered = fftshift(fft(filtered_data));
fft_freq_filtered = (-N/2:N/2-1)*(1/N);
figure;
subplot(2,1,1);
plot(fft_freq_original, abs(fft_original), 'b');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum Before Applying Filter');
subplot(2,1,2);
plot(fft_freq_filtered, abs(fft_filtered), 'r');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum After Applying Filter');

Réponses (1)

hello
i prefer to use an elliptic filter as it has a steep roll off after the cut of frequency (fc)
here's the filter alone
fc = 0.25; % cut off freq (normalized to fs/2)
fs = 1;
order = 6; % 6th-order lowpass elliptic filter
ripple_dB = 3; %passband ripple
sa = 30; % stopband attenuation,
[b,a] = ellip(order,ripple_dB,sa,fc/(fs/2));
freqz(b,a,[],fs)
subplot(2,1,1)
ylim([-100 20])
and used in your code
clc;
clear;
close;
data=readmatrix("DATA1.csv"); % VHDL genarated data IQ
% load('num_coef100.mat'); % fdatool genarated coefficients
% LPF=(coef_100.');
real1=data(:,1);
imag1=data(:,2);
IQ_DATA= real1 + 1i*imag1 ;
iq_data = IQ_DATA;
% filter_coefficients = LPF;
% Apply the filter to your IQ data
fc = 0.25; % cut off freq (normalized to fs/2)
fs = 1;
order = 6; % 6th-order lowpass elliptic filter
ripple_dB = 3; %passband ripple
sa = 30; % stopband attenuation,
[b,a] = ellip(order,ripple_dB,sa,fc/(fs/2));
filtered_data = filter(b, a, iq_data); % IIR
% Compute the FFT of the original IQ data
N = length(iq_data);
fft_original = fftshift(fft(iq_data));
fft_freq_original = (-N/2:N/2-1)*(1/N);
% Compute the FFT of the filtered data
fft_filtered = fftshift(fft(filtered_data));
fft_freq_filtered = (-N/2:N/2-1)*(1/N);
figure;
subplot(2,1,1);
plot(fft_freq_original, abs(fft_original), 'b');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum Before Applying Filter');
subplot(2,1,2);
plot(fft_freq_filtered, abs(fft_filtered), 'r');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum After Applying Filter');

9 commentaires

VIJETH J SHETTY
VIJETH J SHETTY le 29 Fév 2024
Thank you so much for your reply. I believe the filter is successfully removing the sidelobes in matlab but in realtime it's causing unintended issues:
After applying the filter to the generated frames, transmitting them results in the spectrum shrinking by half, effectively reducing the bandwidth and rendering the frames unable to decode.
If I utilize the coefficients generated from the filter during frame transmission in the RF configuration, it chops the entire frame.
It would be greatly appreciated if you could provide guidance on resolving these issues.
Mathieu NOE
Mathieu NOE le 29 Fév 2024
hello again
maybe we have to double fc
can you try again with fc = 0.5
Mathieu NOE
Mathieu NOE le 29 Fév 2024
Modifié(e) : Mathieu NOE le 29 Fév 2024
also, maybe this is not relevant, but I wonder if we would rather use filtfilt instead of filter
filtfilt does twice the filter action, once in forward time and a second time in backward time direction, so the filter's phase delay is compensated
this is the real portion of your signal before and after filtering with filter with the 6th order elliptic filter
notice the time shift
now with filtfilt, (and to have the same amount of filtering I reduced the order to 3 , but it's applied twice on the signal so it's basically the same as doing one filtering with a 6th order filter)
notice NO time shift
code :
clc;
clear;
close;
data=readmatrix("DATA1.csv"); % VHDL genarated data IQ
% load('num_coef100.mat'); % fdatool genarated coefficients
% LPF=(coef_100.');
real1=data(:,1);
imag1=data(:,2);
IQ_DATA= real1 + 1i*imag1 ;
iq_data = IQ_DATA;
% filter_coefficients = LPF;
% Apply the filter to your IQ data
fc = 0.25; % cut off freq (normalized to fs/2)
fs = 1;
order = 3; % 6th-order lowpass elliptic filter
ripple_dB = 1; %passband ripple
sa = 30; % stopband attenuation,
[b,a] = ellip(order,ripple_dB,sa,fc/(fs/2));
% filtered_data = filter(b, a, iq_data); % IIR
filtered_data = filtfilt(b, a, iq_data); % IIR
% Compute the FFT of the original IQ data
N = length(iq_data);
fft_original = fftshift(fft(iq_data));
fft_freq_original = (-N/2:N/2-1)*(1/N);
% Compute the FFT of the filtered data
fft_filtered = fftshift(fft(filtered_data));
fft_freq_filtered = (-N/2:N/2-1)*(1/N);
figure;
subplot(2,1,1);
plot(fft_freq_original, abs(fft_original), 'b');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum Before Applying Filter');
subplot(2,1,2);
plot(fft_freq_filtered, abs(fft_filtered), 'r');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum After Applying Filter');
VIJETH J SHETTY
VIJETH J SHETTY le 4 Mar 2024
Modifié(e) : VIJETH J SHETTY le 4 Mar 2024
Hi, thank you for your response. I apologize for the delay. I've tried all the suggestions you provided, but unfortunately, they're not yielding the desired results in real-time. For testing, I'm using the AD361 RF (XC7Z020CLG200-1) board. Additionally, I've experimented with the AD61 filter wizard, akin to fdatool, but the outcomes remain unchanged.
Mathieu NOE
Mathieu NOE le 4 Mar 2024
then maybe yhe idea of filtering the data is simply not the good path
is there any reason why the sidelobes appear in first instance ?
VIJETH J SHETTY
VIJETH J SHETTY le 5 Mar 2024
To the best of my knowledge, the presence of these sidelobes outside of the desired frequency band could be due to issues with the RF configuration or the impulse response. However, I'm not entirely sure about the exact cause. I found similar issues reported by others on the internet, as seen in this link: https://ez.analog.com/rf/wide-band-rf-transceivers/design-support/f/q-a/91545/abnormal-behaviour-of-rx-fir-in-ad9361.
I attempted the solutions provided there, but unfortunately, I haven't observed any improvement.
The filter is only to applicable within the specified band, which in our case is 20 MHz, but these sidelobes persist outside of this band.
Mathieu NOE
Mathieu NOE le 5 Mar 2024
ok , tx for the infos
unfortunately I cannot really help on the Tx / Rx potential issues due to hardware
VIJETH J SHETTY
VIJETH J SHETTY le 6 Mar 2024
Thank you for trying to help despite the hardware limitations. I appreciate your efforts.
Mathieu NOE
Mathieu NOE le 6 Mar 2024
Wished I ould do better, but I am aware that I have reached my limits
hope you find a way to solve it

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by