# TimeTrig

## `TimeTrig` (FB)

FUNCTION\_BLOCK TimeTrig

FB timer (On/Off timer) with separate on/off durations and triggers for state changes. It only runs when xEnable is active and switches between on and off based on the time settings.

Function The program creates a pulse function / blinker with the following characteristics:

> Is activated by xEnable. Start state is set via xStartQ. tOn determines the duration in the “on” state. tOff determines the duration in the “off” state. xQ is the current output state (on/off). xOnTrig and xOffTrig are event flags that are set for one cycle when the state changes. Internal helper variables \_tTime, \_tStart, \_xEnTrig are used for time measurement and edge detection.

InOut:

| Scope  | Name       | Type   | Comment                                                        |
| ------ | ---------- | ------ | -------------------------------------------------------------- |
| Input  | `xEnable`  | `BOOL` | input signal                                                   |
| Input  | `tOn`      | `TIME` | on delay                                                       |
| Input  | `tOff`     | `TIME` | off delay                                                      |
| Input  | `xStartQ`  | `BOOL` | start option TRUE = start with pulse, FALSE = start with pulse |
| Output | `xQ`       | `BOOL` | output pulse                                                   |
| Output | `xOnTrig`  | `BOOL` | rising edge when xQ = TRUE                                     |
| Output | `xOffTrig` | `BOOL` | rising edge when xQ = FALSE                                    |
| Output | `tET`      | `TIME` | elapsed time since the rising edge (switch)                    |
