Siemens - FTP S7-1200 (V1.0)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

FTP Data Exchange between

FTP Server and a SIMATIC S7-1200


Controller

Application Description October 2013

Applications & Tools


Answers for industry.
Warranty and Liability

Warranty and Liability

Note The Application Examples are not binding and do not claim to be complete with
regard to configuration, equipment or any contingencies. The application
examples do not represent customer-specific solutions; they are only intended to
provide support for typical applications. You are solely responsible for the correct
operation of the described products. These application examples do not relieve
you of the responsibility to use sound practices in application, installation,
operation and maintenance. Through using these Application Examples, you
acknowledge that we will not be 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
Copyright Siemens AG 2013 All rights reserved

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
deficiency or breach of a condition which goes to the root of the contract
(wesentliche Vertragspflichten). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change in the burden of
proof to your disadvantage.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the express consent of Siemens Industry Sector.

Caution
The functions and solutions described in this entry predominantly confine
themselves to the realization of the automation task. Please also take into account
that corresponding protective measures have to be taken in the context of
Industrial Security when connecting your equipment to other parts of the plant, the
enterprise network or the Internet. For more information, please refer to Entry ID
50203404.
http://support.automation.siemens.com/WW/view/en/50203404

Siemens Industry Online Support


This entry is from the Siemens Industry Online Support. The following link will take
you directly to the download page of this document:
http://support.automation.siemens.com/WW/view/en/81367009

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 2
Table of Contents

Table of Contents
Warranty and Liability ................................................................................................. 2
1 Task ..................................................................................................................... 4
2 Solution............................................................................................................... 6
2.1 Overview............................................................................................... 6
2.2 Core functionality.................................................................................. 8
2.2.1 Principle of the core functionality ......................................................... 8
2.2.2 Overview of the user interface ........................................................... 10
2.3 Hardware and software components ................................................. 11
2.3.1 Validity ................................................................................................ 11
2.3.2 Components used .............................................................................. 11
3 Basics ............................................................................................................... 13
4 Mode of Operation ........................................................................................... 14
4.1 Overview............................................................................................. 14
4.2 Description of scenario 1: sending process data to an FTP
server.................................................................................................. 17
4.2.1 Details on the FTP function block: FTP_1200_CMD ......................... 17
4.2.2 Details on FB SEND_DATA ............................................................. 20
4.2.3 Details on FB GENERATE_DATA ................................................... 21
4.2.4 Details on FB GENERATE_FILENAME .......................................... 21
Copyright Siemens AG 2013 All rights reserved

4.2.5 Details on the used data types and constants ................................... 22


4.3 Description of scenario 2: receiving process data from an FTP
server.................................................................................................. 25
5 Installation and Commissioning .................................................................... 28
5.1 Hardware installation .......................................................................... 28
5.2 Installation of the software.................................................................. 29
5.3 Commissioning ................................................................................... 29
5.3.1 FTP server .......................................................................................... 29
5.3.2 S7-1200 controller and HMI ............................................................... 31
5.3.3 Adapting the S7 program ................................................................... 34
6 Operating the Application ............................................................................... 35
6.1 Menu navigation ................................................................................. 35
6.2 Scenario 1 (storing data) .................................................................... 36
6.3 Scenario 2 (fetching data) .................................................................. 37
6.4 Settings............................................................................................... 38
7 Related Literature and Links .......................................................................... 39
8 History............................................................................................................... 39

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 3
1 Task

1 Task

Introduction
The widely distributed FTP (File Transfer Protocol) offers you the possibility of filing
data on almost any server system of all the known operating systems.
All S7-300/400/1500 controller families already have the option of operating FTP
communication via special CPs (communication processors).
This application shows how an S7-1200 can also use FTP.

Overview of the automation task


The following figure provides an overview of the automation task.
Figure 1-1

Integration of S7-1200 in FTP server


existing FTP environment
Copyright Siemens AG 2013 All rights reserved

PROFINET / IE

FTP
+
S7-300 with S7-400 with S7-1500 with S7-1200
CP 343-1 CP 443-1 CP 1543-1

Standard solution

Description
In many projects and on many systems it is necessary to exchange process data
between controller and servers/PCs, in order to enable working with the there
produced data outside of the control level as well. 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 were able to exchange process data with FTP via an FTP server
using S7-300/400/1500 and using a communication processor. With this
application, the S7-1200 is included into the existing FTP environment.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 4
1 Task

Requirements of the automation task


The following table shows the automation requirements for this application.
Table 1-1
Requirement Explanations
Saving data from the S7-1200 Scenario 1 shall demonstrate how process data can
controller on the server be loaded from the controller to a server using an
FTP block.
Requesting data from the FTP Scenario 2 shall demonstrate how data (e.g. recipes)
server of S7-1200 can be loaded from a server into the controller using
an FTP block.
Copyright Siemens AG 2013 All rights reserved

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 5
2 Solution
2.1 Overview

2 Solution
2.1 Overview
Display
The following figure gives a schematic overview of the most important components
of the solution and its interconnection:

Figure 2-1

FTP server:
FTP server
software with file
storage
Copyright Siemens AG 2013 All rights reserved

PROFINET / IE

FTPclient - S7-1200
controller:
S7 program with FTP
function block
FTP_1200_CMD and HMI:
process data HMI screen

Note The FTP function block (FTP_1200_CMD) is delivered with the example project
of this application. This block enables the FTP data exchange.

Description
In order to operate FTP communication without CP, a function block
(FTP_1200_CMD) must map the FTP in the S7-CPU. The block must establish
logic connections from a controller to FTP servers as well as send and receive
commands and data taking into consideration the FTP. In this application, two
scenarios are explained which illustrate using the above mentioned block.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 6
2 Solution
2.1 Overview

Advantages
The solution presented here offers you the following advantages:
Simple and easy to understand FTP communication with an S7-1200 via the
FTP_1200_CMD block.
The command set of the block corresponds to that of the FTP communication
via S7-300/400/1500 controller (with CP).
Expandability of the example application by some process data and different
FTP servers. Illustration of the data exchange by an HMI operation.

Topics not covered


This application does not contain a description of:
SCALANCE products
FTP servers
HMI panels
PLCs (especially S7-1200)
SCL programming
Basic knowledge of these topics is assumed.
Copyright Siemens AG 2013 All rights reserved

Note The FTP function block delivered with this application exclusively fulfils FTP
client functions

Assumed knowledge
Basic knowledge of STEP 7 V12, WinCC V12, FUP, SCL, Ethernet and TCP/IP is
assumed.

Comparing the most important FTP features in the SIMATIC S7 environment


Table 2-1
FTP feature S7-300/400 S7-1500 S7-1200
Via CP

(CP 343-1 / 443-1) (CP 1543-1)
FTP server

Number of parallel 10/20 32 4
client connections
FTP active

FTP passive

FTPS

Full S7-FTP command
set

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 7
2 Solution
2.2 Core functionality

2.2 Core functionality


The example project for this application contains two scenarios:
Scenario 1: transferring process data to the FTP server
Scenario 2: retrieve data from the FTP server

2.2.1 Sequence of the core functionality

The following figure shows the schematic sequence of the entire application:
Figure 2-2
Wait for the new
5 trigger

1 START

Connecting with
FTP server
Copyright Siemens AG 2013 All rights reserved

No
2 Connected?

Yes

Trigger data
exchange

Activate error display Activate OK display


Data sent/ No Terminate program sequence Terminate program sequence
3 received? Display specific status Display specific status
(depending on error) (OK; 0000)

Yes

Disconnect from
FTP server

Properly dis- No
4 connected?

Yes

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 8
2 Solution
2.2 Core functionality

Table 2-2
Action Note
1. After a start trigger was output with The connection data are entered via the
START, the PLC connects with the user interface (IP address, User name,
FTP server Password)
2. The program checks the connection For NOK, the red display lights up in the
status: HMI interface
OK: triggers sending or receiving the
data
NOK: terminates the program sequence
outputs the error-specific status
3. The program checks the data For NOK, the red display lights up in the
exchange: HMI interface
OK: triggers the disconnection process
NOK: terminates the program sequence
and outputs the error-specific status
4. The program checks the proper For OK, the green display lights up.
disconnection process: For NOK, the red display lights up.
OK: terminates program sequence and
outputs the status; job completed
successfully; wait until job triggered
again.
Copyright Siemens AG 2013 All rights reserved

NOK: terminates the program sequence


and outputs the error-specific status
5. Wait for the new trigger

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 9
2 Solution
2.2 Core functionality

2.2.2 Overview of the user interface

Scenario 1
The figure below shows the user interface for scenario 1
Figure 2-3
Copyright Siemens AG 2013 All rights reserved

Scenario 2
The figure below shows the user interface for scenario 2
Figure 2-4

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 10
2 Solution
2.3 Hardware and software components

2.3 Hardware and software components


2.3.1 Validity

This application is valid for


STEP 7 Professional as of V12 SP1
WinCC Professional as of V12 SP1
S7-1200 controller
common FTP servers

2.3.2 Components used

This application has been generated using the following components:

Hardware components
Table 2-3
Component No. Order number Note
Copyright Siemens AG 2013 All rights reserved

SIMATIC S7-1200 1 6ES7 214-1AG31-0XB0 Alternatively, any other


CPU 1214C DC/DC/DC SIMATIC S7-1200 can
also be used.
SCALANCE X 1 6GK5 008-0BA00-1AB2 Alternatively, another
XB008 switch can be used.
PM 1207 1 6EP1 332-1SH71 Alternatively, a different
voltage supply can also be
used.
SIMATIC HMI 1 6AV2 181-4GB00-0AX0 Starter kit with WinCC;
TP700 Comfort alternatively, another
SIMATIC HMI panel can
also be used.
SIMATIC RACK PC 1 6AG4 112-1GP21-0BX0 Alternatively, another
IPC647C server/PC can also be
used.

Software components
Table 2-4
Component No. Order number Note
STEP 7 1 6ES7 822-1AA02-0YA5 Alternatively, a smaller package
PROFESSIONAL is also possible.
V12 SP1
WinCC 1 6AV2 101-0AA02-0AA5 Included in the TP700 Comfort
PROFESSIONAL starter kit; when using a
V12 SP1 different HMI, a smaller WinCC
package can be used.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 11
2 Solution
2.3 Hardware and software components

Component No. Order number Note


FileZilla Server 1 Freeware (GPL) The download link for FileZilla
V0.9.41 Server is given in the Literature
section: /4/
Alternatively, any other FTP
server program can also be
used.

Sample files and projects


The following list includes all files and projects that are used in this example.
Table 2-5
Component Note
81367009_FTP_S7-1200_CODE_V1_0.zip This zip file contains the STEP 7
project.
81367009_FTP_S7-1200_DOKU_V1_0_en.pdf This document
Copyright Siemens AG 2013 All rights reserved

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 12
3 Basics

3 Basics
FTP general
FTP was developed to exchange data between a client and a server; furthermore,
it is designed for directory management via remote access. In the world of
automation technology, this is a useful protocol for making the data exchange as
simple as possible.
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). As a
standard, it is sent to port 21 of the FTP server (it must be open at the server or
forwarded, otherwise no communication will be established). When data transfer is
requested, the FTP server now initiates a TCP connection to the transferred IP
address and the port from FTP server port 20.
Copyright Siemens AG 2013 All rights reserved

The active mode is used when the FTP server is located behind a firewall, since
the data connection is initiated from the FTP server outwards, hence, not blocked
by the firewall; i.e. the FTP server acts actively.

FTP passive
In this mode, the FTP client sends a PASV or EPASV command to port 21 of the
FTP server, which prompts it to open a random port and transferring it to the FTP
client 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.
The passive mode is used when the FTP client is located behind the firewall since
the data connection is initiated from the FTP client outwards and the firewall
normally does not block any packages. The FTP server hence reacts passively.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 13
4 Mode of Operation
4.1 Overview

4 Mode of Operation

4.1 Overview
Program structure
The figure below shows the program structure of the S7 user program.
Figure 4-1

GENERATE_
FILENAME

Scenario 1
DB_FTP_
DATA
GENERATE_
DATA

DB_FTP_
SEND_
USER_
DATA
PARAM

-TCON
MAIN FTP_1200_ -TSEND
Copyright Siemens AG 2013 All rights reserved

[OB 1] CMD -TDISCON


-TRCV

RECIEVE_
DATA DB_FTP_
DATA2

Scenario 2
DB_HMI

User Library System Data


program block blocks blocks

Description
In Scenario 1 (SEND_DATA), process data is generated and filed in a data block.
In scenario 1, TCP connections with a server are established via the FTP function
block FTP_1200_CMD. The FTP is mapped in the block in order to transfer data
to the FTP server via FTP.

In scenario 2 (RETRIEVE_DATA), TCP connections with a server are also


established via the FTP function block. In contrast to scenario 1, data is loaded
here from the FTP server to the controller (data block).

The data is located on the FTP server in the form of files. The data type of this file
can be selected at will by the user according to file names. Principally, any data
type can be written to or read.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 14
4 Mode of Operation
4.1 Overview

Block list
The table below gives you an overview of the program blocks of this application.
Table 4-1
Element Symbolic name Description
OB1 MAIN Cyclic OB:
calls the blocks for scenario 1 and 2
FB1 SEND_DATA Scenario 1:
FTP manager for sending data to the FTP server.
FB2 RETRIEVE_DATA Scenario 2:
FTP manager for receiving data from the FTP server
FB10 GENERATE_FILENAME Creates a file name for the FTP data exchange for
scenario 1.
FB11 GENERATE_DATA Creates randomly generated process data for FTP
data exchange for scenario 1.
FB60 FTP_1200_CMD Protected FTP function block:
enables FTP communication for S7-1200 controllers.
DB100 DB_HMI_INTERFACE Interface DB for controlling the application via HMI
DB200 DB_FTP_DATA DB for process data of scenario 1
Copyright Siemens AG 2013 All rights reserved

DB101 DB_FTP_DATA2 DB for process data of scenario 2


DB102 DB_FTP_USER_PARAM DB for communication parameters and FTP
registration information
DB1 iDB_SEND_DATA Instance DB for FTP Manager for scenario 1
DB2 iDB_RETRIEVE_DATA Instance DB for FTP Manager for scenario 2
DB10 iDB_GENERATE_FILEN Instance DB for GENERATE_FILENAME
AME
DB11 iDB_GENERATE_DATA Instance DB for GENERATE_DATA
DB60 iDB_FTP_1200_CMD Instance DB for FTP_1200_CMD in scenario 1
DB61 iDB_FTP_1200_CMD_2 Instance DB for FTP_1200_CMD in scenario 2

Note Each function block includes an instance data block (iDB_xxxx). These are not
depicted in the program structure (Figure 4-1).

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 15
4 Mode of Operation
4.1 Overview

MAIN
OB 1 calls the FTP Manager for scenario 1 and 2 (FB SEND_DATA, FB
RETRIEVE_DATA). Furthermore, it calls the FBs for generating data names and
process data (GENERATE_FILENAME and GENERATE_DATA) for scenario 1.
The process data of the FTP DBs (DB_FTP_DATA and DB_FTP_DATA_2) are in
OB 1 prepared for the display on the HMI and then stored in the HMI interface DB.
Another function for deleting the process data of scenario 2 is realized within MAIN.
A tag in DB_HMI_INTERFACE is used (STOR_RETR) for mutually interlocking
scenario 1 and 2.

SEND_DATA (scenario 1)
The FTP Manager for scenario 1 contains a step chain consisting of three steps:
CONNECT STORE/APPEND DISCONNECT. In FB SEND_DATA, the FTP
function block FTP_1200_CMD is called up three times to perform the above
mentioned steps. The job trigger only reacts to a positive edge. For details see
chapter 4.2.

RETRIEVE_DATA (scenario 2)
Copyright Siemens AG 2013 All rights reserved

The FTP Manager for scenario 2 also contains a step chain consisting of three
steps: CONNECT RETRIEVE DISCONNECT. In RETRIEVE_DATA, the FTP
function block FTP_1200_CMD (see 4.2.1 Details on the FTP function block:
FTP_1200_CMD) is called up three times to perform the above mentioned steps.
The job trigger only reacts to a positive edge. For details see chapter 4.3.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 16
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

4.2 Description of scenario 1: sending process data to an


FTP server
The figure below shows the program sequence for scenario 1:
Figure 4-2

Enter Generate
connection Generate
process
data file name
data

Trigger
START

Establish
connection with FB: FTP_1200_CMD
FTP server
Copyright Siemens AG 2013 All rights reserved

Transferring
FB: FTP_1200_CMD
data

Terminate
connection with FB: FTP_1200_CMD
FTP server

Output
the
status

In scenario 1, file names and process data can be generated. These are
transferred to an FTP server and stored under the given file name. The data
exchange for scenario 1 runs entirely within FB SEND_DATA.

4.2.1 Details on the FTP function block: FTP_1200_CMD

General
FTP function block FTP_1200_CMD maps the FTP and hence enables the actual
FTP communication. It can perform the following FTP commands:
CONNECT (connect / login)
DISCONNECT (disconnect / log off)
STORE (save data)
APPEND (attach data)
RETRIEVE (fetch data)
DELETE (delete file)

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 17
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

To be able to use the block correctly, two data blocks must be created; one for user
data and transfer, another one for the connection parameters. User data types are
included in the delivery scope of this application (see 4.2.5 Details on the used
data types and constants).

Parameter interface
Figure 4-3

Input

Output
InOut
Copyright Siemens AG 2013 All rights reserved

Input

Subsequently, all parameters for the FTP function block are explained:

Inputs
Table 4-2
Name Data type Description
FTP_REQ Bool Job triggered at positive edge
ID Int Freely selectable connection ID of the TCP
connection.
NOTICE: ID and ID+1 are reserved and
unique across the project.
FTP_CMD Int FTP command (see 4.2.5 User constants)
FTP_MODE Bool True=passive; False=active
FTP_SERVER_DAT FTP_SERVER FTP server information (see 4.2.5 UDTs)
_PARAM
FTP_CLIENT_DAT FTP_CLIENT_ FTP client information (see 4.2.5 UDTs)
PARAM
FTP_FILENAME String File name for FTP communication
FTP_SERVER_TYPE Bool For determining the FTP server type
True=other; False=SIEMENS CP
FTP_FILE_HEADER FTP_HEADER FTP header for intermediate storage of various
_1200 meta data (see 4.2.5 UDTs)
FTP_FILE_DATA Variant Process or user data for FTP communication
(see 4.2.5 UDTs)

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 18
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

Outputs
Table 4-3
Name Data Description
type
DONE Bool True, if job successful
BUSY Bool True, while job running
ERROR Bool True, if job failed
STATUS Word Outputs the current job status in form of a HEX code

Note The output values are only pending for one cycle.

STATUS HEX codes


Table 4-4 Description of the status
DONE BUSY ERROR STATUS Description
X 0 Job completed successfully without error
Copyright Siemens AG 2013 All rights reserved

X 8181 Job running


X 8D11 Unexpected error while establishing the
connection
X 8D22 Passive mode could not be activated (STORE)
X 8D24 STORE/APPEND could not be executed
X 8D27 Data connection not terminated properly
X 8D32 Passive mode could not be activated
(RETRIEVE)
X 8D34 RETRIEVE could not be executed
X 8DF1 Time exceeded (5s)
X 8F56 NEW bit still set at RETRIEVE, see chapter
4.2.5.
X 8F60 Invalid user data
X 8F62 Invalid file name
X 8F69 Connection attempt to existing connection

Note Further STATUS messages are possible and result from the OUC blocks used in
the FTP function block (see reference /3/).

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 19
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

4.2.2 Details on FB SEND_DATA

Scenario 1 manages an entire FTP communication send cycle. FTP function block
FTP_1200_CMD is called here in a sequencer in order to perform the following
individual functions:
Establish a connection with the FTP server
Performing the authentication
Transferring data
Disconnect from the FTP server
The inputs of the FTP function block FTP_1200_CMD are supplied with the
respectively required parameters via FB SEND_DATA.

Parameter interface
Figure 4-4
Copyright Siemens AG 2013 All rights reserved

Input

Output
InOut

Subsequently, all parameters for scenario 1 are explained:

Inputs
Table 4-5
Name Data type Description
SEND_REQ Bool Job initiation at positive edge; starts a send job
CLIENT_PARAM FTP_CLIEN FTP client information (see 4.2.5 UDTs)
T_PARAM
SERVER_PARAM FTP_SERVE FTP server information (see 4.2.5 UDTs)
R_PARAM
FILENAME String File name for FTP communication
MODE Bool True=passive; False=active
SERVER_TYPE Bool For determining the FTP server type
True=other; False=SIEMENS CP
FTP_DATA Variant Process or user data for FTP communication (see
4.2.5 UDTs)
ID Int Freely selectable connection ID of the TCP
connection.
NOTICE: ID and ID+1 are reserved and unique
across the project.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 20
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

Name Data type Description


APPE_STOR Bool For differentiation whether to overwrite or attach:
True= overwrite; False= attach
FTP_HEADER FTP_HEAD FTP header for intermediate storage of various
ER_1200 meta data (see 4.2.5 UDTs)

Outputs
Table 4-6
Name Data type Description
DONE Bool True, if job successful
BUSY Bool True, while job running
ERROR Bool True, if job failed
STATUS Word Outputs the current job status in form of a HEX
code

STATUS HEX codes


Copyright Siemens AG 2013 All rights reserved

The STATUS HEX codes are taken from the STATUS of the FTP function block,
see 4.2.1 Details for FTP function block: FTP_1200_CMD.

4.2.3 Details on FB GENERATE_DATA

GENERATE_DATA automatically generates process data according to the


following principle:
NR=#, temp1=#C, temp2=#C, Voltage=#V, Speed=#rpm, Date=YYYY-
MM-DD, Time=HH:MM:SS;;
Example:
NR=2, temp1=25C, temp2=87C, Voltage=221V, Speed=2102rpm,
Date=2013-09-28, Time=11:15:01;;
These data are stored in DB_FTP_DATA (as array of chars) and
DB_HMI_INTERFACE (as string).

4.2.4 Details on FB GENERATE_FILENAME

GENERATE_DATA generates file names according to the following principle:


FILE_#_YYYY-MM-DD.dat (example: FILE_5_2013-09-28.dat). The number is
generated continuously and the data read from the CPU. These file names are
stored in DB_FTP_USER_PARAM and DB_HMI_INTERFACE.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 21
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

4.2.5 Details on the used data types and constants

UDTs
Additionally, to the blocks of the S7 user program of this application, the following
UDTs (User Defined data types) are necessary to supply the parameter interfaces
of FB FTP_1200_CMD.

FTP_CLIENT_PARAM (is used in DB_FTP_USER_PARAM)


Table 4-7
Name Data Description
type
IP_ADDRESS Struct Consists of four USInt fields for the client IP
address octets
PORT_START_ADRESSE Int Port start address for the FTP client
Copyright Siemens AG 2013 All rights reserved

FTP_SERVER_PARAM (is used in DB_FTP_USER_PARAM)


Table 4-8
Name Data Description
type
IP_ADDRESS Struct Consists of four USInt fields for the server IP
address
USERNAME String[32] FTP user name
PASSWORD String[32] FTP password

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 22
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

FTP_HEADER_1200 (used in DB_FTP_DATA and DB_FTP_DATA_2)


Table 4-9
Name Data Description
type
Reserve_Byte 0 Byte Wildcard for further functions
EXIST Bool True: data array verified
LOCKED Bool True: data array locked; no communication
possible
NEW Bool True: new data were saved to the data array
ACT_LENGTH DInt Current data array size in bytes
MAX_LENGTH DInt Maximal data array size in bytes
FTP_REPLY_CODE Int Contains the last FTP server response
DATE_TIME DTL Time stamp for last change date
Copyright Siemens AG 2013 All rights reserved

FTP_DATA_1200 (used in DB_FTP_DATA and DB_FTP_DATA_2)


Table 4-10
Name Data type Description
DATA Array[0..1000] Char-type data array of 1000 bytes.

Note An array can include a maximum of 32767 characters.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 23
4 Mode of Operation
4.2 Description of scenario 1: sending process data to an FTP server

FTP_TELEGRAM (used in DB_FTP_DATA and DB_FTP_DATA_2)


Data type FTP_TELEGRAM combines FTP_DATA_1200 and
FTP_HEADER_1200.
Table 4-11
Name Data type Description
FTP_HEADER FTP_HEADER_1200 UDT: FTP_HEADER_1200
FTP_DATA FTP_DATA_1200 UDT: FTP_DATA_1200

User constants
FTP function block FTP_1200_CMD distinguishes its operations by constant INT
values at a parameter interface (see 4.2.1 Details on FTP function
block: FTP_1200_CMD). The following user constants were created for this:
Copyright Siemens AG 2013 All rights reserved

Table 4-12
Name Value Description
CMD_CONNECT 1 Connecting with server; logging on
CMD_STORE 2 Storing data on server under a file name
CMD_RETRIEVE 3 Fetching data from the server under a file name
CMD_DELETE 4 Deleting file under file name
CMD_QUIT 5 Logging off; disconnecting from the server
CMD_APPEND 6 Attaching data on server under a file name

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 24
4 Mode of Operation
4.3 Description of scenario 2: receiving process data from an FTP server

4.3 Description of scenario 2: receiving process data from


an FTP server
The figure below shows the program sequence for scenario 2:
Figure 4-5

Enter Delete
Enter file
connection process Deletion optional
data name data

Trigger
START

Establish
connection with FB: FTP_1200_CMD
FTP server
Copyright Siemens AG 2013 All rights reserved

Transferring
FB: FTP_1200_CMD
data

Terminate
connection with FB: FTP_1200_CMD
FTP server

Output
the
status

In scenario 2, process data is loaded from an FTP server into the controller (giving
the file name). The user can delete them again from the respective DB on the
controller. The data exchange for scenario 2 runs entirely within FB
RETRIEVE_DATA.

Details on FB RETRIEVE_DATA
Scenario 2 manages an entire FTP communication receive cycle. FTP function
block FTP_1200_CMD (see 4.2.1 FTP function block FTP_1200_CMD) is called
here in a sequencer in order to perform the following individual operations:
Establish a connection with the FTP server
Performing the authentication
Receiving data from the server
Disconnect from the FTP server
The inputs of the FTP function block FTP_1200_CMD are supplied with the
respectively required parameters via FB RETRIEVE_DATA.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 25
4 Mode of Operation
4.3 Description of scenario 2: receiving process data from an FTP server

Parameter interface
Figure 4-6

Input

Output

InOut

Subsequently, all parameters for scenario 2 are explained:

Inputs
Table 4-13
Copyright Siemens AG 2013 All rights reserved

Name Data type Description


RETR_REQ Bool Job initiation with positive edge starts a receive
job
ID Int Freely selectable connection ID of the TCP
connection.
NOTICE: ID and ID+1 are reserved and unique
across the project.
MODE Bool True=passive; False=active
SERVER_PARAM FTP_SERVER FTP server information (see 4.2.5 UDTs)
_PARAM
CLIENT_PARAM FTP_CLIENT_ FTP client information (see 4.2.5 UDTs)
PARAM
FILENAME String File name for FTP communication.
SERVER_TYPE Bool For determining the FTP server type:
True=standard FTP server; False=SIEMENS CP
FTP_HEADER FTP_HEADER FTP header for intermediate storage of various
_1200 meta data (see 4.2.5 UDTs).
FTP_DATA Variant Process or user data for FTP communication (see
4.2.5 UDTs)

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 26
4 Mode of Operation
4.3 Description of scenario 2: receiving process data from an FTP server

Outputs
Table 4-14
Name Data type Description
DONE Bool True, if job successful
BUSY Bool True, while job running
ERROR Bool True, if job failed
STATUS Word Outputs the current job status in form of a HEX
code

STATUS HEX codes


The STATUS HEX codes used here are taken from the STATUS of the FTP
function block, see 4.2.1 Details for FTP function block: FTP_1200_CMD.
Copyright Siemens AG 2013 All rights reserved

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 27
5 Installation and Commissioning
5.1 Hardware installation

5 Installation and Commissioning

5.1 Hardware installation


The figure below shows the hardware setup of the application:
Figure 5-1
SIMATIC RACK PC
IPC647C

Programming unit

XB008

PROFINET / IE
Copyright Siemens AG 2013 All rights reserved

SIMATIC HMI
24 V TP700 Comfort
PM 1207 S7-1200

24 V
24 V

NOTICE In general, the installation guidelines for all components have to be observed.

Table 5-1
No. Action
1. Connect the switch, the HMI and the controller to a 24 V voltage supply.
2. Connect the server and the programming unit to a 230 V power supply.
3. Connect each component to a port at the switch vie Ethernet cable (RJ45).

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 28
5 Installation and Commissioning
5.2 Installation of the software

5.2 Installation of the software


This chapter describes the steps for the installation of the example code.

Note It is recommended to run the latest versions of any installed software.

FTP server software


Table 5-2
No. Action Note
1. Download an FTP server software. The download link for FileZilla server is
contained in the literature section: /4/
This program is recommended for the
application since it is easy to operate and set up
in a very functional way.
2. Install the FTP server software on your Follow the instructions of the program.
server.

TIA Portal with STEP 7 and WinCC


Copyright Siemens AG 2013 All rights reserved

Table 5-3
No. Action Note
1 Install STEP 7 V12 on your programming Follow the instructions of the program.
unit.
2 Install WinCC V12 on your programming Follow the instructions of the program.
unit.

5.3 Commissioning

NOTICE When assigning the IP addresses of your devices please ensure that they
are all located in the same subnet and each IP is only assigned once
across the subnets.

5.3.1 FTP server

The following table shows how to commission 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 data in his
root directory.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 29
5 Installation and Commissioning
5.3 Commissioning

Table 5-4
No. Action Screenshot
1. Start the FileZilla server interface on your
FTP server and click on OK.
Now you are logged on at the server
interface.
Here you could track any of the actions
running on the server and make settings.

2. In the menu bar, click on Edit and then on


Settings to get to the server settings.

All of your desired settings can be made


here.

For this application example you can use the


default settings.

Confirm with OK.

3. In the menu bar, click on Edit and then on


Users to get to the Users management.
Copyright Siemens AG 2013 All rights reserved

Select the General page and click on


Add.

In the field you enter an FTP user name, for


example ftp_user.

Confirm with OK.

4. Activate the Password checkbox and enter


the password in the field on the right, for
example ftp_user.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 30
5 Installation and Commissioning
5.3 Commissioning

No. Action Screenshot


5. Select the Shared folders page and in the
Shared folders section you click on Add.

In the now opened Explorer you navigate to


the folder you wish to use as FTP root
directory for the created user, select the
folder (for example, a previously created
folder: FTP_Server) and acknowledge with
OK.

Activate the checkboxes Read, Write,


Delete and Append.

Confirm with OK again.


6. Make sure that the server is online:
the online icon must be activated.

Now you have created an FTP user with


password, root directory with all of the rights.
The FTP server is now ready for the
application example and for processing user
requests.
Copyright Siemens AG 2013 All rights reserved

5.3.2 S7-1200 controller and HMI

Controller
The table below shows how to commission the S7-1200:
Table 5-5
No. Action Picture / Note
1. Load the example application to your http://support.automation.siemens.com/WW/view/
programming unit and unzip the archive. en/81367009

2. Open the example project FTP_1200_CMD.ap12


3. Open the Device configuration of the SIMATIC S7-1200
controller (PLC_1). CPU 1214C DC/DC/DC

When using the same controller as in the


example, proceed with step 5.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 31
5 Installation and Commissioning
5.3 Commissioning

No. Action Picture / Note


4. Right-click on the controller and click on
Change device.

Select your S7-1200 from the tree and confirm


with OK.

5. Right-click on the controller and click on


Properties.

In the area navigation of the inspection


window you select PROFINET interface.

In Ethernet addresses you enter an IP


address and Subnet mask.
Copyright Siemens AG 2013 All rights reserved

Please ensure that these match the IP


address and subnet mask of the server.

Network the controller with a subnet.


6. In the project navigation you select the
controller and download the program into the
controller.

The configuration of the controller has now


been completed.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 32
5 Installation and Commissioning
5.3 Commissioning

HMI
The table below shows how to commission the HMI:
Table 5-6
No. Action Picture / Note
1. Open the Device configuration of the HMI TP700 Comfort
(HMI_1).

When using the same HMI as in the


example, proceed with step 3.
2. Right-click on the HMI and click on Change
device.

Select your used HMI from the tree and


confirm with OK.
Copyright Siemens AG 2013 All rights reserved

3. Right-click on the HMI and click on


Properties.

In the area navigation of the inspection


window you select PROFINET interface.

In Ethernet addresses you enter an IP


address and Subnet mask.
Please ensure that these match the IP
address and subnet mask of the server.

Network the HMI with a subnet.


4. In the project navigation you select the HMI
and load the program into the HMI.

Note: if the HMI is currently not in Runtime,


you need to activate Transfer on the HMI.

After a successful transfer, the WinCC


Runtime starts automatically.

The configuration of the HMI has now been


completed.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 33
5 Installation and Commissioning
5.3 Commissioning

5.3.3 Adapting the S7 program

Three parameters of the FTP function block or the FTP Manager respectively
(SEND_DATA / RECEIVE_DATA) are in this application statically transferred to the
parameter interfaces of the blocks and cannot be controlled via the HMI.
In the TIA project you open the MAIN block to change these.
Please read the respective notes on the parameter interfaces in chapter 4.2.2 and
4.3.1.

The three parameters are described as follows.


Adjusting to the hardware
If your hardware setup deviates from that of the example application, it may be
necessary to change the parameters SERVER_TYPE of both FTP managers
(SEND_DATA and RETRIEVE_DATA).

Adjustment to the configuration


When using this application within a comprehensive project where some of the
TCP connections have already been configured, you adjust the ID parameter of
both FTP managers (each ID (hence ID and ID+1) must only be used once).
Copyright Siemens AG 2013 All rights reserved

Adjustment to the FTP server


The standard setting for the FTP mode of the server is usually passive. When
using active, you need to adjust the MODE parameter of the FTP manager.

Modifications at the user program


You can change the data volume to be sent or received by adjusting the DATA
(Array of Char) tag in the UDT FTP_DATA_1200 (at PLC data types). The maximal
possible array length is 32767 chars, the minimal is 1. Please ensure that the
complete program is recompiled after the modification.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 34
6 Operating the Application
6.1 Menu navigation

6 Operating the Application


6.1 Menu navigation
Figure 6-1 Operator user interface of HMI Runtime

Main menu
Copyright Siemens AG 2013 All rights reserved

Example application Industry Online Support Information

Note In the user interface of the HMI you can change the display language of each
picture from German to English and vice versa by clicking on the flag icons

The example application can be started via the main menu and continuing
information be called up via the Industry Online support.
In the left tree in the example application you can switch between scenario 1 and 2.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 35
6 Operating the Application
6.2 Scenario 1 (storing data)

6.2 Scenario 1 (storing data)


Figure 6-2

5
Copyright Siemens AG 2013 All rights reserved

3 4 6

Note If IP address, user name, password and file name have already been entered in
scenario 2, these are adopted as a standard for scenario 1. You can change the
parameters afterwards manually.

The following table gives a step-by-step description of operating scenario 1:


Table 6-1
No. Action Note
1. Enter the IP address of your FTP server into the provided
fields.
2. Enter the user name and the appropriate password for the
FTP user created in the server.
3. Create a file name via the Create file name button or Look out for subfolders, for
manually enter one into the respective field. example:
FTP_Server/Datei1.dat

Any file ending is possible.


4. Generate process data via the Generate process data
button.
5. In the Overwrite / Append drop-down list you chose whether If the file does not yet exist, it is
you wish to append the data to the already existing data in generated on the server.
the given file or overwrite everything.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 36
6 Operating the Application
6.3 Scenario 2 (fetching data)

No. Action Note


6. Start the data transfer via the START button. If the green status display lights
up, the job has been executed
successfully. The process data
can now be viewed on the FTP
server at the given file name.
If the red status display lights
up, then problems occurred
during the job. Further
information is available in the
error report:

6.3 Scenario 2 (fetching data)


Figure 6-3
Copyright Siemens AG 2013 All rights reserved

4 5

Note If IP address, user name, password and file name have already been entered in
scenario 1, these are adopted as a standard for scenario 2. You can change the
parameters afterwards manually.

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 37
6 Operating the Application
6.4 Settings

The following table gives a step-by-step description of operating scenario 2:


Table 6-2
No. Action Note
1. Enter the IP address of your FTP server into the provided
fields.
2. Enter the user name and the appropriate password for the
FTP user created in the server.
3. Enter the file name of the file to be transferred into the Look out for subfolders in the
respective field. server root directory, for
example:
CPU1/Datei1.dat
4. Delete the process data on the controller via the Delete data Optional
record button
5. Start the data transfer via the START button. If the green status display lights
up, the job has been executed
successfully. The process data
can now be viewed in the
Process data field.
If the red status display lights
up, then problems occurred
during the job. Further
Copyright Siemens AG 2013 All rights reserved

information is available in the


error report:

6.4 Settings
The figure below shows the settings options of HMI Runtime:
Figure 6-4

Enable monitor
keyboard Open the Task Terminate Runtime;
Manager Trigger the transfer

Stop runtime

Calibrate screen

Extablish
connection with Terminate PLC
PLC connection

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 38
7 Related Literature and Links

7 Related Literature and Links


This list is not complete and only represents a selection of relevant literature.
Table 7-1
Topic Title / Link
\1\ Siemens Industry http://support.automation.siemens.com
Online Support
\2\ Downloadseite des http://support.automation.siemens.com/WW/view/de/81367009
Beitrages
\3\ OUC-Bausteine: http://support.automation.siemens.com/WW/view/de/77991795
TCON; TDISCON;
TSEND; TRCV;
\4\ FileZilla Server https://filezilla-project.org/download.php?type=server

8 History
Table 8-1
Copyright Siemens AG 2013 All rights reserved

Version Date Modifications


V1.0 10/2013 First version

FTP-Kommunikation S71200
Version 1.0, Entry ID: 81367009 39

You might also like