Block that writes a recipe into a recipe file from a variable.
Ladder Representation

Block Structure
Variable Type |
Name |
Data Type |
Description |
VAR_INPUT |
Execute |
BOOL |
Block enabling |
FILENAME# |
STRING |
Name of the recipe file |
|
INDEX |
WORD UINT |
Recipe index to be written |
|
SRC |
STRUCT |
Variable where the data is read |
|
VAR_OUTPUT |
Q |
BOOL |
End of operation |
ERROR |
BOOL |
Error occurrence flag |
|
ERRORID |
BYTE USINT |
Identifier of the occurred error |
|
VAR |
WRITERECIPE_INST_0 |
WRITERECIPE |
Instance of access to block structure |
Operation
When this block identifies a leading edge in Execute, it gets the data from SRC file and sends them to the recipe file selected by the INDEX index in the FILENAME#. If everything goes successfully, Q receives TRUE and remains so while Execute is TRUE.
|
NOTE! Recipes stored in RAM is identified by 'RECIPE_NAME'. Recipes stored on the SD card are identified by 'RECIPE_NAME.CSV'. |
If there is any error in the execution, the Error output is activated and ErrorID displays an error code according to the table below.
Code |
Description |
1 |
Incomplete recipe |
2 |
Invalid structure |
3 |
Nonexistent recipe |
4 |
Invalid file |
5 |
Invalid file or nonexistent SD card |
6 |
SD card blocked for writing |
Block Flowchart

Example in Ladder

The above example attempts to write the contents of SRC in the index 4 of the recipes file stored in SD card 'RECIPE_SD.CSV'. The block does not find the specified file, enabling the ERROR output with ERRORID with value 5 and disabling the Q output.

The above example attempts to write the contents of SRC in the index 4 of the recipes file stored in SD card 'RECIPE_SD.CSV'. The block finds the specified file, but does not find the index 4, enabling the ERROR output with ERRORID with value 3 and disabling the Q output.

The above example attempts to write the contents of SRC in the index 4 of the recipes file stored in SD card 'RECIPE_SD.CSV'. The block finds the file and the specified index, stores values in the recipe, disables the ERROR output and enables Q output.
Example in ST
The example below displays the instructions for applying the example above in the ST language.
VAR SRC : STRUCT_RECIPE; WRITERECIPE_INST_0 : FB_WriteRecipe; END_VAR
WRITERECIPE_INST_0.Execute := DI1; WRITERECIPE_INST_0(FILENAME:='RECIPE_SD.CSV', INDEX:=1, SRC:=SRC); DO1 := WRITERECIPE_INST_0.Q;
|
|---|