average / averageL

PLCopen motion icon

 Function Block - Calculates the average of signal samples.

Inputs

Input

Data Type

Range

Unit

Default

Description

RUN

BOOL

 

 

 

Enabling command.

XIN

REAL

 

 

 

Input signal.

N

DINT

 

 

 

  • Number of samples stored for average calculation.
  • Cannot exceed 128.

Outputs

Output

Data Type

Range

Unit

Description

XOUT

REAL

 

 

  • Average of the stored samples.
  • averageL has LREAL arguments.

Remarks

  • Average is calculated according to the number of stored samples.
    • This can be less than N when the block is enabled.
      • The N input (or the number of samples) is taken into account only when the RUN input is FALSE.
    • By default, the number of samples is 128.
  • RUN must be reset after a change in the number of samples.
    • Cycle the RUN input when you first call this function; this clears the default.

FBD Language Example

FFLD Language Example

  • In the FFLD Language, the input rung is the RUN command.
    • The output rung keeps the state of the input rung.
    • ENO has the same value as RUN.

IL Language Example

(* MyAve is a declared instance of AVERAGE function block *)
Op1: CAL MyAve (RUN, XIN, N)
     FFLD  MyAve.XOUT
     ST  XOUT

ST Language Example

(* MyAve is a declared instance of AVERAGE function block. *)
MyAve (RUN, XIN, N);
XOUT := MyAve.XOUT;

See Also