Engee documentation
Notebook

BER calculation for QPSK

The Error Rate Calculation block calculates the bit error rate (BER). Using this block, we can obtain the BER for the communication system and analyse the performance of our system. In this example, we will look at a simple QPSK receiver and transmitter model. It is shown in the figure below.

image.png

Next, let's define an auxiliary function to run the model.

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]:
run_model (generic function with 1 method)

Next, we initialise the signal-to-noise ratios for our model and declare the bit error variable.

In [ ]:
EbNoArr =  [1, 3, 5, 7, 10, 12, 15, 17, 20, 23, 25];
ber = zeros(length(EbNoArr));
EbNo = 0;

Now let's run the model at different values of signal-to-noise ratio.

In [ ]:
for i in 1:length(EbNoArr)
    EbNo = EbNoArr[i]
    run_model("QPSK") # Запуск модели.
    BER = collect(BER)
    ber[i]=BER.value[end][1]
end

Plot the BER graph.

In [ ]:
plot(EbNoArr,ber, seriestype=:scatter, title = "BER", label = "QPSK")
Out[0]:

Conclusion

As you can see from this example, the higher the signal to noise ratio, the smaller the error. Here we have shown how to plot BER for a simple model of a communication system and how to apply this method to analyse the system.