A recent DMC project for an OEM machine builder involved automatically generating log files for each machine. The twist? Each log file needed to be unique and easily traceable to the machine that generated it. This can be achieved using the PLC serial number and/or MAC address, and Siemens has a built-in System Function Block (SFB52 - RDREC) that can be used to extract this data.
First let's take a look at the block and its inputs.
-
REQ: Boolean input to request a Read.
-
ID: Hardware identifier of the hardware module to read from (can be found by going to PLC tags -> Show all tags, and selecting the System constants tab). I want to read the PLC’s serial number so I’m using PLC_1[Common].
-
Index: This is the data record number. To read the serial number, the index happens to be 16#AFF0.
-
MLEN: Maximum length (bytes) to read from the data record.
-
RECORD: This is the destination where the read will be stored. This MUST be greater than or equal.
After executing the read, you will then need to parse the data in order to obtain the relevant information. In the example above, we read 100 bytes from the 16#AFF0 data record of PLC_1. The serial number is stored in bytes 28-44. Using SFC222 (Chars_TO_Strg), I was able to extract the serial number into a string that was easily included in the log file.
You can use SFB52 with an S7-1500 PLC as well. Additionally, you can read more than just the serial number of the PLC. A few examples with their associated parameters are shown below:
|
ID
|
INDEX
|
Bytes
|
PLC Serial Number
|
50
|
16#AFF0
|
28-43
|
PLC Hardware Revision
|
50
|
16#AFF0
|
44-45
|
PLC Software Revision
|
50
|
16#AFF0
|
46-49
|
PLC MAC Address
|
64
|
16#8080
|
20-25
|
MC Serial Number
|
51
|
16#AFF0
|
28-43
|
Learn more about DMC's Siemens PLC Programming Services.