Multi-product lines carry one parameter set per product (temperature, speed, durations, positions...), and recipe switching means "load the selected recipe into the working area; the equipment reads only the working area". A two-layer "recipe library + working area" data-block structure makes switching a copy operation and adding a recipe a data entry, not a code change. This article gives the structure and the deployment steps.
| Layer | Content | Property |
|---|---|---|
| Recipe library | An array of N recipe structures: recipe 1~N, each holding the full parameter set | Retentive storage, editable from the HMI |
| Working area | One parameter structure: read-only to the running equipment | The only place process logic references |
| Switching control | Current recipe number, switch request, switch status | Edge-triggered copy |
The key discipline: process logic references the working area only, never the library directly. The moment the logic contains "recipe 2's temperature" hard-coded, the recipe mechanism is broken — every reference is "working.Temperature", and which recipe sits in the working area is the switching layer's business alone.
Define the recipe as a structure/UDT: heating temperature, hold time, conveyor speed, press position, allowed deviation, product name (string)... roughly 20~50 parameters. The library is a structure array in a DB (Array[1..20] of UDT_Recipe). The array's virtue: switching copies by index, the HMI edits by index, and adding a recipe means filling another array slot — zero program change.
| Member | Type | Example |
|---|---|---|
| Name | String | "ProductA-Blue" |
| Heating temperature | REAL / scaled integer | 180.0 °C |
| Hold time | Integer (s) | 30 |
| Conveyor speed | Integer (0.1 m/min) | 125 → 12.5 m/min |
| Press position | Integer (0.01 mm) | 12500 → 125.00 mm |
| Checksum | Word | Verifies data integrity at load |
① Trigger: the HMI selects a recipe number and presses "switch"; the PLC takes the recipe number's change edge; ② verify: the number is in range and the recipe's checksum is correct (keeping corrupted library data from loading); ③ copy: BLKMOV/MOVE transfers Array[number] wholesale into the working area and sets "switch complete". Execute with the machine stopped or idle — switching while running is a different requirement (online changeover) that must wait for a "safe point" (end of a cycle); this article covers stopped switching.
The recipe library must sit in a retentive area (DB retention attribute / holding D area) or an outage erases it. Three supports: ① factory default recipe: on first power-up (or when the library is detected invalid) load defaults and mark "default"; ② checksums: compute over the parameter area on save, verify at load — HMI-corrupted data is caught at the switch gate; ③ edit permissions: recipe pages tiered — operators select, process engineers edit.
| Screen | Function | Points |
|---|---|---|
| Recipe selection | Dropdown for the number + switch button + done/error feedback | Disable switching while running (or route to online changeover) |
| Recipe editor | Read/write library parameters by number, with save and verify | Recompute the checksum on save |
| Current parameters | Read-only view of the working area | Always shows the parameters "in force" |
The HMI binds the library array by index directly; the "current parameters" screen binds the working area, so the operator always sees what is actually in force and never wonders "I changed the recipe, why nothing happened".
| Symptom | Cause | Fix |
|---|---|---|
| Recipes gone after an outage | Library area not retentive | Enable retention / move to a holding area |
| Some parameters unchanged after switching | Hard-coded in logic / copy length short | Audit references; align copy length with the structure |
| Corrupt data loaded, machine misbehaves | No checksum | Add checksums; refuse on failure |
| Machine stumbles when switching live | No safe-point control on the switch timing | Stopped switching, or cycle-boundary online changeover |
| HMI edit has no effect | No re-switch (working area not refreshed) | Switch again, or a "sync" button re-copies |
A recipe system is "data and logic separated": logic reads the working area (stable), data lives in the library (editable), and switching is the single channel between them. Govern the channel (edge, verification, timing) and the recipe system becomes the live template of "new recipes without code changes"; leave the channel open (logic reading the library, random live copies) and it becomes a false-action generator.
DB structure/array and retention attributes follow the platform manuals (TIA, CODESYS, AutoShop); block-transfer behaviour follows the applied-instruction chapters; recipe governance and change records follow the corporate quality system; online changeover timing must preserve safety per GB 5226.1 / IEC 60204-1.
Acceptance tests: power-off retention, 20 consecutive switches with identical results, and the corruption-interception test (hand-break one parameter's checksum — it must alarm).