Signal_Statistics: Calculating Maximum, Minimum, Average and Variance

 

Signal_Statistics Function Block

Pin Diagram

This figure shows the pin diagram of the Signal_Statistics function block:

G-SG-0030326.3.gif-high.gif

 

 

Functional Description

This function block calculates the maximum, minimum, average and variance of a series of input values.

This function block considers the input value in each controller scan cycle as a Sample.

Minimum Value

Minimum Output value is the value which is minimum amongst all the recorded samples.

Maximum value

Maximum Output value is the value which is maximum amongst all the recorded samples.

Average Value

The average value is equal to the sum of the observations (samples) divided by the number of observations (samples).

G-SG-0030575.1.gif-high.gif

 

 

Where:

on = Number of samples recorded

oXn = Input samples

oG-SA-0045112.1.gif-high.gif = Calculated output

Variance Value

The variance is equal to the mean of the squares of samples minus the square of the mean (Average output value).

G-SA-0045197.1.gif-high.gif

 

Where:

on = Number of samples recorded

oXn = Input samples

o G-SA-0045112.1.gif-high.gif = Calculated output

Example

oStatistics (Enable: = TRUE, Input: = 1, 2

oMinimum Output =1

oMaximum Output = 2

oAverage = (1 + 2) / 2 = 1.5

oVariance = ((1 * 1 + 2 * 2) / 2) - (1.5 * 1.5) = 2.5 - 2.25 = 0.25

Input Pin Description

This table describes the input pins of the Signal_Statistics function block:

Input

Data Type

Description

i_xEn

BOOL

TRUE: FB enabled

FALSE: FB Disabled

i_rIput

REAL

Bit position

Range: ±3.4e+38

Output Pin Description

This table describes the output pins of the Signal_Statistics function block:

output

Data Type

Description

q_xActv

BOOL

FB status output

q_rMin

REAL

Minimum value

Range: ±3.4e+38

q_rMax

REAL

Maximum value

Range: ±3.4e+38

q_rAvge

REAL

Average value

Range: ±3.4e+38

q_rVrnc

REAL

Variance value

Range: ±3.4e+38