How to manage measurements: mapped, calculated, manual, and parameter

Wiki: Setup, edge and devices

When to use this

You want to see or edit every measurement in the plant, the numbers you chart, alert on and classify, in one place, regardless of where it came from: a gateway’s live poll, a calculation, or a hand-entered value.

Steps

  1. Open Measurements, under Setup at the bottom of the sidebar, right after Sources. Measurements
  2. Pick a node from the plant tree picker (site, area, work center, or machine), Measurements is always scoped to a node, so you’re never scrolling a plant-wide list.
  3. Filter by kind: Mapped (comes straight off a gateway source), Calculated (a formula over other measurements, authored in the script editor), Manual (a human enters it), or Parameter. Each row carries a kind badge so you never have to guess. To act on several at once, tick their boxes. The bar above the list counts everything selected, including rows on other pages, and says how many are not shown. When you tick Select all on page and more measurements match than fit on a page, Select all N matching selects every one of them. The bar then offers Configure, Set meaning, Enable or Disable (calculated measurements) and Move to node.
  4. Create a measurement with New measurement, or go faster with the bulk actions: Bulk create (CSV), Update mapped (CSV), and Backfill history (CSV) for loading historical readings.
  5. Click any measurement’s name to open its Measurement Detail hub: identity, source provenance, transform, the KPI/alarm rules that read it, history, and (for a calculated measurement) a link to its script and lineage. Lineage starts at the gateway and source that read the measurement, then shows every calculation upstream and downstream of it. The pencil next to a mapped or calculated measurement’s name renames it and sets its unit and an optional note shown under the name. The gateway tag it reads from and its history stay the same. The trash can on a calculated measurement deletes it. If a formula uses the measurement, the hub lists it. Those formulas keep working and show the new name. A measurement that a formula or an alert rule reads cannot be deleted. The message says what still reads it, and the measurement can be deleted once that is changed or removed. A mapped measurement whose source was removed stays in the list with its history. To remove it, open the machine’s Measurements tab, open Advanced on its row and select Remove. Its past readings are then no longer shown. Move to machine there re-homes the measurement onto a different machine without touching its history, see Already have the tags? for the full flow.
  6. Switch to the Live Watch tab to see values update in real time as they arrive, instead of a static list, useful right after wiring a new measurement, so you can confirm it’s actually flowing before leaving the page. Measurements, Live Watch

Create a calculated measurement

Open New measurement and choose Calculated. The page reads from top to bottom:

  1. Name and an optional Unit. Two calculations may share a name.
  2. Inputs: the measurements it is calculated from. With a recipe open, each of its measurement fields appears here.
  3. Recipe or formula: pick a recipe under Start from a recipe, or select Write a formula. On a phone or tablet, Show functions opens the list of functions. Tap a function to add it at the cursor. What it does shows under the list.
  4. Meaning and Machine. The machine starts as the machine of the first input, and the page says so. Pick another machine to keep the calculated measurement somewhere else.
  5. Preview on recent readings shows each input’s value next to the result. A formula that uses a shift, job, product or machine function gets the answer for the selected machine as it is right now. Every row of the preview shows that same answer, including rows built from older readings.
  6. Create calculated measurement saves everything at once. If something is missing, the line under the button says what. If the save is refused, nothing is changed.

Check against past readings works the formula out over a stored window of 10 minutes, 1 hour or 24 hours, with a chart and the readings with their inputs. Nothing is saved. When you change the formula or its inputs afterwards, the result is marked as out of date until you run it again.

Records sets when the result is saved. A new calculated measurement starts on only changes: a value is recorded when it differs from the last recorded one, and a steady value is still recorded every 5 minutes. Ignore changes up to treats smaller moves as no change, and Record a steady value every sets the interval for a steady value. Record a change no sooner than limits a result that changes on every reading, such as a running total, to one record per that many seconds. The value recorded is the one current when the time is up, and it is recorded when the time is up even if the inputs have stopped changing. In the cloud it can appear up to a minute later, with the time the interval ended. A gateway on a release older than 0.2.49 records every change, and the page says so. The number must be more than 0 and no longer than the interval for a steady value. Every reading records a value on each reading of the first input. A calculated measurement keeps the setting it was saved with.

When the meaning is Run / stop signal or Part counter and the measurement lives on a machine, the page offers Use as this machine’s run signal (or part count) after saving. If the machine already uses it, the page says so.

Create a calculated measurement from a recipe

A recipe writes the formula for a common calculation from a few fields. Pick one under Start from a recipe:

  • Running total from a counter turns a counter that rolls over or gets reset into a total that only goes up. Enter how many counts make one full turn of the counter (1000 for a counter that runs 0 to 999), or leave it empty if it never rolls over. A drop that would mean more counts than Most counts between two readings is treated as a reset. Counts per part divides every increase: leave it at 1 when several parts are made in each cycle, or enter how many counts make one part when one part is counted several times.
  • Rate from a count divides the counts added between two readings by the time between them, per hour, per minute or per shift. A drop in the count, or two readings with no time between them, records no value. Use it on a count that only goes up, such as the output of a running total.
  • Running from a load, power or current threshold reads 1 while the measurement is above the value you enter and 0 otherwise. Stops only below the threshold by keeps it running until the reading falls that far below the threshold, so a reading that hovers near the threshold does not flicker. Running only after this many seconds above ignores short spikes. With either of these set, the calculation runs in the cloud.
  • Unit conversion converts a measurement with a standard factor, such as °C to °F or psi to bar.
  • Ignore small changes records a new value only when the measurement moves by more than the amount you enter. A steady value is still recorded at the interval you set, every 5 minutes unless you change it.
  • Time in state adds up how long a measurement held one value, such as a state code, in seconds, minutes or hours. A stretch between two readings longer than Longest gap counted is left out, so an outage is not counted.

A machine has one run signal. If the machine already has one, the form says so and you pick another meaning, or change the other measurement’s meaning first.

Each recipe shows what it outputs, the formula it writes, and the meaning it sets. The meaning appears under Meaning, where you can change it before saving. The preview runs the formula against the inputs’ recent readings. Select Edit as formula to change the formula by hand. From then on it is an ordinary formula.

A link can open a recipe with its fields filled in, for example from a suggestion elsewhere in the app.

Read one bit or name a state code

Many controllers pack several on/off values into one status word, or report a state as a number. Two functions in the formula’s function list cover these:

  • bit(word, n) is 1 when bit n of the reading is on and 0 when it is off. Bits count from 0 to 63, starting at the lowest. bit(status, 3) reads the bit worth 8.
  • lookup(code, {1: 'Running', 2: 'Idle', 3: 'Faulted'}, 'Unknown') turns a state code into a name, or into another number. The table holds up to 64 entries, each a number followed by a number or a short text. The last value is used for a code that is not in the table. Without it, such a code records no value. lookup(code, {3: 1, 5: 1}, 0) reads 1 for codes 3 and 5 and 0 for any other code.

A reading of NaN or infinity records no value. A reading that is text or empty records no value and shows an error in the measurement’s health line. A calculated measurement that uses either function runs in the cloud.

To require two conditions, join them with and: (a > 1) and (b > 2). A formula written as a > 1 & b > 2 is refused when you save it, because it compares a with 1 & b. Put the & part in its own parentheses when that is what you mean, as in a > (1 & b) > 2.

A result that is not a finite number records no value and shows an error in the health line. Examples are a result too large to hold, or the square root of a negative number. A formula whose result is text records the text. A formula that reads a measurement whose reading is text receives the text, on a gateway and in the cloud, and prev() of it is the previous text. The preview and Check against past readings show text readings and the results worked out from them.

In a script, a variable cannot have the same name as an input. Saving, previewing or checking such a script is refused, and the message names the variable to rename.

Rounding, the clock and time windows

  • round(x) rounds a value exactly halfway to the nearest even number. round(2.5) is 2 and round(3.5) is 4. round(x, 2) keeps two decimal places.
  • now() is the local time of the computer that runs the formula. On a gateway that is the gateway’s time zone. In the cloud it is the cloud server’s time zone, so the two can differ. timestamp() counts seconds and reads the same in both places.
  • window_max(x, 60), window_min(x, 60) and window_avg(x, 60) report one value per window of the given number of seconds. The window is at least 1 second.
  • A window reads each reading on which the formula reaches it. In x > 3 and window_max(x, 60), or in one branch of an if, the window reads only the readings where that condition lets the formula get to it. While a window is still open, the parts of the formula after it are still worked out, so every window in the formula reads the same readings.
  • The health line shows at most 300 characters of an error message.

Turn text states into run and stop

Some machines report their state as text, such as ACTIVE, STOPPED or FEED_HOLD from an MTConnect agent. A text reading is recorded as text, and charts show no number for it.

To use a text state as a machine’s run signal:

  1. Open the measurement’s Measurement Detail page. Its meaning must be Run / stop signal.
  2. In the Reading card, select Value map.
  3. For each text the machine sends, enter the text and the state it means: run, stop, or another name such as setup. Any state other than run counts as stopped for downtime and OEE. Text matches ignoring upper and lower case.
  4. Select Save.

The map applies to readings received after you save it. A text that is not in the map shows as Unknown on the Reading card. It never counts as a stop: the kiosk and the cell monitor keep the machine’s last known state, and show no data when there is none. Users with the user role or above can edit the map. A formula that reads the measurement receives the text the machine sent. In a formula, machine.state() gives 1 while the machine runs and 0 otherwise.

Edit tags in a spreadsheet

Update mapped (CSV) changes existing tags in bulk. Select Current tags as template to download every tag with its id, then edit the file and upload it. Rows are matched by id. The editable columns are scale, offset, deadband, report_on_change, unit and meaning. The other columns are context and are ignored.

A blank unit cell leaves the tag’s unit as it is, so a unit someone typed is never cleared by an empty cell. A value in the cell replaces the old unit. A file downloaded and uploaded again without edits changes nothing. A measurement that has no unit takes the tag’s new unit. A measurement that already has one keeps it.

When a reading is bad or uncertain

Gateways report when the machine or its controller says a reading is not valid, for example an OPC UA server that returns a bad status, an MTConnect agent that reports UNAVAILABLE, or a read that fails. A bad reading records no value, so the chart shows a gap. The Reading card on the Measurement Detail page shows Bad reading and how long it has been bad. Once a good value arrives, the card shows how many bad readings were reported and when the last one was.

A reading the source marks as uncertain is recorded with its value, and the Reading card shows Uncertain.

A gateway page lists readings that were refused, for example a value that is neither a number nor text, or text from a tag set up as a whole number or on/off value.

Where a calculated measurement runs

The script editor shows where the formula runs and why, in one sentence above the live preview. The sentence updates as you edit. A formula runs on a gateway when every input is a reading from that one gateway and it uses no shift, job, product or machine function. Anything else runs in the cloud. For example:

  • Runs on gateway Press Line because every input is a reading from it.
  • Runs in the cloud because its inputs come from more than one gateway.
  • Runs in the cloud because an input does not come straight from a gateway. One input is a calculated, manual or parameter measurement.
  • Runs in the cloud because it uses shift.current(), which the cloud answers.
  • Runs in the cloud because gateways do not run latch() yet.

A formula that runs on a gateway keeps working while the gateway is offline. Its readings reach the cloud when the connection returns.

An input of a formula that runs on a gateway can be set to Local only on its source’s tag row, so the gateway uses every reading and sends only the formula’s result. The input’s measurement page then says the raw value is not sent or stored and names the formula that uses it. If you save the formula so that it runs in the cloud, or so that it no longer reads that input, the input goes back to Every change in the same save, and the editor says so above the save button before you save.

cycle_count() counts the same way in both places. The first reading after the formula is created, or after its running total starts again, sets whether the signal is high or low and is never counted.

Check that a calculated measurement is working

A calculated measurement shows a health line on its detail page and in its script editor. The first line says what is wrong right now. Under it, the editor and detail page count the errors recorded so far and when the last one happened.

  • Input stale: Press 1 Temp last reported 20 min ago. An input has sent no reading for longer than about 12 minutes. The measurement records no value until that input reports again. Manual and parameter inputs keep their value until someone changes it, so they never go stale.
  • A message from the formula, such as a division by zero. The measurement records no value for that reading and recovers on the next reading that calculates.
  • Working now. An earlier error is on record and the latest reading calculated normally.
  • An input of this formula was deleted. Pick a replacement input in the script editor and save.
  • Waiting for a first reading from an input. The measurement cannot calculate until every input has reported once.

A formula that runs on a gateway reports its health with the gateway’s regular check-in, so the line can trail by a minute or two. A formula set to run only on change still records a value at least every 5 minutes, so a gap longer than that means the measurement has stopped.

The Live Watch tab shows the same reason in its Health column for each calculated measurement.

Change a calculated measurement’s formula

Open the measurement and select Edit expression. Change the formula, its inputs, name, unit, meaning or machine, then select Save changes. All of it saves together.

Some formulas keep a running value between readings, such as a total built with accum(), a count from edge_count() or cycle_count(), or a step from prev(). When you change one of these, the editor asks Start the running total again?

  • Start again is selected by default. The new formula counts from the next reading.
  • Keep the current total carries the value it has now into the new formula.

A formula that runs on a gateway always starts its running total again when the formula or its inputs change, so the editor says so instead of asking. Changing only when the formula runs, or its deadband, keeps the running total.

A gateway saves the running totals of its formulas to the cloud every 5 minutes while they change. When you replace the gateway, or reinstall it, the new one continues each total from the last saved value. The measurement page says when the gateway last saved the running total and, after a replacement, from which saved value it continued. Counts made between the last save and the replacement may be missing. A gateway that still has its own running total keeps it.

Saved readings are not recalculated. Values recorded before the change keep the old formula’s results.

The measurement page lists each saved change under Formula history, newest first: the version number, when it was saved, who saved it, and what changed. Open Formula before and after to compare the two formulas.

Notes

  • Measurements shows what you chart, alert on and classify. The tags a gateway reads (the addresses, before anyone has said what they mean) live on the source’s own detail page instead: Gateways → a gateway → Sources & tags tab → a source. See How to manage gateways: the gateway home.
  • Mapped, Calculated, Manual, and Parameter measurements share one kind-filtered list.
  • A calculated measurement’s create/edit surface is its own full-page script editor. Measurements links out to it instead of editing formulas inline.
  • Tag Discovery is a separate, opt-in assist that samples candidate tag addresses you give it and ranks how worth keeping each one looks, reached from the Connect a machine flow when a live address browse isn’t available for the protocol, not from Measurements directly. See How to run tag discovery.