FB_Timer: Timer

Overview

The following graphic shows the pin diagram of the function block  FB_Timer:

G-SE-0047227.1.gif-high.gif

 

 

The function block %TM in EcoStruxure Machine Expert - Basic can configure 3 types of timers:

oTON (Timer On-Delay): this type of timer is used to control on-delay actions.

oTOF (Timer Off-Delay): this type of timer is used to control off-delay actions.

oTP (Timer-Pulse): this type of timer is used to create a pulse of a precise duration.

For more information refer to the CoDeSys online help in EcoStruxure Machine Expert: CoDesSys-Libraries/Standard Library/Timer.

NOTE: When changing the timer type online while i_xEnable is TRUE, the formerly selected timer type is reset and the new timer type starts. FB outputs behave according the newly selected timer.

I/O Variables Description

The TwidoEmulationSupport library provides a function FB_Timer, which calls the timer type TON, TOF or TP depending on the input i_etTimerType. The given TimeBase is used for calculating the preset time.

The table describes the input variables of the function block in the TwidoEmulationSupport library:

Input

Data type

Description

i_xEnable

BOOL

Rising edge starts counting up q_iCurrentValue.

i_iPreset

INT

Initial value of the preset value (0..32767)

i_etTimerType

ET_TimerType

Indicates the timer type: TON, TOF, or TP

i_etTimeBase

ET_TimerTimeBases

Time base of 1 ms, 10 ms, 100 ms, 1 s, 1 min

Default: 1 min

i_etMaxVal

ET_TimerCounterMaxVal

Maximum value

i_xRetentive

BOOL

Behavior of the timer:

oTRUE: timer keeps value of the output q_iCurrentValue when disabled, and continues counting from previous value when enabled again

oFALSE: timer resets the output q_iCurrentValue after disable

The data type for the input variable i_etTimerType is:

TYPE ET_TimeType:
(
TON    := 1,   //   On-delay Timer
TOF    := 2,   //   Off-delay Timer
TP     := 3,   //   Pulse Timer
) INT;
END_TYPE

NOTE: If an invalid value is given to i_etTimerType, then q_xOutput stays at FALSE and q_iCurrentValue stays at 0.

The data type for the input variable i_etTimeBase is:

TYPE ET_TimerTimeBases:
(
tb1MS     := 1,   //   1 millisecond time base
tb10MS    := 2,   //   10 millisecond time base
tb100MS   := 3,   //   100 millisecond time base
tb1S      := 4,   //   10 second time base
tb1M      := 5,   //   1 minute time base
) INT;
ET_TYPE

The data type for the input variable i_etMaxVal is:

TYPE ET_TimerCounterMaxVal:
(
Val9999   :=  0,  //    Value  9999
Val32767  :=  1   //    Value  3267
) INT
END_TYPE

The table describes the output variables of the function block in the TwidoEmulationSupport library:

Output

Data type

Description

q_xOutput

BOOL

Timer output

q_iCurrentValue

INT

Elapsed time