Professional Documents
Culture Documents
PB Communication Via Network Components en
PB Communication Via Network Components en
This entry is from the Service&Support portal of Siemens AG, Sector Industry,
Industry Automation and Drive Technologies. The general terms of use
(http://www.siemens.com/terms_of_use) apply.
Clicking the link below directly displays the download page of this document.
http://support.automation.siemens.com/WW/view/en/49741875
Question
How do you exchange data between PC and SIMATIC S7 over PROFIBUS
network components using the S7 communication?
Answer
The instructions and notes listed in this document provide a detailed answer to this
question.
Table of Contents
1 Introduction........................................................................................... 5
2 Overview of the Sample Program ........................................................ 6
Plant configuration................................................................................ 6
Function of the sample program .......................................................... 6
Function overview ................................................................................ 7
Data communication............................................................................. 7
Active partner and passive partner ...................................................... 7
Program overview ................................................................................ 8
User program of the active partner PC station..................................... 8
User program of the passive partner S7-400 station ........................... 8
3 Plant Configuration............................................................................... 9
3.1 Overview .............................................................................................. 9
3.2 Hardware and Software Components Used......................................... 9
Hardware components ......................................................................... 9
Required cables and other hardware ................................................. 10
Software requirements ....................................................................... 10
Wiring 10
4 Function Mechanisms of the Sample Program .................................. 11
4.1 Working Method of the Sample Program ........................................... 11
4.1.1 Data Communication.......................................................................... 11
4.1.2 Sequence of the User Program in the Active Partner PC Station...... 11
Increase data...................................................................................... 11
4.1.3 Sequence of the User Program in the Active Partner S7-400
Station ................................................................................................ 11
4.1.4 Overview ............................................................................................ 11
4.2 Functions and Function Blocks .......................................................... 12
4.2.1 Functions and Function Blocks in the User Program of the S7-
400 Station ......................................................................................... 12
4.3 Details of the User Program of the PC Station .................................. 12
4.3.1 Program Sequence ............................................................................ 12
4.3.2 WndProc () ......................................................................................... 13
Overview 13
4.3.3 My_write_request ()............................................................................ 14
Overview 14
Parameters of the s7_write_req () function ........................................ 14
Return value ....................................................................................... 15
4.3.4 My_read_request () ............................................................................ 15
Overview 15
Parameters of the s7_read_req () function ........................................ 15
Return value ....................................................................................... 16
4.3.5 My_get_read_confirmation () ............................................................. 16
Overview 16
Parameters of the s7_get_read_cnf () function.................................. 16
Return value ....................................................................................... 16
4.4 Program Details of the User Program of the S7-400 Station ............. 16
4.4.1 OB1 .................................................................................................... 17
Overview 17
Description ......................................................................................... 17
5 How to Use the Sample Program....................................................... 18
6 Other Notes, Tips and Tricks, etc....................................................... 19
6.1 Not Possible to Download Hardware Configuration, Connection
or Blocks to the S7-400 CPU ............................................................. 19
6.2 No Change in the Values of the Written and Read Data ................... 19
6.3 No Change in the Network Status...................................................... 20
1 Introduction
This document provides information about the examples of PROFIBUS
communication between a PC station and a SIMATIC S7 using the PUT and GET
services based on the S7 communication and incorporating network components.
Optical Link Modules (OLM) are used as network components.
Chapter 2 gives an overview of the sample program.
Chapter 4 gives information about the function mechanisms of the sample
program.
This document contains
An overview of the plant configuration.
An introduction to the blocks required and their communication structure.
Details of the user program of the PC station and SIMATIC S7.
Information on how to use the sample programs.
Other notes, tips and tricks, etc.
CPU 414-1
CP 443-5
PROFIBUS network
with OLM
OLM 1 OLM 2
Function overview
The overview of functions shows the principal working method of the sample
program.
Figure 2-2
Active partner Passive partner
PC station S7-400 station
Prepare data
for sending
Write data (2 bytes)
Save and
display
received data
Data communication
2 bytes of data are exchanged cyclically between the two stations involved in the
communication. The user data is in the first byte and the OLM status in the second
byte. These are displayed in the relevant dialog window on the PC.
Program overview
Figure 2-3
Active partner PC station Passive partner S7-400 station
PC user program
Data transfer
PUT
Call the PUT and GET functions Internal operating system
when requested, functions provide data,
Increment value Scan signaling contact cyclocally
Data transfer
GET
3 Plant Configuration
This chapter gives you an overview of the configuration and the hardware and
software components used to create the sample program.
3.1 Overview
Table 3-1 gives an overview of the configuration used to create the sample
program.
Table 3-1
Table 3-3
Slot Module Order number
1 PS 407 10A 6ES7407-0KA00-0AA0
2 CPU 414-1 6ES7414-1XG02-0AB0
4 CP443-5 Basic 6GK7 443-5FX00-0XE0
Notes The sample project has been created with a specific hardware configuration.
This must be maintained to ensure proper functioning.
If you use a different configuration, with a different CPU or CP, for example, then
you must change the sample program accordingly.
Software requirements
STEP 7 V5.03 or higher
NCM S7 INDUSTRIAL ETHERNET V5.03 or higher
SIMATIC NET PC software S7-5613/Windows NT for CP5613 or higher
Wiring
You must set the isolated contacts to the input module of the S7-400 station to
evaluate the alarm contacts of the OLMs.
Figure 3-1
2 bytes of data are exchanged cyclically between the two stations involved in the
communication.
You need a user program in the active partner PC station. This uses functions from
a library for the communication. The exact functions of the user program are
described in section 4.3.
Increase data
The value of the data to be written is increased by one and the write/read cycle
starts over.
4.1.3 Sequence of the User Program in the Active Partner S7-400 Station
In the active partner S7-400 station the alarm contacts of the OLMs are read in and
put as status byte in the send buffer for the passive partner. In this way the passive
partner reads out the network status in addition to the user data.
4.1.4 Overview
Figure 4-1 gives a graphical view of how the user programs work in the active and
passive partners.
Figure 4-1
Active partner PC station Passive partner S7-400 station
PC CP CP CPU
• prepare the CP
• PUT Wirte to the Enter the network
passive station status in the
• GET
memory bit area
Read from the
passive station
Increment the
value of data to be
written by 1
PROFIBUS
Communication cycle
No functions and function blocks are called in the user program of the S7-400
station to transfer data.
The data is provided by the internal operating system functions.
Figure 4-2
Start
switch
(aMessage)
return (0)
IDM_START
my_initiate_request ()
return (FALSE)
End
4.3.2 WndProc ()
Overview
Figure 4-3
Description
The WndProc() function is called cyclically. It controls the sequence of the
application and is therefore comparable with an OB1 in SIMATIC S7.
The WndProc() function processes EVENTS originating from the application
window. When the user sends new data, the application generates a message.
The messages are used as control values in the WndProc () function.
4.3.3 My_write_request ()
Overview
Figure 4-4
Description
The my_write_request () function is called in the my_receive () function. The
my_write_request () function writes the data to the passive station.
Parameter Description
Value[]:
This parameter is an array in which the data to be
sent is stored. The HIBYTE is set to the value "0"
because the network status of the passive station is
entered in this byte.
Return value
The return value of the s7_write_req () function is stored in the iRet parameter. If
the return value does not have the value "S7_OK", then the fault is output and the
application is terminated.
4.3.4 My_read_request ()
Overview
Figure 4-5
Description
The my_read_request () function is called in the my_receive () function. The
my_read_request () function reads the data from the passive station.
Return value
The return value of the s7_read_req () function is stored in the iRet parameter.
If the return value does not have the value "S7_OK", then the fault is output
and the application is terminated.
4.3.5 My_get_read_confirmation ()
Overview
Figure 4-6
Description
When the read job has been completed is evaluated in the
my_get_read_confirmation () function.
Return value
The return value of the s7_get_read_cnf () function is stored in the iRet parameter.
If the return value does not have the value "S7_OK", then the fault is output and
the application is terminated.
4.4.1 OB1
Overview
Figure 4-7
Description
OB1 is the block responsible for cyclic processing of the user program. The alarm
contacts are evaluated in OB1.
Table 6-2
Check Remedy
Check whether the PROFIBUS bus cable is Connect the PROFIBUS bus cable to the
connected to the CP443-5 in the S7-400 RS485 interface of the CP443-5 and the
station and to CP5613 in the PC station. OLM.
If the PROFIBUS cable is not connected to Connect another PROFIBUS bus cable to
CP443-5 in the S7-400 station and to the RS485 interface of the CP5613 and the
CP5613 in the PC station, no connection OLM.
can be established between the two
stations. Data exchange is not possible.
Check whether monitoring of the port is Set the switch on the top side of the OLM to
enabled. "1" for the ports to be monitored.
You can enable and disable the monitoring
function individually for each port. At the
ports where monitoring is enabled a node
must be connected and the network adapter
enabled so that the OLM recognizes a link.
You can determine this from the control
LEDs (LS [port number]) on the front.
Check that the CPU is in "RUN" mode. Switch the CPU to "RUN" mode via the key
Since the user program evaluates the alarm switch or the PG command.
contacts in the S7-400 station the CPU
must be in "RUN" mode to deliver a correct
status.
Notes If these notes, tips and tricks etc. for the commissioning and working of the
sample program have not been of assistance, then repeat the commissioning of
the sample program.