Measure Reading Spread
medium
Reports the average and spread of the valid readings among eight.
What it teaches
Two sets of readings can share the same average while one swings far more from reading to reading. Report the average, then the spread: how far the readings typically sit from it. The array always has eight slots, but In_Count says how many hold readings this time. Leave the rest out of the maths.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Analyze | Input | BOOL | 0 | Request a new calculation |
| In_Count | Input | DINT | 8 | Valid samples, from 2 through 8 |
| Cfg_MaxSpread | Input | REAL | 2 | Nonnegative maximum acceptable sample standard deviation |
| Out_Mean | Output | REAL | 0 | Mean of the valid samples |
| Out_Spread | Output | REAL | 0 | Sample standard deviation, dividing by count minus one |
| Sts_Valid | Output | BOOL | 0 | Latest request had valid count and limit |
| Sts_Unstable | Output | BOOL | 0 | Spread is strictly greater than the limit |
| Ref_Samples | InOut | REAL[8] | — | Read-only readings |
Required behavior
- A request acts once on a change from 0 to 1. Holding it high does not repeat the action.
- On a rising In_Analyze, analyze Ref_Samples[0] through Ref_Samples[In_Count - 1]. Count must be 2 through 8 and Cfg_MaxSpread must be nonnegative.
- Out_Mean is their arithmetic mean. Out_Spread is the square root of the sum of squared differences from that mean divided by (In_Count - 1).
- A valid request sets Sts_Valid = 1 and Sts_Unstable = 1 only when Out_Spread > Cfg_MaxSpread.
- An invalid request sets both results and both status outputs to 0. Otherwise outputs hold until another request. Never modify Ref_Samples.
- Measurements and configuration are finite values with magnitudes at most 10000.