Skip to main content

Using Visualization Elements to Control Recipe Management

Basics for the representation of recipe data

All recipe data (both their identifiers and their values) are stored in the system as STRING. When a recipe is loaded, the Recipe Manager interprets these values and transfers them to the respective PLC variable.

To display the recipe data in a visualization, the associated information must be extracted into designated string variables or string arrays. These variables can then be directly linked to visualization elements in order to display their contents.

Detailed procedures can be found in the following use cases:

  • Extraction of recipe data

  • Extraction of recipe definition data

Tip

Explicit extraction of the recipe values is not required when the values are written directly to the PLC variables of a recipe. In this case, the respective variables can be linked to visualization elements as usual.

Recipe management via visualization elements

You can manage and use the recipes created in CODESYS by means of a visualization. Various input actions are available for this purpose in the input configuration of a visualization element. The following functions can be triggered via the Execute Command input action:

  • Read Recipe

    Loads a selected recipe and transfers its values to the PLC variables.

  • Write Recipe

    Writes the current values of the PLC variables to the selected recipe.

  • Load Recipe from File

    Loads a recipe from an external storage location (e.g. file system) to the project.

  • Save Recipe in File

    Exports a recipe to a file for archiving or further use.

  • Create Recipe

    Creates a new recipe with the stored structure (recipe definition).

  • Delete Recipe

    Removes an existing recipe from the project management.

For more information, see the following: Dialog:Input Configuration

Example: Loading recipes by means of visualization elements

Requirement: The Visualization object is added to the project.

  1. Create a recipe according to the instructions in the chapter Using Recipes.

    . Assign the following names:
    • Recipe definition: "Recipes"

    • Recipes: "Recipe1" and "Recipe2"

    • Variables: iValue1 and iValue2

    Type in different variable values of both recipes.

  2. Open the Visualization object in the editor.

  3. Drag a Button element to the visualization. Label it "Load Recipe 1". You can specify the text by double-clicking the element or in the Texts → Text property.

  4. Click the value field of the Input configuration: OnMouseDown property.

    The Input Configuration dialog opens.

  5. Select Execute command in the left of the left side and click the _visu_img_input_configuration_button.png button.

    The configuration of the Internal command opens on the right side of the dialog.

  6. Select the Write Recipe command from the list box.

  7. Click the _visu_img_input_configuration_button_plus.png button.

    The WriteRecipe command is added to the list.

  8. Specify the first parameter as Recipes and the second parameter as Recipe1.

  9. Click OK to exit the dialog.

  10. Drag a second button to the visualization, name it "Load Recipe 2", and repeat Steps 4 to 8. For Step 7, specify Recipe2 as the second parameter.

  11. Load the program to the controller and start it. Click the Load Recipe 1 and Load Recipe 2, and monitor the variables iValue1 and iValue2.

The other recipe commands are assigned to visualization elements in the same way as this example. For a description of the internal commands, see the help page of the input configuration.