7

Click here to load reader

TIP57

Embed Size (px)

Citation preview

Page 1: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 1/7

 TIP: S72_57B TOPIC: How to Connect an S7-300 (Master) to an S7-200 (Slave) by Means of PROFIBUS VERSION: 4.0 DATE: 02/99

***SPECIAL HARDWARE REQUIREMENTS***

  One CPU 215-2 DP  One S7-300 PLC, consisting of a PS 307 2A power supply unit, a

CPU 315-2 DP, and an SM 374 digital input/output simulatormodule

  One PC/PPI cable for programming the S7-200  One PROFIBUS cable (The cable should be terminated on both ends

by means of the matching resistor integrated in the connector.The switch on each connector should be in the ON position.)

  One MPI cable for programming the S7-300  One PC with MPI card (and the STEP 7 programming software,

Version 3.1, as well as STEP 7-Micro/WIN Version 2.0)

***OVERVIEW***

 In this example, a CPU 215-DP is connected to a CPU 315-DP by means of the PROFIBUS. PROFIBUS-DP (or DP Standard) is a remote I/O communication protocol defined by the European Standard EN 50 170. Devices that adhere to this standard are compatible even though they are manufactured by different companies. "DP" stands for "distributed peripherals," that is, remote I/O. PROFIBUS stands

 for "Process Field Bus."

 The CPU 315-2 DP is the master station. The CPU 215-2 DP is used exclusively as a slave device. To ensure faultless communication between the DP master station and the CPU 215-2 DP, you need to make certain settings on the two devices. You use the STEP 7 programming software (starting with Version 3.1) to make the settings and to initialize the master as explained in detail below.

 The sample program for the S7-200 demonstrates how you can apply the S7-300 inputs to the outputs of the S7-200. In addition, the program makes it possible to represent the S7-200 inputs on the output module of the S7-300.

 Sample Program in DP Master (CPU 315-2 DP)

 With STEP 7 (Version 3.1): The sample program of the DP master is located in organization block 1 (OB1). It is very simple; the code itself consists of the following lines (only one network):

Network 1: // Transfer inputs of master (CPU 315-2 DP) to slave

 (CPU 215-2 DP)L PIW 0 // Get the I/O input word of the input

 // moduleT PQW 256 // Transfer it to address area 256

 // (the Send mailbox of the master, or // I/O output area)

 // Transfer inputs of slave (CPU 215-2 DP) to master (CPU 315-2 DP)L PIW 256 // Get the I/O input word 256 (the inputs of the slave)T PQW 4 // Transfer it to the outputs of the output moduleBE // End of block  

 The master station initiates the data transfer by reading the I/O input word of an input module and storing it in the I/O output area (starting with address PQ 256). The master station sends this stored input word to the slave station.

 In addition, the master reads the I/O input area (starting with address PI 256) where the inputs of the slave are imaged, and stores the word in the physical outputs of an output module. If, for example, an input of the CPU 215-2 DP is activated, it will be indicated on the output module of the CPU 315-2 DP. Conversely, the input of the CPU 315-2 DP is indicated on the CPU 215-2 DP.

 Memory Model DP Master and DP Slave

 The purpose of a PROFIBUS connection is the exchange of data. Data from one PLC is transferred to another PLC. The initiator of this data transfer is designated as the "master," and the other

 communication station is the "slave." The principle is simple: the master reads the data from the Send mailbox of the slave and stores it in an I/O input area. In addition, the master transfers data to the Receive mailbox of the slave. Because the CPU 215 can only be a slave, the Send and Receive mailboxes are in the variable (V) memory area of the CPU.

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.

Page 2: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 2/7

 In the master station, you can configure where the Receive mailbox of the slave station starts by setting an offset. If the offset is 0, this means that the Receive mailbox starts at variable memory byte VB0. If the offset is 5000, the Receive mailbox starts at VB5000. In addition, you can specify the size of the Receive mailbox in bytes when you configure the master station. If the size is 16 bytes and the offset is 5000, the Receive mailbox starts at VB5000 and ends at VB5015. You can also configure the Send mailbox of the slave station, which is adjacent to the Receive mailbox. In this case, if the size of the Send mailbox is 16 bytes, it extends from VB5016 to 5031.

 Data Exchange

 Once you have connected the CPU 215 to the master station and you have downloaded the configuration information, the CPU 215 enters the data exchange mode. In this mode, the master station sends output data to the CPU 215 and the CPU 215 responds with input data. The V memory address that is supplied as part of the configuration information specifies the starting location of the output data that is sent by the master station. The starting location of the input data follows the last byte of output data immediately. In order to know the start address of the input data, you must know how many words of output data the master station is configured to send.

 You must know the start address of the data buffers and their lengths at the time you create your user program for the CPU 215. The

 output data that is sent by the master station must be moved by the program in the CPU 215 from the output buffer to the various locations for use. Likewise, the input data must be moved from various locations to the input buffer for transfer to the master station.

 Data Consistency

 In a system where data values that are larger than a single byte must be accessed one byte at a time, make sure that all multi-byte values are accessed as a unit, thus preserving data consistency. The CPU 215 operating system guarantees word consistency as long as the data is aligned on word boundaries. The user program can guarantee both double word and buffer consistency. To make this guarantee, the user program must perform all data transfers to or from the input and output buffers within the main program or in a subroutine

 that is called from the main program. If data is transferred to or form the input and output buffers from an interrupt routine, then double word and buffer inconsistencies must be expected.

 The S7-200 Programmable Controller System Manual, Order No. 6ES7 298-8FA01-8BH0, provides you with more information about using the CPU 215 as a DP slave device.

***PROGRAM DESCRIPTION***

 A brief explanation of the sample program for DP communication between the CPU 215-2 DP and CPU 315-2 DP is provided below. The program is located in the CPU 215-2 DP, which represents the DP slave station. In this example, the slave station reads data that the master station (CPU 315-2 DP) reads from an input module and then transfers to the slave station. The slave station writes the values to its own physical outputs. The program writes the values of the physical inputs of the slave station to the master station.

 How to Monitor the DP Standard Protocol You can use special memory bytes SMB110 to SMB115 to monitor the status of the DP standard protocol.

 SMB110 Port 1 The values of bits 1 and 0 of SMB110 indicate the DP standard protocol status of Port 1 as follows:

00 = DP communications have not been initiated since power on.01 = Error in configuration/parameter assignment detected.10 = Currently in data exchange mode.11 = Dropped out of data exchange mode.

 SMB111 to SMB115 are updated each time the CPU accepts configuration/parameter assignment information. These locations

 are updated even if a configuration/parameter assignment error is detected. These locations are cleared every time the CPU is turned on.

SMB111This byte defines the address of the slave'smaster (0 to 126).

SMB112 These bytes define the V memory address of theSMB113 output buffer (offset from VB0). SMB112 is the

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.

Page 3: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 3/7

most significant byte, and SMB113 is theleast significant byte.

SMB114 This byte defines the number of bytes for the

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.

Page 4: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 4/7

Network 1 Create Pointers to Output Data and Input Data

 The input buffer (Send mailbox) and output buffer (Receive mailbox) of the CPU 215-2 D are in the variable memory area of the CPU. The input buffer follows the output buffer immediately in the variable memory area. Variable memory byte VB0 is the first possible start address of the output buffer (Receive mailbox) of the CPU 215-2 D.

 Load special memory bit SM0.0 to process this network every scan cycle. Set variable memory double word VD1000 to function as a pointer to variable memory byte VB0 by moving &VB0 into VD1000. (The & in front of VB0 indicates that you are moving the address of this memory location to VD1000. VD1000 then acts as a pointer to this location.) In this case, VD1000 is the output pointer. Move the value in special memory word SMW112 (the variable memory address of the output buffer, offset from VB0) into variable memory word VW1002 to add in the output offset. Set variable memory double word VD1004 to function as a pointer to variable memory byte VB0 by moving &VB0 into VD1004. In this case, VD1004 is the input pointer. Move the value in special memory word SMW112 into variable memory word VW1006 to add in the output offset. Move the constant 0 into accumulator AC0 to clear the accumulator.

 Move the value in special memory byte SMB114 into AC0 to get the number of output bytes. Add the value in accumulator AC0 (the number of output bytes) to the value in variable memory word VW1006 (the output offset) to get the offset pointer to the input buffer.

SM0.0

&VB0 VD1000

SMW112 VW1002

&VB0 VD1004

SMW112 VW1006

+0 AC0

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.

Page 5: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 5/7

SMB114 AC0

AC0

VW1006 VW1006

Network 2 Set the Output Count

 Compare the value in special memory byte SMB114 to the constant 9. If the value in SMB114 (the number of output bytes) is greater than or equal to 9, move the constant 8 into variable memory byte VB1008 to indicate an output count of 8. If the value in SMB114 (the number of output bytes) is not greater than or equal to 9, move the value in SMB114 into VB1008 to indicate that the output count is equal to the number of output bytes.

SMB114

9

8 VB1008

SMB114 VB1008

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.

Page 6: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 6/7

Network 3 Set the Input Count

 Compare the value in special memory byte SMB115 to the constant 9. If the value in SMB115 (the number of input bytes) is greater than or equal to 9, move the constant 8 into variable memory byte VB1009 to indicate an input count of 8. If the value in SMB115 (the number of input bytes) is not greater than or equal to 9, move the value in SMB115 into VB1009 to indicate that the input count is equal to the number of input bytes.

SMB115

9

8 VB1009

SMB115 VB1009

Network 4 Copy: DP Outputs to Outputs, Inputs to DP Inputs

 Load special memory bit SM0.0 to process this network every scan cycle. Move the number of bytes indicated in VB1008 (the DP outputs) from the location pointed to by variable memory double word VD1000 to output bye QB0. (The asterisk in front of VD1000 indicates that the contents of this double word are a pointer to another location in memory, namely to the location of the DP outputs). Move the number of bytes indicated in VB1009 (the inputs) from input byte IB0 (the inputs of the CPU 215-2 DP) to the location pointed to by variable memory double word VD1004. (The asterisk  in front of VD1004 indicates that the contents of this double word are a pointer to another location in memory, namely

 to the location of the DP inputs).

SM0.0

*VD1000

VB1008 QB0

IB0

VB1009 *VD1004

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.

Page 7: TIP57

7/26/2019 TIP57

http://slidepdf.com/reader/full/tip57 7/7

Network 5 Main Program End

 End the main program.

INDUSTRIAL AUTOMATION

PROLIFIC SYSTEM AND TECHNOLOGY PVT.LTD.