Displaying the Last Loaded Recipe in WinCC V15.1 Recipe View
Recipe-driven HMI applications in TIA Portal V15.1 frequently require traceability of the data record most recently transferred to the controller. The recipe view object displays the data set currently selected by the operator, but it does not inherently store or display the identifier of the dataset that was last written to the PLC. This article documents a complete mechanism for tracking, displaying, and re-modifying the last loaded record using the system function RecipeViewSetDataRecordToPLC, a paired HMI tag that mirrors the active dataset number, and a PLC-side tracking variable for audit and process-control purposes. The approach is valid for WinCC Comfort, WinCC Advanced, and WinCC Professional V15.1 and is compatible with S7-1200, S7-1500, ET 200SP, and ET 200S controllers.
1. Problem Definition
When an operator loads a recipe data record to the PLC from the recipe view and then navigates to another screen, returning to the recipe page does not reveal which record is currently active on the controller. The recipe view is initialized with the first record in the recipe or the record linked to its Data Record Number property, not with the record most recently transferred to the PLC. This creates a gap in three areas:
- Operator visibility: The operator cannot determine which recipe is active on the machine without reloading or manually inspecting PLC tags.
- Audit traceability: The PLC has no persistent record of which dataset was loaded, complicating batch and version-controlled processes.
- Workflow continuity: The operator cannot resume editing the active recipe on screen return because the view does not auto-select the loaded record.
The problem is not a defect in the recipe view; it is a missing application-level integration between the HMI's recipe view selection state and a persistent tracking variable on the PLC. The solution is to push the dataset identifier to the PLC at the moment of transfer, then bind the recipe view's Data Record Number to a tag that mirrors the PLC value.
2. Prerequisites
Verify the following engineering environment conditions before implementation:
- TIA Portal V15.1 installed with the appropriate WinCC option (Comfort, Advanced, or Professional) licensed and activated.
- An HMI device added to the project tree (Basic Panel, Comfort Panel, or WinCC Runtime Advanced / Professional target).
- An HMI connection to the target PLC configured under Devices & Networks with consistent area pointers and connection resources on both sides.
- A recipe created in the HMI project under Recipes & Data records with at least one data record and tag mappings to PLC variables.
- A recipe view object placed on a process screen with tag connections valid for the target recipe.
- A free HMI tag of type
IntorWordfor mirroring the currently selected dataset number. - A free PLC tag of type
IntorWord(preferably in a data block for symbolic addressing) for storing the last-loaded dataset number.
RecipeViewSetDataRecordToPLC system function is documented for Comfort Panels, WinCC Runtime Advanced, and WinCC Runtime Professional. For Basic Panels, recipe handling is performed through the recipe view object on the screen rather than through scriptable system functions; confirm your target device's capability in the TIA Portal Help before implementation.3. WinCC V15.1 Recipe System Architecture
The recipe system in TIA Portal V15.1 consists of three hierarchical levels:
- Recipe element: A single tag value within a recipe. Each element maps to an HMI tag and (optionally) a PLC tag.
- Data record: A complete set of recipe element values. Data records are the transferable units in runtime.
- Recipe: A collection of data records for a specific process. Each recipe is a separate entity with its own tag mappings.
Recipes are stored on the HMI device in internal flash memory or on a configured storage medium (SD card, USB, network share). The data record transferred to the PLC is held in the runtime memory of the HMI until a new record is selected or the runtime is restarted, depending on the persistence settings. The recipe view displays the contents of the runtime in-memory dataset and the available records for selection; it does not communicate directly with the PLC for tracking purposes.
4. Recipe View Properties Relevant to Tracking
The recipe view exposes a defined set of properties. The following table summarizes the properties used in the tracking workflow:
| Property | Data Type | Description | Tracking Usage |
|---|---|---|---|
| Recipe Number | Int | Recipe selected in the view | Bound when multiple recipes are present and dynamic selection is needed |
| Data Record Number | Int | Currently selected data record (1-based) | Bound to CurrentRecipeDataset HMI tag for tracking |
| Data Record Name | String | Symbolic name of the selected record | Displayed for operator clarity |
| Operator input enabled | Bool | Permits value editing in the view | Must be enabled for modify-after-load workflows |
| Output as text | Bool | Formats numeric values as strings | Recommended for operator displays |
5. HMI Tag Configuration
5.1 Create the Active Dataset Mirror Tag
- Open the HMI tag table in the project tree: HMI device → HMI tags → Default tag table (or your custom table).
- Add a new tag named
CurrentRecipeDatasetwith data typeInt. - Set the connection to the PLC only if the tag is to be polled from the controller. For a purely HMI-side mirror bound to the recipe view property, leave the connection unassigned.
- Set the acquisition mode to
Cyclic continuouswith a cycle time of 1 second (or 500 ms for responsive tracking).
5.2 Create the Operator Display Tag
- Add a tag named
LastLoadedDatasetDisplaywith data typeIntand connection to the PLC pointing to theHMI_LastLoadedDatasettag address. - Set acquisition mode to
Cyclic continuouswith a 500 ms cycle to keep the on-screen display current.
5.3 Create the Timestamp and Operator Tags (Optional)
For full audit traceability, add additional HMI tags bound to the PLC for timestamp and operator ID:
-
LastLoadTimestamp(Date_And_Time, 8 bytes) — populated from the HMI system time at the moment of transfer. -
LastLoadOperator(String, e.g., 32 characters) — populated from the current logged-in user name.
6. PLC Tag Configuration
- Open the PLC's data block designated for HMI interface data (e.g.,
DB_HMI_Interface). - Add a static variable
HMI_LastLoadedDataset : Int;with a default value of 0 to indicate "no recipe loaded". - Add a static variable
HMI_LastLoadTimestamp : Date_And_Time;for audit purposes. - Add a static variable
HMI_LastLoadOperator : String[32];for the operator identifier. - Compile the PLC program and download to ensure the tag is reachable from the HMI.
7. System Function Reference
The TIA Portal V15.1 system function library provides several recipe view functions. The functions used in this article are summarized in the table below.
| System Function | Effect | Typical Use |
|---|---|---|
RecipeViewSetDataRecordToPLC |
Writes the currently selected dataset from the recipe view to the PLC tags | Load-to-PLC button event |
RecipeViewGetDataRecordFromPLC |
Reads current PLC tag values into the recipe view's in-memory dataset | Read-from-PLC button event |
RecipeViewClearDataRecord |
Resets the recipe view's in-memory dataset to default values | Cancel or reset action |
RecipeViewCopyDataRecord |
Duplicates a dataset within the recipe view | New-record-from-existing workflows |
RecipeViewSaveDataRecord |
Persists the in-memory dataset to the HMI recipe storage | Save edits to durable storage |
SetTag |
Writes a value to an HMI tag (or to a connected PLC tag) | Tracking variable update on transfer |
GetTag |
Reads the current value of an HMI tag | Pre-load validation and status checks |
8. Step-by-Step Implementation
8.1 Configure the Recipe View
- Open the screen containing the recipe view object in the TIA Portal V15.1 HMI editor.
- Select the recipe view object. In the properties window, navigate to Properties → General.
- Bind
Data Record Numberto the HMI tagCurrentRecipeDataset. This makes the selection state visible to the rest of the application. - Bind
Recipe Numberto a tag if multiple recipes are present and selection should be dynamic. - Under Properties → Operator input enabled, ensure the checkbox is activated to permit value editing after the initial load.
8.2 Add the Load-to-PLC Button
- Drag a button element onto the screen and label it Load to PLC.
- Open the button's event configuration (Properties → Events → Click).
- Add a system function. From the list, select
RecipeViewSetDataRecordToPLC(or in localized TIA Portal versions, the equivalent system function name). Configure the parameters as follows:
| Parameter | Value | Notes |
|---|---|---|
| Recipe View | Name of the recipe view object on the active screen | Select from the screen's object list |
| Data Record Number | 0 (use currently selected record) | Or specify a fixed value for fixed-record workflows |
| Mode | Overwrite | Default behavior; Do not overwrite is available for protected PLC values |
- Add a second system function:
SetTag. Configure the parameters:
| Parameter | Value | Notes |
|---|---|---|
| Tag (Destination) |
HMI_LastLoadedDataset (PLC tag) |
Connected to the PLC's data block variable |
| Value (Source) |
CurrentRecipeDataset (HMI tag) |
The mirror tag of the recipe view's Data Record Number |
- Add additional
SetTagfunctions to write the timestamp and operator ID if audit tracking is required. - For the timestamp, add a
SetTagwith the value source set to the system function or HMI tag for the current date and time. - For the operator, add a
SetTagwith the value source set to the system variable for the current user (e.g.,@CurrentUseror the equivalent localized variable in your TIA Portal installation).
8.3 Add the Read-from-PLC Button
- Add a second button labeled Read from PLC.
- Open the Click event configuration.
- Add the system function
RecipeViewGetDataRecordFromPLCwith the same recipe view and data record number parameters as the load function. - Do not add the SetTag tracking writes; the tracking variable is only updated on transfer to the PLC.
8.4 Add the Last-Loaded Display
- Add an I/O field to the screen, positioned directly above or adjacent to the recipe view.
- Bind the field's output to the HMI tag
LastLoadedDatasetDisplay(which mirrors the PLC'sHMI_LastLoadedDataset). - Configure the field as output only (no operator input) to prevent accidental edits.
- Add a static text label Last loaded record: next to the field.
- For audit, add additional display fields for the timestamp and operator, bound to their respective mirror tags.
8.5 Auto-Select the Last Loaded Record on Screen Open
- Open the screen's Events → Loaded event (the screen initialization event).
- Add the
GetTagsystem function to read the value of theLastLoadedDatasetDisplayHMI tag into a temporary local variable. - Add the
SetTagsystem function to write the temporary value to theCurrentRecipeDatasetHMI tag. The recipe view, bound to that tag, will update its selection automatically. - Alternatively, configure the recipe view's
Data Record Numberproperty to point directly to the PLC tag via an HMI tag that is connected to the PLC; on screen load, the recipe view is initialized to the PLC's recorded value without additional scripting.
9. PLC-Side Integration
The PLC can react to recipe load events by monitoring the tracking variable for changes. A typical implementation uses an edge detection block to trigger audit logging or downstream process actions.
9.1 Change Detection Logic
- Create a static variable
LastDatasetSeen : Int;in the same data block asHMI_LastLoadedDataset. - In a cyclic OB (e.g., OB1), compare
HMI_LastLoadedDatasetwithLastDatasetSeen. - If the values differ, raise a one-shot flag
RecipeChangedFlag : Bool;and updateLastDatasetSeento the new value. - Use the flag to invoke a logging function block, send a notification, or trigger a process interlock.
9.2 Validation Logic
For validated processes, the PLC can reject unauthorized dataset changes:
- Define an allow-list of permitted dataset numbers in a separate data block.
- When
RecipeChangedFlagrises, compare the new dataset number against the allow-list. - If the value is not in the list, restore the previous PLC tag values from a backup buffer and raise an alarm.
10. Reading the Recipe from the PLC
The RecipeViewGetDataRecordFromPLC function is the inverse of the transfer function. It is used when the PLC has been modified outside the HMI (e.g., manual tuning at the controller, or a recipe restored from PLC-side storage) and the operator must view the current state in the recipe view.
- The operator presses the Read from PLC button.
- The recipe view's in-memory dataset is overwritten with the current PLC tag values.
- The operator can review the values, then press Save (a button invoking
RecipeViewSaveDataRecord) to persist the values to the HMI recipe storage. - The
HMI_LastLoadedDatasettracking variable on the PLC is not modified; the read operation is informational.
11. Modifying the Last Loaded Recipe
The end-to-end operator workflow for modifying a recipe that is already active on the PLC is:
- Operator navigates to the recipe screen. The recipe view's
Data Record Numberis bound to the PLC tracking variable, so the view displays the last loaded record. - Operator edits the values in the recipe view input fields. The in-memory dataset is updated.
- Operator presses Load to PLC. The system function
RecipeViewSetDataRecordToPLCwrites the modified values to the PLC tags. - The
SetTagfunctions update the PLC tracking variables (dataset number, timestamp, operator). - The PLC's change detection logic raises the
RecipeChangedFlag, triggering any configured downstream actions. - Operator presses Save to persist the in-memory dataset to the HMI recipe storage.
12. Workflow State Diagram
13. Multi-Recipe Scenarios
When multiple recipes are present in the HMI project, each recipe must have its own tracking variable set to avoid cross-contamination. Recommended naming convention:
-
CurrentRecipeDataset_Filling— for the filling process recipe -
CurrentRecipeDataset_Labeling— for the labeling process recipe -
HMI_LastLoadedDataset_Filling— PLC-side mirror for the filling recipe -
HMI_LastLoadedDataset_Labeling— PLC-side mirror for the labeling recipe
Bind each recipe view's Data Record Number property to the corresponding CurrentRecipeDataset_<Process> tag. Each load button writes to its own PLC tracking variable.
14. Security and Operator Permissions
For validated environments, restrict recipe transfer operations to authorized operators:
- In the HMI user administration, create a group RecipeOperators with the right Load recipe.
- In the recipe view configuration, set the required authorization for operator input to the RecipeOperators group.
- For the load button, configure the Authorization property to the same group.
- In the PLC, the change detection logic can also require a valid operator ID by comparing the
HMI_LastLoadOperatorstring against an allow-list.
15. Backup, Restore, and Data Consistency
Recipes in TIA Portal V15.1 are stored on the HMI device. The storage location depends on the panel type and project settings:
- Internal flash for most Comfort Panels and WinCC Runtime targets
- Configured storage path (SD card, USB, network share) for advanced configurations
To ensure data consistency across HMI replacements, use the recipe export and import functions:
- From the recipe view in runtime, trigger the Export data records function to write a CSV file to a configured path.
- On the replacement HMI, trigger Import data records to load the CSV.
- The
HMI_LastLoadedDatasetvalue should be backed up with the project documentation, as it is not stored in the recipe file itself.
16. Performance and Memory Considerations
Recipes with large data records (hundreds of elements or large string values) can affect HMI startup and transfer times. Recommendations:
- Limit recipe element counts to the operational minimum; offload rarely changed parameters to a separate configuration recipe.
- For strings, use
String[32]orString[64]rather thanWStringto reduce memory footprint. - Disable the recipe view's Show column headers and Show status bar options if the HMI is performance-constrained.
- Avoid running the
RecipeViewSetDataRecordToPLCfunction in a tight loop; it is intended for operator-driven actions, not for high-frequency data transfer.
17. Verification
After implementing the configuration, perform the following checks to confirm correct behavior:
| Verification Step | Procedure | Expected Result |
|---|---|---|
| Initial load | Select a record and press Load to PLC | PLC tags contain the record values; HMI_LastLoadedDataset equals the record number |
| Navigation | Switch to another screen, then return to the recipe screen | Display field shows the last loaded record number; recipe view auto-selects the record if bound to the tracking tag |
| Selection change | Select a different record in the recipe view |
CurrentRecipeDataset HMI tag updates; PLC tracking variable is unchanged until Load to PLC is pressed |
| Modify and reload | Edit values in the view, press Load to PLC | PLC tags reflect the modified values; tracking variable updated to the same record number (or new number if the selection changed) |
| Read from PLC | Modify a value directly on the PLC, then press Read from PLC | Recipe view displays the PLC value; tracking variable is unchanged |
| PLC change detection | Monitor RecipeChangedFlag in the PLC |
Flag rises on each Load to PLC action; clears after the PLC processes the change |
| PLC Variable Inspection (Online Watch) | ||
Watch HMI_LastLoadedDataset
|
Online → Watch table | Value increments or changes to the new record number on each transfer |
Watch HMI_LastLoadTimestamp
|
Online → Watch table | Date_And_Time value updates on each transfer |
Watch HMI_LastLoadOperator
|
Online → Watch table | String value reflects the current logged-in user |
18. Troubleshooting Matrix
| Symptom | Likely Cause | Remediation |
|---|---|---|
| Tracking tag on PLC does not update | SetTag function missing, misconfigured, or pointing to the wrong tag | Open the button event configuration and verify the SetTag parameters; confirm the target PLC tag is reachable via the HMI connection |
| Recipe view does not auto-select the last loaded record on screen open | Data Record Number property is not bound to a tag, or the tag is not updated on screen load | Bind the property to a tag mirroring the PLC tracking variable; ensure the tag is acquired cyclically |
| RecipeViewSetDataRecordToPLC fails silently | Recipe view is not on the active screen, or recipe name does not match the configuration | Verify the screen selection and recipe name in the function call; check for typos in localized function names |
| Recipe values in the PLC do not match the recipe view | Tag mapping points to a different data block or offset, or the connection is interrupted | Re-verify the tag connections in the recipe configuration; check the HMI connection status in the diagnostics view |
| Operator cannot modify the loaded record | Operator input is disabled in the recipe view properties | Enable the operator input option in the recipe view configuration |
| Display field shows 0 after load | SetTag function writes 0 because the recipe view's Data Record Number tag is not initialized | Verify the acquisition mode and initial value of the mirror tag; add a GetTag in the screen Loaded event to pre-populate the mirror from the PLC |
| Transfer function takes several seconds | Recipe contains many elements or large string values | Profile the recipe tag list; consider splitting into multiple recipes or reducing string lengths |
| Timestamp tag on PLC shows invalid date | Date_And_Time tag not properly mapped or the SetTag value source is incorrect | Verify the system function or tag used for the timestamp; ensure the Date_And_Time format (8 bytes) is respected |
| Tracking variable persists from a previous session | Tag is not reset on HMI restart; PLC retains the last value | Initialize the tracking variable to 0 in the PLC startup OB if a "no recipe loaded" state is desired at startup |
19. Best Practices
- Use symbolic PLC tags (data block members) for the tracking variable rather than absolute Merker addresses to improve program portability and refactoring safety.
- Implement a one-shot trigger on the PLC side to detect changes in the tracking variable, enabling audit logging, recipe-change events, or downstream interlocks.
- Add operator authentication (role-based) for the load button in validated processes; the operator ID should be recorded in the audit tag set.
- Use distinct HMI tag names prefixed with the recipe name (e.g.,
CurrentRecipeDataset_Filling) when multiple recipes are present to avoid cross-contamination of tracking variables. - Document the tag linkage in the project documentation to support maintenance, future migrations, and FAT/SAT test protocols.
- Test the read-from-PLC path in a controlled manner; the function overwrites the in-memory dataset without confirmation, which can lead to data loss if not followed by a save action.
- For multi-language HMI projects, verify the localized names of the system functions in the target TIA Portal installation; localized function names differ between language packs.
20. Related Operations and Reference
Beyond tracking the last loaded record, TIA Portal V15.1 supports several recipe management functions that complement this workflow. For projects that require copying recipes, recipe elements, or data records within the HMI device — for example, to duplicate a baseline recipe to a new variant — the Siemens documentation on Copying recipes within an HMI device covers the supported workflows for Basic Panels, Comfort Panels, RT Advanced, and RT Professional targets. Note that some copy operations are restricted to WinCC Runtime Professional; verify the target device's capabilities in the TIA Portal Help before implementation.
FAQ
Which WinCC versions support RecipeViewSetDataRecordToPLC?
The system function is available in WinCC Comfort, WinCC Advanced, and WinCC Professional from TIA Portal V13 SP1 onward, including V15.1. The function name and parameter interface are consistent across these versions, though localized names may differ between language packs.
Can the recipe view automatically select the last loaded record when the screen opens?
Yes. Bind the recipe view's Data Record Number property to a tag that mirrors the PLC tracking variable. When the screen initializes, the tag value drives the recipe view to display the corresponding record without additional scripting.
Does reading from the PLC change the tracking variable?
No. The RecipeViewGetDataRecordFromPLC function only updates the recipe view's in-memory dataset with the current PLC tag values. The PLC tracking variable is only written when the operator explicitly transfers a record to the PLC via RecipeViewSetDataRecordToPLC paired with SetTag.
How can I prevent the operator from loading an incomplete record to the PLC?
Add validation logic in the PLC program that checks the tracking variable change against expected values, or use a confirmation prompt on the HMI before executing the transfer. Recipe view operator input fields can also be configured with input limits and value ranges to restrict valid entries at the source.
Is the tracking mechanism compatible with S7-1200 and S7-1500 controllers?
Yes. The mechanism uses only standard tag transfer functions and works with any S7 PLC supported by the configured HMI connection. No special PLC function blocks are required; the controller treats the tracking tag as a standard data word in a data block.
What happens to the tracking variable when the HMI runtime is restarted?
The HMI-side mirror tag is reset to its initial value on runtime start, but the PLC tracking variable retains its last value. The display field, bound to the PLC tag, continues to show the last loaded record after a restart. If a "no recipe loaded" state is required at startup, initialize the tracking variable to 0 in the PLC startup OB.