Engee documentation
Notebook

Multi-position Frequency Modulated (MFSK) car radar

The example examines the design of an automotive radar based on a multi-position frequency modulation (MFSK) signal to estimate the range and speed of several objects.

Functions used

In [ ]:
Pkg.add(["LinearAlgebra", "DSP"])
   Resolving package versions...
┌ Warning: It looks like the Kaleido process is not responding. 
│ The unresponsive process will be killed, but this means that you will not be able to save figures using `savefig`.
│ 
│ If you are on Windows this might be caused by known problems with Kaleido v0.2 on Windows (you are using version 0.2.1).
│ You might want to try forcing a downgrade of the Kaleido_jll library to 0.1.
│ Check the Package Readme at https://github.com/JuliaPlots/PlotlyKaleido.jl/tree/main#windows-note for more details.
│ 
│ If you think this is not your case, you might try using a longer timeout to check if the process is not responding (defaults to 10 seconds) by passing the desired value in seconds using the `timeout` kwarg when calling `PlotlyKaleido.start` or `PlotlyKaleido.restart`
└ @ PlotlyKaleido /usr/local/ijulia-core/packages/PlotlyKaleido/U5CX4/src/PlotlyKaleido.jl:24
  No Changes to `~/.project/Project.toml`
  No Changes to `~/.project/Manifest.toml`
In [ ]:
include("$(@__DIR__)/calcParamMFSK.jl")

using DSP,FFTW,LinearAlgebra

function run_model( name_model, path_to_folder ) # определение функции для прогона модели
    Path = path_to_folder * "/" * name_model * ".engee"
    if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
        model = engee.open( name_model ) # Открыть модель
        engee.run( model, verbose=true ); # Запустить модель
        engee.close( name_model, force=true ); # Закрыть модель
    else
        model = engee.load( Path, force=true ) # Загрузить модель
        engee.run( model, verbose=true ); # Запустить модель
        engee.close( name_model, force=true ); # Закрыть модель
    end
    return
end;

function DataFrame2Array(X)
    out = collect(X)
    out_data = zeros(eltype(out.value[1]),size(out.value[1],1),size(out.value[1],2),length(out.value))
    [out_data[:,:,i] = out.value[i] for i in 1:length(out.value)]

    return out_data, out.time
end

function calc_spectrogram(x::Array,fs::Real,title::String;
    num_pulses::Int64 = 4,
    window_length::Int64 = 32,
    nfft::Int64=32,
    lap::Int64  = 30,
    thesh::Real = -Inf)

    gr()

    spec_out = DSP.spectrogram(x[:,:,1:num_pulses][:],window_length,lap;window=kaiser(window_length,3.95),nfft=nfft,fs=fs)

    power = DSP.pow2db.(spec_out.power)
    power .= map(x -> x < thesh ? thesh : x,power)

    power_new = zeros(size(power))

    power_new[1:round(Int64,size(power,1)/2),:] .= power[round(Int64,size(power,1)/2)+1:end,:]
    power_new[round(Int64,size(power,1)/2)+1:end,:] .= power[1:round(Int64,size(power,1)/2),:]

    fig = heatmap(fftshift(spec_out.freq).*1e-6,spec_out.time .*1e3, permutedims(power_new),color= :jet,
        gridalpha=0.5,margin=5Plots.mm,size=(900,400))
    xlabel!("Частота, МГц")
    ylabel!("Время, мс")
    title!(title)

    return fig
end;

1. Description of the model structure

image_2.png

The block diagram is similar to the example (Automotive radar for estimating the range and speed of multiple targets). The main differences are:

  • Using a continuous radiation generator with multi-position frequency modulation;
  • Signal processing that takes into account two parameters: the beat frequency and the phase shift between scans

Signal processing unit

image_2.png

The signal processing subsystem consists of the following stages:

  1. The received signal is multiplied with the complex conjugate input signal in the Dechirp block, as a result of which the signal is demodulated;
  2. At the next stage, the demodulated signal is processed in the Sweep Spectrum block, where its spectrum in the frequency domain is calculated using the fast Fourier transform;
  3. Next, the process of detecting peaks in the spectrum corresponding to the targets takes place using a one-dimensional detector (CA CFAR Detector)
  4. At the final stage, using the found values of the beat frequencies and the phase difference between the sweeps, estimates of the range and speed of targets are calculated in the Solve Range Doppler Equation block.;

2. Initialization of input parameters

The simulation scenario is the following scenario: a vehicle with radar is moving from a reference point at a speed of 100 km/h (27.8 m/s)

There are ** two target vehicles** in the viewing area, which are a passenger car and a truck, each vehicle has a corresponding distribution channel. The car is moving at a distance of 50 meters from the radar and is moving at a speed of 60 km/h (16.7 m/s). The truck is located at a distance of 150 meters from the radar and is moving at a speed of 130 km/h (36.1 m/s).

The signal propagation channel is a free space.

To initialize the input parameters of the model, we will connect the file "calcParamMFSK.jl". If you need to change the parameter values, then open this file and edit the necessary parameters.

In [ ]:
include("$(@__DIR__)/calcParamMFSK.jl") # подключения файла с валидационными параметрами
paramRadarMFSKMT = CalcParamMFSK(); # валидация входных параметров
T = paramRadarMFSKMT.T; # шаг моделирования
SimT = T; # Время моделирования

3. Launching the model

In [ ]:
run_model("MFSK_Radar_Range_Estimation_MT",@__DIR__); # Запуск модели
Building...
Progress 0%
Progress 100%
Progress 100%

4. Reading simulation results

In [ ]:
sig_MFSK, fast_time = DataFrame2Array(MFSK) # входной ЛЧМ-сигнал
out_range, _ = DataFrame2Array(Range) # сигнал после цифровой обработки
out_speed, slow_time = DataFrame2Array(Speed); # оценки дальности

5. Visualization of radar operation

5.1 Input signal spectrogram

Let's construct a spectrogram of the input signal using the calc_spectrogram function

In [ ]:
calc_spectrogram(
    sig_MFSK, # ЛЧМ-сигнал
    paramRadarMFSKMT.Fs, # частота дискретизации
    "Cпектрограмма сигнала c MFSK";
    num_pulses=1 # количество импульсов отображения
)
Out[0]:

The frequency component of the LC spectrogram has a stepwise character, which corresponds to a multi-position frequency modulation of the signal. In fact, the MFSK signal consists of two FMCW signal scans with a fixed discrete frequency offset. The scanning time of the emitted signal, which is determined by the product of a discrete step by the number of steps, is approximately 2 ms, which is several orders of magnitude longer than for a continuous LFM signal (about 7 microseconds).

5.2 Estimating the range and speed of objects

Let's analyze the result of the radar operation

Let's compare estimates and true values of ranges and speeds (the range to a car is 50 m, to a truck is 150 m)

In [ ]:
println("Оценка дальности автомобиля $(round(out_range[1,1,end];sigdigits=5)) м")
println("Оценка дальности грузовика $(round(out_range[2,1,end];sigdigits=5)) м")

println("Оценка дальности автомобиля $(round(out_range[1,1,end]-50;sigdigits=5)) м")
println("Оценка дальности грузовика $(round(out_range[2,1,end]-150;sigdigits=5)) м")
Оценка дальности автомобиля 49.664 м
Оценка дальности грузовика 149.99 м
Оценка дальности автомобиля -0.3361 м
Оценка дальности грузовика -0.011043 м

Now let's compare the estimates and the true speed values (relative speed of a car is 40 km/h, truck -30 km/h)

In [ ]:
println("Оценка относительной скорости автомобиля $(round(out_speed[1,1,end]*3.6;sigdigits=5)) км/ч")
println("Оценка относительной скорости грузовика $(round(out_speed[2,1,end]*3.6;sigdigits=5)) км/ч")
println("Погрешность оценки относительной скорости автомобиля $(round(out_speed[1,1,end]*3.6-40;sigdigits=5)) км/ч")
println("Погрешность оценки относительной скорости грузовика $(round(out_speed[2,1,end]*3.6-(-30);sigdigits=5)) км/ч")
Оценка относительной скорости автомобиля 39.941 км/ч
Оценка относительной скорости грузовика -30.857 км/ч
Погрешность оценки относительной скорости автомобиля -0.059183 км/ч
Погрешность оценки относительной скорости грузовика -0.85661 км/ч

Analyzing the simulation results obtained, it can be concluded that the values of the radar estimates correspond to the stated accuracy in range (1 meter) and speed (1 km/h)

Conclusion

In the example, the design of an atomic radar model using a probe signal with multi-position frequency modulation was considered. As a result of the model, an estimate of the relative speed and distance from the radar to objects (car and truck) was found with a radar resolution accuracy of 1 meter in range and approximately 1 km/h in speed.

It should also be noted that the use of the considered signal made it possible to increase the scanning time compared to a continuous FM signal from 7 microseconds to 2 ms, which can reduce the cost of equipment.