S7-1x00 DataLogging DOC V4.0 en
S7-1x00 DataLogging DOC V4.0 en
monitoring process
data
Siemens
SIMATIC S7-1200 / S7-1500, STEP 7 V16 (TIA Portal) Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/64396156 Support
Legal information
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2020 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.
Table of Contents
Legal information ......................................................................................................... 2
1 Task ..................................................................................................................... 4
1.1 Overview............................................................................................... 4
2 Solution............................................................................................................... 5
2.1 Overview of the overall solution ........................................................... 5
2.2 Description of the core functionality ..................................................... 8
2.3 Hardware and software components used......................................... 11
3 Function Mechanisms of this application example ..................................... 14
3.1 General functions ............................................................................... 16
3.1.1 FB "LGF_SinusCI" .............................................................................. 16
3.1.2 FB "LGF_Impulse" .............................................................................. 16
3.2 FB "DataLog1200"/"DataLog1500" .................................................... 17
3.2.1 FC "Num2Name" ................................................................................ 20
3.3 FB "TMAIL_C" .................................................................................... 21
3.4 SIMATIC Automation Tool.................................................................. 23
3.5 Remote access to the controller ......................................................... 26
4 Commissioning the application example ...................................................... 27
4.1 Hardware customization ..................................................................... 27
4.2 PG/PC system settings ...................................................................... 28
© Siemens AG 2020 All rights reserved
1 Task
1.1 Overview
Introduction
Supermarkets and discount retailers must guarantee certain foodstuffs remain
refrigerated. If the cooling chain is broken, these foodstuffs can no longer be sold
but must be discarded.
This is why the cooling temperature must be continually recorded, archived and
monitored (with reporting functionality).
Discounter
© Siemens AG 2020 All rights reserved
Data Logging
ALARM
2 Solution
2.1 Overview of the overall solution
The STEP 7 development environment (TIA Portal) provides "Data log" data
recording for the SIMATIC S7-1200/S7-1500. Using these instructions, process
data can be saved in CSV format (comma-separated value) in the CPU's flash
memory (only with S7-1200) or on an inserted Memory Card.
You can access these CSV data logs as follows (for instance, to analyze them in
Microsoft Excel):
Table 2-1
No. Access type Saved in flash memory...
Reading out via... ...of the CPU ...On the SIMATIC Memory Card
(S7-1200 only) (SMC)
1. ...card reader no yes (CPU must be stopped for this)
2. ...integrated PLC web server yes yes
3. …SIMATIC Automation Tool no yes (also possible to automate
Version V3.1.4 (\16\) using
ApplicationProgrammingInterface)
4. ...as an attachment to an yes yes (automated by calling the
email sent from the CPU instruction "TMAIL_C" V6.0)
© Siemens AG 2020 All rights reserved
In the application example, the data logs will be saved on a Memory Card that is
inserted into the CPU. Manual access from the remote station will be displayed via
the integrated PLC web server. The DataLog files will be automatically uploaded
through the SIMATIC Automation Tool Version 3.1 SP4.
The SIMATIC S7-1x001 is capable of routing, which makes remote access over the
internet possible. For secure communication, the connection is available via a VPN
tunnel (virtual private network) with the appropriate hardware.
The "TMAIL_C" instruction V6.0 offers encrypted email sending through the
internal interface of the CPU, along with optional attachment functionality for files in
the file browser (such as Data Logs). To do this, the CPU needs an internet
connection and an existing account with an email provider with SMTP server
(simple mail transfer protocol) (\17\).
This function is used to implement alarm messaging and sending of the data log
file.
You can also send the alarm message as an SMS using a communications
extension:
• via SCALANCE M router or (\14\)
• via the CP 1242-7 GPRS for the S7-1200 (\15\)
This application example was tested with
• STEP 7 V16 (TIA Portal)
• S7-1200 CPU Firmware V4.4
• S7-1500 CPU Firmware V2.8
Note Additional information on calculating the service life of the SIMATIC Memory
Card can be found under \13\.
1 In the following, the S7-1200 and S7-1500 will be collectively referred to as S7-1x00.
Diagram
The following figure shows the most important components of the solution:
Figure 2-1
Service-PC with Email-Provider Email-Provider (Sender) Automation
• TIA Portal for remote maintenance • Receipt of the email dispatch order
(Recipient) • Sending email to recipient
network
• Goggle Chrome for • Receiving the email
manual DataLog upload
• SIMATIC Automation Tool for
automatic DataLog upload
• Email reception (email client
• for recipient providers)
Gateway- Gateway-
Server Server
SCALANCE
TS Adapter IE
Internet Internet Internet M874-x
Advanced
Win 10 Modem/ Router
Modem/ Router Router
Advantages
This application example offers you the following advantages:
• Introduction to data logging with all functions
• Alarm generation via secure email
• Transmission of data logging, event-triggered as an email attachment
• Transmission of data logging, time-triggered via the API of the SIMATIC
Automation Tool
• Basics of remote maintenance through a VPN tunnel
Delimitation
The following system function blocks are called according to their function and
described:
• For data logging:
– DataLogCreate V1.0
– DataLogOpen V1.1
– DataLogWrite V1.0
– DataLogClear V1.1
– DataLogClose V1.0
– DataLogDelete V1.1
© Siemens AG 2020 All rights reserved
– DataLogNewFile V1.1
• "TMAIL_C" V6.0 for email sending
A detailed description of these instructions can be found in the Online Help in TIA
Portal by selecting the block and pressing F1, or in the system manual for STEP 7
(TIA Portal) (\6\).
This application example only describes the basics on creating a VPN tunnel.
Please refer to \10\ for a detailed description of the topic "Secure remote access
with VPN".
Secure email sending is implemented with the CPU's internal interface. This variant
also offers data log file sending as an email attachment. Further information on
sending secure requests to the email provider, even via the communications
extension with a Security CP, can be found in the application example
"Sending e-mails to the SMTP server with an S7 CPU" (\17\).
Refer to the application examples \14\ and \15\ for the alarm message via SMS
function.
The API of the SIMATIC Automation Tool provides the basis for automatic
uploading of data log files. A detailed description of the SIMATIC Automation Tool
V3.1 SP4 can be found in the user manual (\19\).
Required knowledge
Basic knowledge on the topic of "network communication" is assumed.
The data log instructions are used in the user program to save process values to
log files. The log files can be stored on the Memory Card (MC) or in the internal
storage of the CPU (only S7-1200). The log files are saved in CSV format. You can
access the CSV file as described in Table 2-1.
In this application example, the "Data Log" functionality consists of the following
seven instructions:
"DataLogCreate"
Figure 2-3
Use the "DataLogCreate" instruction to create data log file in the "\DataLogs" folder
of the load memory and specify the name ("NAME" parameter) and the maximum
number of data records ("RECORDS" parameter).
Choose the time stamp format with the "TIMESTAMP" parameter.
The data to be recorded are specified as a structure or PLC data type via the
"DATA" parameter.
Specify the headers (column headers) of the recorded data in the data log with the
"HEADER" parameter.
Creating a data log file with a specified name will generate a number ("ID"
parameter), which can be used to identify this file.
"DataLogOpen"
Figure 2-4
S7-1200 S7-1500
The "DataLogOpen" instruction opens an already existing data log file. A data log
file must be opened in order to write new data records to the file. You can use the
parameter "MODE" to decide whether the existing data records will be overwritten.
You can select the data log with the "ID" parameter. When "ID" = 0, the data log to
be opened will be specified by the name "NAME".
Opening the data log file with the "NAME" parameter will return the "ID" that other
DataLog instructions can use to access this file.
© Siemens AG 2020 All rights reserved
For the S7-1500, the "DataLogOpen" instructions also contain the interface
parameter "Data" (pointer to the data structure of the data log). In comparison to
the S7-1200, this enables verification of data consistency.
"DataLogWrite"
Figure 2-5
The "DataLogWrite" instruction writes a data record to the specified data log. The
already existing target data log must be opened so that the "DataLogWrite"
instruction can be run.
You can select the data log with the "ID" parameter.
"DataLogClear"
Figure 2-6
"DataLogClose"
Figure 2-7
You can select the data log with the "ID" parameter.
"DataLogNewFile"
Figure 2-8
S7-1200 S7-1500
You will use the "DataLogNewFile" instruction to create a new data log with the
same properties as an existing data log file and a new name. Specify the maximum
number of data records with the "RECORDS" parameter.
The template file is specified with the "ID" parameter. Once the new data log file
with a new name ("NAME" parameter) is created, a new "ID" will be generated and
output for this file.
For the S7-1500, the "DataLogNewFile" instructions also contain the interface
parameter "Data" (pointer to the data structure of the data log). In comparison to
the S7-1200, this enables verification of data consistency.
"DataLogDelete"
Figure 2-9
Note More detailed information on Data Logging can be found in the Online Help in
TIA Portal by selecting the block and pressing F1, or in the system manual for
STEP 7 (TIA Portal) (\6\).
Hardware components
Table 2-2
Components Qty. Order number Note
POWER SUPPLY S7-1200 1 6EP1332-1SH71
PM1207
CPU 1211C, DC/DC/DC, 1 6ES7211-1AE40-0XB0 Firmware V4.4.0 (\4\)
6DI/4DO/2AI
CPU 1511C-1 PN 1 6ES7511-1CK01-0AB0 Firmware V2.8.2 (\5\)
SIMATIC S7 MEMORY 1 6ES7954-8LF02-0AA0 Insertable load memory; for saving the
CARD, 24 MB DataLog files;
created as Program card (\3\)
Remote service PC 1 With internet connection
Ethernet cable 4 6XV1870-3QH20
TP CORD RJ45/RJ45 2M
Circuit breakers 1 5SY6116-6 1-pin B, 16A
DSL modem 1–2 --- Depends on provider and router
TS Adapter IE Advanced 1 6ES7972-0EA00-0XA0 Optional (for other VPN server variants,
see \10\)
Table 2-3
No. Components Qty. Order number Note
5. SIMATIC STEP 7 1 6ES7822-0AA06-0YA5 • With update 1 (\8\)
Basic V16 • For configuration of the
S7-1200
6. SIMATIC STEP 7 1 6ES7822-1AA06-0YA5 • With update 1 (\8\)
Professional V16 • For configuration of the
S7-1200 and S7-1500
7. SIMATIC Automation 1 6ES7853-1AE03-0YA5 (\16\);
Tool V3.1 SP4 license required for use of the API
8. .NET Framework 4.6.2 1 Required to run the
"UploadDataLog.exe" file
9. Microsoft Excel 1 Component of
Microsoft Office
10. Task Scheduler Part of Windows 10 operating
system
The following list contains all files and projects used in this example.
Table 2-4
No. Components Note
1. 64396156_S7-1x00_DataLogging _TiaV16_CODE_V4.0.zip This compressed file contains the
STEP 7 project.
2. 64396156_SAT_UploadDataLog_SatV3.1.4_EXE_V1.4.zip This packed file contains the
executable program,
"UploadDataLog.exe", for
uploading the DataLog data in
connection with the SIMATIC
Automation Tool V3.1.4 or later
(\16\), as well as the source code
in C#.
3. 64396156_S7-1x00_DataLogging_DOC_V4.0_en.pdf This document.
Passwords
Project registration
Figure 2-10
Siemens.1
For the S7-1x00, the access level "HMI access" is selected (chapter 4.3.2).
The following passwords are assigned:
Table 2-5
Access level Password
© Siemens AG 2020 All rights reserved
repeats until the specified maximum number of new data logs is reached and
the labeling begins again from the start in the original data log. Using the
preset parameters, the data records are deleted before the first recording.
• FB "TMAIL_C", together with the instance DB "InstTmailcCsvTransfer" sends
an email with the temperature data log as an attachment once the maximum
number of data records has been reached (FB "DataLog1x00" with instance
DB "InstDataLogNewFile").
The tags for parameter entry of the interfaces for the function blocks are located in
the DB "Data".
The last error-free and error-containing runs through the functions described above
are each retained with a time stamp. In the event of a run with errors, the status
and sub-status will be saved.
Figure 3-1
Cyclic LGF_
Interrupt SinusCI
LGF_
Impulse
DataLog
Main Data
1x00
InstDataLog
SameFile
TMAIL_C
© Siemens AG 2020 All rights reserved
InstTmailc
Alarm
DataLog
1x00
InstDataLog
NewFile
TMAIL_C
InstTmailc
CsvTransfer
Organisation Instance
blocks Instructions data blocks Data blocks
3.1.1 FB "LGF_SinusCI"
3.1.2 FB "LGF_Impulse"
3.2 FB "DataLog1200"/"DataLog1500"
The FB "DataLog1x00" coordinates data logging. The aim is to write a data record
into the data log (data logging file). To do this, the data log is created, opened and
written to, depending on the initial circumstances.
You can program the behavior in the event of an overflow (maximum number of
data records exceeded):
• Write to the existing data log with/without prior emptying (ring buffer)
• Close the existing data log and create/open and write to a new data log
with/without prior emptying
You also have the option of deleting the (newly) created data log.
The FB "DataLog1x00" exists for the SIMATIC S7-1200 (FB "DataLog1200") and
the S7-1500 (FB "DataLog1500"), as the interfaces for the instructions
"DataLogOpen" and "DataLogNewFile" contained therein differ depending on
controller.
The functionality of the FB "DataLog1x00" is identical, however.
full Bool
currentName String
data
Variant Variant
Figure 3-4 shows the program sequence chart of the FB "DataLog1x00" for the
write process ("write" = TRUE).
Figure 3-4
© Siemens AG 2020 All rights reserved
Then the data log will be written to with the current data record using the
"DataLogWrite" instruction. When writing is successful (done) the data record
counter will be incremented (n:=n+1) and queried whether the maximum number of
data records has been reached (n = nMax?). If so, this will be signaled (full
:=TRUE).
A query will then be issued whether the maximum number of new data logs has
been reached (m = mMax?). If this is not yet true, the current data log will be
closed using the instruction "DataLogClose", this will be registered (closed :=
TRUE) and the counter incremented for new data logs (m:=m+1).
Furthermore, in the event of an error message (error) for the DataLog instructions,
the following statuses will be stepped accordingly:
• In the event of non-existent data log ("Not exist"), jump to instruction
"DataLogCreate".
• In the event of data log not opened ("Not open"), jump to instruction
"DataLogOpen".
• In the event of existing data log ("Already exist"), also jump to instruction
"DataLogOpen".
When the data log is created successfully (done), the data record counter will be
reset (n:=0) using the instruction "DataLogCreate", and is thus synchronized (sync
:= TRUE).
All data logs with the name "<name>" to "<name>_<newFileMax>" will be deleted
using the input "delete" (= TRUE). The "delete" input has a higher priority than the
"write" input. Therefore "delete" must = FALSE in order to execute a write
© Siemens AG 2020 All rights reserved
In the application example, the FB "DataLog1x00" for data logging the temperature
is called twice in the cyclic OB "Main":
• with the instance DB "InstDataLogSameFile" for writing to the existing data log
(without prior emptying) in the event of an overflow: Using this data log, the
automatic upload is performed via the SIMATIC Automation Tool
(Table 2-1 no. 3).
• with the instance DB "InstDataLogNewFile" for creating/opening and writing to
a new data log (with prior emptying) in the event of an overflow: Upon reaching
the maximum number of data records, the current data log will be sent as an
email attachment while the new data log can continue being written to
(Table 2-1 no. 4).
3.2.1 FC "Num2Name"
The FC "Num2Name" takes the string "nameIn" and "number" and generates the
"nameOut" in the form "<nameIn>_<number>".
It is called in the FB "DataLog1x00" and specifies for "newFileMax" > 0 the name of
the new data log for the instructions "DataLogNewFile" and "DataLogOpen" and
"DataLogDelete".
USInt number
3.3 FB "TMAIL_C"
The FB "TMAIL_C" uses SMTP (Simple Mail Transfer Protocol) to send an email
over TCP/IP on the CPU's Industrial Ethernet connection.
"TMAIL_C" is executed asynchronously and the command extends over multiple
© Siemens AG 2020 All rights reserved
Figure 3-6
© Siemens AG 2020 All rights reserved
The connection data, addressing and authentication for the mail server are passed
at the parameter "MAIL_ADDR_PARAM".
The email is sent via the integrated interface of the CPU by means of a secured
connection (SNMP over TSL) to an external email server.
The system data type "TMail_QDN_SEC" is used at the parameter
"MAIL_ADDR_PARAM".
Once activated, "TMAIL_C" logs in to the mail server (specified with the fully-
qualified domain name) with the access credentials (username and password) and
the X.509 V3 certificate loaded on the CPU (CA) for the mail server (with which the
TLS client validates the authentication from the TLS server); it then sends the email
request with the specified recipient address and the specified text (as well as
attachment).
Refer to application example \17\ for more information on the topic "Sending emails
over secured email connections".
Note The console application runs at the Windows Command Prompt "cmd.exe". The
sequence of the arguments is specified in Table 3-3. The arguments are
separated by spaces.
• The console application lists the available network adapters and displays the
error message "WRONG NUMBER OF ARGUMENTS !!!", since the application
requires that 4 or 5 arguments be passed.
• Remember the number of the network adapter to browse to.
Note: The network adapter with the "Auto" affix makes it possible to reach the CPU
for the network adapter setting DHCP.
5. Start the console application with the necessary arguments (see Table 3-3):
"UploadDataLog.exe 1 192.168.0.2 DataLog.csv c:\MyDataLogs read"
No. Action
check if folder ‚DataLogs‘ exists
• Display number of data logs found
1 data log files are found
• Check the found data logs with the searched file names:
check data log name 'DataLog.csv'
• Upload the selected DataLog file to the specified destination folder:
upload data log to destination c:\MyDataLogs
© Siemens AG 2020 All rights reserved
7. Open the destination folder and check whether the selected DataLog file exists.
Note If you receive an error message, please check the accessibility of the CPU - for
example via the ping command in the Command Prompt - and modify the
settings of the network adapter if you absolutely must.
A simultaneous online connection to the S7-1200, for example with STEP 7 (TIA
Portal), will prevent access to the data logs.
If you wish to modify the program code of the file "UploadDataLog.exe", you will
find a description of how to create a console application in Microsoft Visual Studio
in chapter 3.1 of the application example "Automated loading and archiving of the
CPU service data by means of the SIMATIC Automation Tool via the Application
Programming Interface (API)" (\12\).
Remote access to the controller via the internet is not necessarily required for
manual downloading of the recorded DataLog files. Local access is also sufficient
for demonstration purposes.
However, internet access is required to send emails via external providers.
For email sending, you must enable the port or protocol for outgoing connections
on the VPN server (router or TS Adapter IE Advanced):
• TCP port 465: SMTPS (Simple Mail Transfer Protocol over Secure Socket
Layer) or
• TCP port 587: MSA (Mail Submission Agent) with STARTTLS
• UDP port 123: NTP (Network Time Protocol)
The following protocols must be enabled for incoming connections on the VPN
server (router or TS Adapter IE Advanced):
• Simple Network Management Protocol (SNMP) for email sending
• Hyper Text Transfer Protocol over Secure Socket Layer (HTTPS) for retrieving
the CPU web server in an internet browser
• Internet Control Message Protocol (ICMP) to ping the CPU
Hardware installation
The following figure shows the hardware setup of the application.
Figure 4-1
L1
N
PE
DC24V+
DC24V-
WAN
LAN IP adress 192.168.0.2
Subnet mask 255.255.255.0
IP adress 192.168.0.1
Router adress 192.168.0.1
Subnet mask 255.255.255.0
DNS server
DSL-Router2
CPU 1511C-1 PN
IP adress 192.168.0.3
Subnet mask 255.255.255.0
Router adress 192.168.0.1
DNS server
Wi-Fi DSL-Router1
ISDN
Remote
IP adress Win 10 Service PC
Subnet mask
Router adress
DHCP
Note Please refer to the S7-1200 system manual (\3\) for how to Import CSV format
data logs to non-USA/UK versions of Microsoft Excel.
Table 4-2
No. Action
1. Open the Windows Task Scheduler by clicking the Windows 10 icon and searching
for it.
© Siemens AG 2020 All rights reserved
No. Action
3. This will open the "Create Basic Task Wizard".
• Assign a name.
• Click on "Next >".
No. Action
5. The current date is used as the start date.
• Input a start time.
• Click on "Next >".
•
© Siemens AG 2020 All rights reserved
No. Action
7. Enter the following entries in the "Start a program" settings window:
• Program/script:
UploadDataLog.exe
• Adding arguments (optional):
1 192.168.0.2 DataLog.csv c:\MyDataLogs read
• Start in (optional):
c:\Program Files\Siemens\Automation\SimaticAutomationTool\bin\
Click on "Next >".
© Siemens AG 2020 All rights reserved
No. Action
9. • In the "General" screen under "Security options", select the option "Run
whether user is logged on or not".
• Select the "Run with highest privileges" option.
• Under "Configure for:" select "Windows 10"
• Switch to the "Triggers" screen.
© Siemens AG 2020 All rights reserved
No. Action
11. • In "Advanced settings" activate the option "Repeat task every:"
• Select "5 minutes" as the interval.
• Select "for a duration of:" "1 day"
• Check the option "Stop all running tasks at end of repetition duration".
• Check "Stop task if it runs longer than:"
• Select "4 minutes" as the time.
• Accept the settings with "OK".
© Siemens AG 2020 All rights reserved
No. Action
13. • Under "Power", select the option "Wake the computer to run this task".
• Finish setting the properties of the scheduled task by clicking "OK".
© Siemens AG 2020 All rights reserved
14. Due to the security option "Run whether user is logged on or not" in step 9, you
must enter the user account information assigned to perform this task and confirm
with "OK".
15. You can check this function in the "Task Scheduler Library" view.
The created tasks are listed here.
Select the task "UploadDataLog" and press the action "Run" under "Selected Item".
The console application "UploadDataLog.exe" will now run every 5 minutes and
loads the DataLog file "DataLog.csv" (3rd argument) via the network adapter "1"
(1st argument) from the CPU's SIMATIC Memory Card with IP address
"192.168.0.2" (2nd argument) and saves it in the folder "c:\MyDataLogs" (4th
argument). The password for write-protected access to the CPU is "read" (5th
argument).
© Siemens AG 2020 All rights reserved
In order to send the email, the FB "TMAIL_C" needs the email address of the
recipient and the access credentials to your email account, as well as the certificate
of the email provider (sender).
The example project was tested with a Gmail (equivalent to a Google Mail)
account.
The presets and certificate import have already been completed for this.
Table 4-3
No. Action
1. Select your controller and open the OB "Main" in STEP 7 (TIA Portal).
© Siemens AG 2020 All rights reserved
Note: Of course, you can also enter the email address of the sender in order to
receive the email generated by the FB "TMAIL_C" yourself.
No. Action
3. Open the data structure "tmailcAlarm > mailAddrParam" in the DB "Data".
Enter the access credentials for your email account as starting value:
Sending of emails has been tested with a Gmail/Google Mail account. The data
structure "mailAddrParam" contains the presets for this.
You must enter the following starting values if you have a Gmail or Google Mail
account:
• At the "UserName" parameter, enter the access name of the email account as
a string.
e.g.: ’[email protected]’
• At the "PassWord" parameter, enter the password of the email account as a
string.
e.g.: ’Password’
Enter the following parameters under "From":
• "LocalPartPlusAtSign" - the local part of the sender email account address
including the @ character
e.g.: ’sender@’
• "FullQualifiedDomainName" - the name of the email account domain name
e.g.: ’googlemail.com’
© Siemens AG 2020 All rights reserved
Note: If the email provider is different, you will also need the following data:
• FQDN (Fully Qualified Domain Name) of the email server, "MailServerQDN"
(line 15)
• TCP port of the email server, "RemotePort" (line 21)
• Reference to the previously imported X.509 V3 (CA) certificate of the email
server "TLSServerCertRef" (line 24)
Additional information on downloading and importing the necessary certificates can
be found in chapter 2.2 of the application example "Sending Emails to SMTP
Servers with an S7 CPU" \17\.
4. Repeat steps 2 and 3 in the data structure "tmailcCsvTransfer" in the DB "Data" for
the DataLog transfer.
No. Action
5. Make the necessary settings in your Gmail or Google Mail account:
• Enable IMAP
• Access through less secure apps
A detailed description of this topic can be found in chapter 2.2.2 of the application
example "Sending Emails to SMTP Servers with an S7 CPU" (\17\).
The CPU Ethernet address and time of day properties must be individually
customized. In addition, the web server must be enabled so that the DataLog files
can be loaded via remote access.
Table 4-4
No. Action
1. Select the controller and right-click to open the "Properties...".
© Siemens AG 2020 All rights reserved
2. • Under "PROFINET interface > Ethernet addresses > IP protocol", enable the
option "Use router".
• Enter the IP address of your VPN-capable router (on the controller side).
• Adjust the IP address and the subnet mask to match your router network.
No. Action
3. • Under "PROFINET interface > Time synchronization", select the option "Enable
time synchronization via NTP server".
• Enter at least one IP address of your reachable NTP server.
Note: NTP requires that port 123 be enabled for the UDP networking protocol.
The IP address of the Deutsche Telekom AG, Darmstadt NTP server "ntp1.sda" is
already filled in this project.
The correct CPU system time is required for certificate comparison.
• Under "User management", open the settings for the access level of the user
"Everyone" with the button.
The "Everyone" user does not need a password for web server access. If you wish
to secure access with a password, you must "<Add new user>", assign a password
and make the following settings for the access level.
No. Action
5. Enable the settings:
"The user is authorized to..."
• ...read watch tables
• ...read files
Apply the settings with the button.
© Siemens AG 2020 All rights reserved
No. Action
7.
• Enter the password "full", confirm it and apply the settings with the button.
• Repeat steps 6 and 7 for the access level "Read access" with the password
"read".
You can use "Add new" for other previously imported certificates (see \17\ chapter
2.2).
9. • Under "Advanced configuration", open "DNS configuration".
• Enter the DNS server address (see Figure 4-1).
10.
Click the button to apply the CPU properties.
Before remotely accessing the S7-1x00, the CPU interface must be parameterized
according to specification (see Figure 4-1).
To do this, load the project to the CPU via direct connection on site, as described
below:
Table 4-5
No. Action
1. • Save the project.
• Select the program folder of the S7-1x00 and transfer the program to the
controller with "Online > Download and reset PLC program".
No. Action
4. Confirm the "Load preview" by clicking the "Load" button.
5. • You may need to enter the password "full" for full access.
• Confirm the entry with "OK".
© Siemens AG 2020 All rights reserved
Note Data logs are stored persistently ("non-volatile") in the load memory of the
controller, thus making them secured against power failure and program
changes.
You can delete the data logs as follows:
• With the "DataLogDelete" instruction (as in FB "DataLog1x00")
• Via the enabled function in the web server
• With the SIMATIC Automation Tool
• Via direct access to the SIMATIC Memory Card using a card reader
• Through online access to the SIMATIC Memory Card via TIA Portal:
Format the SIMATIC Memory Card and/or reset CPU to factory settings
If you modify the recorded data ("data") of the FB "DataLog1x00", they will only be
transferred to the CSV file after the data log file has successfully been generated
again with "DataLogCreate".
If you leave the name of the data log ("name") unchanged, the FB "DataLog1x00"
will try to write to the existing data log with the original data structure.
You can successfully re-generate the data log file by deleting the existing data
log(s) with the "delete" input.
Proceed as follows to do this:
Table 4-6
No. Action
1. • Open the data block "Data".
• Press the "Monitor all" button.
• Change the tag "delete" (here shown with the example "dataLogNewFile") to
TRUE by double-clicking.
© Siemens AG 2020 All rights reserved
No. Action
3. • Open the structure "dataLogNewFile".
• Add a new tag to the "data" structure, for example.
5. • Then download the modified project to the CPU (see chapter 4.3.3).
The modified data log will be re-generated at a positive edge at the "write" input
("Data".write).
No. Action
4. The certificate is shown.
• Click the "Install certificate..." to start the Certificate Import Wizard.
No. Action
7. • Select "Place all certificates in the following store".
• Click the "Browse" button.
• Select "Trusted Root Certification Authorities" as certificate store.
• Click "OK" to confirm your selection, then press "Next".
© Siemens AG 2020 All rights reserved
9. • Click "OK" to close all windows once the certificate has successfully imported.
You must then restart Google Chrome so that the certificate will be recognized
when the web server is retrieved.
Table 5-1
No. Action
1. Establish the VPN connection.
No. Action
4. • Open the watch table "WatchTable" in STEP 7 (TIA Portal).
Note: If you then receive a message "There is a problem with this website's security
certificate.", then download the Siemens security certificate as described in
chapter 4.4.
© Siemens AG 2020 All rights reserved
3. You will then see a list of all existing DataLog files with file size and time stamp of
most recent access.
• Click on the name of the file you want (here: "DataLog.csv").
No. Action
4. Using the display window, you have the ability to open the CSV file or save it.
• Click "Open" (2x).
5. Thanks to the region settings made earlier (see chapter 4.2.1), the CSV file will be
shown in Microsoft Excel properly divided into columns for
• Data record number "Record"
© Siemens AG 2020 All rights reserved
• Date "Date"
• Time stamp "UTC Time"
• Temperature "Temperature"
.
Table 5-3
No. Action
1. • Open the Windows Task Scheduler program.
2. The task "UploadDataLog" task created in chapter 4.2.2 is listed in the "Task
Scheduler Library" under "Task Scheduler (Local)".
• If this task is disabled (see column "Status"), select the task and enable it via
"Actions > Selected item".
3. When the status indicates "Ready", the task is performed every 5 minutes.
The security option "Run whether user is logged on or not" (Table 4-2 step 9)
© Siemens AG 2020 All rights reserved
2. If the alarm email was not successfully received, please check the last status
messages of the "TMAIL_C" block (with the instance DB "InstTmailcAlarm").
• To do this, open the watch table "WatchTable".
Under "TMAIL_C - Alarm" you will find the time stamp for the last successful
("done") or faulty ("error") runs of the FB "TMAIL_C", as well as the returned status
("status") and SFB_STATUS ("sfbStatus") in the event of an error.
Refer to the description of the "TMAIL_C" block for an interpretation (\6\).
6 Appendix
6.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
support.industry.siemens.com
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
www.siemens.com/industry/supportrequest
© Siemens AG 2020 All rights reserved
Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
support.industry.siemens.com/cs/sc
https://support.industry.siemens.com/cs/ww/en/view/109775861
\10\ Overview document: Secure remote access with VPN
https://support.industry.siemens.com/cs/ww/en/view/26662448
\11\ Why is the "Certificate error" message shown in the address line when downloading
the web page of an S7-300/400/1200 CPU over "https://..."?
https://support.industry.siemens.com/cs/ww/en/view/63314183
\12\ Automated loading and archiving of the CPU service data by means of the SIMATIC
Automation Tool via the Application Programming Interface (API)
https://support.industry.siemens.com/cs/ww/en/view/109760829
\13\ How do you calculate the service life of a memory card of the S7-1500/S7-1200 and
ET 200?
https://support.industry.siemens.com/cs/ww/en/view/109482591
\14\ Sending and Receiving SMS Messages via a SCALANCE M Router
https://support.industry.siemens.com/cs/ww/en/view/54361177
\15\ Signaling and Switching via SMS with S7-1200 and CP 1242-7 GPRS V2 (Set 32)
https://support.industry.siemens.com/cs/ww/en/view/58638283
\16\ SIMATIC Automation Tool - the tool for support during commissioning, service and
maintenance of SIMATIC devices
https://support.industry.siemens.com/cs/ww/en/view/98161300
\17\ Sending Emails to SMTP Servers with an S7 CPU
https://support.industry.siemens.com/cs/ww/en/view/46817803
\18\ Library with general functions (LGF) for SIMATIC STEP 7 (TIA Portal) and SIMATIC
S7-1200 / S7-1500
https://support.industry.siemens.com/cs/ww/en/view/109479728
\19\ SIMATIC Automation Tool V3.1 SP4 User manual
https://support.industry.siemens.com/cs/ww/en/view/109774222