Recipe Files: Background Information and File Structure
The maximum number of recipe files that can be stored depends on the controller type. The number of data sets per file depends on the Safety PLC involved. For a SPLC 3000 class each recipe file may contain up to 128 data sets (file sections) each with a maximum of 64 bytes of recipe data.
The following table lists the amount of recipe data for two Safety PLC types:
Safety PLC type | No. of recipe files | Total amount of recipe data |
---|---|---|
SPLC 3000 class | 8 | 64 Kbytes (8 files * 128 data sets * 64 bytes) |
SPLC 1000 class | 8 | 1 Kbyte (8 files * 2 data sets * 64 bytes) |
The file names for recipe files are rcp_00x.svv with x = 0 to 8.
Recipe files contain safety validated values (svv) with various checksums (see following section "File structure").
Recipe file structure
A recipe file is structured as follows:
At the beginning of the file there is a file header followed by up to 128 data sets (sections) with stored recipe data. Each section has its own CRC for data protection (DataSetCRC). At the end of the file there are a file checksum (FileCRC) and a total CRC which are both described below. The number of data sets per file is variable (configurable) and depends on the Safety PLC type.
The following graphic shows the maximum file size with 128 data sets:
Recipe file header
The file header has the following structure:
- 4 bytes project CRC: project CRC of the application.When reading recipe data with the SF_RecipeRead function block, a validation of the ProjectCRC can be activated by switching the CheckProjectCRC input of this FB to SAFETRUE. See section "Fault avoidance" of the SF_RecipeRead FB for details.The comparison of the project CRC helps ensuring that the recipe file to be read has been written out of exactly the same application project (version).
The project checksum has been calculated in PLCnext Engineer when building the project and was then written into the project file.
The SF_RecipeWrite FB reads this checksum from the project file and writes it into the header of the recipe file.
If the CheckProjectCRC input is set to SAFETRUE, the SF_RecipeRead FB reads the ProjectCRC from the recipe file header and compares it with the ProjectCRC of the current project. - 32 bytes project name: application name out of which the file was written.
- 64 byte serial number of the Safety PLC.When reading recipe data with the SF_RecipeRead function block, a validation of the serial number can be activated by switching the CheckSerialNumber input of this FB to SAFETRUE. This validation detects if recipe data have been read from a target system other than the one for which the recipe file was written. See section "Fault avoidance" of the SF_RecipeRead FB for details.
- 28 bytes reserved for future extensions.
File sections data sets with CRC
Each file section (data set) in a recipe file is composed as follows:
- 64 byte data set consisting of 16 values, each 4 bytes in size.
- 4 byte data set CRC.When reading recipe data with the SF_RecipeRead function block, a validation of the DataSetCRC can be activated by switching the CheckDataSetCRC input of this FB to SAFETRUE. If the checksum is not as expected, the read data is considered as invalid. This configurable validation helps ensure that exactly the right data set is read. Independently of this configurable validation, the FB always checks the data set consistency by recalculating and comparing the data set CRC.See section "Fault avoidance" of the SF_RecipeRead FB for details.
File checksum (FileCRC) and internal total CRC
At the penultimate position of the recipe file, the FileCRC with the size of 4 bytes is inserted which is calculated over the file header and all DataSetCRCs in the file sections.
When reading recipe data with the SF_RecipeRead function block, a validation of the FileCRC can be activated by switching the CheckFileCRC input of this FB to SAFETRUE. If the checksum is not as expected, the read data is considered as invalid. See section "Fault avoidance" of the SF_RecipeRead FB for details.
This configurable validation helps ensure that exactly the right file is read.
Independently of this configurable validation, the FB always checks the file consistency by recalculating and comparing the total CRC which is stored at the end of the recipe file. This checksum is calculated over the entire data in the file including the above-mentioned FileCRC. This CRC is not visible in the application and is used for internal data validations of the FB.