Note The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These Application Examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these Application Examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these
Application Examples and other Siemens publications e.g. Catalogs the
contents of the other documents have priority.
We do not accept any liability for the information contained in this document.
Any claims against us based on whatever legal reason resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (Produkthaftungsgesetz), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
Siemens AG 2017 All rights reserved
Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, systems, machines and networks.
tion 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 only
form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems,
machines and networks. Systems, machines and components should only be
connected to the enterprise network or the internet if and to the extent necessary
and with appropriate security measures (e.g. use of firewalls and network
segmentation) in place.
Additionally, Siemens guidance on appropriate security measures should be
taken into account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens products and solutions undergo continuous development to make them
more secure. Siemens strongly recommends to apply product updates as soon
as available and to always use the latest product versions. Use of product
versions that are no longer supported, and failure to apply latest updates may
increase customers exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial
Security RSS Feed under http://www.siemens.com/industrialsecurity.
Table of Contents
Warranty and Liability ................................................................................................. 2
1 Introduction ........................................................................................................ 4
1.1 Overview............................................................................................... 4
1.2 Mode of Operation ................................................................................ 6
1.3 Components used ................................................................................ 8
2 Engineering ........................................................................................................ 9
2.1 Interface description "Ftp1X00Cmd" .................................................... 9
2.2 Configuring the FTP server ................................................................ 10
2.3 Integration into the user project .......................................................... 14
2.4 Operating "Ftp1X00Cmd" ................................................................... 18
2.5 Error handling of "Ftp1X00Cmd" ........................................................ 20
3 Valuable Information ....................................................................................... 21
3.1 Basics ................................................................................................. 21
3.2 Alternative solutions ........................................................................... 22
4 Annex ................................................................................................................ 23
4.1 Service and support ........................................................................... 23
4.2 Links and literature ............................................................................. 24
4.3 Change documentation ...................................................................... 24
Siemens AG 2017 All rights reserved
1 Introduction
1.1 Overview
Initial situation
The common File Transfer Protocol (FTP) offers you the opportunity to store data
on server systems. FTP supports almost all server and operator systems.
All controllers of the product families S7-300, S7-400 and S7-1500 support the FTP
communication via special communication processors (CPs).
This application example shows you how a S7-1200 or S7-1500 can also use the
FTP communication without a special CP with certain FTP servers on the basis of
the open user communication (TCON, TSEND, TRCV and TDISCON).
Note The function of this application example can only be guaranteed with the FTP
servers tested.
FTP
PROFINET IE
+
ET 200SP
S7-1500 S7-1200
S7-300 with S7-400 with S7-1500 with CPU
CP 343-1 CP 443-1 CP 1543-1
Description
In many projects and on many systems it is necessary to exchange process data
between controllers and servers/PCs, so that it can also be worked with the
incoming data outside of the control level. This is made possible by standardized
protocols. FTP is a simple protocol which works according to the client-server
principle and fulfills this task.
So far, users who used a S7-300, S7-400 or S7-1500 could only exchange process
data with a CP via FTP using a FTP server. In this application example, S7-1200
and S7-1500 are integrated into the existing FTP environment without
communication processor.
Advantages
The solution presented here offers the following advantages:
Simple and easy to understand FTP communication with an S7-1200 or S7-
1500 via the "Ftp1X00Cmd" block.
The command set of the block corresponds to that of the FTP communication
via S7-300, S7-400 or S7-1500 controllers with CP.
Note The FTP function block delivered with this application example exclusively fulfills
FTP client functions.
Siemens AG 2017 All rights reserved
1
Data
entry
Control connection
2 Connect Disconnect 8
Error;
7
error status
User Not
4 10
Authentication faulty Connected
Siemens AG 2017 All rights reserved
12 Execute
Send
13
mode
Send
14
command Data connection
faulty
Data transfer 16
Software components
The following table shows what software components have been used for the
application example.
Siemens AG 2017 All rights reserved
Table 1-4
Component Qty. Article number Note
STEP 7 1 6ES7 822-1AA02-0YA5 Alternatively, a smaller
PROFESSIONAL V14 package is also possible.
SP1
FileZilla server 1 Freeware (GPL) The download link to
V0.9.46 FileZilla Server is
available in chapter 4.2: \4\
2 Engineering
2.1 Interface description "Ftp1X00Cmd"
Function description
The "Ftp1X00Cmd" FTP function block maps the FTP and hence enables the
actual FTP communication based on the open user communication. It can perform
the following FTP commands:
CONNECT (connect und log in)
DISCONNECT (disconnect and log out)
STORE (save data)
APPEND (attach data)
RETRIEVE (fetch data)
DELETE (delete file)
Block interface
The following figure shows the interfaces of the "Ftp1X00Cmd" function block.
Figure 2-1: Ftp1X00Cmd
Ftp1X00Cmd
Siemens AG 2017 All rights reserved
String username
String password
String filename
ftpData
Variant Variant
connectionData
TCON_IP_v4 TCON_IP_v4
The following table describes the interfaces of the "Ftp1X00Cmd" function block.
Table 2-1: Parameters of Ftp1X00Cmd
Name P type Data type Comment
connect IN Bool TRUE = controller connection to FTP server
is connected
FALSE = controller connection is separated
execute IN Bool FTP job trigger at positive edge
connectionId IN Word Freely selectable connection ID of the TCP
connections.
NOTICE: ID and ID+1 are reserved. These
are unique throughout the project.
ftpActiveMode IN Bool FALSE = passive FTP mode
TRUE = active FTP mode
Note The output values "done" and "error" are only pending for one cycle if "connect"
and "execute" are not set.
Siemens AG 2017 All rights reserved
Function chart
The following function chart shows how the output parameters respond in
dependence to the input parameters.
Figure 2-2
connect
(manually)
execute
(manually)
connected
busy
error
on cycle
active
Note For this application example the configuration of the FTP server is shown on the
example of the FileZilla server. For different FTP servers the required
configuration steps may also differ.
Function block "Ftp1X00Cmd" cannot be used with any FTP server. The function
is only guaranteed and tested with the following FTP servers: SIMATIC CP,
Filezilla and JanaServer.
Installation
The following instructions show you how to install the FileZilla server.
Table 2-2
No. Action Remark
1. Download the FileZilla server. The download link to FileZilla Server is
available in chapter 4.2.
This program is recommended for the
application example since it is easy to
operate and structured in a very
functional way.
2. Install the FTP server software on your Follow the instructions of the program.
server.
Siemens AG 2017 All rights reserved
Note Make sure you have the latest FileZilla server version.
Configuration
The table below shows you the required steps for the configuration of the FileZilla
server. If another FTP server software is used, their manuals need to be followed
for commissioning. It is important to create a user with password and full
access to the files in its root directory for the application example to work
properly.
Table 2-3
No. Action Screen
1. Start the FileZilla server interface on your FTP
server and click on OK.
You are logged into the interface.
Here, you could track any of the actions
running on the server.
Note When assigning your devices IP addresses, make sure that the CPU that works
as FTP client and the FTP server are located in the same subnet and each IP
address is only assigned once within the subnet.
Prerequisites
The following prerequisites apply for the use of the application example:
S7-1200 as of firmware V4.0
S7-1500 as of firmware V1.0
Compatible FTP server has been configured
Restrictions
The following restrictions apply for this application example.
The application example works only with the tested FTP servers and as of the
software version tested.
Only four FTP users can be connected at the same time from a controller to a
FTP server.
Siemens AG 2017 All rights reserved
Note Working with a second TIA Portal instance requires more system resources than
the "reference projects" view.
In order to control the block you also have to interconnect the inputs "connect",
"execute", "ftpCmd" and "ftpActiveMode". In the application example, these inputs
are interconnected with "PLC tags". The tags used are listed in the tag table
included.
The following figure shows the call of the "Ftp1X00Cmd" block in the application
example.
Figure 2-3
Siemens AG 2017 All rights reserved
Note The interconnection of the parameters described here is the basic requirement
for the operation of the block. Without an interconnection, a controller connection
to the FTP server cannot be established.
The specified user has to be created on the server side in order to be able to
establish the connection.
Note If you adjust the code, a maximum of 8192 bytes can be received by
"Ftp1X00Cmd".
Note The prerequisite for successful operation is that the FTP server is compatible
with the "Ftp1X00Cmd" block and that it has been configured as described in
chapter 2.2.
The following figure is to illustrate the dependencies of the inputs and outputs of
the "Ftp1X00Cmd" block.
Figure 2-4
No
connect Successful? error
Yes
done
connected
execute error
No
Yes
Successful? done
1
2
3
4
1. varConnect If this tag is set, the controller connection is established and the
user specified on the "username" input is logged in to the FTP
server, using the password specified on the "password" input. If
the tag is reset, the controller connection is established and the
user is logged out.
2. varExecute The job for FTP data transmission is started if there is a positive
edge.
3. varFtpMode This is where the FTP mode for the data transmission is
specified.
4. varFtpCmd Here, the FTP command is specified.
5. varDone Status area:
varBusy The tags reflect the status of the "Ftp1X00Cmd" block. This is
varError where you can see whether the controller connection is
varConnected connected and whether the block is error free or with what
specific error it was run.
varStatus
3 Valuable Information
3.1 Basics
FTP general
FTP was developed to exchange data between a client and a server. Furthermore,
it is designed for managing directories via remote access. In the world of
automation technology, FTP is a useful protocol to easily exchange data.
There are two modes for FTP communication:
active FTP
passive FTP
FTP active
In this mode, the FTP client opens a random port (>1023) and sends it and its own
IP address to the FTP server using a special command (PORT or EPRT). By
default, the command is sent to port 21 of the FTP server. Port 21 of the server has
to be open or forwarded in the firewall of the server; otherwise no communication
will be established. When data transfer is requested, the FTP server initiates a data
connection to the transferred IP address and FTP server port 20.
The active mode is used when the FTP server is located behind a firewall, since
Siemens AG 2017 All rights reserved
the data connection is initiated from the FTP server outwards and is therefore not
blocked by the firewall. Hence, the FTP server reacts actively.
The figure below illustrates the active FTP communication on the example of the
RETRIEVE command.
Figure 3-1
FTP passive
In this mode, the FTP client sends a PASV or EPASV command to port 21 of the
FTP server. The FTP server then opens a random port and transmits this port
number to the FTP client together with its IP address. For the data transfer, the
FTP client now initiates a TCP connection to the IP address sent by the FTP server
and the port.
If the FTP client is located behind a firewall, the passive mode is used. The stateful
packet inspection normally always allows outgoing data packets in the firewall.
Hence, the FTP server reacts passively.
The figure below illustrates the passive FTP communication on the example of the
RETRIEVE command:
Figure 3-2
4 Annex
4.1 Service and support
Industry Online Support
Do you have any questions or need support?
Siemens Industry Online Support offers access to our entire service and support
know-how as well as to our services.
Siemens Industry Online Support is the central address for information on our
products, solutions and services.
Product information, manuals, downloads, FAQs and application examples all
information is accessible with just a few mouse clicks at
https://support.industry.siemens.com
Technical Support
Siemens Industry's Technical Support offers quick and competent support
regarding all technical queries with numerous tailor-made offers
from basic support right up to individual support contracts.
Please address your requests to the Technical Support via the web form:
www.siemens.en/industry/supportrequest
Service offer
Siemens AG 2017 All rights reserved
Our service offer comprises, among other things, the following services:
Product Training
Plant Data Services
Spare Parts Services
Repair Services
On Site and Maintenance Services
Retrofit and Modernization Services
Service Programs and Agreements
Detailed information on our service offer is available in the Service Catalog:
https://support.industry.siemens.com/cs/sc