Вы находитесь на странице: 1из 32

Application for Communication

Client / Server Communication with (I) Slaves via S7 Basic Communication (I_PUT/ I_GET)

Client / Server Communication with (I) Slaves via S7 Basic Communication

Warranty, Liability and Support

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 document 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). However, claims arising from a breach of a condition which goes to the root of the contract shall be limited to the foreseeable damage which is intrinsic to the contract, unless caused by intent or gross negligence or based on mandatory liability for injury of life, body or health. The above provisions does not imply a change in the burden of proof to your detriment. The Application Examples are not binding and do not claim to be complete regarding the circuits shown, equipping and any eventuality. They do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible in ensuring that the described products are correctly used. These Application Examples do not relieve you of the responsibility in safely and professionally using, installing, operating and servicing equipment. When using these Application Examples, you recognize that Siemens cannot be made liable for any damage/claims beyond the liability clause described above. 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 - then the contents of the other documents have priority. Copyright 2004 Siemens A&D. It is not permissible to transfer or copy these Application Examples or excerpts of them without first having prior authorization from Siemens A&D in writing. For questions about this document please use the following e-mail-address: csweb@ad.siemens.de

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Rev. A Final 18.02.2004

2/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Table of contents
1 2 2.1 2.2 3 3.1 3.2 3.3 3.4 4 4.1
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Task Specification...................................................................................... 4 Principle of the Automation Solution ....................................................... 6 Overview ...................................................................................................... 6 Required components .................................................................................. 6 Function Mechanisms and Project Descriptions .................................... 8 Main properties of the S7 basic communication .......................................... 8 Structure and function of the S7 project..................................................... 12 Server interface.......................................................................................... 16 Client user program.................................................................................... 16 Commissioning ........................................................................................ 21 Configuring the hardware and loading the S7 project ................................ 21 Bus cabling................................................................................................. 23 Operator control and monitoring ................................................................ 24 Integrating a further (I) slave ...................................................................... 29

4.2 4.3 4.4

Rev. A Final 18.02.2004

3/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Task Specification

Technological task / overview A CPU, as master, is connected to several intelligent stations (I Slaves) via a Profibus interface.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 1-1

Small data sets shall be transferred from the slave to the master using the S7 basic communication.

Note The S7 basic communication technology has been selected as it is supported by all todays (not highly available) CPUs of the 300 and 400 series. The configuration of an active S7 connection, as it would be required for an S7 communication (PUT/ GET), is only possible using at least CPU 317 or an additional Profibus CP as an interface.

Application requirements The application shall illustrate methods of bi-directional data transfer to intelligent Profibus stations. In the case of the S7 basic communication, I_PUT/ I_GET enables you to exchange data with intelligent DP slaves without an additional Profibus CP. The slaves are servers which provide small data sets. The master CPU as client collects the data of several servers. In spite of its passive server interface, the trigger for data transfer comes from the slaves. Furthermore, it should be possible to transfer data sets which exceed the maximum user data size of the S7 basic communication (76 bytes).

Rev. A Final 18.02.2004

4/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

This application shows how the corresponding user interface should look like at both the server and client sides. An I slave can actively send the pre-processed data sets to the DP master. The DP master receives the data packets and stores them in separate receive buffers. A simple disposal and acknowledgement routine should be provided at the client site for this purpose.

Note This mechanism is generally applicable to all communication types, where the CPU provides only a mere server interface (e.g. X_PUT/X_GET, PUT/GET). The PUT/GET topic is described in detail in the Client Server Communication between WinAC Basis and S7-200 Stations via S7 Communication (PUT/GET) Application.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Rev. A Final 18.02.2004

5/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

2
2.1

Principle of the Automation Solution


Overview
The following figure shows the entire hardware configuration.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 2-1

The computer (PG/PC) is used for configuration, as well as for operator control and monitoring of the sample application. Intelligent slaves have their own CPU which are able to process I/O signals on site. The S7 basic communication enables you to exchange data between slave and master stations using a Profibus connection.

2.2
Hardware

Required components

Table 2-1

Component Simatic Field/Power PG On Board CP 5611 PS 307 5A CPU 315-2 DP

MLFB / Order number 6ES7711-XXXXX-XXXX -6ES7 307-1EA00-0AA0 6ES7 315-2AG10-0AB0

Note Part of PG hardware Or similar PS Support of S7 basic communication (see FAQ 506934) 64k (as an example)

IM151-7 CPU ET200S Micro Memory Card

6ES7 151-7 AA10-0AB0 6ES7 953-8LF00-0AA0

Rev. A Final 18.02.2004

6/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Software The following software is required for commissioning:


Table 2-2

Component STEP7 V5.2 NCM S7 Profibus

MLFB / Order number 6ES7810-4CC06-0YX0 --

Note Part of STEP7

Example project This Application consists of the present documentation and a STEP7 example project. The example project includes the hardware configuration for both stations as well as an executable STL user program for each station.
Table 2-3
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Component 20987910_BaseComm_Islaves_DOKU_v10_d.pdf 20987910_BaseComm_Islaves_DOKU_v10_e.pdf 20987910_BaseComm_Islaves_CODE_v10.zip

Note Documentation, German Documentation, English STEP7 example project

Installation notes are available in Chapter 4 Commissioning.

Rev. A Final 18.02.2004

7/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

3
3.1

Function Mechanisms and Project Descriptions


Main properties of the S7 basic communication
All todays (not highly available) S7/M7 300/400 (incl. WinAC Slot 41x) and C7-600-CPUs have simple functions (SFCs) for transmission of small data volumes via S7 connections. The connections are not configured but explicitly established during the SFC call. The maximum amount of transferable user data per communication job is 76 bytes at all CPUs as a standard.

Physical connection of communication partners The S7 basic communication is realized through the following networks: MPI Profibus
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Position in the ISO/OSI reference model Like the S7 communication, the S7 basic communication also uses the S7 protocol for data transfer.

Fig. 3-1

Rev. A Final 18.02.2004

8/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

The S7 protocol is located on level 7 in the ISO/OSI reference model (application layer) as the used system interface is purely based on application data. Classification of services of the S7 basic communication The S7 basic communication supports the following services: I_GET/ I_PUT X_ SEND/ X_RCV X_GET/ X_PUT

Table 3-1 contains an overview of the respective performance data. This Application is focused on the service which is coloured in the table below.
Table 3-1

Services/ Features
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

I_GET/ I_PUT E, A, M, D 8 bytes for 300 CPUs 76 bytes for 400 CPUs

X_ SEND/ X_RCV E, A, M, D 8 bytes for 300 CPUs 76 bytes for 400 CPUs

X_GET/ X_PUT E, A, M, D 8 bytes for 300 CPUs 76 bytes for 400 CPUs External (Client / Server) See CPU specification SFC 67 X_GET SFC 68 X_PUT SFC 69 X_ABORT Via its MPI address

Address areas Data consistency Principles Max. number of connections Block types

Internal (Client / Server) External (Client / Server) See CPU specification SFC 72 I_GET SFC 73 I_PUT SFC 74 I_ABORT See CPU specification SFC 65 X_SEND SFB 66 X_RCV Via its MPI address

Station addressing

Logical address = diagnostic address

In contrast to external services (with X in front), communication partners of internal services (with I in front) must be in the same S7 station (slave stations are integrated into the hardware configuration of the master station in this example). User interface I_PUT/ I_GET This service enables you to exchange data with all communication partners which can be addressed via E/A addresses of a station (e.g. DP systems). Since this functionality is provided by the operating system of the partner, no SFC is needed to be placed there. The number of communication partners which can be successively accessed is not limited (if the disconnection has been configured after the job execution; see parameters CONT in Table 3-2 and Table 3-3). Yet, the data exchange is considerably quicker if the connection remains established. For more information on possible resource problems see Chapter 4.4 Integrating a further (I) slave.

Rev. A Final 18.02.2004

9/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Sending with SFC 73 I_PUT The figure below shows the SFC 73 input and output parameters.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 3-2

The individual parameters are defined as follows:


Table 3-2

Parameter REQ CONT

Decl. IN IN

Description The inactive system function is activated at High status. CONT=0: Once the data transfer is complete, the connection is disconnected. The used connection resource is released again. CONT=1: After completion of the data transfer, the connection remains established. Due to this, the next job can be executed faster.

IOID

IN

Identifier of the address range of the partner module: B#16#54 = Peripheral input (PI) B#16#54 = Peripheral output (PO)

LADDR VAR_ADDR SD

IN IN IN

Diagnostic address of the partner module configured in the HW configuration. Pointer to the areas on the partner module to which the data will be written. Data area to be sent. SD must be the same length as the VAR_ADDR parameter at the communication partner. Moreover, the data types of SD and VAR_ADDR must also match. Error code, if an error occurs while the function is being executed. High, sending is not yet completed.

RET_VAL BUSY

OUT OUT

Rev. A Final 18.02.2004

10/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Receiving with SFC 72 I_GET The figure below shows the SFC 72 input and output parameters.

Fig. 3-3
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

The individual parameters are defined as follows:


Table 3-3

Parameter REQ CONT

Decl. Description IN IN The inactive system function is activated at High status. CONT=0: Once the data transfer is complete, the connection is disconnected. The used connection resource is released again. CONT=1: After completion of the data transfer, the connection remains established. Due to this, the next job can be executed faster.

IOID

IN

Identifier of the address range of the partner module: B#16#54 = Peripheral input (PI) B#16#54 = Peripheral output (PO)

LADDR

IN

Diagnostic address of the partner module configured in the HW configuration. Pointer to the areas on the partner module from which the data will be read. Error code if an error occurs while the function is being executed. High, read job is not yet completed. The receiving area where the data is stored. RD must be the same length as the VAR_ADDR parameter of the communication partner. Moreover, the data types of RD and VAR_ADDR must also match.

VAR_ADDR IN RET_VAL BUSY RD OUT OUT OUT

Rev. A Final 18.02.2004

11/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

3.2

Structure and function of the S7 project

Operating principle The S7 project consists of a server (DP slave) and a client (DP master) station. The server CPU provides fictitious data in a data block (source area). By setting a special trigger bit, the client is prompted to fetch the data. In spite of its passive server interface, the DP slave logically functions as master. The user program of the client CPU cyclically polls the trigger bit of the server CPU. If the High status is detected, the data is transmitted into a local data block (target area). Finally, the trigger bit of the server is reset by the client.

Note
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

As described in Table 3-2 and Table 3-3, the CONT parameter affects the connection establishment and disconnection of the communication between the communication partners at I_PUT and I_GET. In the present S7 project, CONT was always parameterized with TRUE which causes that the used connection remains established after completion of the job. This reduces the access time for data transmission, however, it also occupies connection resources permanently. The limit of the maximum number of connection resources, as well as the number of communication partners involved, must thereby be taken into consideration (see Chapter 4.4 "Integrating a further (I) slave.

Rev. A Final 18.02.2004

12/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Data flow model The components involved in the communication are illustrated in the figure below as an example for one connection.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 3-4

According to an ID from the declaration section of the source area, the data is stored in one of the 5 receive buffers created for the slave stations. Besides the net data, a time stamp specifying the trigger time is additionally transferred and saved.

Rev. A Final 18.02.2004

13/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Program structure The S7 project has the following structure.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 3-5

The function of the individual blocks is described in the section below.

Note OBs 82 and 86 are also located at the server site in the block container, but they are not described in this document in detail as they have not been changed. They are used for error control in slave operation.

Rev. A Final 18.02.2004

14/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Description of program components


Table 3-4

Component OB100 COMPLETE RESTART OB1

Function When restarting the CPU, the Acknbit is set to 0. When acknowledging, this value is assigned to the start bit of the communication partner. FB1 is called for each communication partner (data server) with one instance DB per partner. The diagnostic address of these modules (source address) as well as the number of a further data block (target area) is transferred. Every 100 ms a polling trigger bit is set which fulfils the starting condition for I_GET calls for polling communication partners in OB1. FB1 includes a sequence chart. In the first step, the server is polled for a new job (polling). If a new job exists, the data is requested in the following steps and the receipt finally acknowledged on the server by resetting the corresponding bit. FC1 is called by FB1 to dynamically generate the ANY Pointer required for the I_GET call (data transfer) using the polled information (data set length and -ID). Instance DB of FB1. As FBI is called for each slave with a separate instance DB, communication procedures can run completely in parallel. Target area for the configured DP slave. The data block includes 5 receive buffers of type UDT1 DATA of 108 bytes each. 8 bytes are reserved for a time stamp and 100 bytes for net data. Only FC1 is called. The bit signalling the client that new data is ready to be fetched is polled in DB1. When a positive edge is identified, the system time is read in and filed in DB1 as a time stamp. The source area includes a declaration section: Start (1 bit), Length (1 byte), Record_ID (1 byte), a time stamp (8 bytes) and maximum 100 bytes of the data type UDT1 DATA for net data.

OB35 CYC_INT5

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Client Server

FB1 CLIENT

FC1 DYN_ANY

DB1Instance of FB1

DB3 SLAVE3 UDT1 DATA OB1 FC1 SERVER

DB1 DATA_RECORD

UDT1 DATA

100 bytes are reserved for net data.

Rev. A Final 18.02.2004

15/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

3.3

Server interface

Note The user program of the server is limited to updating the time stamp in DB1 after the start bit was set there, as already mentioned in Table 3-4. The comments in the AWL code are sufficient for understanding the procedures involved.

The DB1 DATA_RECORD memory area, the actual interface of the server, has the following structure:
Table 3-5

Symbolic Name Start Length


Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Start address 0.0 1.0 2.0

Explanation Signals the client that a new data set is available. Specified length of net data. 100 bytes are defined as the maximum value. A value between 1 and 5 specifying the receive buffer where the data is to be stored in the respective client DB. It is automatically updated by the S7 program. Specifies the time when the start bit was set. Maximum 100 bytes of net data.

Record_ID

Time_Stamp Data_record

4.0 From 12.0

3.4

Client user program

Program sequence The following table describes the FB1 CLIENT program sequence. It is realized as a simple sequence chart.

Note For an understanding of FC1 DYN_ANY for dynamic generation of ANY pointers, comments in the AWL code are sufficient.

Rev. A Final 18.02.2004

16/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Table 3-6

Flowchart Network 1

Explanation STEP 1 (first step of the sequence chart) STEP 1 is activated after the first call of FB1 as well as at the end of the sequence chart. An I_GET call (SFC 72) which polls the first 3 bytes from the source DB is started by OB35 on each trigger as long as STEP1 is active. The received start bit is checked after each complete I_GET call. Depending on the received data set length, the start conditions for either one or two I_GET calls are activated. Furthermore, length specifications required for the pointers are calculated.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

to Network 2 Network 2 STEP2

Based on the polled information, FC1 generates ANY pointers required for I_GET as a source and target address.

The time stamp and (the first) net data are loaded.

If a further I_GET call is required to transfer all the data, STEP2_a is activated. Otherwise the acknowledgment takes place in STEP3.

to Network 3

Rev. A Final 18.02.2004

17/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Flowchart Network 3

Explanation STEP2_a

Based on the polled information, FC1 generates ANY pointers required for I_GET as a source and target address. They point to the second packet of the data set. The second packet of the net data is loaded.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

to Network 4 Network 4 STEP3

The successful receipt of data is acknowledged on the server by resetting the start bit.

to the block end

Rev. A Final 18.02.2004

18/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Code excerpt FB1 CLIENT Poll The SFC72 I_GET call for polling a server (DP slave) is depicted below. The functions of individual parameters have already been described in Table 3-3.

Fig. 3-6
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

The ANY pointer to the source area (VAR_ADDR) is directly specified here. The target area parameter (RD), however, point to a byte array in the instance DB. The first 3 bytes of the source DB are polled. The start bit, data set length and -ID are contained there. The 3 bytes are stored locally. Finally, the array is evaluated and the following information filtered. InstructionFromServer (Start bit) Length (byte) Record_ID (byte)

Code excerpt FB1 CLIENT Data receipt Dependent on the polled data set length one or two I_GET calls are required. Both code elements are only distinguished by their source and target addresses which were dynamically generated by FC1 DYN_ANY beforehand. The example figure below shows an I_GET call for the first of two possible data packets.

Rev. A Final 18.02.2004

19/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 3-7

The ANY pointers to the source and target area are provided here with the return values of FC1 DYN_ANY. Besides the addresses, the dynamic pointers also include the number of bytes to be transferred which is specified by the polled length. Code excerpt FB1 CLIENT Acknowledgment For write access to the server an I_PUT function is called which resets the start bit in the source DB.

Fig. 3-8

VAR_ADDR directly points to the first bit in DB of the server. The value of the local bit memory AcknBit (M2.1) describes the value which is already in the Low status (False cannot be directly transferred to the SD parameter).

Rev. A Final 18.02.2004

20/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Commissioning

Note At this point, we will not go further into the installation of STEP7. The installation takes place in the familiar Windows environment and is self-explanatory. There is a number of methods to load S7 user programs into CPUs, however, just one of them is described in the following. Please use the method you prefer.

4.1

Configuring the hardware and loading the S7 project


The components of the hardware configuration can be seen in Chapter 2.2 Required components

Table 4-1
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Step 1

Action

Description / Picture

Mount the S7-300 with the PS Master station module to the rack rail according to the installation guidelines. Mount the IM151-7 CPU (ET 200S) incl. Micro Memory Card to a rail according to the installation guidelines and connect the power supply. During initial commissioning, (delivery status) the CPUs can be accessed via MPI. Open the Run ->SIMATIC -> STEP 7 -> PG/PC-Setting the PG/PC-Interface dialog box. Select MPI as the access point.
Slave station

Rev. A Final 18.02.2004

21/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Step 4

Action Check the settings in the Properties dialog box and close the two dialog boxes by clicking OK.

Description / Picture

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Connect the MPI interface of the Master CPU directly with your PG/PC using an MPI/ Profibus cable. If not already done, open the project in the SIMATIC Manager and select Station1_Master. Load the client program into S7-CPU using PLC -> Download or the button. Besides the user program, the network configuration already configured in the HW configuration is loaded: MPI address: Profibus DP address: 2 2

Checkmark the PG/PC is the only See Step 3 and Step 4. master on the bus in the Properties dialog box of the PG/PC interface. Now connect the Profibus interface of the ET 200S directly with your PG/PC. Select Station2_Slave and load the Besides the user program, the network server program into the CPU of the configuration already configured in the HW ET 200S using PLC -> Download configuration is loaded: or the button. Profibus DP address: 3

Rev. A Final 18.02.2004

22/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

4.2

Bus cabling
By loading the stations, the IM 151-7 CPU has been configured as (I) slave and the S7-300 CPU as DP master. In the following, the installation of the Profibus communication is completed.

Table 4-2

Step 1

Action Connect the Profibus interface of the Master CPU to the MPI/Profibus interface of the ET 200S. Connect a further MPI/ Profibus cable you connected to your PG/ PC alternatively to the Profibus connector of the master or slave. Open the Start ->SIMATIC -> STEP 7 -> PG/PC-Setting the PG/PC-Interface dialog box. Select Profibus as the access point.

Description / Picture Bus cabling

Configuration cable

3
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Rev. A Final 18.02.2004

23/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Step 4

Action Check the settings in the Properties dialog box and close the two dialog boxes by clicking OK.

Description / Picture

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

4.3

Operator control and monitoring

Introduction Variable tables by means of which communication is controlled are included in the Master and Slave user programs. AT_Master and VAT_Slave can be found in the respective block container of the two configured stations and opened by a double-click of the mouse. To display both open variable tables side by side, we recommend using the menu item Window Arrange Horizontally. Using the button will display the online values in the stations. button can be used for overwriting the values with a

Furthermore, the control value.

Rev. A Final 18.02.2004

24/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

VAT_Slave (Server)

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 4-1

The memory areas under Declaration, as well as Net data must be controlled manually. Under Timestamp, however, the user program stores the time at which the start bit is changed to 1. The addresses entered are defined as follows:
Table 4-3

Address DB1.DBX 0.0 DB1.DBB 1 DB1.DBB 2 DB1.DBB 4 DB1.DBB 5 DB1.DBB 6 DB1.DBB 7 DB1.DBB 8

Symbol DATA_RECORD.Start DATA_RECORD.Length DATA_RECORD.Record_ID

Meaning Start bit: instructs the master station to transfer data The length of net data to be transferred in bytes Specifies the receive buffer in the target DB of the master station Year Month Day Hour Minute

Rev. A Final 18.02.2004

25/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Address DB1.DBB 9 DB1.DBB 10 DB1.DBB 11 DB1.DBB 12 DB1.DBB 13 DB1.DBB 14 ... DB1.DBB 111

Symbol

Meaning Second Millisecond (digits 1 and 2) Millisecond (digit 3) and weekday

DATA_RECORD.Data_record.Data[1] DATA_RECORD.Data_record.Data[2] DATA_RECORD.Data_record.Data[3] ... DATA_RECORD.Data_record.Data[10 0]

Maximum 100 bytes of net data

VAT_Master (Client)

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 4-2

Rev. A Final 18.02.2004

26/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Besides the polled information and 5 receive buffers, some interesting status bits for monitoring the program sequence are also displayed under Process control.

Note If the S7-300 CPU is in RUN, fast status changes of the symbols RET_VAL_get and Busy_get can be seen. This is caused by the cyclic triggering of the I_Get function to poll the slave by OB35.

The symbols entered (memory spaces) are defined as follows:


Table 4-4

Address DB1.DBX 4.4 DB1.DBB 6


Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Symbol Instance of FB1.Instruction FromServer Instance of FB1.Length Instance of FB1.Record_ID Instance of FB1.STEP1 Instance of FB1.STEP2 Instance of FB1.STEP2_a Instance of FB1.STEP3 Instance of FB1.Busy_get

Meaning Start bit The length of net data to be transferred in bytes Specifies the receive buffer Status of the sequence chart of FB1

DB1.DBB 8 DB1.DBX 4.0 DB1.DBX 4.1 DB1.DBX 4.2 DB1.DBX 4.3 DB1.DBX 5.0 DB1.DBW 10 DB1.DBX 5.1 DB1.DBW 12 DB3.DBB 0 DB3.DBB 1 DB3.DBB 2 DB3.DBB 3 DB3.DBB 4 DB3.DBB 5 DB3.DBB 6 DB3.DBB 7 DB3.DBB 8 ... DB3.DBB 539

Indicates whether an I_GET function is being currently executed

Instance of FB1.RET_VAL_ get Indicates the status of the I_GET function (refer to Help) Instance of FB1.Busy_put Indicates whether an I_PUT function is being currently executed

Instance of FB1.RET_VAL_ put Indicates the status of the I_PUT function (refer to Help) Receive buffers 1 to 5 of the target DB which each contain the time stamp and net data

SLAVE3.ID_1.Data[1] ... SLAVE3.ID_5.Data[100]

Rev. A Final 18.02.2004

27/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Control of data transfer The following step table shows you how to transfer data from the slave to the master. Set the CPUs into the RUN status, open both variable tables and use the button to change to the online mode.
Table 4-5

Step 1

Action Enter any values into the Modify value column of VAT_Slave in the Net data area. Click the values. button, to apply control

Description / Picture

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Proceed in the same way with the data set length (value range 0 to 100) and the -ID (value range 1 to 5).

If you now set the start bit, the current time is entered under Timestamp.

Monitor the start bit.

After approx. 1 second the start bit is reset by the master. The transfer of data was successful.

Now have a look at the result in VAT_Master. Your data is in the respective receive buffer of the target DB.

Rev. A Final 18.02.2004

28/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Note The following average time values for complete jobs with different data set lenghts have been determined in a test: Entire data packet <= 76 bytes (one Get_call) Entire data packet <= 76 bytes (two Get_calls) approx. 140ms approx. 205ms

4.4

Integrating a further (I) slave

Hardware configurations
Table 4-6

Step 1
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Action Click on the Insert Station menu command to add a further SIMATIC 300 Station to the S7 project.

Description / Picture

Open the HW configuration. Move the IM 151-7 CPU object from Hardware Catalog Profibus DP ET 200S to the empty station window using Drag & Drop. Open the Properties dialog box by double-clicking the MPI/DP. There, you select the Profibus interface type. The dialog box Properties automatically opens. Select Profibus and set the address to 4. Close both dialog boxes by clicking OK and store the configuration.

Rev. A Final 18.02.2004

29/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Step 4

Action Open the HW configuration of Station1_Master. Move the ET 200S / CPU object from Hardware Catalog Profibus DP ET 200S to the DP Master system using Drag & Drop. (see figure of Step 7) The dialog box DP Slave properties automatically opens. Click the "Connect" button.

Description / Picture

Assign the master and slave addresses to each other in the Configuration tab using the Edit button. One of the default address assignments can be removed. Close the configuration with "OK".

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Note the diagnostic address assigned by the system on the "General" tab (here 2044).

Save and close the hardware configuration.

Rev. A Final 18.02.2004

30/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

S7 programs
Table 4-7

Step 1

Action Copy the contents of the block container from Station2_Slave (without the system data) to Station3_Slave. When asked if the already existing OB1 is to be overwritten, say "Yes".

Description / Picture

In the block container of Station1_Master you now create a DB4 SLAVE4 from DB3 SLAVE3 using Copy or Save As. The indices in the symbolic names refer to the bus addresses.

Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

To be able to monitor a further data Same as receive area of DB3 SLAVE3. transfer, the variable table See Step 6 of Table 4-5. VAT_Master is to be extended by the receive area of the DB created in Step 2. Open OB1 of Station1_Master in AWL editor and add another FB1 CLIENT call with a new instance DB (Call FB1, DB2) under network 2. When asked if DB2 is to be created, say Yes. Parameterize Source_Addr with the slave diagnostic address in hexadecimal format (see Table 4-5, Step 6). Enter the number of the data block (in hexadecimal format) created in Step 2 behind Destin_DB (here 4 for DB4). Save and close OB1.

Now you can directly load the Station1_Master CPU using the existing Profibus connection.

Rev. A Final 18.02.2004

31/32

Client / Server Communication with (I) Slaves via S7 Basic Communication

Step 6

Action To load the user program of Station3_Slave, execute the steps of Tables 4-1 and 4-2 relevant for Station2_Slave.

Description / Picture

Maximum configuration Connections, once established between master and slave, remain established. Therefore it is important to observe the maximum number of connection resources of your CPU. The relevant specification can be found in the HW configuration under the properties of the configured CPU. The CPU 315-2 DP, used here as an example, provides a maximum of 12 connections for the S7 basic communication.
Copyright Siemens AG Fehler! Unbekannter Name fr Dokument-Eigenschaft. All rights reserved 20987910_BaseComm_Islaves_DOKU_v10_e

Fig. 4-3

As mentioned in Table 3-2and Table 3-3, the program makes it also possible to disconnect the connection after each communication job.

Rev. A Final 18.02.2004

32/32

Вам также может понравиться