Modelling of LC-oscillator based on Colpitts scheme
This example shows the implementation of a Colpitts oscillator circuit with a nominal frequency of 9 MHz. The oscillation frequency is given by the formula:
Schematic diagram of the model:

Define the function to load and run the model:
In [ ]:
function start_model_engee()
try
engee.close("lc_oscillator", force=true) # закрытие модели
catch err # в случае, если нет модели, которую нужно закрыть и engee.close() не выполняется, то будет выполнена её загрузка после catch
m = engee.load("$(@__DIR__)/lc_oscillator.engee") # загрузка модели
end;
try
engee.run(m) # запуск модели
catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
m = engee.load("$(@__DIR__)/lc_oscillator.engee") # загрузка модели
engee.run(m) # запуск модели
end
end
Out[0]:
Running the simulation
In [ ]:
try
start_model_engee() # запуск симуляции с помощью специальной функции, реализованной выше
catch err
end;
Write from simout to voltage signal variables:
In [ ]:
res = collect(simout)
V = collect(res[1])
Visualisation of simulation results
In [ ]:
using Plots
In [ ]:
plot(V[:,1], V[:,2], label="Напряжение, В", linewidth=2, title="Напряжение LC-осциллятора")
Out[0]:
In [ ]:
plot(V[:,1], V[:,2], label="Напряжение, В", linewidth=2, xlim=(4e-5, 4.1e-5), title="Напряжение LC-осциллятора в течение 1 микросекунды")
Out[0]: