Working with Recipes in the PAC

This tutorial provides a brief overview of how to do basic recipe operations in the PAC, including reading and writing recipes to a file, reading values from the PLC into recipes, writing values from recipes into variables in the PLC and managing recipe files.

The easiest way to work with recipes in the PAC is to use Parker's PAC_RecipeHandler function block. This function block performs all of the basic tasks associated with using recipes and can save development time. You can find it pre-imported into each of these project archives, or within the stand-alone compiled library.

Select the project that matches your version of Parker Automation Manager, or the separate compiled libary:

Standalone Library: Compiled Library

PAM1.4: RecipeHandler_PAM1.4

PAM1.3: RecipeHandler_PAM1.3

 

PAM1.2: RecipeHandler_PAM1.2

 

 

See below for a tutorial for using Recipes, and an explanation of the function block:

The first thing that must be done to use recipes is to add the Recipe Manager in PAM.  To add the Recipe Manager, right-click "Application".  Click "Add Object" and then click "Recipe Manager" near the bottom of the list.  In the dialog box that appears, click "OK".  A visual representation of these steps is shown below.

recipesfigure1_4863-20240521-001140.png

 

Figure 1: Visual representation of the procedure to add the Recipe Manager.

 It is worth noting that only one Recipe Manager can be added to a project.  This is not a limitation as the Recipe Manager simply defines some baseline parameters about how the PAC stores and accesses recipes.  When the Recipe Manager is added, PAM automatically adds the recipe handling library to the project.

Once the Recipe Manager has been added, the user has the option to set several different parameters that the PAC will use when working with recipes.  A visual breakdown of the options on the Storage tab is given below.

recipesfigure2_4864-20240521-001140.png

 

Figure 2: Annotated view of the Recipe Manager's Storage tab.

Elements of the Storage tab:

  1.  

Storage Type: The options available are Textual and Binary.  Textual recipes are stored in human-readable ASCII format when they are saved to a disk file.  Binary recipes are stored on the disk as pure machine data.  Binary files will likely be smaller, but it is generally recommended that users set this option to Textual in case they find themselves in a situation where a person or an outside program need to read the recipe file.  Binary files are advantageous for users who are working with extremely large recipes that take a long time to load or machine builders who want to protect their intellectual property. 2.       File Path: The path to the disk and folder in which the recipe is stored, including the final backslash.  It is possible to set this to a drive and folder on a computer that is on the same network as the PAC, provided the proper steps have been taken to grant the PAC access to the drive.  This is useful for pulling recipes off of a shared network drive.  If the recipes are going to be stored locally on the PAC, the file path should be set to "\Hard Disk2\folder\subfolder\ ".  The PAC's SD card is "\Hard Disk\", and "\Hard Disk2\" is the first USB stick to be inserted into the PAC.  The actual slot in which the USB stick is placed is irrelevant; the first one to be inserted is referred to by the PAC as "\Hard Disk2\".  It is important that the user has formatted the USB stick as FAT32, or FAT16 or FAT8 to make it PAC-compatible.  USB sticks formatted as NTFS will not be recognized by the PAC.

NOTE: Never allow the PAC to perform writing actions to its own SD card.  Doing so introduces the possibility of overwriting or corrupting system files.  In addition, continuous write cycles on an SD will eventually make it unusable.  For this reason, Parker strongly recommends performing read/write operations on a USB drive that can be easily replaced in the event that it fails. 3.       File Extension: This is the extension that the recipe files will be given when they are written to the disk.  This will not have any real effect other than to tell the PAC not to search for any other file types when loading or saving recipes. 4.       Separator: This allows the user to specify which symbol or set of symbols will be used to delimit values from their variable names.  If the user sets this to "Comma" and sets "File Extension" to ".csv", then Microsoft Excel will be able to open the user's recipe files natively.  This can be a convenient way to edit recipes. 5.       Columns Panel: Here, the user can specify which columns in the Recipe Definition will be included when the recipe is saved to the disk.  This is useful for users who want to keep some working documentation in their recipes ("Comments" column) or for users who want to have a record of how much a value has fluctuated during runtime ("Maximal" and "Minimal" columns).  The order of the columns can also be rearranged using the "Up" and "Down" buttons. 6.       Save as Default: This button allows the user to make these Recipe Manager settings their default settings in PAM.

The "General" tab only has two options.  "Recipe management in the PLC" must be checked if the user wants to use recipes during runtime.  If "Save changes to recipes automatically" is checked, the PAC will automatically save any runtime recipe changes to the disk.  It is recommended to check both boxes.

At this time, create a Recipe Definition.  A Recipe Definition is a template from which recipes can be created.  There is no limit to how many Recipe Definitions or recipes a project or PLC can have, other than a limitation of memory.

 

To create a Recipe Definition, right-click "Recipe Manager" and click "Add Object".  Then click "Recipe Definition...".  In the dialog box that appears, give your Recipe Definition a name and click "Add".  It is now possible to add variables to the Recipe Definition.  These can be of any type, including arrays and structures.

One important thing to discuss at this point is the storage of REAL and LREAL data types.  In textual format, these are saved as both decimal and hexadecimal values next to one another in the file that is generated.  This is important for users who want the file to be human-readable.

A variable can be added simply by typing its name in the left-hand column.  A recipe can be added by right-clicking any point in the recipe grid and then clicking "Add a new recipe".

 

Figure 3: Adding a new recipe to a Recipe Definition

New recipes can be given a name and can also be copied from a pre-existing recipe if the user only wants to make minor changes.  Parameters can then be set by typing values into each cell and pressing .

This tutorial will now explain how to use the PAC_RecipeHandler function block.  Users who are interested in using lower-level recipe-handling routines can open the function block's source code and read through it.

Import PAC_RecipeHandler into the current PAM project.  This can be done by installing the library (PAC_RecipeHandler.compiled-library) containing PAC_RecipeHandler and adding it to the project through the Library Manager.  The library also contains an enumeration called PAC_RECIPE_ACTION, which will be discussed later.  A visual representation of PAC_RecipeHandler is shown below.

 

Figure 4: Visual representation of PAC_RecipeHandler

The use of this function block will be explained by defining the purposes of its inputs and outputs.  There will also be a detailed explanation following that of the PAC_RECIPE_ACTION enumeration, as this defines the scope of what actions PAC_RecipeHandler can perform.

Table 1: Inputs and outputs of PAC_RecipeHandler

Inputs:

 

Execute:

On a rising edge, PAC_RecipeHandler will perform the selected action on the specified recipe.  The action will be performed once.  To perform another action, "Execute" must be set to FALSE then set to TRUE.  Type BOOL.

ActionType:

Selects the type of action to be performed.  This is covered in detail in the explanation of PAC_RECIPE_ACTION.  Type PAC_RECIPE_ACTION or INT.

RecipeDefinition:

Specifies the Recipe Definition in which the recipe is contained.  Type STRING.

RecipeName:

Specifies the name of the recipe.  Type STRING.

FileName:

Name of the file on the disk.  This only applies for command options marked with an asterisk in the section dealing with PAC_RECIPE_ACTION.  Type STRING.

Outputs:

 

ErrorID:

If the function block encounters an error, it will be reported here.  Type DWORD.

RecipeCount:

If the user has requested a recipe count, the number of recipes will be reported here.  Type INT.

 

The enumeration PAC_RECIPE_ACTION will now be explained in detail.  This is an integer (INT) enumeration that gives the programmer the convenience of passing mnemonic commands to PAC_RecipeHandler instead of an integer.  This makes the program more human-readable.  An explanation of all valid commands and their respective mnemonics is given below.

Table 2: An explanation of available commands for PAC_RecipeHandler

Mnemonic

Integer Equivalent

Description

CREATE

0

Create a recipe and automatically save it to a standard recipe file.

READ

1

Read the current value of the PLC variables into the recipe.

WRITE

2

Write the recipe into the PLC variables.

SAVE

3

Save recipe to the hard disk as a standard recipe file for future use.

CREATENOSAVE

4

Create a recipe but do not save it to a standard recipe file.

DELETE

5

Delete a recipe from a recipe definition (a recipe stored in RAM).

DELETEFILE

6

Delete a standard recipe file stored on the disk (no change to recipe in RAM).

LOADWRITE

7

Load a recipe from a standard recipe file, then write it to the PLC variables.

LOADFROMWRITE

8

Load a recipe from a standard recipe file with a different name, then write it to the PLC variables.

LOAD

9

Load a recipe from a standard recipe file into RAM.  Standard recipe file names take the form "recipe .recipe definition .recipe extension ".

READSAVE

10

Read the current values of variables from the PLC into a recipe and then save it into a standard recipe file.

READSAVEAS

11

Read the current values of variables from the PLC into a recipe and then save it into a standard recipe file with a user-defined name.

RELOAD

12

Reload all of the recipes in a given recipe definition from their standard recipe files on the disk.

This concludes the tutorial on performing basic recipe handling in the PAC.  There are more advanced features that can be accessed, but they are usually only necessary for users integrating recipes into Web Visualization.  Those features are therefore out of the scope of this discussion. 

 

If additional support is needed, customers can contact Parker by emailing the technical support team at emn.service@support.parker.com

 

 

20 November 2015 DC

2018JAN30 - Updated to PAM 1.3, added WebVis screen.

1NOV18 JD -1.4 update