Add Recipe Data Record via Button on Siemens MP377 HMI

David Krause10 min read
HMI ProgrammingSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

On a Siemens MP377 Multi Panel running WinCC Flexible 2008 or TIA Portal WinCC, the recipe toolbar provides New data record, Save data record, Delete data record, Rename data record, Load data record, and Synchronize buttons. Those toolbar functions are bound to the Recipe_View screen object. Outside of a visible Recipe_View, the SaveAsDataRecord action and the New data record button are not exposed as standalone system functions. The proven workaround is to place an invisible Recipe_View on the screen and bind a user button to its built-in system functions. This article documents the exact function calls, tag addresses, and commissioning checks for that technique on an MP377 8" and MP377 12" Touch.

Prerequisites

  • Runtime: WinCC Flexible 2008 SP3 or later, or TIA Portal V13 SP1+ with WinCC Comfort/Advanced for the MP377 panel.
  • Hardware: Siemens SIMATIC MP377 (6AV6 644-0AB01-2AX0 8" Touch or 6AV6 644-0AC01-2AX0 12" Touch). Image ≥ V11.02.00 is required for recipe array tags.
  • Configured PLC: S7-300/400/1200/1500 with a recipe tags DB or a recipe array in the HMI tag table. For MP377, recipes with up to 1000 data records and 2000 elements per record are supported.
  • Storage path: Recipe data records are stored on the internal flash of the MP377 under \Storage Card\Recipes\<recipe_name>\<data_record_name>.csv. Confirm free storage of ≥ 4 MB free flash.
  • Authorizations: Configure operator authorization in the User Administration editor. The New data record action requires the configured operator to hold at least authorization level 4 (Operation) unless the area pointer is overridden.

Recipe Architecture on MP377

Recipes in WinCC are made of three layers: the recipe itself (structure), a data record (a set of values), and the I/O tags that hold the data. The MP377 supports the following recipe object types when configured in the Recipes editor:

Object Type Limits on MP377 Storage
Recipe Container of data records ≤ 1000 per project Flash / memory card
Data record Instance of the recipe ≤ 1000 per recipe Flash / memory card
Element One I/O field per tag ≤ 2000 per record Linked to HMI tag

Recipe tags may be either:

  • Synchronous tags with the PLC (online tags mapped to a PLC DB or memory area). Use absolute addressing in the PLC, e.g., DB10.DBD0, and reference from HMI as PLC>DB10>DBD0.
  • HMI-internal tags (recipe-only, not sent to PLC). The data record must be downloaded with SetRecipeTag after the PLC handshake.

The control flow between Recipe_View and the PLC uses area pointers 8 (Job mailbox) and 9 (Coordination). The job mailbox word 0 must equal 4 before a write job, and the HMI acknowledges with a return of 0xFF00. Refer to the Siemens FAQ: Recipe functions with SIMATIC HMI for the area pointer handshake details.

Why an Invisible Recipe_View Is Required

The system functions exposed by the HMI toolbox for recipe actions are listed in the WinCC Flexible online help under Recipes > System Functions. The exposed standalone functions are:

Function (WinCC) Standalone Available Works Without Recipe_View
SaveDataRecord Yes Yes (writes current to existing)
LoadDataRecord Yes Yes
DeleteDataRecord Yes Yes
RenameDataRecord Yes Yes
GetDataRecordName Yes Yes
GetDataRecordNumber Yes Yes
SetDataRecordName Yes Yes
ClearDataRecord Yes Yes
AddDataRecord (SaveAs / New) No as standalone No
ReadRecipe / WriteRecipe Yes (transfer to/from PLC) Yes

The AddDataRecord function (which appends a new data record with current tag values, the equivalent of the toolbar's New data record button) is exposed only as a proxy of the Recipe_View screen object. On the MP377, when a button configured with the action Recipe > NewDataRecord is placed on a screen that does not contain a Recipe_View, the runtime throws Event ID 13007 ("Recipe function not executed"). The accepted pattern is to add an invisible Recipe_View to the screen, then bind the user button's Press event to that Recipe_View's New data record command.

Step-by-Step: Configure the Invisible Recipe_View Approach

  1. Create the recipe. In the project tree, open Recipes, add a recipe (e.g., Recipe_Batch), and define elements that match your PLC tags, e.g., Setpoint_Temp (REAL, °C), Ramp_Time (INT, s), Product_Code (STRING[16]).
  2. Create at least one data record. Drop one initial data record, e.g., REC_001, with default values. This guarantees the recipe directory exists on the flash card.
  3. Insert a Recipe_View on the screen. Drag Recipe/Simple View or Recipe/Extended View from the toolbox onto the target screen. Set the Recipe property to Recipe_Batch.
  4. Disable toolbar and status bar visibility. Open the Recipe_View properties:
    • Toolbar > Show = No
    • Status bar > Show = No
    • Title > Show = No
    • Border > Show = No
    • Background > Show = No
    • Position X / Y = e.g., -1000 px, -1000 px (off-screen). The runtime will still instantiate the object so its system functions remain accessible.
    • Size Width / Height = leave default (the view will never render).
  5. Add the user button. Place a Button object on the same screen, label it Save As New Record. Under Events > Press, choose Edit > System Function.
  6. Wire the button to the Recipe_View's proxy. In the function list, browse to Recipes > RecipeView_1 > RecipeToolbarButtonFunction and pick the New data record command. The configuration line will resolve to the screen-object method, e.g., RecipeView_1.NewDataRecord(). This binding uses the internal proxy reference, so the Recipe_View is required even though it is invisible.
  7. Prompt for the new record name (optional). Under Events > Press, add a second system function: ShowMessageBox with text "New record name:" and capture the result to a STRING tag NewRecordName. Then chain SetDataRecordName on the recipe view. Set the order: Prompt → NewDataRecord → SetDataRecordName.
  8. Compile and download. Use WinCC Flexible → Project > Compiler > Generate. Compile must complete with no warning W1101 ("Recipe is referenced but the Recipe_View is not on any screen").
  9. Transfer to MP377. Use Transfer > Runtime. Confirm in the MP377 Control Panel > Transfer that the runtime image loads cleanly.

Step-by-Step: Pure Script Alternative (VBScript on TIA WinCC)

If your project is in TIA Portal WinCC Comfort/Advanced, you can implement the same workflow using a VBScript function attached to the button's Press event. This avoids the dependency on a Recipe_View object.

Sub OnLBAction(symButton, sPressed) Dim sName Dim iResult ' --- Build the proposed data record name --- sName = "REC_" & Format(Now, "yyyymmdd_hhnnss") ' --- Read current tag values into the recipe buffer --- HMIRuntime.Tags("Recipe_Batch\Setpoint_Temp").Read HMIRuntime.Tags("Recipe_Batch\Ramp_Time").Read HMIRuntime.Tags("Recipe_Batch\Product_Code").Read ' --- Create the new data record on the panel --- iResult = HMIRuntime.Recipes("Recipe_Batch").CreateDataRecord sName If iResult <> 0 Then HMIRuntime.Trace("CreateDataRecord failed, code=" & iResult) Else ' --- Persist to flash --- HMIRuntime.Recipes("Recipe_Batch").SaveDataRecord sName ' --- Synchronize to PLC area pointers --- HMIRuntime.Recipes("Recipe_Batch").WriteToPLC sName End If End Sub

Error codes returned by HMIRuntime.Recipes(...).CreateDataRecord:

Return value Meaning
0 OK
1 Recipe name invalid
2 Data record name already exists
3 Storage medium full
4 Internal HMI tag cannot be read
5 PLC handshake timeout (job mailbox word 0 ≠ 0xFF00 within 30 s)

Parameter Mapping for Recipe Tags

Recipe element PLC address (S7-1500) HMI tag Datatype
Setpoint_Temp DB20.DBD0 Recipe_Batch\Setpoint_Temp REAL (32-bit)
Ramp_Time DB20.DBW4 Recipe_Batch\Ramp_Time INT (16-bit)
Product_Code DB20.DBB6 (16 bytes) Recipe_Batch\Product_Code STRING[16]

Each element must reference a tag whose PLC connection matches the project's HMI connection. For WinCC Flexible, open Connections editor and confirm the connection name used by the recipe tag points to the S7 PLC with rack/slot matching the actual station (e.g., rack 0, slot 2 for an S7-1500 CPU).

Verification Procedure

  1. Pre-check: On the MP377, navigate to Control Panel > System > Memory. Confirm that free flash ≥ 1 MB before each test.
  2. Initial record: Power-cycle the panel and confirm the recipe directory \Storage Card\Recipes\Recipe_Batch\REC_001.csv is visible via Control Panel > File Browser.
  3. Press the button: From the engineering screen, press the user button. The HMI should briefly show the soft-keyboard prompt (if name was implemented). After confirmation, the screen should display no error message and the button should return to idle.
  4. File confirmation: Re-open File Browser and confirm a new CSV file exists in the Recipe_Batch directory.
  5. PLC confirmation: In TIA Portal, go online with the S7 CPU. Use a watch table with the addresses DB20.DBD0, DB20.DBW4, and DB20.DBB6. Trigger WriteToPLC by re-pressing the button. Confirm the values appear within 2 s of the press.
  6. Runtime alarm log: Check the alarm window on the MP377 for any of the following IDs: 13007, 13008, 13009, 13010. None of these should appear during a clean AddDataRecord run.
  7. Recipe view: Temporarily make the Recipe_View visible on the screen. Open Recipe_Batch and confirm the new data record appears at the bottom of the list with the timestamp-style name set in step 7 of the configuration.

Troubleshooting Matrix

Symptom Alarm / code Root cause Correction
Pressing button does nothing, no alarm None Button event bound to Recipe_View on a different screen or the view is missing. Verify the Recipe_View object exists on the same screen as the button. Open the screen's Object list and confirm RecipeView_1.
Alarm "Function not allowed in current state" 13007 Recipe_View not initialized because the recipe path is missing or the recipe has zero data records. Create at least one initial data record in the recipe editor and recompile.
Alarm "Data record not found" 13008 The button event order calls SetDataRecordName before NewDataRecord. Reorder the events: NewDataRecord → SetDataRecordName → SaveDataRecord.
Alarm "Storage medium full" 13009 More than 1000 data records or flash wear-out exceeded. Archive old records to \Storage Card\Archives via Recipes > Archive, or replace the SD card.
Alarm "PLC handshake failed" 13010 Area pointer 8 (Job mailbox) is not configured in the HMI connection. Open the connection, enable Coordination and Job mailbox pointers. Recompile and download.
VBScript return code 5 5 CPU in STOP or protection level prevents write. Set CPU to RUN-P and confirm the connection's protection password matches.
Recipe_View flickers visible at runtime None Position was set to 0,0 with size 0,0; some firmware builds do not honor (0,0) for invisible rendering. Set Position to a large negative value, e.g., (-2000, -2000), and Size to (1,1).
New record is saved but values are stale None The button event reads the HMI tag cache, not the PLC. Force a tag refresh before AddDataRecord: UpdateTag system function on each input tag.

Field-Proven Caveats

Operator authorization. The AddDataRecord action silently fails on MP377 if the current user is in authorization group 0 (None). Always log in with at least Operator (level 4) before the button is enabled.
CSV encoding. Recipe records are stored as UTF-8 CSV. STRING[16] values that contain semicolons break parsing. Strip or escape semicolons before SaveDataRecord.
Transfer mode. Recipe data records are wiped from flash during a delta transfer. Perform a complete transfer or use Recipes > Backup on the panel before any partial update.
Multilingual projects. When the project has more than one runtime language, the data record name is language-independent. Do not localize the data record name string.

Reference further detail from the official Siemens documentation portal:

FAQ

Why does the AddDataRecord system function not appear in the function list when I have no Recipe_View on the screen?

The AddDataRecord action is a proxy of the Recipe_View screen object in WinCC Flexible. Without an instance of Recipe_View configured on the same screen, the function is not enumerated in the editor. Place an invisible Recipe_View (off-screen position and disabled toolbar/status bar) and the proxy becomes available for the button's Press event.

Can I name a new data record automatically without showing a keyboard?

Yes. In the Press event chain, after NewDataRecord, call SetDataRecordName with a STRING tag populated by the runtime, e.g., a concatenation of a prefix plus a counter tag incremented each press. This avoids prompting the operator and keeps the workflow fully script-driven.

What is the maximum number of data records an MP377 can store?

WinCC Flexible supports up to 1000 data records per recipe on MP377, with up to 2000 elements per record. Practical storage is constrained by the free flash, typically 4 MB after the runtime image; each record consumes roughly 2 KB plus element size.

Does AddDataRecord also send the values to the PLC?

No. AddDataRecord only persists the current tag values to flash on the panel. To transfer to the PLC, follow with SaveDataRecord and then WriteToPLC (or trigger a recipe transfer via the job mailbox word 0 = 4).

How do I migrate this recipe configuration from WinCC Flexible to TIA Portal?

Open the project in TIA Portal and run the migration tool. Recipe structures transfer 1:1. Replace the invisible Recipe_View approach with a VBScript using HMIRuntime.Recipes(...).CreateDataRecord, since TIA Portal exposes the recipe API directly to scripting and no proxy is required.

Back to blog