These instructions describe the “step by step” procedure to write process data based on definable triggers into a database.
In tutorial a SIMATIC S7 PLC is used as data source and a local SQLite Database as data target.
As Codabix offers a uniform interface that is used to access connected devices and databases, this procedure is applicable to any type of data,
that is defined in Codabix.
To carry out the following steps you need a computer (running Windows or Linux), on which you have the necessary rights to install applications.
Furthermore, an internet connection in necessary to load Codabix and the provided standard configuration and to be able to access sample data from our publicly available SIMATIC S7 PLC.
The exact system requirements for hardware and operating system version can be found here:
The following Codabix plugins are required
In this step you install Codabix on your system.
For the purpose of this tutorial we provide you with a basic configuration
for the process data acquisition.
4) Restore Backup
in the console applicationEnter
-key
In this example, the values of two variables (Duration
and Quantity
) will be read from the PLC and a new entry will be created in a database table,
which also contains the MachineID
and the current timestamp. The MachineID
can be used to associate the database entry with the source PLC.
This process should be carried out when the rising edge of the JobCompleted
bit is detected in the PLC.
The PLC variables are defined as follows:
Process data
Duration
Quantity
Trigger
JobCompleted
The database table named oeemachinerecord
has the following columns:
ID
MachineID
Duration
Quantity
Timestamp
In order to map the data acquisition (henceforth referred to as Transfer
) in Codabix, it is divided into three components:
These components are mapped using a folder structure within Codabix.
Each folder that is located under the path /Nodes/Transfers
represents an independent transfer.
To create a new transfer, navigate to the /Nodes/Transfers
node in the node tree.
/Nodes/Transfers
New Transfer
Edit Folder
Edit Folder
dialog, change the name to Data acquisition Machine02
The node tree should then look like this:
In order to define variables whose values are to be recorded, these varibles must be located under the folder node Inputs
.
In addition to the variables from the PLC, the ID of the machine (for this example MachineID = 2
) shall be recorded.
Therefore, first a node of the typeUInt16
is created that will hold this MachineID
as constant value:
Inputs
Add Datapoint Node
from the context menuAdd Datapoint Node
dialog:ID of MAC02
as the nameUInt16
as Value TypeWrite a new Value
Write a new Value
dialog:2
as the new value (as this Transfer will record the data from the machine with MachineID = 2
)
To define the values of the PLC variables as inputs for the transfer, a linked node is created in the Inputs
folder whose link target contains the value node that represents the corresponding PLC variable.
The nodes that represent these variables can be found under the path /System/Devices/S7 TCP-IP Device/Channels/Machine 02/Variables
:
For these two nodes, do the following to link them in the Inputs
folder:
Inputs
Add Datapoint Node
Add Datapoint Node
dialog:Virtual Link
dialog:Since the current timestamp shall be saved in addition to the PLC data, a node must me added that delivers this value.
For this purpose Codabix provides a predefined value node, which can be found under the path /System/Environment/DateTime/UtcNow
.
When reading this node always the current timestamp is returned.
Now, in the same way as in the previous steps, create another link called Current Timestamp
that refers to this node (/System/Environment/DateTime/UtcNow
).
Analogously to the sources of the data, the destinations are defined under the folder node Outputs
.
The table oeemachinerecord
of the database will be used for this.
The nodes that represent the columns of this table are under the path /System/Exchange/SQL Exchange/Databases/OEE/Tables/oeemachinerecord/Columns
.
As in the previous step, create link nodes below Outputs
that are linked to the following nodes:
/System/Exchange/SQL Exchange/Databases/OEE/Tables/oeemachinerecord/Columns/MachineID
/System/Exchange/SQL Exchange/Databases/OEE/Tables/oeemachinerecord/Columns/Duration
/System/Exchange/SQL Exchange/Databases/OEE/Tables/oeemachinerecord/Columns/Quantity
/System/Exchange/SQL Exchange/Databases/OEE/Tables/oeemachinerecord/Columns/Timestamp
The transfer mechanism uses the order of the input and output nodes to differentiate which data should be written to which node.
The value of the first input node is written to the first output node, the value of the second to the second output node and so on.
You can use drag-and-drop to arrange the nodes under Inputs
and Outputs
so that their order matches the order in this screenshot:
To set up the trigger for our example, create a virtual link under the Triggers
folders, whose target is the node /System/Devices/S7 TCP-IP Device/Channels/Machine 01/Variables/JobCompleted
.
So the node tree will look like this:
After completing the previous steps, the data acquisition setup is complete.
To activate the transfer, the value of the node isActive
in the folder of the transfer must me set to true
.
To do this, write true
as the new node value:
The trigger is now read by Codabix every 500ms and checked for a rising edge.
If this is the case, the inputs are read, then the trigger is reset (the value false
is written) and the data is written to the outputs.
This will create a new entry in the database table that contains this data.
The PLC program waits until the trigger has been reset.
After that within 10 seconds new, random values are written to the variables and the trigger is set on true
again.
You can now verify the functionality using an SQLite browser:
<CodabixProjectDirectory>/userdata/mydata.sqlite
. <CodabixProjectDirectory>
stands for the path of the project directory on your operating systems filesystem, that you select when you started Codabix for the first time. This path can be fount in the settings dialog:oeemachinerecord
in the SQLite browserAnother possibility is the view in the dashboard application integrated in Codabix.
Data acquisition Machine02
Inputs
, Outputs
and Triggers
by clicking on the symbols next to them