TOF: Generate off-delay (S7-1200, S7-1500) - STEP 7

FBD (S7-1200, S7-1500)

ft:publication_title
FBD (S7-1200, S7-1500)
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
TOF: Generate off-delay

Description

You can use the "Generate off-delay" instruction to reset the Q output by the programmed time PT. The Q output is set when the result of logic operation (RLO) at input IN changes from "0" to "1" (positive signal edge). When the signal state at input IN changes back to "0" (negative signal edge), the programmed time PT starts. Output Q remains set as long as the time duration PT is running. When the PT time duration expires, the Q output is reset. If the signal state at input IN changes to "1" before the PT time duration expires, the timer is reset. The signal state at the output Q continues to be "1".

The current time value can be queried at the output ET. The timer value starts at T#0s and ends when the value of the time duration PT is reached. When the PT time duration expires, the ET output remains set to the current value until input IN changes back to "1". If input IN changes to "1" before the time duration PT has expired, the ET output is reset to the value T#0s. If the instruction is not called in the program because it is skipped, for example, the ET output returns a constant value as soon as the time has expired.

The "Generate off-delay" instruction can be placed within or at the end of the network. It requires a preceding logic operation.

Each call of the "Generate off-delay" instruction must be assigned to an IEC timer in which the instance data is stored.

For S7-1200 CPU

An IEC Timer is a structure of the data type IEC_TIMER or TOF_TIME that you can declare as follows:

  • Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")

  • Declaration as a local tag of the type TOF_TIME or IEC_TIMER in the "Static" section of a block (for example, #MyIEC_TIMER)

For S7-1500 CPU

An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TOF_TIME or TOF_LTIME that you can declare as follows:

  • Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example, "MyIEC_TIMER")

  • Declaration as a local tag of the type TOF_TIME, TOF_LTIME, IEC_TIMER or IEC_LTIMER in the "Static" section of a block (for example, #MyIEC_TIMER)

Updating the actual values in the instance data

The instance data from "Generate off-delay" is updated according to the following rules:

  • IN input

    The "Generate off-delay" instruction compares the current RLO with the RLO from the previous query, which is saved in the IN parameter in the instance data. If the instruction detects a change in the RLO from "1" to "0", there is a negative signal edge and the time measurement is started. After the "Generate off-delay" instruction has been processed, the value of the IN parameter is updated in the instance data and is used as edge memory bit for the next query.

    Note that the edge evaluation is disrupted when the actual values of the IN parameter are written or initialized by other functions.  

  • PT input

    The value at the PT input is written to the PT parameter in the instance data when the edge changes at the IN input.  

  • Q and ET outputs

    The actual values of the Q and ET outputs are updated in the following cases:

    • When the instruction is called, if the ET or Q outputs are interconnected.

      Or

    • At an access to Q or ET.  

    If the outputs are not interconnected and also not queried, the current time value at the Q and ET outputs is not updated. The outputs are not updated, even if the instruction is skipped in the program.  

    The internal parameters of the "Generate off-delay" instruction are used to calculate the time values for Q and ET. Note that the time measurement is disrupted when the actual values of the instruction are written or initialized by other functions.

Danger

Danger when reinitializing the actual values

Reinitializing the actual values of an IEC timer while the time measurement is running disrupts the function of the IEC timer. Changing the actual values can result in inconsistencies between the program and the actual process. This can cause serious damage to property and personal injury.

The following functions can cause the actual values to be reinitialized:

  • Loading the block with reinitialization

  • Loading snapshots as actual values

  • Controlling or forcing the actual values

  • The "WRIT_DBL" instruction

Before you execute these functions, take the following precautions:

  • Make sure that the plant is in a safe state before you overwrite the actual values.

  • Make sure that the IEC timer has expired before initializing its actual values.  

  • If you overwrite the actual values with a snapshot, make sure that the snapshot was taken at a time when the system was in a safe state.

  • Make sure that the program does not read or write the affected data during transmission.

Parameters

The following table shows the parameters of the "Generate off-delay" instruction:

Parameter

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

S7-1200

S7-1500

IN

Input

BOOL

BOOL

I, Q, M, D, L or constant

I, Q, M, D, L, T,C, P or constant

Start input

PT

Input

TIME

TIME, LTIME

I, Q, M, D, L or constant

I, Q, M, D, L, P or constant

Duration of the off delay

The value of the PT parameter must be positive.

Q

Output

BOOL

BOOL

I, Q, M, D, L

I, Q, M, D, L, P

Output that is reset when the timer PT expires.

ET

Output

TIME

TIME, LTIME

I, Q, M, D, L

I, Q, M, D, L, P

Current timer value

Pulse timing diagram

The following figure shows the pulse timing diagram of the "Generate off-delay" instruction:

Example

The following example shows how the instruction works:

The following table shows how the instruction works using specific operand values:

Parameters

Operand

Value

IN

Tag_Start

Signal transition "0" => "1"; signal transition "1" => "0"

PT

Tag_PresetTime

T#10s

Q

Tag_Status

TRUE

ET

Tag_ElapsedTime

from T#10s => T#0s

When the signal state of the operand "Tag_Start" changes from "0" to "1", the "Tag_Status" operand is set to signal state "1". When the signal state of the "Tag_Start" operand changes from "1" to "0", the time programmed for the PT parameter is started. As long as the time is running, the "Tag_Status" operand remains set to TRUE. When the time has expired, the "Tag_Status" operand is reset to FALSE. The current time value is stored in the "Tag_ElapsedTime" operand.