23
Programming manual Addition Communication between object recognition sensor O2D2xx and Siemens Simatic S7 704567 / 00 02 / 2011 UK

Communication between object recognition sensor O2D2xx · PDF fileCommunication between object recognition sensor O2D2xx and Siemens Simatic S7 4 3 Ethernet connection via TCP protocol

Embed Size (px)

Citation preview

Programming manual Addition

Communication between object recognition sensor O2D2xx

and Siemens Simatic S7

7045

67 /

00

02 /

2011

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

2

Contents1 Preliminary note � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 3

1�1 Symbols used� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 32 General � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 33 Ethernet connection via TCP protocol � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 4

3�1 Principles � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 43�2 Sensor set-up � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 53�3 Set-up hardware configuration / NetPro Step7� � � � � � � � � � � � � � � � � � � � � � 8

4 Overview of the function blocks � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �114�1 FB54, DB54 – Communication block protocol version 1 � � � � � � � � � � � � � 12

4�1�1 Function block description FB54, DB54� � � � � � � � � � � � � � � � � � � � � � 134�2 FB55, DB55 – Communication block protocol version 2 � � � � � � � � � � � � � 14

4�2�1 Function block description FB55, DB55� � � � � � � � � � � � � � � � � � � � � � 154�3 FB56, DB56 – Communication block protocol version 3 � � � � � � � � � � � � � 16

4�3�1 Function block description FB56, DB56� � � � � � � � � � � � � � � � � � � � � � 174�3�2 Function block description FB 100 - Evaluation of data after the com-mand "trigger" � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 184�3�3 Function block description FB 101 – Evaluation after the command "read_stat" � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 194�3�4 Function block description FB 102 - Evaluation of data after the com-mand "read_conf" � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 204�3�5 Function block description FB 103 - Evaluation after the command "read_error" � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 214�3�6 Function block description FB 104 - Change protocol version� � � � � 224�3�7 Further function blocks � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 23

4�4 Implementation for an S7300 controller � � � � � � � � � � � � � � � � � � � � � � � � � � 23

Licences and trademarksMicrosoft®, Windows®, Windows XP® and Windows Vista®are registered trademarks of Microsoft Corporation� All trademarks and company names are subject to the copyright of the respective companies�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

3

1 Preliminary noteThese instructions serve for the set-up and parameter setting of the communi-cation between the object recognition sensor O2D2xx from ifm electronic and an Simatic S7 controller from Siemens�

1.1 Symbols used► Instruction> Reaction, result[…] Designation of pushbuttons, buttons or indications→ Cross-reference

Important note Non-compliance can result in malfunctions or interference�Information Supplementary note

2 GeneralThe instructions describe the set-up and parameter setting of the communication of an O2D2xx sensor (rev� 1031) connected to a S7 controller via Ethernet CP with TCP protocol�The following functions can be carried out:

● Request the trigger pulse (t) ● Select the application (C<group><number>) ● Request the assignment of the application data from the device (a?) ● Request the statistics from the device (s?) ● Request the error code from the device (E?) ● Request the last result from the device (R?) ● Request the device information (D?)

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

4

3 Ethernet connection via TCP protocol3.1 PrinciplesThe data of the TCP connection are transmitted as a data flow, i�e� there is no defined start or end character on the protocol level� The returned data is received byte-for-byte and stored in the receive buffer�For communication via Ethernet, all TCP protocol compatible Ethernet CPs can be used� However, the different selection of the Siemens communication blocks when using controllers of the 300 or 400 series is to be taken into account�The communication was tested with a CPU 414-2DP and a CP 443-1�The device supports 3 different protocol versions, there is a communication block provided for each protocol version�

Version Format

V1 <contents>CR LF

V2 <ticket><contents>CR LF

V3 <ticket><length>CR LF <ticket><contents>CR LF

After a voltage failure, the sensor always communicates in the protocol version V2 after restart�

► Select the requested protocol version�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

5

3.2 Sensor set-up ► Set Applications → Network parameters → IP address, Subnet mask, etc�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

6

► Select the trigger type "TCP/IP" in the active configuration�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

7

► Configure the process interface�

If the detail output is deactivated in this setting, the parameter "Detail_akt" must also be deactivated in FB100�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

8

3.3 Set-up hardware configuration / NetPro Step7 ► Set up and link the object recognition sensor as "Other Station" in NetPro�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

9

► Create the TCP connection with the object recognition sensor� ► Note down the connection ID and CP address for the function block parameter setting�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

10

► Set up the port number as in the parameter setting software�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

11

4 Overview of the function blocksFB54, DB54 – Communication block protocol version 1FB55, DB55 – Communication block protocol version 2FB56, DB56 – Communication block protocol version 3

FB57, DB57 – Change protocol version

FB100, DB100 – Trigger evaluationFB101, DB101 – Status evaluationFB102, DB102 – Error message evaluation FB103, DB103 – Evaluation application assignment

FC11 – (Siemens Standard) FIND FC16 – (Siemens Standard) I_STRING FC26 – (Siemens Standard) MIDFC37 – (Siemens Standard) STRING_DI FC38 – (Siemens Standard) STRING_I

FC40 – INT ->ASCII ticket numberFC41 – INT ->ASCII group numberFC42 – INT -> ASCII configuration number

DB220 – Data field assignment of the application dataDB221 – Data field user data after trigger eventDB222 – Receive buffer

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

12

4.1 FB54, DB54 – Communication block protocol version 1 ► Indicate ID and LADDR (as set up in Net-Pro)�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

13

4.1.1 Function block description FB54, DB54

The parameter RECV_BUF must be declared as absolute, because with some controller types the width of access may not be transmitted correctly in case of symbolic declaration�

The function block establishes the messages to be sent to the sensor and creates a character string from the received data flow�The "trigger" input sends a trigger command to the sensor with each positive edge� In addition the receive buffer is deleted�The "change_appl" input sends an application change command to the sensor with each positive edge� The preselection is indicated at the inputs "group_nr" and "ap-pl_nr"� Moreover, the receive buffer is deleted� (group_nr always 0 with O2D22X)The inputs "read_conf", "read_last", "read_error", "read_info" and "read_stat" send the corresponding status query to the sensor with each positive edge� In addition, the receive buffer is deleted�The received data is read byte-by-byte from the data flow and then stored conse-cutively in the receive buffer�The length of the receive buffer is defined variably as ANY pointer and can be extended or reduced according to the respective requirements�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

14

4.2 FB55, DB55 – Communication block protocol version 2 ► Indicate ID and LADDR (as set up in Net-Pro)�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

15

4.2.1 Function block description FB55, DB55

The parameter RECV_BUF must be declared as absolute, because with some controller types the width of access may not be transmitted correctly in case of symbolic declaration�

The function block establishes the messages to be sent to the sensor and creates a character string from the received data flow�The "trigger" input sends a trigger command to the sensor with each positive edge� In addition, the receive buffer is deleted�The "change_appl" input sends an application change command to the sensor with each positive edge� The preselection is indicated at the inputs "group_nr" and "ap-pl_nr"� Additionally, the receive buffer is deleted� (group_nr always 0 with O2D22X)The inputs "read_conf", "read_last", "read_error", "read_info" and "read_stat" send the corresponding status query to the sensor with each positive edge� The receive buffer is also deleted�The "ticket" no� is incremented internally in the function block�The received data is read byte-by-byte from the data flow and then stored conse-cutively in the receive buffer�The length of the receive buffer is defined variably as ANY pointer and can be extended or reduced according to the respective requirements�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

16

4.3 FB56, DB56 – Communication block protocol version 3 ► Indicate ID and LADDR (as set up in Net-Pro)�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

17

4.3.1 Function block description FB56, DB56

The parameter RECV_BUF must be declared as absolute, because with some controller types the width of access may not be transmitted correctly in case of symbolic declaration�

The function block establishes the messages to be sent to the sensor and creates a character string from the received data flow� The "trigger" input sends a trigger command to the sensor with each positive edge� Also, the receive buffer is deleted�The "change_appl" input sends an application change command to the sensor with each positive edge� The preselection is indicated at the inputs "group_nr" and "ap-pl_nr"� The receive buffer is deleted in addition� (group_nr always 0 with O2D22X)The inputs "read_conf", "read_last", "read_error", "read_info" and "read_stat" send the corresponding status query to the sensor with each positive edge� Apart from that, the receive buffer is deleted�The "ticket" no� is incremented internally in the function block�The received data is read byte-by-byte from the data flow and then stored conse-cutively in the receive buffer�The length of the receive buffer is defined variably as ANY pointer and can be extended or reduced according to the respective requirements�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

18

4.3.2 Function block description FB 100 - Evaluation of data after the command "trigger"

With a positive edge on the input "Start", the data from the receive buffer is evalua-ted once and moved to the data block�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

19

4.3.3 Function block description FB 101 – Evaluation after the command "read_stat"

With a positive edge on the input "Start", the data from the receive buffer is evalua-ted once and provided on the output�

► Indicate the set protocol version of the sensor on the input�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

20

4.3.4 Function block description FB 102 - Evaluation of data after the command "read_conf"

With a positive edge on the input "Start", the data from the receive buffer is evalua-ted once and moved to the data block�

► Indicate the set protocol version of the sensor on the input�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

21

4.3.5 Function block description FB 103 - Evaluation after the command "read_error"

With a positive edge on the input "Start", the error codes from the receive buffer is evaluated once and provided on the output�

► Indicate the set protocol version of the sensor on the input� ► Error codes → operating instructions #704435 chapter 12�21�

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

22

4.3.6 Function block description FB 104 - Change protocol version

With a positive edge on the input "Change" the new protocol version is activated in the sensor�

► Set the input to the current and new protocol version�

UK

Communication between object recognition sensor O2D2xx and Siemens Simatic S7

23

4.3.7 Further function blocks FC11 – (Siemens Standard) FIND FC16 – (Siemens Standard) I_STRING FC26 – (Siemens Standard) MIDFC37 – (Siemens Standard) STRING_DI FC38 – (Siemens Standard) STRING_IThese blocks are taken from the S7 standard library IEC Function Blocks�

FC40 – INT ->ASCII ticket numberFC41 – INT ->ASCII group numberFC42 – INT -> ASCII configuration numberThese blocks convert the required numerical values into ASCII strings�

4.4 Implementation for an S7300 controller ► Replace the communication blocks AG_LSEND (FC50) and AG_LRECV (FC60) in the corresponding blocks FB54, FB55, FB56, FB57 with the blocks from the CP300 library (FC5, FC6)�

The function blocks FB100 - FB104 are not available for the S7300 controller�