Timer/Counter blocks > Date Time Event function block

Date Time Event function block execution

For scheduling events, TE_TIME_STR and ENABLE are inputs. The block gets the internal (system) time (UTC_TIME_STR). 

If RESET is true, the block returns its parameters to the default conditions (sets STATE to 1, or Armed). 

If STATE is Idle, OUT_D is set to false. If this is the first time the block executes and if INTERVAL is not zero, the block sets the target event time.

If the TE_TIME_STR is still in the future the block sets STATE to armed.

During subsequent executions the block continues to compare the current time to TE_TIME_STR. When the two times are the same, OUT_D is set to true and STATE is set to Terminal if there are more events scheduled or set to Idle otherwise.

Relative time versus absolute time

The DTE function block generates events based on Absolute Time (local time of day). If you use multiple DTE blocks to create a Relative Time dependency between events and the events straddle the DST adjustment period, the time relationship of the events changes according to the DST adjustment.

Daylight savings time adjustments

The DTE function block has special behavior during Daylight Saving Time (DST) adjustment periods. The TE_TIME_STR parameter of the DTE (Date-Time-Event) function block adjusts its value while in transition to or from Daylight Saving Time (DST), to match the DST change.

Therefore, if the DST change moves the time forward by an hour, the TE_TIME_STR parameter will have an hour added to its value; and, if a DST change moves the time backward by an hour, the TE_TIME_STR parameter will have an hour subtracted from its value.

This behavior occurs only if both the TE_TIME_STR and INTERVAL_STR parameters of the DTE block contain values as configured through Control Studio edit mode or on-line mode. The TE_TIME_STR parameter is the time of day at which an event is scheduled. It is known as terminal event or TE time and is represented in local ISO time format. While the INTERVAL_STR parameter is the time between recurring terminal events.

The DTE function block behaves this way because it tries to maintain the time interval between events; hence, it changes the value of TE_TIME_STR.

This causes the following possible outcomes:
  • Any single event that is scheduled for a time that does not exist because of a forward DST adjustment does not occur.
  • Any single event that is scheduled in the hour preceding a backwards DST adjustment will not have the second occurrence of the event occur.
  • Periodic events are adjusted forward or backward, depending on the DST adjustment. Periodic events are not  lost.

Trigger an event during a DST transition

Use the following procedure to keep the trigger time constant (rather than keeping the time interval between events constant) during a DST transition.

The following configuration option sets a value on the TE_TIME_STR parameter to ensure that the DTE block will execute at the preferred time and not adjust with DST changes.

Note

Applying this configuration could require modification to suit a user’s requirements and application.

  1. In the module with the DTE function block, add a CALC block.
  2. Set the Calc block to execute BEFORE the DTE block.
    Note

    The Calc block must execute first. This is done to ensure that the value of TE_TIME_STR parameter of the DTE block is set before the DTE function block executes.

  3. Create the following expression in the CALC block:
    '^/PARAM1.CV' := time('$time_format:Local');
    '^/PARAM2.CV' := time_to_str("%D", '^/PARAM1.CV' );
    '^/DTE1/TE_TIME_STR.CV' := '^/PARAM2.CV' +"T03:00:-00";

    The first line of the expression reads the current date and time and writes the value into PARAM1. The second line extracts the date information that will be used in the third line. With the time of day set (in this example, 3 A.M.) as the expression “T03:00:00”, the third line combines the date and time to set the TE_TIME_STR parameter of the DTE function block.

    On a transition to another day, at 12:00 am, this configuration sets the TE_TIME_STR to a time of day as stated in the third line of the CALC block expression.

Note

This configuration might not work when the value of TE_TIME_STR parameter is set to a time coinciding with the hour of the DST change. For example, if a DST transition is set to happen at 1 AM and the time will move forward by an hour, this configuration might not take effect if the TE_TIME_STR parameter is set at any time between 1AM to 2AM.