1. S7-1500 Blocks
1.1. Introduction
This section of the document describes the integration of the S7-1500 function blocks of the JRK Data Acquisition in the TIA Portal.
1.2. Integrating Blocks
1.2.1. Opening the Library
-
Activate the "Libraries" tab on the right side of the TIA Portal.
-
Expand "Global Libraries."
-
Click the "Open Global Library" button.
-
Select and open the JRK_DAQ_V1 library.
-
Expand the JRK_DAQ_V1 library.
-
Expand "Master copies" and copy the blocks into the project using drag and drop. For the export, FB_JRK_DAQ_Connection, FB_JRK_DAQ_Export, and all FCs are needed.
1.2.2. Calling the Connection Block
Program the call of the connection block.
The ConnectionID corresponds to the local connection ID and must be assigned uniquely in the PLC project. The InterfaceID is the hardware identifier of the network interface. For PlcId, enter the PlcId defined in the ConfigTool.
A connection call can manage up to 32 instances, multiple connections from one controller are possible.
1.2.3. Preparing the Process Data Block
Manually assign the data block number.
For the export, it’s necessary to deactivate the optimized block access. The attribute must be set accordingly.
1.2.4. Calling the Export
Program the call of the export function.
The Connection must be the instance of the previously called connection block.
1.2.5. Exporting the AWL Source of the Process Data Block
The DAQ server requires the AWL sources to receive the data blocks. These can be generated in the TIA Portal.
1.3. Blocks
1.3.1. FB_JRK_DAQ_Connection
The block establishes the connection to the DAQ server.
FUNCTION_BLOCK "FB_JRK_DAQ_Connection" VERSION : 0.2 VAR_INPUT ConnectionID : CONN_OUC; // Connection ID InterfaceID : HW_ANY; // Hardware identifier of the network interface from the system constants IP1 : USInt := 10; // Server IP address IP2 : USInt := 128; // Server IP address IP3 : USInt := 35; // Server IP address IP4 : USInt := 182; // Server IP address PlcID : DInt; // Unique Plc number Reconnect : Bool; // Reconnect the connection END_VAR
VAR_OUTPUT Connected : Bool; // Connection established Error : Bool; // Error ErrorCode : Word; // Error code, 16#1000 = TCON, 16#2000 = TSend, 16#3000 = TReceive ErrorStatus : Word; // Status of the block that triggered the error: TCON/TSEND/TRCV END_VAR
1.3.1.1. Result Codes
Result Code | Description |
---|---|
16#1000 |
TCON error, status displayed in ErrorStatus |
16#2000 |
TSEND error, status displayed in ErrorStatus |
16#3000 |
TRCV error, status displayed in ErrorStatus |
1.3.2. FB_JRK_DAQ_Export
This block sends the content of a data block to the DAQ system and provides feedback when the data has been successfully received. The source of the data block and a template file are stored in the DAQ system. An error code is generated in case of an error.
FUNCTION_BLOCK "FB_JRK_DAQ_Export" VERSION : 0.2 VAR_INPUT Trigger : Bool; // Trigger sending by positive edge DBNo : UInt; // DB number of the data block with process data to be sent ConfigID : UInt; // Station number END_VAR
VAR_OUTPUT Done : Bool; // Successfully exported - remains set until Trigger goes back to 0 Busy : Bool; // Command is currently being processed Error : Bool; // Error occurred while executing the function Result : Word; // Result, see table END_VAR
VAR_IN_OUT Connection : "FB_JRK_DAQ_Connection"; // Connection END_VAR
Result Code | Description |
---|---|
16#0001 |
Successfully exported |
16#1000 |
File could not be written |
16#2000 |
Export not configured |
16#2001 |
Data block length does not match configuration |
16#9000 |
Too many instances of the block called on one connection |
2. Configuration Tool
2.1. Introduction
The JRK-DAQ system (Data Acquisition) simplifies the collection and transmission of process data. It collects process data from systems with Siemens S7-300/S7-1500 controllers and outputs this data as files.
2.1.1. System Architecture
The system consists of the following components:
-
JRK DAQ Gateway Windows Service
-
Configuration Interface
-
Libraries with Function Blocks for Siemens S7-300 and S7-1500 controllers
This section of the document describes the Windows service, the configuration interface, and the process for configuring file exports.
2.1.2. Files
The folder structure after installation is as follows:
- C:\JRK DAQ\
-
Installation path
- C:\JRK DAQ\bin\configtool
-
Executable files of the configuration tool
- C:\JRK DAQ\bin\service
-
Files of the JRK DAQ Gateway service
- C:\JRK DAQ\config
-
Configuration files of the JRK DAQ Gateway service
- C:\JRK DAQ\config\logging.xml
-
Logging configuration
- C:\JRK DAQ\config\DaqConnections.json
-
Configuration of system connections - can only be modified through the configuration tool
- C:\JRK DAQ\config\Requests.json
-
Export configuration - can only be modified through the configuration tool
- C:\JRK DAQ\logs
-
Service log files
2.1.3. Definitions
- Data Block
-
In a data block, data in a Siemens S7 controller is structured and named.
- Function Block
-
In function blocks, subroutines are stored in a Siemens S7 controller.
- Template File
-
Data from a data block is inserted into the template file.
2.2. Configuration Interface
2.2.1. Creating a Connection
The list on the left side of the main window displays the currently configured systems. A new connection can be added using the "Add" button. The "Filter" field can be used to search by PlcId or name.
Here, the PlcId and a name must be provided. The PlcId must match the one used in the connection block call in the PLC program, and the name can be chosen freely.
If an unconfigured system connects to the DAQ system, an entry with the name "AutoConfigured" will be automatically created for the PlcId. This entry can then be adjusted using the "Edit" button.
2.2.2. Adding Export Configuration
In the second step, the calls to the export function block must be configured.
The configured exports are displayed in the list.
2.2.3. Configuring Export
Clicking the "Add" or "Edit" button opens the settings dialog for export configuration.
-
Config ID: Must match the one in the S7 PLC program.
-
Choose Data Block Source, which defines the structure of process data and is provided by the PLC programmer.
-
Output file name can be composed using placeholders, see section on Placeholder Variables.
-
Append content to the output file if it exists (if unchecked, the file will be overwritten).
-
Header template file, used only if the output file doesn’t exist.
-
Template file in which values will be inserted.
-
Data block - displays the structure of the data block with process data. All values can be inserted into the template file. To do this, use the name displayed here, see section on Placeholder Variables
If a template file is changed, it will not be automatically reloaded. It needs to be selected again through the configuration dialog. |
2.3. Creating a Template File
Values from the data block are inserted into the template file to generate the output file. Placeholders are replaced by values from the data block, see section on Configuring Export.
{Barcode};{Temperature};{Pressure};{IO:PASS|FAIL}
Barcode;Temperature;Pressure;Result
Barcode;Temperature;Pressure;Result 1234567890;25.000;100.000;PASS 1234567890;25.000;100.000;PASS 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 1234567890;25.000;100.000;PASS 1234567890;25.000;100.000;PASS 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 1234567890;25.000;100.000;PASS 1234567890;25.000;100.000;PASS 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL 0123456789;30.000;25.000;FAIL
2.3.1. Placeholder Variables
Placeholder variables can be used in the template file. These placeholders are replaced with actual values from the S7 controller when generating the output file. Placeholder variables can have two forms:
-
{Name}
-
{Name:Format}
Name
can be:
-
The name of a variable from the data block of the station, see section Configuring Export
-
The name of a user-defined variable of the station, see section Configuring Export
-
One of the predefined variables:
{PlcId} PlcId of the current system
{ConfigId} ConfigId of the current export configuration
Format
is defined in the section Formatting Options.
If no format is specified, the following default formats are used:
Integer |
Without leading zeros |
Floating-point number |
Without leading zeros, 3 decimal places |
BOOL |
PASS for TRUE, FAIL for FALSE |
Date |
dd.MM.yy (see section Date and Time Formats) |
2.3.2. Formatting Options
2.3.2.1. Leading Zeros
{Variable:X}
X
|
Minimum number of digits, filled with leading zeros |
Format | Value of Variable | Output |
---|---|---|
|
|
→ |
|
|
→ |
|
|
→ |
2.3.2.2. Floating-Point Numbers
For REAL-type numbers in the S7 controller.
{Variable:X.Y}
X
|
Minimum number of digits before the decimal point, filled with zeros |
Y
|
Number of digits after the decimal point, filled with zeros, rounded if more digits |
Format | Value of Variable | Output |
---|---|---|
|
|
→ |
|
|
→ |
|
|
→ |
2.3.2.3. Fixed-Point Numbers
{Variable:X.Y}
For INT, DINT, BYTE, WORD, or DWORD-type numbers in the S7 controller.
X
|
Minimum number of digits before the decimal point, filled with zeros |
Y
|
Number of digits after the decimal point, filled with zeros, rounded if more digits |
The number is interpreted as a fixed-point number, and the decimal point is placed accordingly.
Format | Value of Variable | Output |
---|---|---|
|
|
→ 000.005 |
|
|
→ 000.123 |
|
|
→ 456.789 |
2.3.2.4. Exponential Notation
{Variable:X.YeZ}
{Variable:X.Ye+Z}
{Variable:X.YEZ}
{Variable:X.YE+Z}
X
|
Minimum number of digits before the decimal point, filled with zeros |
Y
|
Number of digits after the decimal point, filled with zeros, rounded if more digits |
Z
|
Minimum number of exponent digits, filled with zeros |
When the +
is provided, the sign will always be placed before the exponent. Otherwise, this only happens for negative exponents.
Format | Value of Variable | Output |
---|---|---|
|
|
→ |
|
|
→ |
|
|
→ |
|
|
→ |
2.3.2.5. Padding Texts Left/Right
{Variable:LY,Z}
|
The text is filled to length |
{Variable:RY,Z}
|
|
Format | Value of Variable | Output |
---|---|---|
|
|
→ |
|
|
→ |
|
|
→ |
|
|
→ |
|
|
→ |
2.3.2.6. Date and Time Formats
{Variable:Format}
Formats DATE_AND_TIME timestamp values from the S7 controller
The format can consist of the following characters:
Character | Meaning |
---|---|
|
Day 1-31 |
|
Day 01-31 |
|
Month 1-12 |
|
Month 01-12 |
|
Year 0-99 |
|
Year 00-99 |
|
Year as a four-digit number |
|
Hour 1-12 |
|
Hour 01-12 |
|
Hour 0-24 |
|
Hour 00-24 |
|
Minute 0-59 |
|
Minute 00-59 |
|
Second 0-59 |
|
Second 00-59 |
|
AM/PM indicator |
Format | Value of Variable | Output |
---|---|---|
|
|
→ |
|
|
→ |
2.3.2.7. Text Lists
{Variable:Option0|Option1|..|OptionX}
|
Depending on the value of the variable, the corresponding option is selected. |
For BOOL-type variables, when the value is TRUE, Option0 is chosen, and when the value is FALSE, Option1 is chosen.
Format | Value of Variable | Output |
---|---|---|
|
|
→ |
|
|
→ |
For INT, DINT, BYTE, WORD, or DWORD-type variables, when the value is 0, Option0 is chosen; when the value is 1, Option1 is chosen, and so on.
Note that the numbering starts from 0, not 1! |
Format | Value of Variable | Output |
---|---|---|
|
|
→ Red |
|
|
→ Green |
|
|
→ Blue |
|
|
→ Causes an error |
|
|
→ Causes an error |
If the value is outside the range, no file will be generated! |