Function Block FB_ElapseTime

Description

This Kollmorgen UDFBClosed"User Defined Function Block" UDFB can be used as a sub-function block in another program of the application. It is described using FBD, LD, ST or IL language. Input / output parameters of a UDFB (as well as private variables) are declared in the variable editor as local variables of the UDFB keeps track of the time ( oTotalOnTime) that a Boolean input variable is on. Once the iEN00 enable input is high the Kollmorgen UDFB will keep track of the total time iVariable is on. If iVariable changes to an off state while iEN00 is on, the oTotalOnTime will stop. oTotalOnTime will start to add again once iVariable changes state to high. As long as the iEN00 input is on, iVariable can change states many times. The oTotalOnTime will reflect only the total time that iVariable has been on. While iVariable is still TRUE, oInProcess will also be TRUE and oDone will be FALSE. Once iVariable is FALSE, oInProcess will be FALSE and oDone will be TRUE.

If the iEN00 input goes off, oTotalOnTime stops counting and the Kollmorgen UDFB execution stops. To restart the timer turn iEN00 on again. This will reset oTotalOnTime to zero and counting will begin once iVariable is also on.

Figure 7-195: FB_ElapseTime

Figure 7-196: MFB_ElapseTime – Time Diagram

Arguments

Input

iEN00

Description

Enable for the block

 

Data type

Boolean

 

Range

FALSE or TRUE

 

Unit

n/a

 

Default

FALSE

iVariable

Description

The variable to be tracked

 

Data type

Boolean

 

Range

FALSE or TRUE

 

Unit

n/a

 

Default

FALSE

Output

OK

Description

Function BlockClosedA function block groups an algorithm and a set of private data. It has inputs and outputs. OK. This output follows the state on iEN00 input

 

Data type

Boolean

 

Range

FALSE or TRUE

 

Unit

n/a

oTotalOnTime

Description

The amount of time the iVariable is turned on.

 

Data type

Time

 

Range

0ms – 24h

 

Unit

ms

oTotalOnTime

Description

The amount of time the iVariable is turned on.

 

Data type

Time

 

Range

0ms – 24h

 

Unit

ms

oInProcess

Description

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

 

Data type

Boolean

 

Range

FALSE or TRUE

 

Unit

n/a

oDone

Description

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

 

Data type

Boolean

 

Range

FALSE or TRUE

 

Unit

n/a

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.

Example

Structured text

//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;

Function Block Diagram

Free Form Ladder Diagram

Go back to the top of the page [Top]