In STEP 7 V5.5, how do you read out the IP address of the S7-300 CPU in the user program?
With the system function SFC51 "RDSYSST" you can read out a partial list or excerpt of a partial list of the system status lists (SSL or in German SZL). With the SSL ID and the INDEX you specify the partial list or excerpt of the partial list and the type or number of an object in a partial list. Use the SSL ID = 37 (hex) and the INDEX = 0 (hex) to read out the IP address of the S7-300 CPU.
In this example the system function SFC51 "RDSYSST" is called in the function block FB1. FB1 is called cyclically in OB1.
Inputs and outputs of the system function SFC51 "RDSYSST"
Table 01 shows the inputs of the system function SFC51 "RDSYSST".
|REQ||BOOLEAN||REQ=1: Trigger for processing|
|SZL_ID||WORD||SZL_ID of the partial list or of the excerpt of the partial list
SSL_ID=w#16#37: Read out of the IP address of the S7-300 CPU
|INDEX||WORD||Type or number of an object in a partial list
INDEX=w#16#0: Read out of the IP address of the S7-300 CPU
Table 02 shows the outputs of the system function SFC51 "RDSYSST".
|RET_VAL||INT||If an error occurs during processing of the instruction, the RET_VAL parameter receives an error code.|
|BUSY||BOOLEAN||TRUE: Read procedure has not yet finished|
|SZL_HEADER||STRUCT||The SZL_HEADER is a structure. The structure is described under "SZL_HEADER structure".|
|DR||ANY||Target area for the read SSL partial list or read excerpt of SSL partial list.|
The SZL_HEADER output is a structure defined as follows:
LENTHDR is the length of a data record of the SZL partial list or of the excerpt of the SZL partial list.
- If you have only read out the header information of an SZL parts list, N_DR contains the number of the associated data records available.
- Otherwise N_DR contains the number of data records transferred to the target area.
Target area for the read SSL partial list or read excerpt of the SSL partial list
In this example the read SSL parts list is saved in the data block DB100 "SYS_DATA" starting at address 0. The IP address of the S7-300 CPU, consisting of 4 bytes, is stored in DB100 "SYS_DATA" starting at Address 2, byte for byte as hexadecimal value.
When you have read out the IP address of the CPU, you can then evaluate it in the user program. In this example, the IP address is saved as a decimal value in the instance data block DB1 of FB1.
The download contains the project "Read_IP_Address_STEP7_V55.zip".
Copy the "Read_IP_Address_STEP7_V55.zip" file into a separate directory and then start the file with a double-click. You can then use STEP 7 to open and process the extracted project data.
Read_IP_Address_STEP7_V55.zip ( 247 KB )
The pictures and download in this FAQ response were created with STEP 7 V5.5.