Selecting Recipes Through Scripting

Sepasoft MES Module Suite

Selecting Machine Recipes

The Recipe module provides a number of built-in scripting functions to handle the selection and downloading of recipes to production items.

If you are using location production items instead of lines, cell groups and cells, when a production location product code is set using the system.production.utils.setLocationProductCode script function, the recipe is also selected for the production location. When this happens the recipe values are written to their associated tags. Location variance tracking can be turned off using the system.production.utils.cancelLocationProductCode scripting function.

Scripts can also be used to directly select and cancel recipes for production items. These scripts supports selecting and cancelling recipes from external triggers such as when a button is clicked or when a product code changes.

See system.recipe.setItemRecipe scripting function to select a recipe for a production item and system.recipe.cancelItemRecipe script function to cancel the current recipe for a production item for more details.

Downloading Recipe Settings using Tag Change Event

Recipes can be loaded automatically from a trigger in the PLC, from a Sequential Function Chart (SFC) chart, and many other places. This example shows how to load a recipe to the PLC when a trigger changes in the PLC.

In the tag browser, create a memory tag called Recipe 1 Trigger of type boolean with a default value of false.

 Select the Tag Events tab so we can setup a script that will run automatically and load Recipe 1 when the tag goes to 1.

Select the Value Changed script and enter in the following script:

Python
#if not initialChange and previousValue.value != currentValue.value and currentValue.value:
linePath = "[global]\My Enterprise\Site 1\Packaging\Line 1"
recipe = "Recipe 1"
system.recipe.setItemRecipe("RecipeDemo", linePath, recipe, 1)

 

Set the trigger to 1 and watch the recipe get loaded down automatically. 

Sepasoft MES Module Suite