Switching a recipe means selecting one set of parameters by recipe number and then transferring the whole set into the running area in one go. Using comparison instructions to select the recipe and MOVE to transfer the parameters is the most direct and the most robust approach. The sections below cover how to organise the data, how to interlock the switch and how to validate the parameters.
A recipe is usually a group of parameters such as temperature, time, speed and position. There are two ways to organise them: one data block per recipe, moved as a whole on switching; or all recipes in one large array selected by index. The first is direct to call and easy to maintain individually; the second is easy to manage centrally and suits a large number of recipes with an identical structure.
The recipe number comes from the HMI or a selector switch. Use comparison instructions (equal, range) to map the number to a specific parameter set: equal to 1 moves recipe A, equal to 2 moves recipe B. With many recipes use a comparison chain or a step-by-step test, keep both sides of the comparison the same data type, and provide a default branch so an out-of-range recipe number does not simply do nothing.
Once a recipe is selected, use MOVE or MOVE_BLK to copy its parameters into the "running parameter area", and let the program read only from the running area. In this way the whole set takes effect at once when switching, and parameters cannot be changed halfway through a move. With many parameters, move the block as a whole; item-by-item MOVE easily misses one.
Switch a recipe when the machine is stopped or in a safe state. Use a status bit as an interlock: only move when "switching permitted" is 1, and set a "loaded" flag on completion for later logic to use. Forbidding switching while running prevents parameters changing mid-action, which would create quality and safety problems.
After the parameters reach the running area, use comparison instructions to check they are within the permitted range, and refuse to load and raise an alarm if they are not, so a wrong recipe cannot cause over-temperature or over-speed. Put the check after the move and before enabling, and if it fails, leave the previous recipe unchanged.
| Element | Recommended way | Key point | Note |
|---|---|---|---|
| Recipe number from the HMI | Comparison mapping | Same type, default branch | Act on out-of-range values |
| Calling a single parameter set | MOVE item by item | Direct when there are few items | Many items are easily missed; use a block |
| Switching many parameters as a batch | MOVE_BLK a data block | Keep running and recipe areas apart | Lengths must match |
| Recipes stored in DBs | DB to DB copy | Item by item or as a block | Watch optimised block access |
| Accept only in-range parameters | Comparison clamping | Refuse to load if out of range | Raise an alarm too |
| Switching must have the machine stopped | Status-bit interlock | Forbid switching while running | Confirm the safe state |
| Signal completion of the switch | Set a "loaded" flag | Used by the HMI and later logic | Do not set it on failure |
| Keep the current recipe across power-down | Retentive running area | Avoids reloading | Recheck parameters on power-up |
| Very many recipes | Index plus array | Avoids a long comparison chain | Bounds-check the index |
The real danger in recipe switching is not moving the wrong data but enabling it halfway through. Keeping the recipe area and the running area separate and using a flag to control when to enable avoids this. Looking back, comparison selects, MOVE transfers, and the interlock decides when to transfer; keep these three roles clear and nothing gets tangled.
The semantics of comparison and move instructions and the data type definitions follow GB/T 15969.3, Programmable controllers, Part 3: Programming languages (equivalent to IEC 61131-3). The safety requirements when device parameters are changed follow GB 5226.1 and the equivalent international standard IEC 60204-1. The exact instructions and data block access depend on the CPU version in use.
Put the machine into a switch-permitted state before changing recipes, validate the parameters after loading, and confirm before starting work. Parameters tied to safety limits should have a hard limit or be backed by a further protective circuit.