Anda di halaman 1dari 7

s7-300 lm master, s7-200 lm slave, dng thm module EM277 Network 1 // Readme (In Ladder Logic view, double-click

any Network title for detailed comments. Double-click here for Tip no. and title.) // // Tip057B // TOPIC: How to Connect an S7-300 (Master) to an S7-200 (Slave) by Means of PROFIBUS // VERSION: 5.0 // DATE: 10/01 // // Network 2 // Special Hardware Requirements // // One SIMATIC S7-200 CPU 222, CPU 224, or CPU 226 // One S7-200 EM 277 PROFIBUS-DP expansion module // One S7-300 programmable logic controller, consisting of // a PS 307 2A power supply unit, a CPU 315-2 DP, // and an SM 374 digital input/output simulator module // 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 or CP card, STEP 7 programming software // Version 3.1 or greater as well as // STEP 7-Micro/WIN Version 3.1 // // Network 3 // Disclaimer // // These SIMATIC S7-200 Application Tips are provided free of charge // to give users of the S7-200 examples of programming techniques // available to accomplish certain tasks in various applications. // These Tips do not purport to cover all details or variations in // equipment, nor do they provide for every possible contingency. // Your application may be different from those contemplated herein. // It is your responsibility to use the SIMATIC S7-200 properly in // your application. These Tips do not relieve you of the responsibility // to use sound practices in application, installation, operation // and maintenance. By using these Tips, you acknowledge that Siemens // shall not be liable under any theory for damages or personal // injury resulting from such use.

// // Siemens reserves the right to make changes in these Tips at any // time without notice or obligation. Should a conflict arise between // the suggestions in these Tips and other Siemens publications such // as the S7-200 Programmable Controller System Manual or the // SIMATIC S7 / M7 / C7 Programmable Controllers Catalog ST 70, the // other publication shall take precedence. // // Copyright 2000 Siemens Energy & Automation, Inc. Any form // of duplication or distribution of these Tips or excerpts hereof // is prohibited without the express consent of Siemens Energy & // Automation, Inc. // // Network 4 // Online Help // // To activate the associated online Help file, open the directory // on your desktop where you stored these files or select the // documentation CD and double-click on the 200TIPSB.hlp file. After // the Help file starts, use the Table of Contents or the Help Topics // Index to select the file associated with this tip. // // Network 5 // DP Overview // // An S7-200 CPU and an EM 277 are connected to a CPU 315-DP by means // of PROFIBUS. PROFIBUS-DP (or DP Standard) is a remote I/O // communication protocol defined by the European Standard EN 50 170. // PROFIBUS stands for "Process Field Bus." DP stands for // "distributed peripherals," that is, remote I/O. // // The CPU 315-2 DP is a master station. The S7-200 CPU and the EM 277 // are used exclusively as a slave device. // // The sample program for the S7-200 demonstrates how you can write // the S7-300 inputs to the outputs of the S7-200 and send the S7-200 // inputs to an output module of the S7-300. // // Sample Program in DP Master (CPU 315-2 DP) // // With STEP 7: // 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 S7-200 CPU // // L PIW 0 // Get the I/O input word of the input // // module. // T PQW 256 // Transfer it to address area 256 // // (the Send mailbox of the master, or // // I/O output area). // // Transfer inputs of slave (S7-200 CPU) 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 module. // BE // End of block // // The master station initiates the data transfer by reading an input // word from 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. // // The master reads the I/O input area (starting with address PI 256), // where the inputs from the slave are placed, and stores the word in // the physical outputs of an output module. // // For example, if an input of the S7-200 CPU 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 outputs of the // S7-200 CPU. // // // Network 6 // Program Description // // A brief explanation of the sample program for DP communication between // the S7-200 CPU and CPU 315-2 DP is provided below. The program is // located in the S7-200 which, along with the EM 277, is the DP // slave station. In this example, the outputs of the slave station // display data from an input module on the CPU 315-2. The inputs // of the slave are transferred to the CPU 315-2 and displayed // on the outputs of the CPU 315-2. // // Special Memory Byte SMB224 or SMB274 //

// The values of bits 1 and 0 of special memory bytes SMB224 and SMB274 // indicate the DP standard protocol status. SMB224 shows the status // of the first EM 277 and SMB274 shows the status of the second EM 277. // // The values of bits 1 and 0 indicate the following status: // 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. // // Special Memory Bytes SMB225 to SMB229 or SMB275 to SMB279 // // Special memory bytes SMB225 to SMB229 and SMB275 to SMB279 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. // // SMB225/SMB275 This byte shows the address of the master (0 to 126). // SMW226/SMW276 This value is the V memory address of the output buffer. // SMB228/SMB278 This byte indicates the number of output bytes. // SMB229/SMB279 This byte indicates the number of input bytes. // // This program is a generic DP slave program. It takes the outputs // from the master station and writes them to the physical outputs of // the slave station. The physical inputs from the slave station are // copied to the master station. // // Note: The symbolic names for the pointers to I/O data // and the number of I/O bytes are placed in memory // starting at V2000. Do not set the V memory offset // of the DP data to that value. // // // // Network 7 // ***MAIN PROGRAM*** Create Pointers to Output Data and Input Data // // The outputs from the master and the inputs to the master are stored // in the V memory of the CPU by the EM 277. The outputs are at the // offset supplied by the master. The inputs follow the outputs // directly.

// // Note: The outputs and inputs are defined from the master's point // of view. // // Load special memory bit SM0.0 to process this network // every scan cycle. // // Move the address of the memory location VB0 // to accumulator AC0. AC0 then functions as a pointer // to variable memory byte VB0. The ampersand (&) // in front of VB0 indicates that the address of the // memory location VB0, not its contents, is being // placed in accumulator AC0. // // Special memory word SMW226 contains the // V memory address of the output buffer // as an offset from VB0. // Add the contents of SMW226 to the value // in AC0 (address of the memory location VB0) // and place the result in AC0 // to indicate where the output buffer starts. // // Move the contents of accumulator AC0 (VB0 + offset) // to variable memory double word VD2000. VD2000 then // functions as the pointer to the output data. // // Special memory byte SMB228 contains the number // of bytes of output data. // Convert the contents of this byte to an integer // and place the result in local memory word LW0. // // Add the contents of LW0 (number of output bytes) // to the contents of AC0 (start address of output buffer) // and place the result in AC0 // to indicate where the input buffer starts. // // Move the contents of accumulator AC0 (start address // of input buffer) to variable memory double word VD2004. // VD2004 then functions as the pointer to the input data. // // Network 8 // Set the Out_Count //

// Check the number of output bytes to see if it is larger than the // size of the image register. // // Special memory byte SMB228 contains the number // of bytes of output data set by the master. // Compare the value in SMB228 to 16. // // If the value in SMB228 (number of output bytes) // is greater than 16 (size of image register in the CPU), // move the value 16 to variable memory byte VB2008 // to set the number of output bytes to 16. // // If the number of output bytes is 16 or fewer, // move the value in SMB228 (value from the master) // to VB2008 as the number of output bytes. // // Network 9 // Set the In_Count // // Check the number of input bytes to see if it is larger than the // size of the image register. // // Special memory byte SMB229 contains the number // of bytes of input data set by the master. // Compare the value in SMB229 to 16. // // If the value in SMB229 (number of input bytes) // is greater than 16 (size of image register in the CPU), // move the value 16 to variable memory byte VB2009 // to set the number of input bytes to 16. // // If the number of input bytes is 16 or fewer, // move the value in SMB229 (value from the master) // to VB2009 as the number of input bytes. // // Network 10 // Copy the Outputs and Inputs // // If the DP status shows that the EM 277 PROFIBUS-DP // module is in data exchange mode, then // copy the outputs from the master // to the physical outputs of the CPU and // copy the physical inputs of the CPU

// to the input buffer for transfer to the master. // // Special memory byte SMB224 contains // the status byte for the DP standard protocol. // If the contents of SMB224 is 00000010, // the EM 277 PROFIBUS-DP module is // in data exchange mode. // Compare the value in SMB224 to 2 (binary 00000010). // // If the comparison is true (the EM 277 PROFIBUS-DP // module is in data exchange mode), // move the number of bytes indicated in VB2008 from the location // whose address appears in VD2000 (pointer to the output data) // to output byte QB0 (the physical outputs of the CPU). // (The asterisk in front of VD2000 indicates that // VD2000 is a pointer to the value being referenced // by the Block Move Byte instruction.) // // Move the number of bytes indicated in VB2009 // from input byte IB0 (the physical inputs of the CPU) // to the location whose address appears in VD2004 // (pointer to the input data). // // If the comparison is not true (the EM 277 PROFIBUS-DP // module is not in data exchange mode), // fill 8 words with 0, starting at output word QW0, // to clear all output points.

Anda mungkin juga menyukai