Model of air temperature control system¶
The purpose of this example is to demonstrate the capabilities of the Chart block in forming the logic of controlling various objects. In particular, in this example we will consider the variant of controlling the air temperature in the room.
Principle of operation¶
The model (AirCond_Chart.engee) consists of several subsystems. The outside temperature is generated by a random signal and is realised in the External Temperature block. Thermodynamics inside the room in the subsystem - Room Termodynamics. It models the influence of external heat flow and calculates the current air temperature taking into account the influence coefficient of the air conditioner - heatFlow, the value of which is defined in the Chart block. You can learn more about the implementation of the models by double-clicking on the subsystem of interest.
The Chart unit implements the logic for controlling the room temperature.
The algorithm of the block circuit is as follows. The Chart input receives signals:
- temp - current air temperature in the room, F;
- tempDesired - desired air temperature, F;
Then inside the block the two parameters are compared. If the current temperature is higher than the desired temperature, the heatFlow parameter will take the value -1 and the temperature will start to decrease. If the current temperature is less than the desired temperature, the heatFlow parameter will be set to 1 and the temperature will start to rise. If the current temperature is within the range of acceptable values, the heatFlow will be set to 0.
Let's run the model and see the result of execution.
# Подключение вспомогательной функции запуска модели.
function run_model( name_model, path_to_folder )
Path = path_to_folder * "/" * 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
return model_output
end
run_model("AirCond_Chart",@__DIR__) # Запуск модели.
# Считывание из simout залогированных сигналов
T_ext = simout["AirCond_Chart/T_ext"];
T_ext = collect(T_ext);
heatFlow = simout["AirCond_Chart/Chart.heatFlow"];
heatFlow = collect(heatFlow);
T = simout["AirCond_Chart/T"];
T = collect(T);
using Plots
plot(T_ext.time, T_ext.value, label = "T_ext")
plot!(T.time, T.value, label = "T")
As you can see, when the outside temperature jumps, the temperature inside the room also started to change, but thanks to the control logic, it remained within the acceptable range of values. Let's make a graph of the heatFlow parameter changes to make sure that the Chart block works.
plot(heatFlow.time, heatFlow.value, label = "heatFlow")
Conclusion¶
In this example we have considered a way of implementing the control logic using the Chart block of the finite automata library. The implementation was simplified, but the simulation results show that the model copes well with temperature maintenance.