MATLAB Answers

Hi. I have to create an FMCW signal, transmit, receive and mix them to get the IF signal, and inturn get the radar 2D matrix for post processing. But I my 2nd FFT doesnt give the correct value of velocity.

41 views (last 30 days)
Vigneshwar Dhamodharan
Vigneshwar Dhamodharan on 28 May 2019
Commented: marwa mohamed on 1 Sep 2020 at 8:43
Hi. I am a Masters Student who requires this as a first step to start my Thesis, and I am new to matlab signal processing. I have theoretical knowledge but I just started Matlab implementation of the same. Also I am completely new to the FMCW tool chain. I have to create an FMCW signal, transmit, receive and mix them to get the IF signal, and inturn get the radar 2D matrix for post processing. But I my 2nd FFT doesnt give the correct value of velocity. I set the chirp parameters and thus obtain the Vmax and Rmax values.
There are 2 IF signals created : one the theoretical, obtained from equation, and the other is obtained from mixing the received and transmitted signals and applying a Lowpass Filter. The goal is to create a radar 2D matrix (No. of samples x No. of chirps) so that I can try post processing to get the Range and velocity. I am able to get the correct range value, but the velocity is always wrong. I am unable to figure out what's wrong. I have posted the code below. Any help would be greatly appreciated.
Thanks in advance.
close all;
clear all;
%% Params
%%% Transmit side params
f0 = 10e9;
% dR = 15e-2;
% Rmax = 7.5e3;
% dV = 0.94;
% Vmax = 7.5;
B = 1e9;
T = 1e-5;
Ns = 2048;
L = 64;
% fdmax=1/(1*T);
%%% Receive side params
R1 = 70;
v1 = 50; % Corresponds to 43.2kmph
%% Derived Params
% If Vmax, Rmax, dR, dV specified
% T = c/(4*Vmax*f0);
% B=c/(2*dR);
% Ns = (4*B*Rmax)/c;
% L = ceil(c/(2*f0*dV*T)) ; % No.of Chirps
%If B, T, Ns, L are specified
Vmax = c/(4*T*f0);
m = B/T;
Rmax = Ns*c/(4*B);
dV = c/(2*f0*L*T);
% n=ceil(log10(Vmax));
% factor = roundn(Vmax,n)
% v1 = factor-v1;
t0 = 2*R1/c;
phi0 = 2*pi*f0*t0 - pi*m*(t0^2);
fb = 2*R1*m/c;
fd = -2*v1*f0/c;
% fif_val1 = fb + fd; % For comparison purpose
% fif_val2 = m*t0 +f0*2*v/c;
% v1=v1-T*1e8/2;
fif_val= fb + fd;
Ts = T/Ns;
Fs = 1/Ts;
%% Big time scale
time_scale = zeros(1,L*Ns);
time_scale(1:length(t)) = t(1:end);
%% For No.of chirps = L
for i=1:L-1
time_scale((i*length(t))+1:(i+1)*length(t)) = t + (T*i);
% time_scale=0:Ts:T*L-Ts;
% td=1e-6;
% R= c*td/2
f_t = f0 + m*t;
% f_r = f0 + m*(t-td)/2;
%% For L chirps
f_t = repmat(f_t,1,L);
% New -----------
f_r = zeros(size(f_t));
n = ceil(t0/Ts);
f_r(n+1:end) = f_t(1:end-n);
f_r = f_r + fd;
% f_r = repmat(f_r,1,L);
f_if = f_t-f_r;
% f_if(1:n) = 0;
st = cos(2*pi.*f_t.*t);
rt = cos(2*pi.*f_r.*t);
% rt = cos(2*pi.*f_r.*(t+td)); %%%%%%%%
% rt = cos(2*pi*(f0(t-td) + m*((t-td)^2)/2));
% t = time_scale;
% st = repmat(st,1,L);
% rt = repmat(rt,1,L);
% f_t = repmat(f_t,1,L);
% f_r = repmat(f_r,1,L);
fif = rt.*st;
fif_lpf = lowpass(fif,max(f_if),2*B,'Steepness',0.8);
%% Final IF signal
fif_the = 0.5*cos(phi0 + 2*pi*fif_val.*t);
% fif_the = 0.5*cos(phi0 + 2*pi.*f_if.*t);
%% Plots
% xlimit = 2*T;
xlimit = T/2;
%-------Fig 3 For Big time scale----------%
xlim([0 xlimit])
title("Received signal as st = cos(2*pi.*f_t.*t);")
xlim([0 xlimit])
title("Received signal as rt = cos(2*pi.*f_r.*t);")
xlim([0 xlimit])
title("IF after Mixing")
xlim([0 xlimit])
title("IF after LPF")
xlim([0 xlimit])
title("IF from fif_the = 0.5*cos(phi0 + 2*pi*fif_val.*t);")
% xlim([0 T/10])
hold on;
grid on;
ylim([f0-B f0+(2*B)]);
xlim([0 T*5])
grid on;
xlim([0 T*5])
%% Post processing
% radar_mat = reshape(fif_the,Ns,L); %% Using the Theoretical IF Signal
radar_mat = reshape(fif_lpf,Ns,L); %% Using the Mixed and LPF IF Signal
%% Window function
window_1D = hann(size(radar_mat,1));
window_2D = hann(size(radar_mat,2));
%% FFT
rfft = (fft(radar_mat.*window_1D,[],1));
rfft = rfft./max(max(rfft)); %Normalization
rfft = rfft(1:size(rfft)/2,:);
% zeroPadding = zeros(size(rfft));
% rfft = vertcat(rfft,zeroPadding);
vfft = fft(rfft.*window_2D',[],2);
%% Normalization
% normalize = vfft./max(max(vfft));
%vfft = fftshift(vfft,2)
vfft = vfft./max(max(vfft));
%% Range and Velocity vectors
R = 0:dR:Rmax-dR;
V = linspace(-Vmax, Vmax, L);
h=imagesc(V,R,20*log10(abs(fftshift(vfft,2))),[-60 0]);
cb = colorbar;
xlabel('Velocity (m/s)');
ylabel('Range (m)');


Sign in to comment.

Answers (1)

Honglei Chen
Honglei Chen on 28 May 2019


Vigneshwar Dhamodharan
Vigneshwar Dhamodharan on 28 May 2019
Hi, I have already referred to the example prior to posting this code. I wasnt able to fully understand the codes there as there were no equations involved nor were the basics exposed in those external functions. I am trying to implement it in pure matlab without using external functions like the mentioned phasedarraytoolbox for a complete understanding.
I just want to know if my way of creating the transmit and received signal are correct, if my equation for the IF signal is correct, and if I am doing the FFT the right way.
Thank you for your time. :)
marwa mohamed
marwa mohamed on 1 Sep 2020 at 8:43
Dear Vigneshwar Dhamodharan
did you already managed how to do it? if so, i would need your help please?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!