Engee documentation
Notebook

Permanent magnet synchronous motor

This example will demonstrate a model (model motor_pmsm.engee) of a permanent magnet synchronous motor (PMSM) in generator mode. The process of running the model from the script development environment using command control and visualising the simulation results will be shown. In the simulation, the speed of the SPM shaft changes in jumps from 100 to 200 rpm.

General view of the model

Engee model:

motor_pmsm_engee_2.png

Realisation of the model run using software control:

Loading the required libraries and preparing the MATLAB kernel to compare the Engee model with the Simulink model

In [ ]:
using Plots
using DataFrames
gr();

Load the model:

In [ ]:
model_name = "motor_pmsm"
model_name in [m.name for m in engee.get_all_models()] ? engee.open(model_name) : engee.load( "$(@__DIR__)/$(model_name).engee");

Running a loaded model:

In [ ]:
results = engee.run(model_name)
Out[0]:
Dict{String, DataFrame} with 4 entries:
  "i_c" => 201×2 DataFrame…
  "i_b" => 201×2 DataFrame…
  "w"   => 201×2 DataFrame…
  "i_a" => 201×2 DataFrame

Read instantaneous load current and shaft speed data:

In [ ]:
t = results["i_a"].time;
i_a = results["i_a"].value;
i_b = results["i_b"].value;
i_c = results["i_c"].value;
w = results["w"].value;

Loading and visualisation of simulation data

Output of the graph of dependence of instantaneous current values on time:

In [ ]:
plot(t, [i_a i_b i_c], label=["Ток фазы А" "Ток фазы В" "Ток фазы С"])
plot!(title = "Результаты моделирования в Engee", ylabel = "Мгновенное значение тока, А", xlabel="Время, c")
Out[0]:

Output of the graph of the dependence of the shaft speed on time:

In [ ]:
plot(t, w, label="Скорость вращения вала")
plot!(title = "Результаты моделирования в Engee", ylabel = "Скорость вращения, об/мин", xlabel="Время, c")
Out[0]:

Conclusions:

In this example, tools were used to command control a permanent magnet synchronous motor (PMSM) model. Simulation results were imported into a script, visualised, using interactive plots from the Plots library.