Engee documentation
Notebook

Car radar based on multi-position frequency modulated (MFSK) signal

The example describes the design of a car radar based on a multi-position frequency modulated (MFSK) signal for estimating 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 structural scheme is similar to the example (Automotive radar for range and speed estimation of multiple targets). The main differences are:

  • The use of a continuous radiation generator with multi-position frequency modulation;
  • Signal processing that takes into account two parameters: beat frequency and phase shift between sweeps.

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, resulting in a demodulated signal;
  2. In the next step, the demodulated signal is processed in the Sweep Spectrum block, where its spectrum in the frequency domain is calculated using fast Fourier transform;
  3. Next, the process of detecting peaks in the spectrum corresponding to the targets is performed using a one-dimensional detector (CA CFAR Detector)
  4. At the final stage, using the found values of beat frequencies and phase difference between sweeps, the estimates of range and velocity of targets are calculated in the Solve Range Doppler Equation block;

2 Initialisation of input parameters

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

There are two target vehicles present in the line of sight, which are a car and a lorry, each vehicle has a corresponding propagation channel. The car is 50 metres away from the radar and travelling at 60 km/h (16.7 m/s). The truck is 150 metres from the radar and is travelling at 130 km/h (36.1 m/s).

The signal propagation channel is free space.

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

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

3. Running 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. Visualisation of radar operation

5.1 Spectrogram of the input signal

Let's build 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 spectrogram has a step character, which corresponds to the multi-frequency frequency modulation of the signal. In fact, the signal with MFSK consists of two sweeps of the FMCW signal with a fixed discrete frequency offset. The scanning time of the radiated signal, which is determined by the product of the discrete step by the number of steps, is about 2 ms, which is several orders of magnitude longer than for a continuous FMCW signal (about 7 µs).

5.2 Estimation of range and speed of objects

Let's analyse the result of radar operation

Let's compare the estimates and true values of ranges and speeds (range to a car - 50 m, to a truck - 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 true speed values (relative speed of the car - 40 km/h, of the 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 км/ч

Analysing the obtained simulation results, we can conclude that the values of radar estimates correspond to the declared accuracy in range (1 metre) and speed (1 km/h).

Conclusion

In the example we have considered the design of a model of an automotive radar using a probing signal with multi-position frequency modulation. As a result of the model's operation, an estimate of the onositive speed and distance from the radar to the objects (car and truck) was found with a radar resolution accuracy of 1 metre for range and approximately 1 km/h for speed.

It should also be noted: the use of the considered signal allowed to increase the scanning time compared to a continuous LFM signal from 7 µs to 2 ms, which can reduce the cost of equipment.

Blocks used in example