Skip to content

MU Data and Barcodes

MU data lets a part carry information through the plant: a barcode, a serial number, a variant, a pallet ID or a test result. A Source creates parts with start values, a MUDataWriter changes a value at a station, and a BarcodeReader reports it to the PLC like a real scanner. The data is visible as a label next to the part and in the Inspector.

The data path of an MU An MU template or pre-placed MU declares the data fields with start values. A MUDataWriter at a station writes one field of the MU in its sensor. The MU carries the data and shows it as a label. A BarcodeReader at another station reads one field after a read time. The result goes to a PLC input signal, as a text signal for a Text field, which the PLC reads. MU data fields and start values per MU MUDataWriter writes one field at a station MU carries the data, shows a label BarcodeReader read time, no-read rate PLC reads the signals Int, Float, Bool, Text Source or pre-placed MU Sensor + Field + Source label and Inspector Sensor + Field PLC input signals The writer and the reader each watch a sensor at their station. Both work on the MU that is in that sensor. The data belongs to the MU. It ends when a Sink consumes the MU.
Data path of an MU: declare the fields, write them at one station, read them at another and pass the result to the PLC.
  • Barcode or serial number - A counter at the loading station gives every part its own number, and a reader further down the line reports it.
  • Variant and order data - Parts carry a variant or order number that a controller reads to select the program.
  • Pallet tracking - A pallet carries an ID, a type and a status, like an RFID tag on a workpiece carrier.
  • Quality state - A station writes a result, and a later reader or the PLC uses it.

Add the MUData component to an MU template (the node a Source copies) or to a part you pre-placed in the model. Every part created from the template gets its own copy of the start values.

Select the node, click Add Component in the Inspector and choose MUData. In the Fields list, click Add entry for each field. Each entry shows its name, type and start value in a collapsible header; open it to edit the name, type, start value and label option, one per row:

SettingWhat it does
NameLetters, digits and underscore, not starting with a digit. Each name is used once per MU. The writer, the reader and the label refer to this name
TypeText, Int, Float or Bool
DefaultThe start value, or Unset. A new field starts unset. An explicit 0, empty text or false is a real value
ShowOnLabelShows the field on the 3D label of the part. On by default

A part has at most 32 declared Fields entries. Text is limited to 256 characters, Int must be a whole number and Float must be a finite number.

The Inspector of the pallet PALLET.JIG.ASM.1_1 in the Laser Welding Assembly Station: the MU DATA readout with the live values RFID_PalletId 101, RFID_PalletType 1 and RFID_Status 0, and below it the MUDATA component with the empty Data view, the label paths and the Fields list with three Int entries, each with name, type, start value and the ShowOnLabel check box on its own row

The MU DATA block at the top shows the live values of the selected MU while the simulation runs. An unset field shows as an em dash. The MUDATA block below is the field list. A change there applies to the next part that is created, or after a simulation reset.

Each part carries one JSON document. The existing Fields remain available as typed values at its top level. Use Data on the MUData component for JSON start values, including nested objects and lists. Its default is {}. For example:

{
"order": {
"id": "ORD-42",
"items": [{"qty": 1}, {"qty": 2}, {"qty": 3}]
},
"status": "new"
}

At creation, the part takes Data first, then the start values from Fields. Fields win when the same top-level key occurs in both, and the Problems panel reports the duplicate. Keep each key in one place. Invalid JSON loaded from a model reports mu-data-path and starts with an empty Data object; valid Fields start values still apply. The authored text stays available for correction.

Data offers Fields and JSON views of the same value. This Fields view edits the JSON object’s entries; the separate Fields list still declares the typed station fields. A list of objects with plain values is shown as a table with Add row. Any other nested value shows its size, such as 2 items or 2 keys, with a JSON button that opens the JSON view. Switch views to edit entries individually or edit the JSON text, then click Apply Data to save the draft. Syntax errors and document limit violations block Apply. Changes supply start values for the next part created or after a simulation reset. Live data on a running part is read-only in the Inspector.

The Fields view of Data in the Inspector: text, number and check box values with a remove button each, the list boxes as a table with the columns sku and qty and Add row, the nested values tags, none and order with their size and a JSON button, and the Name and Type fields for a new value

Use order.id for an object property and order.items[2].qty for the quantity in the third list entry. List indices start at 0. A key containing dots can be quoted, for example ["key.with.dots"]. The empty path "" addresses the whole document.

Paths apply to LabelPaths, script data access, the plugin muData facade and the AI/MCP commands below. MUDataWriter and BarcodeReader continue to use declared typed fields in their Field setting.

Path writes can create new keys and missing intermediate objects or lists. A list index equal to its length appends an entry; gaps and incompatible value types are rejected. The keys __proto__, constructor and prototype are forbidden in new paths.

Each part allows 4 KB (4096 UTF-8 bytes) of JSON, counted without formatting whitespace. A write that exceeds this limit is rejected and leaves the previous document unchanged. The Problems panel reports mu-data-limit. The same limit applies to start documents and blocks Apply Data.

The combined budget is 12 MB (12 MiB) across all parts. Exceeding it adds a mu-data-limit warning; writes remain enabled. Documents also allow at most 8 nesting levels, 256 entries per list and 256 UTF-16 code units per text value.

Add MUDataWriter to a station with a Sensor. It writes one path of the part at the sensor, for example order.qty, order.items[0].id or order.payload. These settings and the data stay local in your browser; no cloud service is involved.

SettingWhat it does
SensorOptional. Empty uses the Sensor on this node. A reference selects another Sensor. An unresolved reference is reported and the writer stays inactive
FieldA nonempty MU-data path. Choose a suggestion from the scene’s Fields or Data keys, or enter a path freely. Invalid paths are refused at the input
SourceConstant, Signal, Counter, Pattern or SimTime
TextAsText (default) or Json, shown for Constant and Signal. Determines how Constant or ValueText is interpreted when the target type is unknown. A known target type takes precedence
ConstantA number box, switch, text box or JSON editor matching the target type. Invalid input cannot be applied
PatternText containing {counter}, for example SN-{counter}. Every occurrence is replaced
CounterStartFirst counter value for Counter or Pattern, at least 0. A simulation reset or a change to CounterStart restarts the counter
TriggerOnEnterWrites when an MU enters the Sensor. On by default
TriggerPLC output control slot. A rising edge writes the MU currently in the Sensor
ValueInt, ValueFloat, ValueBool, ValueTextValue control slots for Source=Signal. Bind the slot matching the target type. Objects and lists use ValueText containing JSON
WrittenPLC input feedback. Pulses for one fixed tick after a successful write

The target type comes from a legacy Fields declaration first, then from the value already at the path. A number without a declaration takes either numeric signal: with only ValueInt connected the writer writes a whole number, with ValueFloat connected (or both) a decimal number. At a path that has no value yet, a Signal write needs exactly one connected value signal and a Constant is read as set in TextAs. Objects and lists are Json. If the scene contains templates that disagree, the Inspector treats the target type as unknown.

For an unknown Signal target, all four value slots appear with Bind exactly one value signal. Bind exactly one: that slot determines the type; ValueText uses TextAs. With no slot or several slots bound, mu-data-writer-ambiguous refuses the write. A bound slot always remains visible, including a slot for another type. For known targets, the writer uses only the matching slot.

SimTime writes the current simulation time in seconds as a number. It needs no value signal. Counter writes an integer, or its decimal text to a Text target. The counter advances only after a successful write.

A writer creates a missing key and any missing intermediate containers. Lists permit appending the next entry, but no gaps. This changes the earlier behaviour that reported mu-data-unknown-field for an undeclared writer key. Failed writes leave the document unchanged.

For example, start with:

{"order":{"id":"A-1001","qty":3,"route":["weld","test"]}}

Set Field = timing.entered and Source = SimTime to record arrival time. A second writer with Field = order.payload, Source = Constant, TextAs = Json and Constant = {"priority":true} adds an object to the order. Use a Schema with type: "integer" for order.qty if it should use ValueInt.

JSON from ValueText must be strictly shorter than the effective signal MaxLength, with a default and hard upper bound of 4096 UTF-16 code units. A value exactly at the boundary may already have been truncated upstream, so it is refused too. mu-data-subtree-too-long rejects the write; no partial JSON reaches the part. Invalid JSON is also refused. The MU document still has its own limits: 4096 canonical UTF-8 bytes, depth 8, 256 entries per list and 256 UTF-16 units per scalar string.

Plain Text keeps its existing behaviour: the writer limits signal text to 256 UTF-16 units and reports truncation. The strict no-truncation rule above applies to JSON transport.

Older files may explicitly reference the Sensor on the same node. muData.clearSelfSensorReferences clears these references in one undo step. Runtime scripts changing a station’s Field must call reapplyConfig before the new path takes effect; ordinary Inspector edits, Undo and Redo already use this lifecycle.

The BarcodeReader reads one path from the part at its station and reports the value through normal PLC input signals. It uses the Sensor on the same node when Sensor is empty. Barcode, DataMatrix and RFID use the same read mechanism.

SettingWhat it does
SensorOptional. Empty uses the Sensor on this node; an explicit unresolved reference is reported and does not fall back
FieldA nonempty path, such as order.qty or order. Suggestions and validation work like the writer
ReaderKindBarcode, DataMatrix or RFID. A label only
ReadTimeRead duration in simulation seconds, default 0.2
NoReadRatePercentage of reads that fail, 0–100. The draw is made at the trigger and repeats with the same simulation seed
TriggerOnEnterStarts a read when an MU enters the Sensor. Off by default
TriggerA PLC output. A rising edge starts a read

A trigger sets Busy and clears ReadOK and NoRead. Triggers while busy are ignored. After ReadTime, the reader checks that the captured part is still at the Sensor and that the no-read draw permits success. A present, non-null value produces ReadOK; a missing or null path produces a normal NoRead without a problem. ReadCount counts all completed reads. On NoRead, DataText is empty; numeric and Bool results retain their previous values until another matching success or reset. After another successful read of the same configured path, the other Data slots contain their neutral values (DataText "", DataInt 0, DataFloat 0, DataBool false); changing Field and reapplying keeps the other numeric and Bool results, while reapply clears text as before, and integer values populate both DataInt and DataFloat.

All reader outputs are PLC inputs: the twin writes them and the PLC reads them.

SignalContent
Busy, ReadOK, NoReadRead in progress, success or failure
DataInt and DataFloatEvery integer value is published on both slots
DataFloatOther numeric values
DataBoolA Bool value
DataTextA Text value, or an object/list as canonical JSON with sorted keys and no extra whitespace. Empty on NoRead
ReadCountNumber of completed reads

The Inspector shows slots for the inferred target type and always keeps bound slots visible. An unknown type shows all data slots. Text is never converted to a number.

With the example above, a reader on order.qty publishes 3 to DataInt and DataFloat. A reader on order publishes the entire order as JSON text to DataText. JSON must be strictly shorter than the effective DataText signal MaxLength. At or above the limit, the reader reports NoRead and mu-data-subtree-too-long, and sends no partial JSON. Increase the signal length and choose a sufficiently long PLC STRING variable. See Text signals.

A part with at least one set field marked ShowOnLabel or a configured LabelPaths entry gets a label next to it. The label lists one Name: value row per field, followed by the configured paths. A part whose fields are all unset and which has no LabelPaths has no label.

Set LabelPaths on MUData to an ordered list of at most 6 paths, for example order.id and order.items. These appear alongside ShowOnLabel fields. Objects use the short form {N keys} and lists use [N]: the example above shows {2 keys} for order and [3] for order.items. Missing values show as an em dash. Path values longer than 24 Unicode characters are shortened with an ellipsis.

Labels in the running Laser Welding Assembly Station: each pallet shows RFID_PalletId, RFID_PalletType and RFID_Status, and each valve shows DM_Serial and BC_Code

  • Switch on and off - The labels are an overlay named MU data labels. It is off by default. Switch it with the MU data labels button in the tool strip, or in the Overlays section of the Display panel. Both use the same setting, which the viewer remembers.
  • Only when there is something to show - The button appears only when the loaded model defines data fields shown on labels or LabelPaths.
  • Select or hover - While the overlay is off, a selected or hovered part still shows its label.
  • Loads - A part carried by another part gets its label in its own row above the carrier’s label.
  • Distance and number - Labels fade out with distance. At most 64 labels are shown at the same time.
  • Inspector - A selected part shows its live values in the MU DATA block. Parts that are drawn as instances for speed show their data on the label only.

The reader signals are normal PLC signals. Create them with the Signals buttons in Quick Edit, and link them to the slots of the component. A connected controller reads them, or a Structured Text program in the browser does. The browser runs the twin locally on your computer, not in a cloud service, so the model and its data stay with you. Text values use STRING and WSTRING variables, see Strings.

With a real Beckhoff controller, a text signal is linked to a STRING(n) or WSTRING(n) symbol. The TwinCAT ADS interface describes the string length and encoding. The MU data fields themselves are not sent to the PLC. Only what a reader reports and what a writer takes from a signal reaches the controller.

The Laser Welding Assembly Station shows the whole chain on a running line. Open it in the public demo: choose Projects, then Laser Welding Assembly Station. Select a pallet or a valve and look at the MU DATA block, and switch on MU data labels.

  • Pallets - Each of the 14 pallets carries RFID_PalletId, RFID_PalletType and RFID_Status. Writers set the status on the way, and RFID readers at the stopper and index stations read the ID.
  • Valves - A writer at the part feed gives each new valve a DM_Serial from a counter. A DataMatrix reader at station FG01 reads it with a no-read rate of 2 percent.
  • Barcode - A writer and a barcode reader at the return-conveyor stopper (Stopper02) handle BC_Code.
  • PLC - The reader results are PLC inputs for the signal list. The demo is a display of the data: it does not eject a part on a no-read.

Model courtesy of Villette Oh (GrabCAD).

MU data, the writer and the reader work in the continuous simulation.

In a DES run, the data of the parts work as well:

  • A DES run starts without data from the continuous simulation. Each part it creates gets its document from the MUData template, like in the continuous simulation.
  • Scripts, plugins, AI agents and ST programs with the MU_* functions read and write the data of the parts in the run.
  • The data are part of every DES snapshot. After a restore, the run continues with the same data.
  • A part id can be used again after its part has left the plant. The data of the old part are gone; a later part with the same id carries its own document.

MUDataWriter and BarcodeReader are not active in a DES run yet. The Problems panel reports mu-data-des-stations-unsupported for the run, and the documents stay available. Selecting a target per signal at a turntable or chain transfer (RouteSelect) is not available yet either.

In a multiuser session the data is not synchronised, and followers run no writers or readers.

For an MU handle mu, scripts use these methods with a path:

MethodWhat it does
mu.data.get("order.id")Reads a value. Objects and lists are independent copies; changing a returned copy does not change the part
mu.data.set("order.status", "ready")Writes a JSON value
mu.data.delete("order.status")Removes a value. Deleting a list entry shifts the following entries
mu.data.has("order.status")Checks whether a value exists, distinguishing a missing value from stored null

Reads work in frame hooks and simulation hooks. set and delete write only in simulation hooks; writes from frame hooks raise an error. A rejected write leaves the document unchanged.

Plugins access the same data through PluginContext.muData after ensureFeature('mu-data'). This facade provides get(muId, path), set(muId, path, value), find(path, equals?) and onChange(callback). Reads return copies. Plugin and MCP writes require a running simulation (continuous or DES) with local ownership.

Station components also use paths in Field. After assigning a runtime station’s Field in script or integration code, call reapplyConfig before triggering it; parsed paths are cached until then. Plugin authors can read simulation seconds through PluginContext.simulationTime, the same clock used by writer Source=SimTime. The browser processes this locally; no cloud service receives the data.

An agent reads, writes and searches part documents with these commands:

  • mu.data - reads the whole document as data with muId, or one value with path. A path read returns path and value. Unset fields and missing nested values return null; unknown bare field names raise an error.
  • mu.data.set - writes a live value with muId, path and valueJson, which encodes a JSON value. A successful response includes path and ok: true.
  • mu.data.find - finds parts with a given path. Add equalsJson for equality with a JSON scalar, such as a string, number, boolean or null. Without it, the command checks existence. The result includes matches, total and truncated.

For example, read an order, mark it ready and find ready parts:

web_query("mu.data", {muId: 0, path: "order.id"})
web_execute("mu.data.set", {muId: 0, path: "order.status", valueJson: '"ready"'})
web_query("mu.data.find", {path: "order.status", equalsJson: '"ready"'})

Call reads and searches with web_query, and writes with web_execute. A live write does not create an undo step or a macro line. The earlier field input remains available; when both inputs are supplied, path wins. Writing through the earlier single-field form still requires a declared field.