DC motor with electrical and mechanical parameters
This example will demonstrate a model of a DC motor with electrical and mechanical parameters. The process of launching the model from the script development environment using command control, as well as visualization of the simulation results, will be shown. In the simulation, an alternating torque acts on the shaft of the electric motor.
General view of the models
The Engee model:
Defining the function to load and run the model:
function start_model_engee()
try
engee.close("dc_motor_default", force=true) # closing the model
catch err # if there is no model to close and engee.close() is not executed, it will be loaded after catch.
m = engee.load("/user/start/examples/physmod/dc_motor_default/dc_motor_default.engee") # loading the model
end;
try
engee.run(m, verbose=true) # launching the model
catch err # if the model is not loaded and engee.run() is not executed, the bottom two lines after catch will be executed.
m = engee.load("/user/start/examples/physmod/dc_motor_default/dc_motor_default.engee") # loading the model
engee.run(m, verbose=true) # launching the model
end
end
Loading, running the model, and recording the results
try
start_model_engee() # loading and launching the model
catch err
end;
sleep(5)
# data1 = collect(simout) # extracting data from the simout variable describing collector current and collector-emitter voltage
# Vce = collect(data1[2]) # writing collector-emitter voltage data to a variable
# Ic1 = collect(data1[3]); # writing collector current data to a variable
Writing signals to the data variable:
data = collect(simout)
Recording data on the current and torque on the motor shaft in the variables current and torque:
torque = collect(data[1])
current = collect(data[3]);
Visualization of results
Output of graphs of the dependence of current and torque on time:
p1 = plot(current[:,1], current[:,2], label="Current", color="red")
p2 = plot(torque[:,1], torque[:,2], label="The torque", color="green")
plot(p1, p2, layout=(2,1))
Conclusions:
In this example, tools for command management of the model were used. The simulation results using simout were recorded in the corresponding variables, as well as visualized using interactive graphs from the Plots library.
