Sei sulla pagina 1di 51

6,0$7,& 1(7 4XLFN 6WDUW

$ERXW WKLV 'RFXPHQW

This document contains information on the samples for PROFIBUS FMS communication between a SIMATIC S7 and a SIMATIC S5 station using the READ/WRITE services.

)RU D EULHI RYHUYLHZ RI WKLV VDPSOH UHIHU WR &KDSWHU  )RU GHWDLOHG LQIRUPDWLRQ UHIHU WR &KDSWHU  DQG WKH FKDSWHUV IROORZLQJ
The document covers the following topics: System structure Introduction to the required blocks and their communication structure Program structures and extracts of code Operator control and monitoring Troubleshooting

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

2YHUYLHZ RI WKH 6DPSOH

6FKHPDWLF RI WKH 6\VWHP


)06 &OLHQW 6 6WDWLRQ )06 6HUYHU 6 6WDWLRQ

HQD

QBvrshpr

PROFIBUS

as

PG/PC with STEP 7

&KHFNLQJ WKH )XQFWLRQDOLW\ RI WKH 6DPSOH


You can check that the sample is working correctly based on the variable table of the client. The variable table is contained in the Blocks folder of the STEP 7 project. Data being sent and received has continuously changing values (see also "Operator Control and Monitoring").

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

)XQFWLRQ 'LDJUDP
The following diagram illustrates how the sample works:

SIMATIC 400 Station, Client

SIMATIC S5 Station, Server

3UHSDUH GDWD IRU VHQGLQJ Write data (2 bytes)

$FFHSW MRE Read data (2 bytes)

6DYH UHFHLYHG GDWD

'DWD ([FKDQJH
2 bytes of data are exchanged cyclically by the stations involved in communication.

&OLHQW  6HUYHU
The client initiates the reading/writing of data. The server only reacts to the services of the client and, for example, makes data available for a read job from the client.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

3URJUDP

Client S7-400 OB1


MY_WRITE_CALL FB WRITE

Server SIMATIC S5

MW 4 DI
FB READ

FC36

Accept variable with index 100

Symbol Table Variable with index 100 = DB100

OB1
MY_READ_CALL

MW 8 DI

FC33

Send variable with index 100

'HVFULSWLRQ RI WKH FOLHQW

The WRITE function block is called. Using the WRITE job, 2 bytes of data (the memory word 4 of the client) is written to the memory area of the server (also memory (flag) word 4).

'HVFULSWLRQ RI WKH VHUYHU


At the server, it is only necessary to call the handling block for the communications processor.

After the WRITE job has been executed without error the READ function block is called. Using the READ job, 2 bytes of data (flag word 4 of the server) is read from the server. The client stores the data read in memory word 8.

At the server, the data to be used for the communication is specified in the symbol table, marked as a communication variable and assigned an index.

Once the READ job has been processed without error, the data to write is incremented by 1 and the write/read cycle begins again.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

1RWH DERXW &OLHQW ,QGH[ '% It is not possible to directly enter the index or name of the variable to be used in the communication in the FMS blocks for READ/WRITE. The auxiliary data block, "Index DB", is required. In the sample, this is data block 5 (DB5). It has the following structure:

1RWH DERXW &OLHQW ,QLWLDOL]DWLRQ RI )% :5,7( Before the WRITE function block can be used for communication, it must first be initialized. This is done by calling it once with the parameter value 5(4 . In the sample this is done in OB100 (Startup OB)!

1RWH DERXW &OLHQW 7URXEOHVKRRWLQJ If an FMS block recognizes an error in communication (error bit = 1), the FMS block must be reset before the next trigger (5(4 ). This is done by calling the FMS block with 5(4 . Calling the FMS block again with 5(4  does not change the block parameter "67$786".

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

2SHUDWRU &RQWURO DQG 0RQLWRULQJ


An operator control and monitoring function is available using the supplied variable table. The following conditions must be met to allow you to use the "Monitoring and Modifying Variables" program: There must be an online connection to the CPU. "Monitor variables" must be activated. The values to be modified must be marked as valid.

If the conditions listed above are met, you can determine whether the sample is functioning correctly by observing that the data being written and read are changing continuously.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

6\VWHP 6WUXFWXUH
This chapter lists the hardware and software required to run the sample.

1RWH 6FRSH RI $SSOLFDWLRQ RI WKLV 'RFXPHQW The content of this document assumes a specific configuration (CP 443-5 Basic as FMS client, CP 5431 as FMS server). This documentation can, however, also be used for all FMS READ/WRITE samples of communication between a SIMATIC S7 station as client and a SIMATIC S5 station with CP 5431 as server.

*HQHUDO 6WUXFWXUH
Bus system Communications protocol Platform Communications processors Services PROFIBUS FMS SIMATIC S7 and SIMATIC S5 S7: CP 443-5 Basic, S5: CP 5431 READ, WRITE

The sample uses the FMS protocol. Using this protocol and the READ / WRITE services, there is a data exchange between a SIMATIC S7 and a SIMATIC S5 station. The CP 443-5 Basic and CP 5431 are used as communications processors.

5HTXLUHG +DUGZDUH IRU WKH &OLHQW

6ORW
1 3 4 PS407 10A

0RGXOH

CPU 414-1
CP 443-5 Basic

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

5HTXLUHG +DUGZDUH IRU WKH 6HUYHU

0RGXOH AS 135U / 155U (CPU 928)


CP 5431FMS

1RWH The S7 CP should have firmware version 2.x. You can determine the version of the CP with NCM S7 PROFIBUS Diagnostics (6WDUW ! 6LPDWLF ! 1&0 6 352),%86 ! 352),%86 'LDJQRVWLFV). If your CPs have an earlier version than 2.x it is possible to update their software (download a new version from Internet/Intranet and load it into the CP with the NCM S7 PROFIBUS firmware loader).

&DXWLRQ The samples relate to specific hardware configurations. These must exist to ensure problem-free operation. If you want to use a different configuration, you must make modifications (refer to the notes below).

1RWH 8VLQJ D GLIIHUHQW 6 &38 If you want to use a different S7 CPU for the sample, please read the document "Change_CPU".

1RWH 1RWH 8VLQJ D GLIIHUHQW 6 &3 If you want to use a different S7 CP for the sample, please read the document "Change_CP".

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

&DEOHV DQG 2WKHU +DUGZDUH 5HTXLUHG

MPI cable
PG Cable PROFIBUS cable with at least two connectors PG or PC with MPI and AS Interface

5HTXLUHG 6RIWZDUH
You require the following software to run the sample: Microsoft Windows 95 or Windows NT 4.0 as the operating system

For the SIMATIC S7 station: STEP 7 V4.02 NCM S7 PROFIBUS V4.02

For the SIMATIC S5 station: STEP 5 V6.65 SINEC NCM COM for CP 5431 V4.09

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

6,0$7,& 1(7 4XLFN 6WDUW

,QWURGXFWLRQ WR WKH 5HTXLUHG %ORFNV DQG WKHLU &RPPXQLFDWLRQ 6WUXFWXUH


This chapter covers the following topics: How the sample works Blocks required for communication and their communication structure

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

10

6,0$7,& 1(7 4XLFN 6WDUW

 +RZ WKH 6DPSOH :RUNV


'DWD ([FKDQJH
2 bytes of data are exchanged cyclically by the stations involved in communication.

&OLHQW  6HUYHU
The client initiates the writing/reading of data. The server only reacts to the services of the client and, for example, makes data available for a read job from the client.

6WHSE\6WHS ([HFXWLRQ RI WKH 8VHU 3URJUDP RQ WKH &OLHQW


WRITE: First the client writes data to the memory area of the server by calling the WRITE function block (located in MW4). READ: By calling the READ function block, data is read from the server and stored by the client in MW8. Incrementing data: The value of the data to be written is incremented by 1 and the write/read cycle starts again.

6WHSE\6WHS ([HFXWLRQ RI WKH 8VHU 3URJUDP RQ WKH 6HUYHU


In the PLC program of the server, the handling blocks "SEND ALL" (FB120) and "RECEIVE ALL" (FB121) are required for processing the received FMS READ/WRITE services.

SEND ALL is executed when the READ service is executed on the client. What is read is the server variable with the index 100, which references the S5 address, DB100, 0 (data block 100 word 0). RECEIVE ALL is executed when the WRITE service is executed on the client. What is written is the server variable with the index 100, which references the S5 address, DB100, 0 (data block 100 word 0).

In other words, the client writes and reads data block 100, word 0 on the server.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

11

6,0$7,& 1(7 4XLFN 6WDUW

 %ORFNV 5HTXLUHG IRU &RPPXQLFDWLRQ DQG WKHLU &RPPXQLFDWLRQ 6WUXFWXUH


This chapter describes the WRITE and READ blocks required for FMS communication at the S7 end in greater detail.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

12

6,0$7,& 1(7 4XLFN 6WDUW

:5,7( )XQFWLRQ %ORFN )%

3XUSRVH RI WKH %ORFN


FB WRITE sends data from a specified local data area of the FMS client to a data area of the communication partner, the FMS Server. The local data area can be a data block, process image area, input/output area or a bit memory area. The local data area can be a data block, process image area, input/output area or a bit memory area. 7KH EORFN SDUDPHWHUV DUH GHVFULEHG LQ GHWDLO LQ &KDSWHU 

&RQILJXUHG &RPPXQLFDWLRQ 9DULDEOH 5HTXLUHPHQW


The structure of the variables is set by the communication partner (FMS server). The description of the structure is read from the communication partner when the FMS connection is established. This is then made available on the PROFIBUS CP for converting data from the S7 format to FMS format. The structure description of the variables is only read when a connection is established using GET-OD, if under "Read variable description of communication partner": "All" or "Specified variables from the following list" with information about the desired variables has been selected in the configuration of the FMS connection.

$FFHVV 5LJKWV
Note that read/write access rights can be set (this is not the case with the samples). Transmission is then only possible if the appropriate rights have been assigned to the FMS client.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

13

6,0$7,& 1(7 4XLFN 6WDUW

5($' )XQFWLRQ %ORFN )%

3XUSRVH RI WKH %ORFN


The READ function block reads data from the data area specified by name or index on the communication partner depending on the job parameters. The data read by the client is stored in a data block, a process image area of the I/Os or in a bit memory area. 7KH EORFN SDUDPHWHUV DUH GHVFULEHG LQ GHWDLO LQ &KDSWHU 

5HTXLUHPHQWV &RQILJXUHG &RPPXQLFDWLRQ 9DULDEOH


The structure of the variable is set on the communication partner (FMS server). The description of the structure is read from the communication partner (FMS server) when the FMS connection is established. This is then made available on the PROFIBUS CP for converting data into the S7 format. The structure description of the variables is only read when a connection is established using GET-OD, if under "Read variable description of communication partner": "All" or "Specified variables from the following list" with information about the desired variables has been selected.

$FFHVV 5LJKWV
Note that read/write access rights can be set (this is not the case with the samples). Transmission is then only possible if the appropriate rights have been assigned to the FMS client.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

14

6,0$7,& 1(7 4XLFN 6WDUW

3URJUDP 6WUXFWXUHV DQG ([WUDFWV RI &RGH

This chapter introduces you to the structure of the programs for both the server and client and important sections of code are shown and explained.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

15

6,0$7,& 1(7 4XLFN 6WDUW

5.1 3URJUDP 6WUXFWXUH RI WKH &OLHQW


Program/cycle start

Startup OB is run automatically (OB100), old data deleted, WRITE called with REQ=0

Call WRITE job Yes

Error occurred in WRITE? Yes No WRITE job completed? Yes Call READ job

Object dictionary not yet loaded?

No

Save error number

No

Error occurred in READ? No No READ job completed? Yes Increment variable value

Yes

Save error number

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

16

6,0$7,& 1(7 4XLFN 6WDUW

 ([WUDFWV RI &RGH IURP WKH &OLHQW


&OLHQW 6\PEROV

6\PERO 7DEOH 8VHG IRU WKH )06 6DPSOHV

8VHV
The use of symbols makes the code easier to read. The symbolic name then appears in the program instead of the address. Example: You will see "READ_DATA" instead of "MW8" in the code.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

17

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW 2% 6WDUWXS 2%

3XUSRVH
Fill the used data area with "0" and call the FMS Write service with the parameter REQ = 0.

&DOO
During S7 CPU startup.

1DPH
OB100

&RGH

'HVFULSWLRQ
With the "L" and "T" commands (load, transfer) the data area is filled with 0. The FMS WRITE service is then called; at this point in time, the REQ parameter of the WRITE block is set to "0". In the last section, the REQ parameter of the WRITE block is set to "1" so that it will be executed at the next call.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

18

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW 2%

3XUSRVH
OB1 is responsible for cyclic execution of the user program. In this sample program, the blocks for the READ and WRITE FMS functions are called.

&DOO
OB1 is called in every CPU cycle.

1DPH
OB1

&RGH

'HVFULSWLRQ
OB1 calls the block named "MY_WRITE_CALL" (call FB WRITE) in every CPU cycle. The block "MY_READ_CALL" (call READ function) is only called if "START_READ_CALL" has the value "1", otherwise OB1 ends immediately. "START_READ_CALL" only has the value "1" if the previously started WRITE FMS service has been completed without error.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

19

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW :5,7( -RE

3XUSRVH
Two bytes of data are sent to the server using the FMS service :5,7(.

&DOO
Called within OB1.

1DPH
MY_WRITE_CALL (FC36)

&RGH

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

20

6,0$7,& 1(7 4XLFN 6WDUW

0HDQLQJ RI WKH 3DUDPHWHUV IRU WKH )06 6HUYLFH :5,7( &$// :5,7(  '%
REQ: Edge signal for executing the block. ID: This identifies the FMS connection (obtained with "CPU -> Connections"). VAR_1: This parameter addresses the remote communication variable to be read are written. In the sample, the variable is addressed by the index 100, see Section 4.2.7, Index DB). SD_1: Address of a local data area from which values are sent. DONE: Indicates error-free execution of the job. ERROR: Indicates whether or not an error has occurred. STATUS: Provides detailed information about states or errors during execution of the job.

'HVFULSWLRQ
&$// :5,7(  '% The WRITE FMS service is called. TXHVWLRQ DERXW HUURU VHFWLRQ This queries whether the service has been completed without error. The check is carried out by evaluating the value of the "ERROR" parameter of the WRITE job. HUURU RFFXUUHG VHFWLRQ This section is only processed when the WRITE job returns an error. The "error bit" is reset because the block for error handling is called (&$// 6$9(B:5,7(B(5525 ). QR HUURU VHFWLRQ This section is only processed when the WRITE job is executed without error. The WRITE parameter "DONE" (Job completed?) is checked. If "DONE" is 0 (job is still running), the program jumps to "UHFHSWLRQ RI GDWD QRW FRPSOHWHG", otherwise it jumps to section "UHFHSWLRQ RI GDWD FRPSOHWHG". UHFHSWLRQ RI GDWD FRPSOHWHG VHFWLRQ If the WRITE job is executed without error and is completed, the edge signal is generated to execute the FMS service "READ" (6 5($'B3$5B5(4 ) and the memory bit for calling the READ job is set (6 67$57B5($'B&$// ). UHFHSWLRQ RI GDWD QRW FRPSOHWHG VHFWLRQ If the WRITE job is still not completed, the WRITE parameter "REQ is reset to prevent it being executed again. (5 :5,7(B3$5B5(4 ). The "MY_WRITE_CALL" block, however, is executed again in every OB1 cycle. Consequently, your program checks whether the WRITE job is completed or not in every cycle.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

21

6,0$7,& 1(7 4XLFN 6WDUW

6XPPDU\
The WRITE FMS service is only called if the previous WRITE service and the corresponding READ service were successfully completed. In this case, your program checks whether or not the newly started WRITE service has been executed without error and has been completed. Only then is the READ FMS service executed, otherwise the system waits for the completion of the WRITE service or calls the error handling block if an error has occurred.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

22

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW (UURU +DQGOLQJ DIWHU WKH :5,7( -RE

3XUSRVH
Saves errors occurring in the WRITE service.

&DOO
In the "MY_WRITE_CALL" (FC 36) block, when a prior call to the WRITE service has returned an error.

1DPH
SAVE_WRITE_ERROR (FC30)

&RGH

'HVFULSWLRQ
7KH VHFWLRQ / :5,7(B3$5B67$786 XS WR DQG LQFOXGLQJ -& JRG This checks the status returned by the WRITE FMS service. If the status has a hexadecimal value of "0601", it means the CP on the client end is still busy loading the object dictionary from the server and therefore cannot yet execute the WRITE FMS service. In this case, the code in section "*HW2' VWLOO DFWLYH YDULDEOH QRQ H[LVWHQW" is executed, otherwise the code in section "*HW2' FRPSOHWHG".

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

23

6,0$7,& 1(7 4XLFN 6WDUW

*HW2' VWLOO DFWLYH YDULDEOH QRQH[LVWHQW VHFWLRQ In this section of code the parameter "5(4" of the WRITE FMS service is set to "1" (6 :5,7(B3$5B5(4"). This causes the WRITE FMS service with the "0601" (hex) status that previously failed to be repeated. *HW2' FRPSOHWHG VHFWLRQ If the error that occurred in the previous WRITE FMS service does not have the hexadecimal status "0601", the deviating value is saved in data block 2, data word 0, and the parameter "5(4" of the WRITE FMS service is set to "1" (6 :5,7(B3$5B5(4"), which results in the previously failed WRITE FMS service being repeated.

6XPPDU\
If an error has occurred in the last WRITE FMS service, the WRITE job is repeated. the cause of the error (error number) is saved. Exception: As long as the CP on the client end is reading the object dictionary, no error number is saved and the job is triggered again.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

24

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW 5($' -RE

3XUSRVH
Two bytes of data are read from the server using the FMS service 5($'.

&DOO
In OB1, when the previous WRITE FMS service was completed without error.

1DPH
MY_READ_CALL (FC33)

&RGH

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

25

6,0$7,& 1(7 4XLFN 6WDUW

0HDQLQJ RI WKH 3DUDPHWHUV IRU WKH )06 6HUYLFH 5($' &$// 5($'  '%
REQ: Edge signal for executing the block. ID: This identifies the FMS connection (obtained with "CPU -> Connections"). VAR_1: This parameter addresses the remote communication variable to be read are written. In the sample, the variable is addressed by the index 100, see Section 4.2.7, Index DB). SD_1: Address of a local data area to which values should be sent. NDR: Indicates the error-free reception of data. ERROR: Indicates whether or not an error has occurred. STATUS: Provides detailed information about states or errors during execution of the job.

'HVFULSWLRQ
&$// 5($'  '% The READ FMS service is called. TXHVWLRQ DERXW HUURU VHFWLRQ This asks whether the service has been completed without error. The check is carried out by evaluating the "ERROR" parameter of the READ job. HUURU RFFXUUHG VHFWLRQ This section is only processed when an error occurred in the READ job. The "error bit" is reset because the block for error handling is called (&$// 6$9(B5($'B(5525 ). QR HUURU VHFWLRQ This section is only processed when the READ job is executed without error. The READ parameter "NDR" (data received?) is checked. If "NDR" is 0 (data not yet received), the program jumps to "UHFHSWLRQ RI GDWD QRW FRPSOHWHG", otherwise it jumps to section "UHFHSWLRQ RI GDWD FRPSOHWHG". UHFHSWLRQ RI GDWD FRPSOHWHG VHFWLRQ If the READ job is executed without error and is completed, the edge signal is generated to execute the FMS service "WRITE" (6 :5,7(B3$5B5(4 ) and the memory bit for calling the next READ job is reset (5 67$57B5($'B&$// ). The value of data to send is incremented by 1.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

26

6,0$7,& 1(7 4XLFN 6WDUW

UHFHSWLRQ RI GDWD QRW FRPSOHWHG VHFWLRQ If the READ job is still not completed, the READ parameter "REQ is reset to prevent it being executed again. (5 5($'B3$5B5(4 ). The "MY_READ_CALL" block, however, is executed again in every OB1 cycle. Consequently, the program checks whether the READ job is completed or not in every cycle.

6XPPDU\
The READ FMS service is only called if the previous READ service and the corresponding WRITE service were successfully completed. After it is called, the program then checks whether the activated READ job was executed without error and if data was received. In this case the next WRITE FMS service is triggered. Otherwise the system waits to receive the data or, if an error has occurred, to call the appropriate block.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

27

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW (UURU +DQGOLQJ DIWHU WKH 5($' -RE

3XUSRVH
Saves errors occurring in the READ service.

&DOO
In the "MY_READ_CALL" (FC 33) block, when a prior call to the READ service has returned an error.

1DPH
SAVE_READ_ERROR (FC35)

&RGH

'HVFULSWLRQ
The status (error source) of the previous READ service is saved in data block 2, data word 2, and the parameter "5(4" of the READ FMS service is set to "1" (6 5($'B3$5B5(4"), which results in repeating the previously failed READ FMS service.

6XPPDU\
If an error occurred in the last WRITE FMS service, the WRITE job is repeated. the source of the error (error number) is saved. Exception: As long as the CP on the client is reading the object dictionary, no error number is saved and the job is triggered again.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

28

6,0$7,& 1(7 4XLFN 6WDUW

&OLHQW ,QGH[ '% 'DWD %ORFN '%

3XUSRVH
This data block is used to specify which FMS index is set as the variable for communication. The sample uses a variable with the index 100. Physically, variable 100 is located on the server. In the sample index 100 is actually MW4 (see Section 3.1).

1RWH In FMS, every variable used for communication must be assigned an index. The variable can then be uniquely identified with this index. The variable with this index is physically located on the server!

3XUSRVH
This data block is transfered as the value of "VAR_1" in the FMS services WRITE and READ.

1DPH
Index_DB (DB5)

&RGH

'HVFULSWLRQ
Creates a variable of the data type "STRING[10]" which is given the name "Index100". This parameter contains the variable value "<100>". The "<" and ">" angled brackets are very important because they indicate that this is an FMS index. The FMS services WRITE and READ get this value from the block to be able to address the variable on the server.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

29

6,0$7,& 1(7 4XLFN 6WDUW

 3URJUDP 6WUXFWXUH RQ WKH 6HUYHU

Program/cycle start

OB startup is executed automatically. Synchronize CP 5431

Call SEND ALL handling block (FB120)

Call RECEIVE ALL handling block (FB121)

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

30

6,0$7,& 1(7 4XLFN 6WDUW

 ([WUDFWV RI &RGH IURP WKH 6HUYHU


6HUYHU )06 9DULDEOH

8VHV
At the server the data to be used for the communication must be specified as a communication variable with the NCM software and assigned an index.

,OOXVWUDWLRQ RI WKH 6RIWZDUH 6,1(& 1&0 &20 IRU &3  9

In the sample, an FMS variable of the type INT 16 ("IN 16") with the index 100 is created. Physically this variable corresponds to data block 100, word 0 (S5 address: DB 100 0).

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

31

6,0$7,& 1(7 4XLFN 6WDUW

6HUYHU 2%

3XUSRVH
OB20 calls FB125 which is responsible for the synchronization of the CP 5431.

&DOO
At the startup of the S5 CPU.

1DPH
OB20

&RGH
:JU FB 125 NAME:SYNCHRON SSNR: KY 0,0 BLGR: KY 0,0 PAFE : FY 255 :BE

'HVFULSWLRQ
The block FB125 is called and given parameter values.

1RWH Refer to the appropriate manuals for the meaning of the block parameters.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

32

6,0$7,& 1(7 4XLFN 6WDUW

6HUYHU 2%

3XUSRVH
OB1 is responsible for cyclic execution of the user program. In the following sample program the "FB231" block is called.

&DOO
OB1 is called in every CPU cycle.

1DPH
OB1

&RGH
:JU FB 331 NAME:ALL-S5 0 : : :BE

'HVFULSWLRQ
The block FB231 is called.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

33

6,0$7,& 1(7 4XLFN 6WDUW

6HUYHU )%

3XUSRVH
FB231 calls the handling blocks SEND ALL (FB120) and RECEIVE ALL (FB121). SEND ALL is required to forward data requested from the client through READ. RECEIVE ALL is required to accept the data written from the client through WRITE.

&DOO
OB1 is called in every CPU cycle.

1DPH
FB231

&RGH 3DUW  &DOO 6(1' $//

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

34

6,0$7,& 1(7 4XLFN 6WDUW

&RGH 3DUW  &DOO 5(&(,9( $//

'HVFULSWLRQ
In the first part, the block FB120 (SEND ALL) is called and given parameter values; in the second part, block FB121 (RECEIVE ALL) is called and also given parameter values.

1RWH FB231 is only separated into two parts here for the sake of clarity. In the S5 program it is a single part.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

35

6,0$7,& 1(7 4XLFN 6WDUW

6WDUWLQJ 8S 2SHUDWRU &RQWURO


This chapter covers the following topics: Special notes about starting up the samples Operator control and monitoring

0RQLWRULQJ

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

36

6,0$7,& 1(7 4XLFN 6WDUW

 6WDUWLQJ 8S
6WDUWLQJ WKH 6HUYHU DQG &OLHQW

6WHS 1 2 3 4 5

'HVFULSWLRQ Follow the steps described for starting up an SIMATIC S7 PLC and a PC as contained in the documents "S7 Installation" and "PC Installation". First start the server. Then start the client program from the installation folder. Double-click on the file located there with the extension, .exe. Select the menu item "Write / Read" -> "Start".

1RWH The server must be started first because it provides the services for the client.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

37

6,0$7,& 1(7 4XLFN 6WDUW

 2SHUDWRU &RQWURO DQG 0RQLWRULQJ


1RWH If problems occur during operator control and monitoring, please read Chapter 7, Troubleshooting.

0RQLWRULQJ RQ WKH &OLHQW


It is possible to monitor on the client using the variable table provided in the sample. The following table explains how to use the variable table.

6WHS 1 2 3 4

'HVFULSWLRQ Select "Blocks" in the project window of the SIMATIC Manager under the "Client". Double-click "VAT1". In the program "Monitoring and Modifying Variables", select 3/& ! &RQ QHFW 7R ! &RQILJXUHG &38  To monitor the specified variable, select "9DULDEOH ! 0RQLWRU 

1RWH The monitor function is active when "Online" is displayed in the status bar in the "Monitoring and Modifying Variables" program and you can see a continuously changing progress bar.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

38

6,0$7,& 1(7 4XLFN 6WDUW

When you have completed the steps listed above, you will see the following variable table (the values actually displayed may differ!):

:5,7( 3DUDPHWHU In the upper part ("WRITE-Parameter") you can see the parameters of the FMS service WRITE and most recent WRITE error. ,I WKH VDPSOH LV ZRUNLQJ FRUUHFWO\ $PRQJVW RWKHU WKLQJV WKH SDUDPHWHU '21( :5,7( MRE FRPSOHWHG FKDQJHV LWV VWDWH FRQWLQXRXVO\ IURP  !  SRVVLEO\ WRR TXLFNO\ WR REVHUYH  5($' 3DUDPHWHU In the "READ-Parameter" part you can see the same for the FMS service READ. ,I WKH VDPSOH LV ZRUNLQJ FRUUHFWO\ $PRQJVW RWKHU WKLQJV WKH SDUDPHWHU 1'5 UHFHLYH GDWD FKDQJHV LWV VWDWH FRQWLQXRXVO\ IURP  !  

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

39

6,0$7,& 1(7 4XLFN 6WDUW

'$7$ In the "DATA" section you can see data being written to and read from the server. ,I WKH VDPSOH LV ZRUNLQJ FRUUHFWO\ 'XH WR WKH XSGDWH F\FOH RI WKH YDULDEOH WDEOH WKH ZULWWHQ DQG UHDG GDWD VKRXOG EH GLIIHUHQW E\ D YDOXH RI  ,I WKH VDPSOH LV IXQFWLRQLQJ FRUUHFWO\ WKHVH YDOXHV VKRXOG EH FRQWLQXRXVO\ LQFUHDVLQJ E\ 

1RWH The meaning of the values of the parameters for READ and WRITE is explained in detail in the relevant documentation and in the NCM online help (for example 6WDUW ! 6LPDWLF ! 1&0 6 352),%86 ! +HOS )XQFWLRQV )& ! (QJOLVK ).

1RWH The sample is functioning correctly when the values of the written and read data are continuously increasing by "1!. ! Dont forget! The variable table must be online and monitoring must be active for the values to be updated.

2SHUDWRU &RQWURO RQ WKH &OLHQW


It is possible to operate from the client using the variable table provided in the sample. How to start and activate it was described above.

1RWH To call up the functions, the variable table must be "Online" and "Monitor" must be active so that the values can be updated (see above).

The following table shows you how to change the value of the data sent to (and then read by) the server.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

40

6,0$7,& 1(7 4XLFN 6WDUW

6WHS 1 2

'HVFULSWLRQ Enter a value between 0 and 32767 in the last column ("Modify Value") of the line "MW 4" "WRITE_DATA" in the variable table. Select "Variable" -> "Activate Modify Value"

&RUUHFW IXQFWLRQ If the value has been successfully modified, then value read should also return a value deviating by 1. The client wrote the new value to the server and read it back.

([LWLQJ 2SHUDWRU &RQWURO DQG 0RQLWRULQJ


6WHS 1 2 'HVFULSWLRQ Select 7DEOH ! ([LW in the "Monitoring and Modifying Variables" program. Click the "No" button in the subsequent dialog.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

41

6,0$7,& 1(7 4XLFN 6WDUW

7URXEOHVKRRWLQJ
This chapter is intended to help you if you encounter problems installing and starting up the sample.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

42

6,0$7,& 1(7 4XLFN 6WDUW

 3UREOHPV RQ WKH &OLHQW WKH 6,0$7,& 6 3/&


3UREOHPV 'RZQORDGLQJ WKH +DUGZDUH &RQILJXUDWLRQ WKH &RQQHFWLRQ RU WKH %ORFNV
Run the following checks. If your answer is "NO" to a question, go straight to the corresponding steps in "Remedies".

6WHS 1 2

'HVFULSWLRQ Is the MPI cable connected to both the PG/PC and the S7 CPU? In the "Setting the PG/PC Interface" program is the correct interface parameter set assigned to the "Access point of application" "S7ONLINE (STEP 7)"? For example, "MPI-ISA on board (MPI)" if you are using the PG-MPI port? Is the hardware configuration in the project (offline configuration) identical in every way with the actual configuration (online configuration)? Has the CPU been reset?

3 4

5HPHGLHV
Correct the problem by working through the steps below if your answer was no to one of the questions above. $QVZHU WR 6WHS  ZDV 12 No connection can be established to the S7 CPU, it is not possible to download to the CPU.

6WHS 1 2

'HVFULSWLRQ Insert one end of the MPI cable in the MPI port on your PG or PC. Insert the other end of the MPI cable in the MPI port of your S7 CPU.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

43

6,0$7,& 1(7 4XLFN 6WDUW

$QVZHU WR 6WHS  ZDV 12 No connection can be established to the S7 CPU, it is not possible to download to the CPU.

6WHS 1 2

'HVFULSWLRQ Start the "Setting the PG/PC Interface" program: "Start" -> "Simatic" -> "STEP 7" -> "Setting the PG/PC Interface". Set the module you want to use as the MPI port in "Interface parameter assignment used". For example, "MPI-ISA on board (MPI)" if you are using the PG-MPI port. Click the "OK" button.

<RXU DQVZHU WR VWHS  ZDV 12

6WHS 1

'HVFULSWLRQ Adapt the actual hardware configuration to that of the project or read the documentation "Change_CPU" or "Change_CP" if you want to use a different CPU or CP than the one used in the sample.

<RXU DQVZHU WR VWHS  ZDV 12

6WHS 1 Reset the CPU.

'HVFULSWLRQ

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

44

6,0$7,& 1(7 4XLFN 6WDUW

9DULDEOH 7DEOH :ULWWHQ DQG UHDG GDWD GR QRW FKDQJH


Run the following checks. If your answer is "NO" to a question, go straight to the corresponding steps in "Remedies".

6WHS 1 2 3

'HVFULSWLRQ Is the Profibus cable connected to both the client and the server? Can you see "Online" in the status bar of the variable table? Can you see a continuously changing progress bar in the status bar?

5HPHGLHV
Correct the problem by working through the steps below if your answer was no to one of the questions above. 7KH DQVZHU WR VWHS  ZDV 12 No connection can be established between the stations and data exchange is not possible.

6WHS 1 2 3

'HVFULSWLRQ Connect the end of the PROFIBUS cable to the PROFIBUS port of the client CP. Connect the end of the PROFIBUS cable to the PROFIBUS port of the server. Switch on the terminating resistor on the connector.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

45

6,0$7,& 1(7 4XLFN 6WDUW

<RXU DQVZHU WR 6WHS  ZDV 12 No connection was established to the S7 CPU and monitoring was not possible.

6WHS 1

'HVFULSWLRQ In the program "Monitoring and Modifying Variables", select 3/& ! &RQ QHFW 7R ! &RQILJXUHG &38 .

<RXU DQVZHU WR VWHS  ZDV 12 The monitoring function is not activated.

6WHS 1

'HVFULSWLRQ Select "Variable" -> "Monitor" in the "Monitoring and Modifying Variables" program.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

46

6,0$7,& 1(7 4XLFN 6WDUW

9DULDEOH 7DEOH 2SHUDWRU FRQWURO LV QRW ZRUNLQJ


Run the following checks. If your answer is "NO" to a question, go straight to the corresponding steps in "Remedies".

6WHS 1 2

'HVFULSWLRQ Have you activated 9DULDEOH ! 0RGLI\ 9DOXH 9DOLG in the "Monitoring and Modifying Variables" program? Is the value you entered for memory word 4 (MW2) between 0 and 32767?

5HPHGLHV
Correct the problem by working through the steps below if your answer was no to one of the questions above. <RXU DQVZHU WR VWHS  ZDV 12

6WHS 1

'HVFULSWLRQ Select 9DULDEOH ! 0RGLI\ 9DOXH 9DOLG in the "Monitoring and Modifying Variables" program.

<RXU DQVZHU WR VWHS  ZDV 12

6WHS 1

'HVFULSWLRQ Enter a value between 0 and 32767 in the last column ("Modify Value") of the line "MW 4" "WRITE_DATA" in the variable table.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

47

6,0$7,& 1(7 4XLFN 6WDUW

 3UREOHPV RQ WKH 6HUYHU WKH 6,0$7,& 6 3/&


1RWH Follow the steps described to solve the problem. If your answer is "NO" to a question, go straight to the corresponding steps in "Remedies".

7KH PHVVDJH 3/& 7LPHRXW DSSHDUV


No connection can be established between the PG/PC and the SIMATIC S5 CPU.

6WHS 1 2

'HVFULSWLRQ Is the MPI cable connected to both the PLC interface and the S5 CPU? Is the SIMATIC S5 station switched on?

5HPHGLHV
Correct the problem by working through the steps below if your answer was no to one of the questions above. <RXU DQVZHU WR VWHS  ZDV 12

6WHS 1 2 3 4 5 6

'HVFULSWLRQ Insert one end of the PG cable in the PLC port on your PG or PC. Insert the other end of the PG cable in the PLC port of your S5 CPU. Click the "OK" button when the message "PLC Timeout" is displayed. In the dialog "Settings (Page 2)" select the entry "Mode" using the arrow keys. Press the "F3" key to change to "Online" mode. Press "F8" to return the STEP 5 main menu.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

48

6,0$7,& 1(7 4XLFN 6WDUW

<RXU DQVZHU WR VWHS  ZDV 12

6WHS 1 2 3 4 5 Switch on the S5 PLC.

'HVFULSWLRQ

Click the "OK" button when the message "PLC Timeout" is displayed. In the dialog "Settings (Page 2)" select the entry "Mode" using the arrow keys. Press the "F3" key to change to "Online" mode. Press "F8" to return the STEP 5 main menu.

7KH PHVVDJH 3/& LQWHUIDFH RQ 3* QRW UHDG\


No connection can be established between the PG/PC and the SIMATIC S5 CPU. Your PG cable is possibly attached to the CP instead of the CPU.

6WHS 1

'HVFULSWLRQ Is the MPI cable connected to both the PLC interface and the S5 CPU?

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

49

6,0$7,& 1(7 4XLFN 6WDUW

5HPHGLHV
Correct the problem by working through the steps below if your answer was no to one of the questions above. <RXU DQVZHU WR VWHS  ZDV 12

6WHS 1 2 3 4

'HVFULSWLRQ Insert one end of the PG cable in the PLC port on your PG or PC. Insert the other end of the PG cable in the PLC port of your S5 CPU. Press the "OK" button in the message "PLC interface on PG not ready". Repeat the steps that led to the problem.

,Q WKH SURJUDP 6,1(& 1&0 &20 IRU &3  WKH PHVVDJH &3 LQWHUIDFH QRW UHDG\ DSSHDUV
No connection can be established between the PG/PC and the CP.

6WHS 1 2

'HVFULSWLRQ Is the MPI cable connected to both the PLC interface of the PG/PC and the S5 CPU? Is the SIMATIC S5 station switched on?

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

50

6,0$7,& 1(7 4XLFN 6WDUW

5HPHGLHV
Correct the problem by working through the steps below if your answer was no to one of the questions above. <RXU DQVZHU WR VWHS  ZDV 12

6WHS 1 2 3 4

'HVFULSWLRQ Insert one end of the PG cable in the PLC port on your PG or PC. Insert the other end of the PG cable in the PG port of your S5 CP. Press the "OK" button in the message "CP interface not ready". Repeat the steps that led to the problem.

<RXU DQVZHU WR VWHS  ZDV 12

6WHS 1 2 3 Switch on the S5.

'HVFULSWLRQ

Press the "OK" button in the message "CP interface not ready". Repeat the steps that led to the problem.

1RWH If you do not find the solution to your problem in this chapter, reinstall the sample.

PROFIBUS FMS Communication: (S7-S5 with READ/WRITE)

51

Potrebbero piacerti anche