FB_ElapseTime

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Keeps track of the time (oTotalOnTime) a Boolean input variable is on.

Inputs

Input

Data Type

Range

Unit

Default

Description

iEN00

BOOL

FALSE, TRUE

N/A

FALSE

Enable for the block.

iVariable

BOOL

FALSE, TRUE

N/A

FALSE

The variable to be tracked.

Outputs

Output

Data Type

Range

Unit

Description

OK

BOOL

FALSE, TRUE

N/A

FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. block is OK.

This output follows the state on iEN00 input.

oTotalOnTime

TIME

0ms - 24hr

ms

The amount of time the iVariable is turned on.

oInProcess

BOOL

FALSE, TRUE

N/A

The state of the block’s execution whether or not it is still keeping track of time.

oDone

BOOL

FALSE, TRUE

N/A

The state of the block’s execution whether or not it is completed.

Remarks

Figure 6-105: FB_ElapseTime

Figure 6-106: MFB_ElapseTime – Time Diagram

Usage

  • Enable the block by setting iEN00 to TRUE
  • Either manually set iVariable to TRUE or have the application set this variable to TRUE
  • Once oDone returns TRUE, read the oTotalOnTime to find out how long iVariable was on.

FBD Language Example

FFLD Language Example

IL Language Example

Not available.

ST Language Example

//Keep track of total time that IncremementTimer variable is TRUE while EnableTimer variable is true

//Timer will be reset when EnableTimer variable is false

Inst_FB_ElapseTime( EnableTimer, IncrementTimer );
TotalOnTime := Inst_FB_ElapseTime.oTotalOnTime;