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.

daq

1.2. Integrating Blocks

1.2.1. Opening the Library

  1. Activate the "Libraries" tab on the right side of the TIA Portal.

  2. Expand "Global Libraries."

  3. Click the "Open Global Library" button.

  4. Select and open the JRK_DAQ_V1 library.

open
  1. Expand the JRK_DAQ_V1 library.

  2. 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.

copy en

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.

connection

1.2.3. Preparing the Process Data Block

Manually assign the data block number.

block no

For the export, it’s necessary to deactivate the optimized block access. The attribute must be set accordingly.

block access

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.

export

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.

block generate

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 Codes Connection
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 Codes for Export
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

System Architecture

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

Connections

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.

Add Connection

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.

Configurations

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.

Add/Edit Configuration
  1. Config ID: Must match the one in the S7 PLC program.

  2. Choose Data Block Source, which defines the structure of process data and is provided by the PLC programmer.

  3. Output file name can be composed using placeholders, see section on Placeholder Variables.

  4. Append content to the output file if it exists (if unchecked, the file will be overwritten).

  5. Header template file, used only if the output file doesn’t exist.

  6. Template file in which values will be inserted.

  7. 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.

Example Template File:
{Barcode};{Temperature};{Pressure};{IO:PASS|FAIL}
Example Header Template File:
Barcode;Temperature;Pressure;Result
Example Generated Output File:
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:

  1. {Name}

  2. {Name:Format}

Name can be:

  1. The name of a variable from the data block of the station, see section Configuring Export

  2. The name of a user-defined variable of the station, see section Configuring Export

  3. 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

Examples:
Format Value of Variable Output

{Variable:4}

5

0004

{Variable:4}

123

0123

{Variable:4}

12345

12345

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

Examples:
Format Value of Variable Output

{Variable:3.3}

0.5

000.500

{Variable:3.3}

0.123

000.123

{Variable:3.3}

7.8906

007.891

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.

Examples:
Format Value of Variable Output

{Variable:3.3}

5

→ 000.005

{Variable:3.3}

123

→ 000.123

{Variable:3.3}

456789

→ 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.

Examples:
Format Value of Variable Output

{Variable:1.3e3}

0.005

5.000e-003

{Variable:2.3E2}

0.005

50.000E-04

{Variable:1.3E3}

54

5.400E001

{Variable:1.3e+3}

0.005

5.400e+001

2.3.2.5. Padding Texts Left/Right
{Variable:LY,Z}

The text is filled to length Y with character Z

{Variable:RY,Z}

L - characters are added on the left. R - characters are added on the right.

Examples:
Format Value of Variable Output

{Variable:R4,0}

42

4200

{Variable:L4,0}

ab

00ab

{Variable:R5,.}

xyz

xyz..

{Variable:R5, }

42

42___

{Variable:L5, }

abcdef

abcdef

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:

Date and Time Formats
Character Meaning

d

Day 1-31

dd

Day 01-31

M

Month 1-12

MM

Month 01-12

y

Year 0-99

yy

Year 00-99

yyyy

Year as a four-digit number

h

Hour 1-12

hh

Hour 01-12

H

Hour 0-24

HH

Hour 00-24

m

Minute 0-59

mm

Minute 00-59

s

Second 0-59

ss

Second 00-59

tt

AM/PM indicator

Examples:
Format Value of Variable Output

{Variable:dd.MM.yyyy HH:mm:ss}

2021-04-01T14:42:32

01.04.2021 14:42:32

{Variable:hh:mm:ss tt}

2021-04-01T14:42:32

02:42:32 PM

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.

Example for boolean variables:
Format Value of Variable Output

{Variable:YES|NO}

TRUE

YES

{Variable:YES|NO}

FALSE

NO

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!
Example for Integer Variables:
Format Value of Variable Output

{Variable:Red|Green|Blue}

0

→ Red

{Variable:Red|Green|Blue}

1

→ Green

{Variable:Red|Green|Blue}

2

→ Blue

{Variable:Red|Green|Blue}

3

→ Causes an error

{Variable:Red|Green|Blue}

-1

→ Causes an error

If the value is outside the range, no file will be generated!