×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ, Entry ID: 109483256, Entry date: 04/27/2017
(13)
Rate

How do you read out the status of an MRP ring in the user program of the CPU in STEP 7 V5.x?

  • Entry
  • Associated product(s)
There are two ways of reading out the status of an MRP ring in the user program of the CPU.
  1. Using the system function block SFB52 "RDREC" you read out the data record 8050 (MrpInstanceDataReal) from the redundancy manager.
  2. Use the diagnostics OB OB82.

Read out data record 16#8050 (hex) with the system function block SFB52 "RDREC"
Call the system function block SFB52 "RDREC" in the user program of the CPU to read out the data record 16#8050 (hex) of the redundancy manager in the MRP ring and determine the status of the MRP ring.
In this example a SCALANCE X208 is used as redundancy manager.

The data record number 16#80A2 (hex) is stored in a tag of the Integer data type.


Fig. 1

In this example the maximum length of the data record information to be read is 200 bytes.


Fig. 2

The logical address of the PROFINET component is stored in a tag of the DWORD data type.


Fig. 3

Fig. 4 shows the call of the system function block SFB52 "RDREC".


Fig. 4

Input parameters of the system function block SFB52 "RDREC".

Input parameterData typeDescription
REQBOOLREQ = 1: Perform data record transfer.
IDDWORD

Logical address of the PROFINET IO component.


Note
Specify the diagnostics address of the redundancy manager. This is to be found in the Hardware Configuration (see Fig. 2).

INDEXINT

Data record number.


Note
The data record number.


MLENINTMaximum length of the data record information to be read in bytes.
RECORDANYTarget area for the data record read.

Table 1

The output parameters of the system function block SFB52 "RDREC".
 

Output parameterData typeDescription
VALIDBOOLNew data record has been received and is valid.
BUSYBOOLBUSY = 1: The read procedure has not yet finished.
ERRORBOOLERROR = 1: An error has occurred in the read procedure.
STATUSDWORDBlock status and error information.
LENINTTarget area for the data record read.

Table 2

To determine the diagnostics address of SCALANCE X208 (redundancy manager), you mark SCALANCE X208 in the Hardware Configuration. The diagnostics address of the PROFINET interface of the SCALANCE X208 is at slot X1 in "Diagnostics address" column. In this example you specify the diagnostics address 2041 (dec) = 0x7F9 (hex) at the input parameter ID of the SFB52 "RDREC".


Fig. 5


The data record data read is stored in a data block in a tag of the data type ARRAY [0..199] OF BYTE.

Structure of the Target Area for the Data Record Read
Table 3 shows the structure of the target area for the data record read that is specified at the RECORD input parameter of the system function block SFB52 "RDREC".

ByteArray[0..199] of Byte
Byte 0 and 1Block Type
Byte 2 and 3Block Length
Byte 4Block Version High
Byte 5Block Version Low
Byte 6 to 199

Data:

  • MRP domain
  • Media redundancy roll
  • MRP version
  • Length of the name of the MRP domain
  • Name of the MRP domain
  • Parameter of the redundancy manager or of the client
  • Status of the MRP ring (MRP_RingState)

Table 3

The MRP_RingState byte of the data record information read shows the current status of the MRP ring.

  • Byte MRP_RingState = 1: ring closed, in other words the redundancy manager is passive and only one ring port forwards the ring messages.
  • Byte MRP_RingState = 0: Ring open, in other words the redundancy manager is active and both ring ports forward the ring messages.

Note
The number of the MRP_RingState byte varies because, for example, the length of the name of the MRP domain can be different in each MRP ring. In this example the name of the MRP domain is 11 bytes long. The MRP_RingState byte is always the last byte in the data record. The LEN output parameter of the system function block SFB52 "RDREC" designates the length of the data record read. In this case the length of the data record is 68 bytes. This means that the status of the MRP ring (MRP_RingState) is stored in Byte 68.

Diagnostics OB OB82
If the redundancy manager is a node of a PROFINET IO network, you can also read out the status of the MRP ring in the user program of the CPU using the diagnostics OB OB82. For this you enable the diagnostics interrupt in the redundancy manager.

To enable the diagnostics alarm in SCALANCE X208 (redundancy manager) you go to the Hardware Configuration and open the Properties of the PROFINET interface of SCALANCE X208. In the "Media Redundancy" tab you enable the "Diagnostics interrupts" function.


Fig. 6

In the CPU you enable the function "OB 82 / IO FaultTask - Call at communications interrupt". For this you go to the Hardware Configuration and open the Properties of the PROFINET interface of the CPU. In the "PROFINET" tab you enable the function "OB 82 / IO FaultTask - Call at communications interrupt".


Fig. 7

Now OB82 is called when the ring opens (incoming event) and is called again when the ring closes (outgoing event).
In STEP 7 V5.x, using the parameter "OB82_MDL_ADDR" in OB82 you read out the logical basic address of the device reporting the error. The parameter "OB82_EV_CLASS" reports whether the event is outgoing (B#16#38) or incoming (B#16#39).

Security information
In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.