Recipe Manager in Codesys

Recipe Manager in Codesys

The Recipe Manager package in Codesys can be used to store user and operator values in a file or multiply files with different values. In this example I use it to backup all my operating parameters of a controller. The values are usually saved in the Persistent Variable List, called PVL.

Add a new object to your project and select the “Recipe Manager”

Add a recipe manager in Codesys
Add a recipe manager in Codesys

I keep the default name of the recipe manager object.

Recipe manager object name
Recipe manager object name

The settings for the storage type and amount of data in the recipe can be determined from the available list. I like to keep the storage type textual and with := separator. This way you can actually copy/paste parts of the saved recipe directly into your Codesys code.

Recipe manager storage settings
Recipe manager storage settings

Here I have only two changes from default values. I use “Load matching variables by variablename” so that a incomplete or updated recipe can be used even after changes are made. This is a important decision depending on your application, some recipes needs to be exact! “check recipe for changes” is also checked.

Recipe manager general settings
Recipe manager general settings

A new Recipe Definition is needed, this is the template with the list of values to be able to save recipes for, it is not a recipe in itself.

Adding a recipe definition
Adding a recipe definition

Since I am using the recipe manager to backup operator parameters stored in the PVL, I just call mine Backup_PVL.

Recipe definition name
Recipe definition name

Now we can right-click in the white pane, we get a right-click menu where we can choose to “Add a New Recipe”

Add a new recipe
Add a new recipe

The recipe is a set of values for the variables that we put into the recipe definition. There can be multiply of these recipes, so be sure to give them a meaning name to your application. I am only going to have one, so its named BackupPVL.

Naming the new recipe
Naming the new recipe

Now we can right-click in the white pane, at the top of the “first line”, to be able to select the “Insert Variable” menu item. If you only right-click at the white pane, you can not select this option.

Insert Variable into recipe
Insert Variable into recipe

You can choose to add single variables or tagnames to add to the recipe. I want to make a backup of my complete persistent variables list and can do so by just adding the root structure PVL.

Add variables to recipe
Add variables to recipe

With Recipe Manager and recipe all setup it time to download the project with recipe manager to the PLC and go online. All the current values of the variables in the PVL is now shown.

Download recipe manager to PLC
Download recipe manager to PLC

Right-click on the BackupPVL recipe and select “Read and Save Recipe…” in order to read the data from the PLC and save it in a offline file on your computer.

Read and save recipe
Read and save recipe

Codesys IDE now prompts you about 2 choices. To update the project file with the read recipe or to only save it on a file on your computer. The first option will result in a online change!

Online change or just save file?
Online change or just save file?

The backed up file contains all the variables from the PVL structure in a list of tags separated with := to values, you can now reuse this structure for programming.

PVL backup content
PVL backup content

Loading a recipe from file to the controller can be done by right-clicking the recipe and select “Load and Write Recipe…” from the menu. From the dialog you select a previously made backup file and all the values with matching tagnames will be updated in the PLC.

Load and Write Recipe
Load and Write Recipe

Adding new features, tagnames or functions in your PLC programs will also add new data into the PVL structure. To add or remove new/old tagnames from the recipe right-click on the recipe and select “Update Structured Variables”.

Update Structured Variables
Update Structured Variables

A popup dialog gives a resume of the changes found after scanning for updated variables.

Update Structured Variables
Update Structured Variables

You now have a method for reading, writing and updating a backup of all your user settings in a Codesys controller.


Discover more from SCADA, PLC and Automation Engineering

Subscribe to get the latest posts sent to your email.

2 comments on “Recipe Manager in Codesys

Leave a Reply

Your email address will not be published. Required fields are marked *