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:

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 fields. 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 1, and below it the MUDATA component with the three Int fields, their start values and the ShowOnLabel check boxes

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.

The MUDataWriter writes one field of an MU at a station. Put it on a node that has a Sensor, and point Sensor at it.

The MUDataWriter on the sensor PartFeed_NestSensor: Field DM_Serial, Source Counter, CounterStart 12 and TriggerOnEnter checked

SettingWhat it does
SensorThe station sensor. The writer acts on the MU in this sensor
FieldThe MU data field to write. The field must exist on the MU, otherwise the Problems panel reports it
SourceWhere the value comes from: Constant, Signal, Counter or Pattern
ConstantThe value for Constant, read as the field type (true / false for Bool)
PatternText with {counter}, for example SN-{counter}. Used by Pattern
CounterStartFirst number of the counter for Counter and Pattern. At least 0
TriggerOnEnterWrites when an MU enters the sensor. On by default
TriggerA PLC output. A rising edge writes the MU that is in the sensor at that moment
ValueText, ValueInt, ValueFloat, ValueBoolPLC outputs for Source = Signal. Bind the one that matches the field type
WrittenA PLC input that pulses for one tick after each write

The counter advances only after a successful write. A simulation reset sets it back to CounterStart. A text value from a signal is cut to 256 characters.

The BarcodeReader reads one field of an MU at a station and reports it to the PLC. It works the same for a barcode, a DataMatrix code or an RFID tag.

The BarcodeReader DM_FG01: Field DM_Serial, ReaderKind DataMatrix, ReadTime 0.2 s, NoReadRate 2 percent, TriggerOnEnter checked and the feedback signals Busy, ReadOK, NoRead and DataInt linked

SettingWhat it does
SensorThe station sensor. The reader reads the MU in this sensor
FieldThe MU data field to read
ReaderKindBarcode, DataMatrix or RFID. A label only: it does not change how the reader works
ReadTimeDuration of a read in seconds. Default 0.2
NoReadRateShare of reads that fail, from 0 to 100 percent. 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 read runs like this:

  1. A trigger starts the read. Busy is 1, ReadOK and NoRead are 0. A trigger while the reader is busy is ignored.
  2. After ReadTime of simulation time, the reader checks that the MU is still in the sensor, the field has a value and the no-read draw did not hit.
  3. If so, the value goes to the data signal that matches the field type and ReadOK is 1. Otherwise NoRead is 1, and a text output is empty.

ReadCount counts the finished reads. The results stay until the next trigger. A field that is declared but unset counts as a normal NoRead.

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

SignalContent
Busy, ReadOK, NoReadBool: read in progress, success, failure
DataInt, DataFloat, DataBoolThe value of an Int, Float or Bool field
DataTextThe value of a Text field, as a text signal. Empty on NoRead
ReadCountNumber of finished reads

Bind only the data signal that matches the field type. Text is never converted to a number. See Text signals.

A part with at least one set field marked ShowOnLabel gets a label next to it. The label lists one Name: value row per field. A part whose fields are all unset has no label.

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.
  • 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. They are not active in a DES run, and the Problems panel says so. In a multiuser session the data is not synchronised, and followers run no writers or readers.

An agent reads and sets the data of an MU with two commands:

  • mu.data – reads all fields of the MU with muId, or one field with field. An unset field returns null.
  • mu.data.set – writes a live value. It takes muId, field and valueJson, a JSON string, number or boolean that matches the field type.

Call them with web_query and web_execute. A live write does not create an undo step or a macro line.