FB_ALY_StateHistogram_1Ch

The State Histogram 1Ch counts how often the input signal (INT) has a specific value between the configured minimum and maximum and shows the distribution in a histogram. The first bar represents the boundary values which are smaller than the minimum and the last bar represents the boundary values which are greater than the maximum. The State Histogram 1Ch is suitable for state-machines to show how often the different states are executed.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_StateHistogram_1Ch
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    nNumValues: ULINT;
END_VAR

FB_ALY_StateHistogram_1Ch 1: Outputs

Name

Type

Description

ipResultMessage

I_TcMessage

Contains more detailed information on the current return value. This special interface pointer is internally secured so that it is always valid/assigned.

bError

BOOL

This output is TRUE if an error occurs.

bNewResult

BOOL

When a new result has been calculated, the output is TRUE.

bConfigured

BOOL

Displays TRUE when the function block is successfully configured.

nNumValues

ULINT

Number of values included in the histogram.

FB_ALY_StateHistogram_1Ch 2:Methods

Name

Definition Location

Description

Call()

Local

Method calculates the outputs for a given configuration.

GetResults()

Local

Get result array without adding new values.

Configure()

Local

General configuration of the algorithm with its parameterized conditions.

Reset()

Local

Resets all internal states or the calculations made so far.

SetChannelValue()

Local

Method to pass values to the algorithm.

SetInital()

Local

Method to set initial histogram values.

Sample

VAR
    fbStateHistogram : FB_ALY_StateHistogram_1Ch;
    eStateHistMode : E_ALY_StateHistMode := E_ALY_StateHistMode.Absolute;
    nMin : LINT := 1;
    nMax : LINT:= 20;
    bConfigure : BOOL := TRUE;
    nInput : INT;
    aHistArrayOut : ARRAY[0..21] OF ULINT;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbStateHistogram.Configure(eStateHistMode, nMin, nMax);
END_IF

// Call algorithm
fbStateHistogram.SetChannelValue(nInput);
fbStateHistogram.Call(ADR(aHistArrayOut), SIZEOF(aHistArrayOut));

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics