Siemens SIMATIC S7 CP340, SIMATIC S7 CP341, SIMATIC S7 CP441, SIMATIC S7 CP440 Programming Manual

http://support.automation.siemens.com/WW/view/en/ID 88867653
FAQ 02/2014
CP340/CP341/CP440/CP441 Communication and Programming
SIMATIC S7
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
2
Siemens AG 2014 All rights reserved
This entry is from the Siemens Industry Online Support. The general terms of use (http://www.siemens.com/terms_of_use) apply.
Security informa­tion
Siemens provides products and solutions with industrial security functions that support the secure operation of plants, solutions, machines, equipment and/or networks. They are important components in a holistic industrial security concept. With this in mind, Siemens’ products and solutions undergo continuous development. Siemens recommends strongly that you regularly check for product updates.
For the secure operation of Siemens products and solutions, it is necessary to take suitable preventive action (e.g. cell protection concept) and integrate each component into a holistic, state-of-the-art industrial security concept. Third-party products that may be in use should also be considered. For more information about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a product­specific newsletter. For more information, visit
http://support.automation.siemens.com.
Table of contents
1 <add your text here> ..................................... Fehler! Textmarke nicht definiert.
1.1 <add your text here> ..................... Fehler! Textmarke nicht definiert.
1 Overview
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
3
Siemens AG 2014 All rights reserved
1 Overview
Siemens SIMATIC S7-series serial communication modules mainly include CP340, CP341, CP440-1, CP441-1/2, as well as 1SI 3964/ASCII and 1SI MODBUS/USS of ET200S, etc., and the communication protocols they support mainly include ASCII, RK512, 3964(R), MODBUS Master, MODBUS Slave and other loadable protocols, etc. SIMTIC S7-series serial communication modules and their supported communication protocols are in the corresponding relations shown in the table below:
ASCII
3964(R)
RK512
MODBUS Master
MODBUS Slave
CP340
X X - - -
CP341
X X X X X
CP440
X X - - -
CP441-1
X X - - -
CP441-2
X X X X X
X: support, -: not support
Table 1: Corresponding relations between modules and protocols In actual application, the above-stated serial communication modules may be used to realize serial communication for the following devices:
3rd-party DCS and PLC systems, etc. 3rd-party intelligent device and instrument, etc. Receiving data from scanner and bar-code reader, etc. Sending data to serial printer and other receiving devices All other user-defined protocol devices that support ASCII and MODBUS
This document mainly introduces applications of CP340, CP341, CP440, CP441-1 and CP441-2, as well as ASCII, MODBUS RUT protocols they support, and it also includes the routine used by each module for reference for readers.
Declaration: The virtual project stated in this document has major difference from the real project example, and the example is not programmed in accordance with the specified engineering design flow, and readers shall not confuse it with the real project example. The example is free of charge, and any user may copy or release it freely. The author of the program will not assume any liability for any functionality or compatibility, and users shall assume the related risks. Siemens will not provide error correction of this program example or hotline support. It is suggested that users
1 Overview
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
4
Siemens AG 2014 All rights reserved
should read the related module operation manuals carefully to use them in a better way.
2 Introduction of related software and its applications
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
5
Siemens AG 2014 All rights reserved
2 Introduction of related software and its
applications
2.1 STEP7
STEP7 programming software is used to write PLC program, and it shall be purchased from Siemens. All procedure codes in this document are written with STEP7 V5.4 SP4.
2.2 PtP drive software package
PtP Param V5.1 is the drive software package for CP340/CP341/CP440/CP441, and parameters may only be distributed to the serial communication module and the function block necessary for communication programming may only be integrated in STEP7 after this drive software package is installed. This drive will be provided when the module is purchased, and it may also be downloaded through the following linkage. The updated software version is PtP Param V5.1 SP11 at present. http://support.automation.siemens.com/WW/view/en/27013524
2.3 MODBUS Master drive software package
This drive software package shall be installed when CP341 or CP441-2 is used in MODBUS master, but PtP Param V5.1 drive program software package shall be installed earlier. This drive software package may be purchased when purchasing MODBUS Dongle or be downloaded through the following link:
MODBUS Master drive (RTU) software package:
http://support.automation.siemens.com/WW/view/en/27774018
MODBUS Master drive (ASCII) software package:
http://support.automation.siemens.com/WW/view/en/25356060
2.4 MODBUS Slave drive software package
This drive software package shall be installed when CP341 or CP441-2 is used in MODBUS slave, but PtP Param V5.1 drive program software package shall be installed earlier. This drive software package may be purchased when purchasing MODBUS Dongle or be downloaded through the following link:
MODBUS Slave drive (RTU) software package:
http://support.automation.siemens.com/WW/view/en/27774276
MODBUS Slave drive (ASCII) software package:
http://support.automation.siemens.com/WW/view/en/25356060
2.5 ModScan32 / ModSlave
This is software provided by third party and may be downloaded from the Internet. ModScan32 may be used to emulate MODBUS Master to test its communication with MODBUS Slave. ModSlave may be used to emulate MODBUS Slave to test its communication with MODBUS Master.
3 Manual and related application documents
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
6
Siemens AG 2014 All rights reserved
3 Manual and related application documents
After all drive programs are installed, user may search for all CP module manuals from the computer, whose detailed position is "Start-> SIMATIC-> Documentation -
> English”, or they may be found directly from the folder of STEP7 installation path“… Program files-> Siemens -> Step7 -> S7MANUAL -> S7PtP_Cp”.
Fig. 1: Module manual path diagram
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
7
Siemens AG 2014 All rights reserved
4 ASCII protocol communication
The communication mode in ASCII protocol is used to realize serial communication of user-defined protocol, and it is applicable to communication with the intelligent instrument, bar-code reader, scanner, and printer, etc. that support serial communication.
The following examples are used to introduce the ASCII protocol communication of Siemens serial communication modules CP340, CP341, CP440 and CP441.
4.1 ASCII protocol communication of CP340
4.1.1 Hardware catalog
PS 307
6ES7 307-1EA00-0AA0
CPU 315-2DP
6ES7 315-2AG10-0AB0
MMC
6ES7 953-8LG11-0AA0
CP340
6ES7 340-1AH01-0AE0
4.1.2 Configuration
1. Open STEP 7,and click File->New...to create a new project in name of ptp.
Fig. 2: Dialog box of New project
2. Right-click the project name, select Insert New Object->SIMATIC 300 Station to change the station name to CP340 ASCII.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
8
Siemens AG 2014 All rights reserved
Fig. 3: Insert S7-300 station
3. Double-click Hardware to enter the hardware configuration interface and insert RACK, CPU315-2DP and CP340.
Fig. 4: Configuration hardware
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
9
Siemens AG 2014 All rights reserved
4. Double-click CP340 module, and click Parameter... to configure CP340 parameters.
Fig. 5: CP340 Properties dialog box
5. Select ASCII from Protocol options.
Fig. 6: Protocol selection
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
10
Siemens AG 2014 All rights reserved
6. Double-click the envelop icon under Protocol to configure ASCII communication parameters. The set communication parameters shall be the same as those of the
communication partner. Communication Baud rate: 9600bpsData bit: 8 bits, Stop bit: 1 bit, Parity: none, Character delay time: 4ms, Other parameters shall be
in default settings.
Fig. 7: Distributing communication parameters for ASCII protocol As shown in the Fig. above, if "Activate BREAK monitoring" is selected, the SF red
indicator of CP340 will be on when RS232C cable is not connected or the serial port of the communication partner is not activated.
7. If CP340 in RS422/485 interface is selected, the interface properties shall also be set, as shown below:
Fig. 8: Configuration interface parameters When the interface is in RS485 type (half-duplex mode), the initial state of the
receive side will be R(A)0V/R(B)5V, and it will not support wire-break detection function. When the interface is in RS422 type (full-duplex mode) and the initial state of the receive side is set as R(A)0V/R(B)5V, it will support wire-break detection function. These 2 states correspond to the following interface pins of the communication partner receive side:
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
11
Siemens AG 2014 All rights reserved
Fig. 9: Wiring of receiver at interface RS485/422
8. After the parameters are configured, click button to save and compile the hardware configurations. After it is confirmed that no error exists, download the hardware configurations to CPU to complete the whole hardware configuration process.
Fig. 10: Compile and save hardware configuration
4.1.3 Write communication program
1. Double-click OB1 to open OB1 programming screen. Invoke Send Function Block FB3 P_SEND from Libraries -> CP PtP -> CP340 and distribute instance data block DB3 to it. Set the block parameter LADDR as the start logic address 256 for module CP340 in hardware configuration.
Fig. 11: Logic address of CP340
2. Create Send Data block DB1.
R(A)0V/R(B)5V
R(A)5V/R(B)0V
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
12
Siemens AG 2014 All rights reserved
Fig. 12: Send Data block DB1
3. Invoke Send Function block The parameters of the send function block FB3 P_SEND of CP340 are set as in
the table below:
LADDR
Start logic address in hardware configuration, which is 256 in this example
DB_NO
Send Data block number, which is 1(DB1) in this example
DBB_NO
Start address of Send Data, which is 0(DB1.DBB0) in this example
LEN
Length of send data, which is 10 in this example
REQ
trigger bit of Send Data, rising edge trigger, which is M0.0 in this example
R
Cancel communication, which is not available in this example
DONE
send complete bit, which is TRUE if Send completes and has no error
ERROR
error bit, TRUE indicating that it has an error
STATUS
Status word, ID error code. See CP340 manual for related descriptions
Table 3: Parameter definition of FB3 P_SEND
Fig. 13: Invoke FB3 P_SEND from OB1
4. Invoke Receive Function Block FB2 P_RCV from Libraries -> CP PtP -> CP340 and distribute instance data block DB2 to it. Set LADDR as the start logic address
256.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
13
Siemens AG 2014 All rights reserved
5. Create receive data block DB10.
Fig. 14: Receive data block DB10
6. Invoke receive function block The parameters of the receive function block FB2 P_RCV of CP340 are set as in
the table below:
LADDR
Start logic address in hardware configuration, which is 256 in this example
DB_NO
Send Data block number, which is 10(DB10) in this example
DBB_NO
Start address of Send Data, which is 0(DB10.DBB0) in this example
LEN
Length of receive data, which is MW2 in this example. This value is not 0 only in the current cycle when data are received. The length of received data may be determined by checking the MW4 value.
EN_R
Enable receive bit, which is M0.1 in this example.
R
Cancel communication, which is not available in this example
NDR
Receive complete bit, which is TRUE if Receive completes and has no error
ERROR
error bit, TRUE indicating that it has an error
STATUS
status word, ID error code. See CP340 manual for related descriptions
Table 4: Parameter definition of FB2 P_RCV
Fig. 15: Invoke FB2 P_SEND from OB1
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
14
Siemens AG 2014 All rights reserved
4.1.4 Equipment connection
Use standard RS232C cable to connect serial ports of CP340 and computer. The detailed cable connecting method may be seen in CP340 Manual - Chapter B: Connecting cables.
4.2 ASCII protocol communication of CP341
4.2.1 Hardware catalog
PS 307
6ES7 307-1EA00-0AA0
CPU 315-2DP
6ES7 315-2AG10-0AB0
MMC
6ES7 953-8LG11-0AA0
CP341
6ES7 341-1AH01-0AE0
4.2.2 Configuration
1. Open the project ptp created above, and right-click the project name, select Insert New Object->SIMATIC 300 Station to change the station name to CP341 ASCII.
Fig. 19: Insert S7-300 station
2. Double-click Hardware to enter the hardware configuration interface and insert RACK, CPU315-2DP and CP341.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
15
Siemens AG 2014 All rights reserved
Fig. 20: Configuration hardware
3. Double-click CP341 module, and click Parameter... to configure CP341 parameters.
Fig. 21: CP341 Properties dialog box
4. Select ASCII protocol from Protocol options.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
16
Siemens AG 2014 All rights reserved
Fig. 22: Protocol selection
5. Double-click the envelop icon under Protocol to configure ASCII communication parameters. The set communication parameters shall be the same as those of the
communication partner. Communication Baud rate:9600bpsData bit: 8 bits, Stop bit: 1 bit, Parity: none, Character delay time:4msOther parameters shall be in
default settings.
Fig. 23: Distributing parameters for ASCII protocol
6. If CP341 in RS422/485 interface is selected, the interface properties shall also be set, as shown in the Fig. below. Refer to the text above for initial state of receive side.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
17
Siemens AG 2014 All rights reserved
Fig. 24: Configuration interface parameters
7. After completing configuration, user may click button to save and compile the hardware configuration and download it to CPU after confirming that no error exists. The whole hardware configuration process is completed by now.
Fig. 25: Compile and save hardware configuration
4.2.3 Write communication program
1. Double-click OB1 to open OB1 programming screen. Invoke Send Function Block FB8 P_SND_RK from Libraries -> CP PtP -> CP341 and distribute instance data block DB8 to it. Set the parameter LADDR as the start logic address 256 for module CP340 in hardware configuration.
Fig. 26: Logic address of CP341
2. Create Send Data block DB1.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
18
Siemens AG 2014 All rights reserved
Fig. 27: Send Data block DB1
3. Invoke Send Function block The parameters of the send function block FB8 P_SND_RK of CP341 are set as in
the table below:
LADDR
Start logic address in hardware configuration, which is 256 in this example
DB_NO
Send Data block number, which is 1(DB1) in this example
DBB_NO
Start address of Send Data, which is 0(DB1.DBB0) in this example
LEN
Length of send data, which is 10 in this example
REQ
trigger bit of Send Data, rising edge trigger, which is M0.0 in this example
R
Cancel communication
DONE
send complete bit, which is TRUE if Send completes and has no error
ERROR
error bit, TRUE indicating that it has an error
STATUS
status word, ID error code. See CP341 manual for related descriptions
Other parameters
Irrelevant to ASCII communication protocol, and not available in this example
Table 5: Parameter definition of FB8 P_SND_RK
Fig. 28: Invoke FB8 P_SND_RK from OB1
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
19
Siemens AG 2014 All rights reserved
4. Invoke Receive Function Block FB7 P_RCV_RK from Libraries -> CP PtP -> CP341 and distribute instance data block DB7 to it. Set LADDR as the start logic address 256 in hardware configuration.
5. Create receive data block DB10
Fig. 29: Receive data block DB10
6. Invoke receive function block The parameters of the receive function block FB8 FB7 P_RCV_RK of CP341
are set as in the table below:
LADDR
Start logic address in hardware configuration, which is 256 in this example
DB_NO
Send Data block number, which is 10(DB10) in this example
DBB_NO
Start address of Send Data, which is 0(DB10.DBB0) in this example
LEN
Length of receive data, which is MW2 in this example. This value is not 0 only in the current cycle when data are received. The length of received data may be determined by checking the MW4 value.
EN_R
Enable receive bit, which is M0.1 in this example.
R
Cancel communication, which is not available in this example
NDR
Receive complete bit, which is TRUE if Receive completes and has no error
ERROR
error bit, TRUE indicating that it has an error
STATUS
status word, ID error code. See CP341 manual for related descriptions
Other parameters
Irrelevant to ASCII communication protocol, and not available in this example
Table 6: Parameter definition of FB7 P_RCV_RK
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
20
Siemens AG 2014 All rights reserved
Fig. 30: Invoke FB7 P_RCV_RK from OB1
4.2.4 Equipment connection
Use standard RS232C cable to connect serial ports of CP341 and computer. The detailed cable connecting method may be seen in CP341 Manual - Chapter B: Connecting cables.
4.3 ASCII protocol communication of CP440
4.3.1 Hardware catalog
RACK-400
6ES7 400-1JA01-0AA0
PS407
6ES7 407-0KA02-0AA0
CPU
6ES7 414-3XJ04-0AB0
CP440
6ES7 440-1CS00-0YE0
4.3.2 Configuration
1. Open the project ptp that has been created, and right-click the project name, select Insert a new SIMATIC 400 Station to change the station name to CP440 ASCII.
4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming Entry-ID: 88867653, V1.0, 02/2014
21
Siemens AG 2014 All rights reserved
Fig. 34: Insert S7-400 station
2. Double-click Hardware to enter the hardware configuration screen and insert RACK-400,PS407,CPU414-3DP and CP440.
Fig. 35: Configuration hardware
3. Double-click CP440 module and click Parameter to configure CP440 parameters, and select ASCII protocol in Protocol options.
Loading...
+ 49 hidden pages