DC motor with electrical and mechanical parameters
This example will demonstrate a DC motor model with electrical and mechanical parameters. The process of running the model from the script development environment using command control and the visualisation of the simulation results will be shown. In the simulation, a variable torque is applied to the motor shaft.
General view of the models
Engee model:

Define the function to load and run the model:
In [ ]:
function start_model_engee()
try
engee.close("dc_motor_default", force=true) # закрытие модели
catch err # в случае, если нет модели, которую нужно закрыть и engee.close() не выполняется, то будет выполнена её загрузка после catch
m = engee.load("/user/start/examples/physmod/dc_motor_default/dc_motor_default.engee") # загрузка модели
end;
try
engee.run(m, verbose=true) # запуск модели
catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
m = engee.load("/user/start/examples/physmod/dc_motor_default/dc_motor_default.engee") # загрузка модели
engee.run(m, verbose=true) # запуск модели
end
end
Out[0]:
Loading, running the model and recording the results
In [ ]:
try
start_model_engee() # загрузка и запуск модели
catch err
end;
sleep(5)
#data1 = collect(simout) # выделение из переменной simout данных, описывающих ток коллектора и напряжение коллектор-эмиттер
#Vce = collect(data1[2]) # запись данных о напряжении коллектор-эмиттер в переменную
#Ic1 = collect(data1[3]); # запись данных о токе коллектора в переменную
Write signals to the variable data:
In [ ]:
data = collect(simout)
Out[0]:
Write current and torque data on the motor shaft to the variables current and torque:
In [ ]:
torque = collect(data[2])
current = collect(data[4]);
Visualising the results
Plots of current and torque versus time:
In [ ]:
p1 = plot(current[:,1], current[:,2], label="Ток", color="red")
p2 = plot(torque[:,1], torque[:,2], label="Крутящий момент", color="green")
plot(p1, p2, layout=(2,1))
Out[0]:
Conclusions:
In this example, tools for command control of the model were used. The results of the simulation with simout were recorded in the appropriate variables and visualised, using interactive plots of the Plots library.