Reading Modbus TCP data from Elikont-CS
Introduction
This example shows a simple way to integrate Engee and Elikont-CS. Elikont-CS generates and Engee reads signals in real time using the Modbus TCP protocol.
Elikont-CS
A brief overview
"[Elikont-CS](https://ptk-sura.ru/products/kommunikatsionnyy-server/elicont-cs /)" – software from [Elara JSC](https://elara.ru/products/asu-tp-i-iiot/elikont-ks /?ysclid=mceomskbl9730209168), used for data collection, processing and transmission in industrial automation and Internet of Things (IIoT) systems, acting as an industrial protocol converter, data hub, communication gateway and multiserver.
The version of the communication server used in this example is 2.6.2. The operating system is Windows 10 Pro.
Modbus TCP Server Configuration
The configuration file for deploying the Elikont communication server from the example - Engee_read_1.elconf. It is enough to open it in Elikont-CS and start data exchange.
When creating a Modbus TCP server, you must configure its connection. In this example:
-
Modbus TCP Server IP:
127.0.0.4 -
Port:
502 -
Device address:
1
The generated signals, analog and discrete, will be transmitted to the configured Modbus TCP server.
Generating signals for reading from Engee
The generator module in Elikont CS is used to generate the signals. In the example, it generates two signals:
-
"Iconic_sinusoid" :
-
Data type :
INT16 -
type of generation :
Синус -
period :
4 -
range of values:
-30 000 ÷ 30 000
-
-
"Periodic_bit" :
-
Data type :
BOOLEAN -
type of generation :
Треугольник
-
The same signals are transmitted to the Modbus TCP server.:
Two signal sources have been added to the server signal block. They have been assigned names and addresses of Modbus registers:
"Periodic_bit":
-
Modbus name:
Modbus_periodic_bit -
Register address:
0
"Iconic_sinusoid":
-
Modbus name:
Modbus_sinus -
Register address:
5
After configuring the servers, the generator, and the generated signals, you need to download the server and establish a connection. The screenshot below shows the communication server in the process of generating signals.
For more information about the Elikont-CS setup process, see the [manual](https://ptk-sura.ru/products/kommunikatsionnyy-server/elicont-cs /).
The example model
The model of this example - elicont_cs_read.engee.
A power supply unit is required to connect to the Elikont-CS Modbus TCP Setup from the Hardware section of the Engee Block library. You must specify the server addresses in it. - 127.0.0.4 and the port - 502.
We will read discrete data using the function block 1. - Modbus Read Coil Status. You must specify the server ID in it. - 1, the initial address of the readings (register number) - 0 and the number of read bits - 1.
We will read the analog data using the function block 3. - Modbus Read Holding Register. You must specify the server ID in it. - 1, the initial address of the readings (register number) - 5 and the number of registers being read - 1.
As a result, the example model looks like this:
In addition, you should configure the recording of read data, the management of simulation time in Engee, and the sampling periods of blocks.
Connection to external equipment: Modbus TCP
To connect to external equipment, you need to install a module for working with external equipment. The detailed step-by-step process of connecting Engee to low-level computer interfaces is presented in примере.
# Установить модуль можно непосредственно в скрипте, следующей командой:
# engee.package.install("Engee-Device-Manager")
Simulation
After launching the Modbus TCP server in Elikont-CS and installing the Engee connection to low-level interfaces, we will proceed to launch the example model.:
name = "elicont_cs_read" # Имя модели
include(joinpath(@__DIR__, "start_model_engee.jl")) # Определяем функцию запуска модели
start_model_engee(name) # Запускаем модель
After performing the simulation, we will process the received data reading results over Modbus TCP.
Simulation results
Let's collect data from the variable simout into two variables with the names of the signals in the Modbus server.
data = collect(simout);
t = collect(data[1].time)[:,1];
Modbus_sinus = reduce(vcat, collect(data[1].value)[:,1])
Modbus_periodic_bit = reduce(vcat, collect(data[2].value)[:,1]);
Let's plot the read signals:
gr(size = (1000, 400))
AO = plot(t, Modbus_sinus;
seriestype = :step, title = "Эликонт-КС: аналоговый сигнал",
label = "Modbus TCP \n127.0.0.4:502 \nУстройство 1 \nРегистр 5")
DO = plot(t, Modbus_periodic_bit;
seriestype = :step, title = "Эликонт-КС: дискретный сигнал",
label = "Modbus TCP \n127.0.0.4:502 \nУстройство 1 \nРегистр 0")
plot(DO, AO, layout = (1, 2), legend = :bottomright, xlabel = "Время, с", ylabel = "Величина сигнала")
As can be seen in the graphs, the frequencies, amplitudes, and shapes of the received data correspond to the signals generated from the Elikont-CS.
Conclusion
In this example, a simple configuration of the Elikont-KS communication server for generating discrete and analog signals over Modbus TCP was considered. An Engee connection has been established using the same protocol to read the generated signals into the model and further process them.