Prévia do material em texto
Technical Information SICK AFS60 / AFM60 PROFINET Function Block FB_SICK_AFx60_PN function block for Siemens S7-300 / S7-400 PLCs (SIMATIC STEP7 V5) Technical Information FB_SICK_AFx60_PN Function Block Page 2 / 18 Version history Block Version Date Remark V1.0 03.05.2016 Initial version V1.1 08.03.2017 Change the unit of the PROFINET parameters 1002.1 and 1003.1 from [0,1h] to [s]. No code changes (only documentation) Table of content 1 About this document ........................................................................................................ 3 1.1 Function of this document ............................................................................................ 3 1.2 Target group ................................................................................................................ 3 2 General information ......................................................................................................... 4 3 Hardware Configuration ................................................................................................... 5 3.1 Supported PLCs .......................................................................................................... 5 3.2 Hardware configuration ................................................................................................ 5 4 Function block .................................................................................................................. 6 4.1 Block specifications ...................................................................................................... 6 4.2 Renaming of block numbers ........................................................................................ 6 4.3 Method of function ....................................................................................................... 7 4.3.1 Read data .............................................................................................................11 4.3.2 Write data .............................................................................................................12 4.4 Behavior when error occurs ........................................................................................12 5 Parameter .........................................................................................................................13 6 Error description .............................................................................................................14 7 Example ...........................................................................................................................16 7.1 Read a device a parameter .........................................................................................17 7.2 Write a device parameter ............................................................................................18 Technical Information FB_SICK_AFx60_PN Function Block Page 3 / 18 1 About this document Please read this chapter carefully before you start working with this technical information and the FB_SICK_AFx60_PN function block. 1.1 Function of this document This technical information describes how to use the FB_SICK_AFx60_PN function block. It is used for guiding technical personnel working for the machine manufacturer / operator in pro- ject planning and commissioning. 1.2 Target group This technical information is aimed for specialists, such as technicians and engineers. Technical Information FB_SICK_AFx60_PN Function Block Page 4 / 18 2 General information The function block “FB_SICK_AFx60_PN” simplifies the use of the AFS60 / AFM60 encoder on Siemens S7-300 / S7-400 PLCs. The device has to be embedded into the PROFINET surrounding of your PLC-Controller. Figure 1 shows the concept behind the AFx602 PLC integration. Figure 1: Concept behind the AFX60 PN function block The function block makes it possible to read and write a defined set of device parame- ters (PNU = Parameter number) via PROFINET. Device parameters: - [PNU 922] Telegram Number (Read only) - [PNU 964] Device Identification (Read only) - [PNU 965] Encoder Profile-Number (Read only) - [PNU 971] EEPROM Storage (Read/Write) - [PNU 975] Object Identification (Read only) - [PNU 979] Sensor Format (Read only) - [PNU 980] Parameter List (Read only) - [PNU 1000] Encoder Status Flag (Read only) - [PNU 1001] Device Status Flag (Read only) - [PNU 1002] Service-Log History Absolut (Read only) - [PNU 1003] Service-Log History Relative (Read only) - [PNU 1004] Service-Log Errors (Read only) - [PNU 1005] Speed Calculation (Read only) - [PNU 1006] Temperature Limits (Read/Write) - [PNU 1007] Voltage Limits (Read/Write) - [PNU 1009] Scaling Parameters (Read only) - [PNU 1010] Operation Test (Read/Write) - [PNU 1011] MAC-ID Port 1 (Read only) - [PNU 1012] MAC-ID Port 2 (Read only) - [PNU 1013] Firmware version (Read only) - [PNU 1014] Temperature (Read only) - [PNU 61000] Station Name (Read only) - [PNU 61001] Station IP (Read only) - [PNU 61002] Station MAC-ID (Read only) - [PNU 61003] Station Gateway (Read only) - [PNU 61004] Station Subnet (Read only) - [PNU 65000] Preset Value (Read/Write) - [PNU 65001] Operating Status (Read only) FB_SICK_AFx60_PN Acyclic PROFINET communication DB_SICK_ AFx60_DATA Instance Data SFB53 WRREC SFB52 RDREC Function block (FB77) Data block (DB77) Technical Information FB_SICK_AFx60_PN Function Block Page 5 / 18 3 Hardware Configuration 3.1 Supported PLCs The function block can only be used with S7-300 / S7-400 PLCs which can be programmed with SIMATIC STEP7 V5.x. Communication processor cards (CP-Modules) are not support- ed by the function block. 3.2 Hardware configuration Before the function block can be used, the SICK device has to be projected in the hardware configuration in STEP7. Therefore the corresponding device file (GSD file) has to be import- ed in the hardware library of the STEP7 engineering tool. Figure 2 shows an example projecting of a SICK AFS60A (PROFINET) device. Please use diagnostic address of the “Parameter Access Point” sub-module for the #ID parameter of the function block. Figure 2: Example hardware configuration Technical Information FB_SICK_AFx60_PN Function Block Page 6 / 18 4 Function block The FB_SICK_AFx60_PN function block simplifies the usage of a SICK AFS60 / AFM60 en- coder. The FB allows transmitting and receiving of device specific service data via acyclic PROFINET services. The usage of a communication processor (CP-Module) is not support- ed by this function block. The function block is working asynchronously, which means the processing is done via vari- ous function block call ups. Therefore it is necessary that the function block is called up cycli- cally in the user program. The function block encapsulates the Siemens functions RDREC (SFB52) and WRREC (SFB53), which are used for the acyclic communication between the PLC and AFx60 device. Figure 3: FB_SICK_AFx60_PN function block 4.1 Block specifications Block name: FB_SICK_AFx60_PN (FB77) Version: 1.1 Called up PLC blocks: TON (SFB 4) RDREC (SFB52) WRREC (SFB53) Data blocks: DB_SICK_AFx60_DATA (DB74) Function block call up: Cyclically Used flags: no Language: Instruction list (IL) STEP7 Version: STEP7 V5.5 + SP3 4.2 Renaming of block numbers In general, all block numbers are changeable. Technical Information FB_SICK_AFx60_PN Function Block Page 7 / 18 4.3 Method of function The function block uses thedata block (DB) DB_SICK_AFx60_DATA to handle data. This DB includes all parameters which are needed to exchange service data with an AFX60 de- vice. The data block includes two structures called “ParameterSelection” and “Parameter”. The “ParameterSelection” structure determines which variables should be read or written when the FB is triggering at the #Req input bit. Please note! Further information about the encoder parameters and their limitations, see device documentation. Figure 4: “ParameterSelection” structure of the "DB_SICK_AFx60_DATA" DB Technical Information FB_SICK_AFx60_PN Function Block Page 8 / 18 Figure 5: “Parameter” structure of the "DB_SICK_AFx60_DATA" DB [Part 1/4] Technical Information FB_SICK_AFx60_PN Function Block Page 9 / 18 Figure 6: “Parameter” structure of the "DB_SICK_AFx60_DATA" DB [Part 2/4] Technical Information FB_SICK_AFx60_PN Function Block Page 10 / 18 Figure 7: “Parameter” structure of the "DB_SICK_AFx60_DATA" DB [Part 3/4] Figure 8: “Parameter” structure of the "DB_SICK_AFx60_DATA" DB [Part 4/4] Attention! Please do not change or edit the addressing of the data block “DB_SICK_AFx60_DATA” variables. Otherwise it cannot be ensured that the function block works correctly. Technical Information FB_SICK_AFx60_PN Function Block Page 11 / 18 4.3.1 Read data Before reading out sensor parameters a selection is needed. This selection determines which parameters should be read out from sensor (ParameterSelection). Figure 9 shows an example to read out the temperature limits [PNU 1006] and the voltage limits [PNU 1007]. Figure 9: Read out the temperature- and voltage limits [Part 1/2] Figure 10: Read out the temperature- and voltage limits [Part 2/2] The reading action starts by calling up the FB with a positive trigger (signal change from FALSE to TRUE) at the #Req input bit. The #RW bit must be set to FALSE (read access). As long as there is no valid answer the output #Busy is TRUE. In case the timeout period is ex- cited, a time out error will be generated and the thread will be terminated. The #Done (=TRUE) output shows that the transmission was successful. Now the requested results are available in the “Parameter” sub structure. The output retains its states as long as there is no new positive trigger at the #Req input. Technical Information FB_SICK_AFx60_PN Function Block Page 12 / 18 4.3.2 Write data Before writing a parameter value into the sensor a selection is needed. This selection deter- mines which parameter should be written to the sensor (ParameterSelection). The value that should be written can be defined in the “Parameter” sub structure. Figure 11 shows an example to modify the “preset value” [PNU 65000]. Figure 11: Writing the “Preset Value” parameter [Part 1/2] Figure 12: Writing the "Preset Value" parameter [Part 2/2] The writing action starts by calling up the FB with a positive trigger (signal change from FALSE to TRUE) at the #Req input bit. The #RW bit must be set to TRUE (write access). As long as there is no valid answer the output #Busy is TRUE. In case the timeout period is ex- cited, a timeout error will be generated and the thread will be terminated. The #Done (=TRUE) output shows that the transmission was successful. The output retains its states as long as there is no new positive trigger at the #Req input. Please note! Please note, that you can write only one parameter at the same time. A multi selection is only possible for read-requests. 4.4 Behavior when error occurs An error bit #Error is set and an error code #Errorcode is generated if there is an invalid input value or an incorrect input connection of the FB_SICK_AFx60_PN. In this case, no further processing is carried out until the input has been corrected. Technical Information FB_SICK_AFx60_PN Function Block Page 13 / 18 5 Parameter Parameter Declaration Data type Description EN Input BOOL Enable input (only in the FBD view) ID Input DWORD Diagnostic address of the “Parameter Access Point” sub-module (see Figure 1). Please enter this value in a hexadecimal rep- resentation. TOut Input TIME If the FB action requires a longer time than the “TOut” time, an error is set. Example: TOut:= T#5s Req Input BOOL Positive trigger starts a request with the pa- rameter set in the “Data” (ParameterSelection) RW Input BOOL Read/Write selection FALSE: Read parameter TRUE: Write parameter Data Input BLOCK_DB This input parameter needs a reference to the data block DB_SICK_AFx60_DATA which contains the device data and the selection bits. Done Output BOOL The rising edge indicates if the FB processing is completed Busy Output BOOL Request in process FALSE: Request is terminated TRUE: Request is being processed Error Output BOOL Error flag FALSE: No error detected TRUE: Error detected Errorcode Output DWORD Error code (see error code description) ENO Output BOOL Enable output (only in the FBD view) Table 1: Function block parameters Technical Information FB_SICK_AFx60_PN Function Block Page 14 / 18 6 Error description The parameter #Errorcode contains the following error information: - General function block error codes - Siemens specific error codes generated by the function blocks RDREC and WRREC Further information about these error codes is given in the STEP7 help system. nBlockError Short description Description 16#0000_0000 No error No error 16#0000_0001 Time out Time out error occurred while communicating with device. 16#0000_0002 Reserved - 16#0000_0003 No variable selected for the read/write request No variable selected. Please check your var- iable selection in the “ParameterSelection” structure. 16#0000_0004 More than one variable selected for the write request More than one variable selected. Please check your variable selection in the “Parame- terSelection” structure. Please note, that you can write only one pa- rameter at the same time. A multi selection is only possible for read-requests. 16#0000_0005 Unexpected request reference received The answer telegram contains an unex- pected request reference value (PROFIdrive). 16#0000_0006 Unexpected data type received The answer telegram contains an unex- pected data type value (PROFIdrive). 16#0000_0007 Unexpected “No. of values” received The answer telegram contains an unex- pected “No. of values” value (PROFIdrive). 16#0000_0008 Reserved - 16#0000_0009 Parameter not writable Selected parameter is not writeable Technical Information FB_SICK_AFx60_PN Function Block Page 15 / 18 nBlockError Short description Description 16#0000_XX0A Encode error Encoder error XX = Encoder error number (for more in- formation see device documentation) 16#00 = Impermissible parameter number 16#01 = Parameter value cannot be changed 16#02 = Low or high limit exceeded 16#03 = Faulty sub-index 16#04 = No array 16#05 = Incorrect data type 16#09 = No description data available 16#0B = No operation priority 16#0F = No text array available 16#11 = Request cannot be executed be- cause of operating state 16#15 = Response too long 16#16 = Parameter address impermissible 16#17 = Illegal format 16#18 = Number of values are not consistent 16#19 = Axis/DO nonexistent 16#65 = Memory resource fails 16#0000_000B – 16#0000_000F Reserved - 16#XXXX_XXXX Communication error (RDREC / WRREC) This error is generated by the Siemens func- tion blocks “RDREC / WRREC”. XXXX_XXXX= Error code see STEP7 help system (SFB52/53) Error code begins with:16#DE = Error reading data record 16#DF = Error writing data record 16#C0 = No DPV1 protocol element used Table 2: Function block error codes Technical Information FB_SICK_AFx60_PN Function Block Page 16 / 18 7 Example Figure 13 shows an example call up of the FB_SICK_AFx60_PN function block in the OB1 program. The data block “DB_SICK_AFx60_DATA” contains all accessible service data vari- ables of the device. The #ID parameter of the FB referenced to the diagnostic address of the “Parameter access point” submodule defined in the hardware configuration. The variable-table “AFx60_Test” is used to control this example program via the SIMATIC Manager. Example program: Figure 13: Example call of the FB_SICK_AFx60_PN function block Technical Information FB_SICK_AFx60_PN Function Block Page 17 / 18 7.1 Read a device a parameter This example shows how to read out all accessible parameters of the encoder. Before start- ing the function block with a rising edge at the #Req bit, the following parameters must be set: Figure 14: Variable preselection / Start FB The #Done (=TRUE) output shows that the transmission was successful. Now the requested result is available in the data block DB_SICK_AFx60_DATA. The output retains its states as long as there is no new request is executing on the same variable. Figure 15: Part of the result value Technical Information FB_SICK_AFx60_PN Function Block Page 18 / 18 7.2 Write a device parameter This example shows how to change the temperature limits [PNU 1006] of the encoder. Be- fore starting the function block with a rising edge at the #Req bit, the following parameters must be set: Figure 16: Variable preselection / Write new value Figure 17: Write a new value The #Done (=TRUE) output shows that the transmission was successful.