FB_ALY_Scaler

The Scaler module can be used to perform feature scaling.

Depending on the operation mode, the scaling parameters are used in different ways.

Normalization

FB_ALY_Scaler 1:

Standardization:

FB_ALY_Scaler 2:

The scaling parameters can be configured directly. Alternatively, they can be imported from a file.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_Scaler
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL; 
    bNewResult: BOOL;
    bConfigured: BOOL;
    bBusy: BOOL;
    eState: E_ALY_ConfigState;
    stFileHeader: ST_ALY_FileHeader;
    fResult : LREAL;
END_VAR

FB_ALY_Scaler 3: Outputs

Name

Type

Description

ipResultMessage

I_TcMessage

Contains more detailed information on the current return value. For this special interface pointer, it is ensured internally that it is always valid/assigned.

bError

BOOL

The 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.

bBusy

BOOL

TRUE if the FB is active due to a file access.

eState

E_ALY_ConfigState

Configuration status of the function block.

fResult

LREAL

Outputs the calculated value. This is calculated from the two scaling parameters depending on the scaling mode.
Normalization: Result has a value range of 0..+1
Standardization: Result has a value range of -1..+1.

FB_ALY_Scaler 4:Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

Configure()

Local

General configuration of the algorithm after the individual coefficients have been set.

ConfigureFromFile()

Local

Configuration of the algorithm via a previously created file.

GetBusyState()

Local

This method returns the Busy state of the function block.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

UpdateState()

Local

State update after a state change has been initiated with the ConfigureFromFile() method. Is called up until the target state is reached.

Sample - Configuration by parameter

VAR
    fbScaler : FB_ALY_Scaler_1Ch;
    eScalingMode : E_ALY_ScalingMode := E_ALY_ScalingMode.Normalization;
    fScalingParam1 : LREAL := 2.0; // high
    fScalingParam2 : LREAL := 1.0; // low
    bConfigure : BOOL := TRUE;
    fInput : LREAL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;
    fbScaler.Configure(eScalingMode, fScalingParam1, fScalingParam2);
END_IF

// Call algorithm
fbScaler.SetChannelValue(fInput);
fbScaler.Call();

Sample – Configuration by file

VAR
    fbScaler : FB_ALY_Scaler_1Ch;
    eScalingMode : E_ALY_ScalingMode := E_ALY_ScalingMode.Normalization;
    tTimeout : TIME := TIME#5S;
    sFilePath : STRING := '%TC_BOOTPRJPATH%\Scaler.json';
    bConfigure : BOOL := TRUE;
    fInput : LREAL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;
    fbScaler.ConfigureFromFile(tTimeout, sFilePath);
END_IF

// Update pending state
IF fbScaler.eState = E_ALY_ConfigState.Pending THEN
    fbScaler.UpdateState();
END_IF

// Call algorithm
IF fbScaler.eState = E_ALY_ConfigState.Configured THEN
    fbScaler.SetChannelValue(fInput);
    fbScaler.Call();
END_IF

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics