FB_ALY_ProductivityDiagnosis_3Ch

The Productivity Diagnosis 3Ch algorithm calculates the productivity of the process during a production interval. The diagram below schematically illustrates the relationship between the production process and the individual production cycles.

FB_ALY_ProductivityDiagnosis_3Ch 1:

The production interval can be started and stopped via the input Is Producing. During the execution of the production interval, the production cycles are counted. Each production cycle corresponds to one piece produced. A production cycle starts with an edge at Start Cycle and stops with an edge at Stop Cycle. The productivity over the entire production interval (Productivity) is calculated after stopping the interval when the signal Is Producing no longer meets the condition for Threshold Level Producing. The completed production cycles and therefore all finished pieces are taken into account. Productivity is calculated as the ratio of pieces actually produced per time and the target value of pieces to be produced in a given time. The output Productivity Last Cycle is calculated from the time required for the last production cycle in relation to the configured time for a piece. Any break times between cycles are not taken into account. The output Expected Productivity estimates the total productivity during the production interval. For this purpose, the previous production time is extrapolated to the total productivity for the target value of the pieces to be produced. The algorithm can be configured with the target value for the Produced Pieces within a configured interval (Production Time), e.g. 1 piece in 30 seconds or 50 pieces per hour.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_ProductivityDiagnosis_3Ch
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    bProducing: BOOL;
    bCycleFinished: BOOL;
    fProductivity: LREAL;
    fProductivityLastCycle: LREAL;
    fExpectedProductivity: LREAL;
    fbElapsedTime: FB_ALY_Timespan;
    nProductionCycles: ULINT;
END_VAR

FB_ALY_ProductivityDiagnosis_3Ch 2: 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.

bProducing

BOOL

Indicates that the production interval is active.

bCycleFinished

BOOL

TRUE if a production cycle has been completed, otherwise FALSE.

fProductivity

LREAL

Productivity of the entire production interval in percent.

fProductivityLastCycle

LREAL

Productivity of the last production cycle in percent.

fExpectedProductivity

LREAL

Estimates the productivity of the production interval. Specified in percent.

fbElapsedTime

FB_ALY_Timespan

Timespan since the start of the production interval.

nProductionCycles

ULINT

Number of complete production cycles in the current production interval.

FB_ALY_ProductivityDiagnosis_3Ch 3: Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

Configure()

Local

General configuration of the algorithm with its parameterized conditions.

ConfigureChannel()

Local

Channel-specific configuration for the respective algorithm.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

FB_ALY_ProductivityDiagnosis_3Ch 4: Properties

Name

Type

Access

Definition location

Initial value

Description

fTolerance

LREAL

Get, Set

Local

0.0

Tolerance value for the Equal / NotEqual comparisons

Sample

VAR
    fbProductivityDiagnosis : FB_ALY_ProductivityDiagnosis_3Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    stThresholdIsProducing : ST_ALY_Threshold;
    stThresholdStartCycle : ST_ALY_Threshold;
    stThresholdStopCycle : ST_ALY_Threshold;    
    nNumProducedPieces : ULINT := 40;
    tProductionTime : LTIME := LTIME#1H;
    bConfigure : BOOL := TRUE;
    bIsProducing : BOOL;
    bStartProductionCycle : BOOL;
    bStopProductionCycle : BOOL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;
    
    stThresholdIsProducing.eComparisonOperator := E_ALY_ComparisonOperator.Equals; 
    stThresholdIsProducing.fThreshold := 1;
    stThresholdStartCycle.eComparisonOperator := E_ALY_ComparisonOperator.Equals; 
    stThresholdStartCycle.fThreshold := 1;
    stThresholdStopCycle.eComparisonOperator := E_ALY_ComparisonOperator.Equals; 
    stThresholdStopCycle.fThreshold := 1;
    
    fbProductivityDiagnosis.ConfigureChannel(1, stThresholdIsProducing);
    fbProductivityDiagnosis.ConfigureChannel(2, stThresholdStartCycle);
    fbProductivityDiagnosis.ConfigureChannel(3, stThresholdStopCycle);
    fbProductivityDiagnosis.Configure(nNumProducedPieces, tProductionTime);
END_IF

// Get current system time
fbSystemTime.Call();

// Call algorithm
fbProductivityDiagnosis.SetChannelValue(1, bIsProducing);
fbProductivityDiagnosis.SetChannelValue(2, bStartProductionCycle);
fbProductivityDiagnosis.SetChannelValue(3, bStopProductionCycle);
fbProductivityDiagnosis.Call(fbSystemTime.tSystemTime);

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics