FB_CTRL_MEDIAN_FILTER

FB_CTRL_MEDIAN_FILTER 1:

The function block specifies the median. The median is the mean value of a list of values ordered by size. This means that one half of the collected data values is smaller than the median value, the other half is larger.

The programmer must create an array "ARRAY [1..2(n+2)] OF LREAL", in which the function block can store the internal required data.

FB_CTRL_MEDIAN_FILTER 2: Inputs

VAR_INPUT
    fIn                 : FLOAT;
    fManSyncValue       : FLOAT;
    eMode               : E_CTRL_MODE;    
    bSync               : FLOAT;
    bHold               : BOOL;
END_VAR

Name

Type

Description

fIn

FLOAT

Input value of the median filter

fManSyncValue

FLOAT

Input value to which the median filter can be set or which is output in manual mode.

eMode

E_CTRL_MODE

With a rising edge at this input the median filter is set to the value "fManSyncValue".

bSync

FLOAT

Input that specifies the operation mode of the function block.

bHold

BOOL

TRUE at this input holds the internal state and thus also the output.

FB_CTRL_MEDIAN_FILTER 3: Outputs

VAR_OUTPUT
    fOut        : FLOAT;
    eState      : E_CTRL_STATE;
    eErrorId    : E_CTRL_ERRORCODES;
    bError      : BOOL;
END_VAR

Name

Type

Description

fOut

FLOAT

Output of the median filter

eState

E_CTRL_STATE

Status of the function block

eErrorId

E_CTRL_ERRORCODES

Supplies the error number when the output bError is set.

bError

BOOL

Becomes TRUE, as soon as an error occurs.

FB_CTRL_MEDIAN_FILTER 4: Inputs/ outputs

VAR_IN_OUT
    tCtrlCycleTime        : TIME := T#0ms;
    tTaskCycleTime        : TIME := T#0ms;
    nSamplesToFilter      : UINT;
    pWorkArray_ADR        : POINTER TO FLOAT := 0;
    nWorkArray_SIZEOF     : UINT := 0;
END_VAR

Name

Type

Description

tCtrlCycleTime

TIME

Cycle time with which the control loop is processed. This must be greater than or equal to the TaskCycleTime. The function block uses this input value to calculate internally whether the state and the output values have to be updated in the current cycle.

tTaskCycleTime

TIME

Cycle time with which the function block is called. If the function block is called in every cycle this corresponds to the task cycle time of the calling task.

nSamplesTo
Filter

UINT

Number of values "n" used to form the median value.

pWorkArray_
ADR

POINTER TO FLOAT

The address of the array where the input values are temporarily stored.

nWorkArray_
SIZEOF

UINT

Size of the WorkArrays