NETR / NETW Wizard

STEP

 

1

Specify the Number of Network Operations You Need

2

Initialize PPI Master Mode

3

Configure PLC to PLC Network Operations

4

Generate Code

To facilitate the exchange of data between PLCs connected on a network, the S7-200 supports Network Read (NETR) and Network Write (NETW) instructions. The NETR instruction reads a configured amount of data from a specified address in a remote PLC. The NETW instruction writes a configured amount of data to a specified address in a remote PLC. The operations of the NETR and NETW instructions are controlled by the first 7 bytes in the data table. One of the values in this table is the length of data to read/write, which can be from 1 to 16 bytes. This gives a total data table size of up to 23 bytes.

The wizard queries you for initialization options, and then generates program code and data block code for the specified configuration. After you choose NETR or NETW from screen one, the wizard queries you for the following information:

STEP 1 Specify the Number of Network Operations You Need

The NETR/NETW Formula for the S7-200 Instruction Wizard can be used to simplify the configuration of network operations. The wizard queries you for initialization options, and generate completed configurations based on your choices. The Wizard allows you to configure up to 24 separate network operations, and generate code to coordinate them.

STEP 2 Initialize PPI Master Mode

a)Which PLC Port does the network operations communicate through? This is necessary for initializing PPI/Master mode. See Notes below

b)The wizard creates a subroutine that is used to initialize the data tables used by each network operation. This subroutine also initializes PPI Master mode communications. What should the initialization subroutine be named?

c)The wizard also creates a subroutine to execute the network operations that are configured. What should the execution subroutine be named?

STEP 3 Configure PLC to PLC Network Operations

For each network operation, you need to supply the following information:

a)Is this operation a NETR or a NETW?

b)What is the network address of the remote PLC with which you want to communicate?

c)What is the address of the data table in the local PLC? This is the data table that is defined for you in the initialization subroutine.

d)What is the address of the data area in the remote PLC? This is the location in the remote PLC where data is to be written or read.

e)What is the length of the data to be read/written by this operation?

f)The wizard creates a subroutine for each operation that you can use for data manipulation. What would you like this subroutine to be named? The use of the data manipulation subroutine is discussed in greater detail below.

STEP 4 Generate Program Code

Once these queries have been answered, and you have clicked the Finish button the S7-200 Instruction Wizard generates code for the network operations you have specified. The subroutines created by the wizard become part of the project. To enable the network communication within the program, place a call in the MAIN program block to the execution subroutine. Use SM0.0 to call this subroutine every scan cycle. This initiates the execution of the configured network operations. The data manipulation subroutines created for each network operation are called automatically at the appropriate time.

NETR /- NETW Programming Notes:

Coordinating Multiple NETR/NETW Operations

Once a NETR or NETW operation is initiated, it is important to allow the communication to finish, before using any of the data that the operation might have read or written. For this reason, the S7-200 Instruction Wizard generates code to ensure that each operation finishes before another is initiated. To facilitate this, each network operation is coded as a series of SCR segments. The code generated for each network operation consists of 3 SCR segments: an execute segment, a wait segment, and an error segment.

1.The execute segment initiates the network operation, and transitions to the wait segment.

2.The wait segment checks the status bits from the operation. If the status bits indicate that the network operation has completed without error, then the next network operation is enabled. If the status bits indicate that there has been an error with the operation, then the code transitions to the error segment for that operation.

3.The error segment (by default) transitions to the next operation. Error handling is discussed in greater detail below.

Manipulating the Data Table of a Network Operation

The code generated by the S7-200 Instruction Wizard guards against conflicting network operations and also provides a way to ensure that your program manipulates the data that has been read/written at the correct time. The code generated for each network operation contains a subroutine for data manipulation. The purpose of this subroutine differs depending on whether the network operation is a NETR or a NETW.

For NETR, the data manipulation subroutine is called each time the read operation has completed successfully. You should add code to the subroutine to transfer data out of the data table, or to manipulate the data as appropriate for your application.

Note: The data area of a NETR or NETW table has a +7 byte offset from the table address specified as the “Starting address of the table”. The example network operation below reads VB0 and VB1 from station 1 and puts the data in VB7 and VB8 in the local CPU:

For a NETW operation, the data manipulation subroutine is called before the operation is initiated. You should add code to the subroutine to transfer data into the data table, in preparation for a write.

Each of the data manipulation subroutines is also called on the first scan of the program, so that the data tables are initialized before any network operations are executed.

Error Handling

Both the NETR and NETW instructions set an error bit, and a specific error code, if the operation does not complete successfully. The S7-200 Instruction Wizard generates code to check for errors returned by each operation. If an error is detected, then the error SCR segment for that operation is enabled. This SCR segment is provided so that you can add error-handling code to your application.

As a default, the wizard generates code in each error segment to automatically enable the next network operation. You might wish to modify this code to retry the operation, stop all network operations, or re-initialize the operation's data table.

PPI/Master Mode

For the NETR and NETW instructions to communicate across your network properly, the selected PLC communications port must be configured for PPI/Master mode. The S7-200 Instruction Wizard generates code to initialize PPI/Master mode.

PPI Master mode is configured in the initialization subroutine generated by the wizard. This subroutine is called on the first scan of the program. No network operations are enabled until after the first program scan, so that the initialization can take place.

Code Generated by the NETR/NETW Wizard

The Wizard creates at least two subroutines. The first is an initialization subroutine that configures PPI master mode communications for the PLC port you specify, and also initializes the data tables for each network operation. The second subroutine contains the implementation of the network operations. This subroutine contains a series of SCR segments (three for each operation) that coordinate the execution of the operations you specified.

In addition to these two subroutines, a subroutine is generated for each operation that should be used for manipulating the data read/written by the network operation.

Attaching the Generated Code to Your Program

To enable the wizard configuration in your program, you need to place two subroutine calls in the MAIN block of your program. Place a call to the initialization subroutine when you wish to begin PPI Master mode communications. When you wish to begin the execution of your network read/write operations, place a call to the execution subroutine.