Communication Via The CM PTP Rs232 of The Simatic S7-1500 Using Freeport Protocol
Communication Via The CM PTP Rs232 of The Simatic S7-1500 Using Freeport Protocol
https://support.industry.siemens.com/cs/ww/en/109474684
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
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 of the burden of
proof to your detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of the Siemens AG.
Security
information
Siemens provides products and solutions with industrial security functions that
support the secure operation of plants, solutions, machines, equipment and/or
networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a productspecific newsletter. For more information, visit
http://support.industry.siemens.com.
03/2013
Table of contents
Table of contents
Warranty and liability................................................................................................... 2
1
Task ..................................................................................................................... 4
Solution............................................................................................................... 5
2.1
2.2
Introduction ........................................................................................... 8
Setting the parameters in the TIA Portal V12....................................... 9
Overview............................................................................................. 11
Operation of the FB PtP_Freeport (FB770) ....................................... 13
States and call of the FB PtP_Freeport (FB770) ............................... 13
Startup state ..................................................................................... 15
Configuration (Port_Config) state .................................................... 16
Reset receive buffer (Receive_Reset) state .................................... 18
Receive data (Receive_P2P) state .................................................. 19
History............................................................................................................... 29
03/2013
1 Task
2.1 Solution overview
Task
Introduction
This application shows you how to use the serial interface of the SIMATIC S7-1500
automation system.
As an example, the data of a handheld scanner is received via the communication
interface of the automation system and stored in the controller.
Overview of the automation task
The following figure gives an overview of the automation task:
Figure 1-1
S7-1500
Automation system
S7-1500
Controller:
configuration,
data storage
RS232
Communication interface
Reading
device
Data carrier
03/2013
2 Solution
2.1 Solution overview
Solution
2.1
Solution overview
Engineering sPaPion
STEP7 V12
MV340
CM PPP
RS232
S7-1500
03/2013
2 Solution
2.2 Hardware and software components used
Advantages of this solution
This application offers you the following advantages:
Validity
2.2
Hardware components
Table 2-1
Component
Qty.
Ordering number
Note
PM 70W 120/230
AVC
6EP1332-4BA00
CPU 1516-3
PN/DP
6ES7516-3AN00-0AB0
CM PtP RS232
HF
6ES7541-1AD00-0AB0
SIMATIC MV340
6GF3340-0HT01
Note
If you are using a different hardware than the one in the sample
project, you have to perform the respective changes in the hardware
configuration!
03/2013
2 Solution
2.2 Hardware and software components used
Standard software components
Table 2-2
Component
STEP7 V12
(TIA Portal V12)
Qty.
1
Ordering number
Note
6ES7822-1AE02-0YA5
Note
109474684_S71500_CM_PtP_MV340_DOKU_V1_en.pdf
Application Description
109474684_S7-1500_CM_PtP_MV340_CODE_V1.zip
In the chapter Literature you can find helpful links on the issue.
On the HTML page of the application you can furthermore find a project to connect
the handheld reader MV340 via the CM PtP of an ET 200SP to a S7-300 station.
03/2013
3.1
Introduction
Freeport is a freely programmable, telegram-based protocol which is also known as
ASCII protocol. It controls the data transmission for a point-to-point connection
between the communication module and a communication partner.
The Freeport protocol only includes the bit transmission layer (layer 1).
You can set different parameters for the protocol. You have to specify a large
amount of the parameters separately, for the send and for the receive direction.
Parameter
The following parameters for the connection can be set for the sending of data via
the Freeport protocol:
Parity
Stop bits
Flow control
Operating mode
The parameters below can be set separately, for the receive and the send direction
each:
According to the settings, the CM will recognize the start and the end of a telegram.
An extensive list with description of the parameters of the Freeport protocol can be
found in the Configurations for Point-to-Point Connections manual (see Literature
\http://support.automation.siemens.com/WW/view/en/59057093 \)
03/2013
3.2
Figure 3-1
Make sure that the communication partner of the CM PtP (in this application
example the handheld reader MV340) is suitably configured to your settings.
Instructions for Freeport
Additionally or alternatively to the settings in the hardware configuration (see
Figure 3-1) the following three instructions are provided. These instructions
overwrite the settings of the hardware configuration.
Port_Config
You can change the RS232 port parameters, such as, for example, the data
transmission rate in running operation with the Port_Config (port configuration)
instruction from the user program.
Receive_Config
You can change the serial receive parameters in running operation with the
Receive_Config (receive configuration) instruction. This instruction configures
the conditions that identify the start and the end of the received data.
Send_Config
You can change the serial transmission parameters in the user program in
running operation with the Send_Config (send configuration) instruction. This
instruction configures the start and end identifier that are sent with a telegram.
03/2013
Receive_P2P
The Receive_P2P instruction (receiving data via a point-to-point connection)
checks the telegrams that have been received in the CM. If a telegram is
available, it is transferred from the CM to CPU.
Send_P2P
The Send_P2P instruction (sending point-to-point data) starts the transmission
of data and transfers the content of the assigned buffer to the communication
module.
If your serial terminal device uses secondary signals, you can set them and read
them out with the following instructions, provided automatic operation is not
configured:
Signal_Set
Signal_Get
03/2013
10
4.1
Overview
Functions
The S7 program realizes the following functions:
Receiving the data of the MV340 from the CM PtP (Receive_P2P) and storage
in a ring buffer
Schematic layout
Figure 4-1 shows the program structure of the STEP7 project.
Figure 4-1
03/2013
11
Main
OB100
Startup
FB770
PtP_Freeport
DB770
PtP_Freeport_DB
Instance DB of FB PtP_Freeport
DB771
Port_Config_Settings
DB772
buffer_ptp
Instruction:
FB610
Port_Config
Instruction:
FB617
Receive_Reset
Instruction:
FB614
Receive_P2P
Instruction:
FB1001
R_TRIG
03/2013
Program call
Description/classification
In-house development
Symbolic name
System blocks
Element
12
4.2
4.2.1
States
FB770 fulfils the following tasks:
Receiving data from the communication module and storage in a ring buffer
This functionality has been realized as a simple sequence with the following states:
Figure 4-2
New start
INIT
Init = OK
Wait for
Data
Reset =
DONE
Configuration =
DONE
A precise description of the individual states can be found in chapter 4.2.2 Startup
state.
03/2013
13
Figure 4-3
Table 4-2
Parameter
PORT
Type
IN
UInt
Note
INIT
IN
Bool
DONE
OUT
Bool
ERROR
OUT
Bool
03/2013
14
4.2.2
Type
Note
STATUS
OUT
DWOR
D
STATE
OUT
Int
RING_PLACE
OUT
Int
LENGTH
OUT
UInt
Startup state
Overview
The internal program variables, such as, for example, the current state of the
program and the current position in the ring buffer.
03/2013
15
4.2.3
Overview
The FB770 is in the Configuration state due to the initialization in Startup state
and the setting of the internal "PtP_Freeport_DB".navi.state = "Configuration"
variable.
In this state the Port_Config instruction for setting the communication parameters
of the point-to-point connection is called.
Note
The call of Port_Config is optional and overwrites the settings of the hardware
configuration. If you want to change your communication settings dynamically,
use the Port_Config instruction for this purpose.
Program code
Figure 4-4
2.
1.
3.
4.
03/2013
16
No
.
Step
Note
1.
2.
3.
4.
Parameter
Value
PROTOCOL 0 (Freeport)
Note
Protocol
BAUD
PARITY
DATABITS
STOPBITS
2 (2 stop bits)
Stop bits
Flow control
MODE
Operating mode
0 (Full duplex
RS232)
Note
03/2013
17
4.2.4
Overview
If the DONE output of Port_Config shows that the configuration job has been
completed, the reset receive buffer state is triggered.
The receive buffer is reset, in the event that there is already data in the receive
buffer of the CM PtP.
Program code
Figure 4-5
1.
2.
3.
Description
The following step table describes the program code:
Table 4-4
No.
Step
Note
1.
2.
3.
03/2013
18
4.2.5
Overview
FB770 goes to the Receive data state once the receive buffer of the
communication module was deleted. As a result, the initialization steps are ended
and the Receive data state is processed cyclically.
The Receive data state is split the following way:
Figure 4-6
1.
2.
3.
Step
4.
5.
6.
Note
Note!
The CM PtP RS232 HF can
receive telegrams of a length of
up to 4kByte.
03/2013
19
1.
2.
.
.
3.
Step
Note
7.
8.
9.
Note!
Your telegram last received starts in the
DB buffer_ptp with RING_PLACE
offset and ends with ; or after the
number of LENGTH bytes.
03/2013
20
Requirement
You have to adjust the communication settings of the CM PtP if one of the following
conditions is fulfilled:
You are not using the default settings of the handheld reader SIMATIC MV340
You are using a different distributed I/O device which has different
communication settings than the default settings of the MV340.
Procedure
10.
11.
Note
Port_Config:
Changing of parameters such as data transmission rate via the user program
in running operation.
For this purpose, compare the previous section with the instruction on how to
directly change parameters in the sample project via the DB
Port_Config_Settings.
03/2013
21
If you want to change other parameters, you can insert the following instructions:
Send_Config
Changing the serial transmission parameters via your program. This instruction
configures the conditions that indicate the start and the end of the data to be
sent.
Receive_Config:
Changing the serial receive parameter via your program in running operation.
This instruction configures the conditions that identify the start and the end of
the received data.
No.
Instruction
Note
12.
13.
03/2013
22
No.
Instruction
14.
15.
16.
NOTICE
Copyright Siemens AG 2013 All rights reserved
Note
03/2013
23
6.1
Hardware
You require the hardware that is listed in chapter 2.2 Hardware and software
components used.
Structure
Figure 6-1
Engineering station
PS
MV340
CM
S7-1500 PtP
STEP7 V12
RS232
230V
230V
The table describes the procedure for the hardware setup of the project.
Observe the rules for the set up of a PLC station.
Table 6-1
No.
Procedure
17.
18.
19.
20.
Note
03/2013
24
Procedure
21.
22.
23.
Note
Save settings
03/2013
25
6.2
No.
Procedure
1.
2.
3.
4.
Note
03/2013
26
6.3
Figure 6-2
ABCDEFGHIJKL
Hello World!
Siemens AG
0123456789
If you would like to send individual data, you can use, for example, code
generators that you can find on the internet.
Example:
http://www.automation.siemens.com/mcms/identification-systems/en/code-readingsystems/Pages/default.aspx
On the right under "More information > Data Matrix Code Generator"
03/2013
27
Note
Indicates the current status of the
program.
PtP_Freeport_DB".RING_PLACE
PtP_Freeport_DB".Control.Rcv_Length_save
PtP_Freeport_DB".Control.P2P_NDR_save
PtP_Freeport_DB".Control.P2P_ERROR_save
PtP_Freeport_DB".Control.Config_ERROR_save
PtP_Freeport_DB".Control.Reset_ERROR_save
PtP_Freeport_DB".navi.state
03/2013
28
7 Related literature
Related literature
This list is by no means complete and only reflects a selection of suitable
information.
Table 7-1
Topic
Title
\1\
Link to this
document
http://support.automation.siemens.com/WW/view/en/109474684
\2\
Siemens Industry
Online Support
http://support.automation.siemens.com
\3\
SIMATIC MV340
Manual
http://support.automation.siemens.com/WW/view/en/61909865
\4\
CM PtP
Configurations for
Point to Point
Connections
http://support.automation.siemens.com/WW/view/en/59057093
\5\
Device manual
Communication
module
CM PtP RS232
HF
http://support.automation.siemens.com/WW/view/en/59057160
\6\
Device Manual
Communication
Module
CM PtP RS232
BA
http://support.automation.siemens.com/WW/view/en/59057152
History
Table 8-1
Version
Date
V1.0
27.02.2013
03/2013
Modifications
First version
29