# Configure a Measure

Machine 1's coolant temperature drifts as the spindle works harder, and engineering wants to see that trend without storing every reading. You'll simulate the signal, then summarize it with a measure.

:::action[Simulate a coolant temperature signal]

1. In Ignition Designer, in the `Kanoa` tag provider, open `[Kanoa]CoreForge/Philadelphia/Machining/Machine 1`.
2. Create an **Expression** tag named `Coolant Temp`, data type **Float**.
3. Set its expression to:

   ```text
   22 + 1.5 * sin(toMillis(now(1000)) / 300000.0) + 0.3 * sin(toMillis(now(1000)) / 7000.0)
   ```

   This gives a slow swing of roughly 30 minutes of ±1.5 °C around 22 °C, with a faster ripple on top, updating once a second.

4. Confirm the value changes in the tag browser.

:::

:::action[Define the measure]

1. Navigate to **Configuration → Ops → Measures**.
2. Create a measure named `Coolant Temperature` and link it to **Machine 1**.
3. Set its aggregation to an average, adding one with the aggregation editor if none exists yet.
4. Enable the **Tag** checkbox and save.

:::

Enabling **Tag** creates a measure UDT instance in a `measures` folder under Machine 1's tags in the `Kanoa` provider. The UDT does the collecting. It holds values in memory and, when the window is full, calculates the statistics and writes one record to the database.

:::action[Connect and configure the measure tag]

1. Open the tag browser in the designer, and find the new `Coolant Temperature` instance under Machine 1's `measures` folder.
2. Edit the `measureValue` tag. Change the `Value Source` to a `Reference Tag` and point the `Source Tag Path` to `[.]../../Coolant Temp`.
3. Set `maxSampleCount` to `60` and `maxSampleDurationSecs` to `60`, so a record is written about once a minute.
4. Set `enabled` to `true`.
5. Watch the `data` dataset fill with samples, and `update` fire when the window completes.

:::

| Window setting | Use it when |
|---|---|
| `maxSampleCount` | Values arrive at a steady rate and you want a fixed number per record |
| `maxSampleDurationSecs` | You want one record per time period, regardless of how often the value changes |

Because each record keeps its `sampleCount`, averages across many windows, lines or sites can be weighted correctly later, rather than treating every window as one data point.

:::check

Copy this script into the Ignition Designer Script Console (**Tools → Script Console**) and run it. It checks the `Coolant Temp` simulator tag, the `Coolant Temperature` measure and its average aggregation, the measure tag and its settings, and that records are being written. Each check prints PASS or FAIL with what to fix. It doesn't change anything.

<details>
<summary>Show the check script</summary>

::check-script{src="ops/10-measures/1-configure-measures.py" title="checkLesson-measures.py"}

</details>

:::
