Semi-natural modelling on RITM (Gate valve control via Modbus)¶
Introduction¶
This example deals with the modelling of an electrically operated pipeline gate valve on the RITM semi-natural modelling suite (CPM RITM), with data transfer between the operator and the Engee model via Modbus TCP.
Model description¶
The model of this example is test_SUI.engee
. The control object is an electrically operated pipeline gate valve, which is enclosed in an activatable subsystem Valve
. The activation signal enable
is equal to one in the presence of voltage in the supply circuit of the gate valve (signal VoltageOK
), correct phasing of the supply voltage (signal PhaseOK
) and absence of the control signal to stop the gate valve. Input signals for the subsystem are signals for opening open
and closing close
of the gate valve. Simultaneous supply of these signals blocks the change of the gate valve position. To provide signals for opening/closing it is also necessary to have power supply in the control circuits. The power supply check signal is simulated by the CO_OK
and CC_OK
blocks respectively.
The example model implements two modes of operation - gate valve testing by simulation in Engee and hard real-time operation on CPM RITM. The variable mode
is responsible for switching between the modes. In case of mode = 1
the signals for opening/closing of the gate valve come from the blocks Test_open
and Test_close
, the signal for stopping - from the variable stop
, and in case of mode = 0
the control signals come from the peripheral blocks Modbus TCP. The variable stop
is equal to "0" by default. The mode and stop variables are set in the callbacks, function PreLoadFunc
.
At the output of the gate valve subsystem the signals are taken and output via Modbus TCP:
- gate valve status:
opened
(open) andclosed
(closed), - activation of magnetic starters of opening/closing:
MPO
(MPO is switched on) andМПЗ
(MPZ is switched on), - opening/closing torque switches tripping:
MVO
(MBO tripped) andMVZ
(MBZ tripped).
The signal Valve_position
(gate valve position) is also taken at the subsystem output, but is not output via Modbus TCP.
In addition to the above mentioned signals, the signals VoltageOK
, PhaseOK
, CO_OK
and CC_OK
are also output via Modbus TCP.
Modbus peripheral blocks¶
The following peripheral blocks **Modbus TCP* are used in the example for data transmission via **Modbus TCP*:
- Modbus TCP Setup - for setting up the connection with the server,
- Modbus Read Coil Status - for reading flag registers,
- Modbus Write Coils - for writing bits.
IP address and port number, response waiting time and number of reconnection attempts are set in the connection setting block. The parameter "Server ID" is set the same for all peripheral units and can be used to realise operation with several Modbus servers.
The flag register read blocks set the initial read register and the number of registers to be read. In the example, these blocks transmit to the model the commands to open/close and stop the gate valve written in registers at addresses 863, 864 and 862 respectively.
The bit write blocks set the starting address and number of bits to be written from the model. In the example, the model generates bits for writing to registers at addresses 1681 - 1688, 1572 - 1573.
Subsystem of the control object¶
The activatable subsystem of the gate valve Valve
is shown in the figure below.
The operation of the gate valve is simulated by a linear inertia element with limitation valve_state
. Thus, when the gate valve is signalled to open/close, it opens/closes in 1 second. The state "0" corresponds to the position "open" and "1" to the position "closed". The initial state is "closed". The subsystem also simulates the operation of torque switches (Blocks MVO
and MVZ
). The state "1" corresponds to normal operation of the gate valve, and "0" corresponds to torque overload and fault. In addition, the subsystem checks the end states of the gate valve.
Modelling in Engee¶
Let's load and execute the example model.
Путь_примера = "$(@__DIR__)";
Имя_модели = "test_SUI";
Путь_модели = joinpath(Путь_примера, Имя_модели*".engee")
if Имя_модели ∉ getfield.(engee.get_all_models(), :name)
engee.load(Путь_модели);
end
модель = engee.run(Имя_модели);
Let's get the variables of the model to build.
время = модель["valve_position"].time;
открытие = модель["test_open"].value;
закрытие = модель["test_close"].value;
положение_0 = модель["valve_position"].value;
открыто_0 = модель["opened"].value;
закрыто_0 = модель["closed"].value;
длина = length(положение_0)
положение = Vector{Float64}(undef, длина)
открыто = Vector{Float64}(undef, длина)
закрыто = Vector{Float64}(undef, длина)
for i in 1:длина
положение[i] = положение_0[i][1]
открыто[i] = открыто_0[i][1]
закрыто[i] = закрыто_0[i][1]
end
Build graphs of opening and closing of the gate valve - output test signals of opening and closing, gate valve position and end states.
using Plots
gr(size=(1000,300), xlims = (0,10))
график_1 = plot(время, [открытие, положение, открыто]; title = "Открытие задвижки")
график_2 = plot(время, [закрытие, положение, закрыто]; title = "Закрытие задвижки")
plot(график_1, график_2; layout = (1,2), label = ["Сигнал" "Положение" "Состояние"])
As can be seen from the graphs, the gate valve model performs opening and closing with the specified inertia.
Operation of the model on the CPM RITM¶
Before starting to run the model on RITM RITM, we need to make sure that the connection is correct, and then we will go to the interactive execution mode of the model.
The considered model is executed on RITM CPM in real time mode for 100 seconds. In the process of the model operation there is an exchange of data via Modbus TCP with the simulator ModbusPal.
The record of the gate valve model operation on RITM is given in the animation ritm_valve_record.gif
.
When tag 863 is signalled, tag 1683 is set, indicating that the gate valve opening magnetic starter is switched on. This changes the position of the gate valve. After 1 second, tag bit 1681 is set, indicating that the gate valve is fully open. When the gate valve is signalled to close by tag 864, first the tag bit 1684 of the magnetic starter is set, and after 1 second the closing limit switch is actuated, setting tag bit 1682. When the gate valve stop signal (tag 862) is given, the gate valve operation is blocked and the opening/closing signals have no effect.
Conclusion¶
In the example, the Engee model for an electrically operated pipeline gate valve was considered, which is executed on CPM RITM in real time mode. The gate valve is controlled and its states are read via Modbus TCP protocol.