Add a recipes editorΒΆ

Purpose of this module

In this module, we will create and configure a set of objects useful for managing a recipe:

  • database in which to store the recipes data at runtime

  • a Recipe Schema object in which to define the set of variables or ingredients of the recipe

  • a graphical widget (Recipes Editor) to enable the user to manage recipes at runtime

This is the final result:

../_images/481a6e970eb02c4024ee0ef9b80ddb5b5720f0f8.gif
  1. Create the database for the recipes

    1. In Project, right-click DataStores, then click New > Embedded Database: EmbeddedDatabase1 appears.

    2. Rename EmbeddedDatabase1 to RecipeDB.

      Note

      multiple databases used to store different data can exist in the same project. This allows for better project readability.

  2. Create and set the Recipe Schema object

    In the Recipe Schema object, we will set up the set of PLC variables that make up the recipe and the database in which to store recipes at runtime. We will configure the object:

    1. Right-click Recipes, then click New > Recipe Schema: RecipeSchema1 appears.

    2. Rename RecipeSchema1 to MyRecipe.

    3. Click MyRecipe, in the Destination node property set a dynamic link with PLC_PRG. Alternatively, from Project drag PLC_PRG onto the Destination node value. In this way, from the MyRecipe object the variables that make up the recipe can be selected from those imported from the PLC.
      ../_images/a1ab896b37922d3ce8e734350635ad7afecac91a.png
    4. Double-click MyRecipe: the editor to select the variables of interest opens.

    5. Select the variables Ingredient01, Ingredient02 and Ingredient03 and click Apply: the variables synchronized are the recipe ingredients.

      Note

      if the selected PLC variables are changed, this step must be repeated to display the changes in the MyRecipe object.

    6. In the Store property of MyRecipe, set a dynamic link with RecipeDB: in RecipeDB a MyRecipe table with three columns is automatically configured, one for each recipe variable.

      ../_images/a286302eafb263eb098fd9572dcc858b91fc8ed8.png
  3. Configure the widget to manage the recipes

    The Recipes Editor widget makes it possible to display the recipe ingredients at runtime and to set the values of the variables, to store/modify different recipes, and to load the desired recipe on the PLC. We will configure the widget:

    1. To add the widget, click image1: the template library opens.

    2. In Widgets, select Recipes Editor and drag it into Page4 (type): the RecipesEditor1 object appears in the panel.

    3. Close the template library.

    4. To link the widget to the recipe, click RecipesEditor1 and in its RecipeSchema property set a dynamic link with MyRecipe.

    5. For the widget to show the recipe variables inside RecipesEditor1, right-click RecipesEditorUISetup, then select Execute Setup: the ingredients in the widget update.

      ../_images/189467f484378d1f63bb80b4b9c7673398913533.png

    Below is the description of the widget buttons:

    Button

    Function

    Save

    Store the recipe in the database during editing.

    Delete

    Delete the selected recipe from the database.

    Load

    Load the recipe values from the PLC to the HMI application.

    Apply

    Apply the selected recipe on the PLC.

  4. Check the operation at runtime

    1. Click image2Emulator and wait for the runtime window to appear.

    2. Click Page4 to display the recipe widgets.

    Store a new recipe

    1. Edit the value of the ingredients.

    2. In the combo box, enter a name for the recipe and press ENTER.

    3. Click Save: the recipe is stored in the database.

    4. Repeat the previous three steps for each recipe to save.

    Apply a recipe on the PLC

    1. Select the desired recipe: the values of the recipe ingredients are displayed.

    2. Click Apply: the recipe is applied and in the right column the widget displays the values of the ingredients loaded on the PLC.

    3. To change the values of the ingredients on the PLC, change the values in the spin box and click Apply: the values of the ingredients on the PLC are updated in the right column.

image3 Record and display alarms