Realisation of FIR filter on basic elements
In this example we will understand the structure of the FIR filter and analyse the behaviour of the filter at different coefficients inside it.
A basic FIR filter consists of a delay line and coefficients by which the delayed signal is multiplied, after which the results are added up.
The figure below shows the FIR filter circuit containing 4 coefficients.

Next, let's add the auxiliary function of the model and determine the coefficients for several runs of the filter.
In [ ]:
# Подключение вспомогательной функции запуска модели.
function run_model( name_model)
Path = (@__DIR__) * "/" * name_model * ".engee"
if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
model = engee.open( name_model ) # Открыть модель
model_output = engee.run( model, verbose=true ); # Запустить модель
else
model = engee.load( Path, force=true ) # Загрузить модель
model_output = engee.run( model, verbose=true ); # Запустить модель
engee.close( name_model, force=true ); # Закрыть модель
end
sleep(5)
return model_output
end
Out[0]:
In [ ]:
К_arr = [0.1 0.2 0.3 0.4; 0.16 0.38 0.38 0.16; 1 2 3 4]
Out[0]:
Run the model in a cycle and analyse the results by plotting the results in time and frequency domains.
In [ ]:
out_arr = zeros(1001,3)
K, K1, K2, K3, K4 = 0, 0, 0, 0, 0
for i in 1:3
K = К_arr[i,:]
K1, K2, K3, K4 = K[1], K[2], K[3], K[4]
run_model("Basic_FIR_filter") # Запуск модели.
out = collect(simout["Basic_FIR_filter/out"]);
out_arr[:,i] = out.value
end
plot(out_arr)
Out[0]:
In [ ]:
using FFTW
Comp_out = ComplexF64.(out_arr);
spec_out = fftshift(fft(Comp_out));
plot([10log10.(abs.((spec_out/3e6)))], label =["0.1 0.2 0.3 0.4" "0.16 0.38 0.38 0.16" "1 2 3 4"])
ylabel!("Мощность дБВт")
xlabel!("Частота МГц")
Out[0]:
Conclusion
As we can see from the resulting graphs, filter coefficients affect changes in both signal power and frequency characteristics.