TONR: Time accumulator (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
TONR: Time accumulator

Description

You can use the "Time accumulator" instruction to record how long the signal is at the input of instruction "1". The time measurement is started when the result of logic operation (RLO) changes from "0" to "1" (positive signal edge). The time is recorded as long at the RLO is "1". If the RLO changes to "0", time recording is stopped. If the RLO changes back to "1", the time recording is continued. The query of the timer status for "1" returns the signal state "1" if the recorded time exceeds the value of the specified time duration and the RLO at the input of coil is "1".

The current timer status is stored in the "Q" structure component of the IEC timer. You can use a normally open contact to query timer status for "1" or a normally closed contact for "0".

The timer status "Q" and the currently recorded timer "ET" can be reset to "0" using the "Reset timer" instruction.

Specify the duration under the instruction at <Operand1> (duration) and specify the IEC timer to be started above the instruction at <Operand2> (IEC timer).

The "Time accumulator" instruction can be placed only at the end of the network. It requires a preceding logic operation.

Note

The start and the query of the IEC Timer may be on different expiry levels as each query of the outputs Q or ET updates the IEC_TIMER structure.

For S7-1200 CPU

The "Time accumulator" instruction stores its data in a structure of the data type IEC_TIMER or TONR_TIME. You can declare the structure 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 TONR_TIME or IEC_TIMER in the "Static" section of a block (for example, #MyIEC_TIMER)

For S7-1500 CPU

The "Time accumulator" instruction stores its data in a structure of the data type IEC_TIMER, IEC_LTIMER, TONR_TIME or TONR_LTIME. You can declare the structure 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 TONR_TIME, TONR_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 "Time accumulator" is updated according to the following rules:

  • IN input

    The "Time accumulator" 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 "0" to "1", there is a positive signal edge and the time measurement is continued. If the instruction in the RLO detects a change from "1" to "0", there is a negative signal edge and the time measurement is interrupted. After the "Time accumulator" 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.  

  • R input

    The signal "1" at input R resets the time measurement and blocks it. Edges at the IN input are ignored. The signal "0" at input R enables time measurement again.

  • 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 "Time accumulator" 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 "Time accumulator" instruction:

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

VALUE

Input

TIME

TIME, LTIME

I, Q, M, D, L or constant

Duration with which the IEC Timer runs.

<IEC Timer>

InOut

IEC_TIMER, TONR_TIME

IEC_TIMER, IEC_LTIMER, TONR_TIME, TONR_LTIME

D, L

IEC Timer which is started.

You can find additional information on valid data types under "See also".

Pulse timing diagram

The following figure shows the pulse timing diagram of the instruction:

Example

The following example shows how the instruction works:

The "Time accumulator" instruction is executed if there is a positive signal edge in the RLO. The time is recorded as long as the operand "Tag_Input" has the signal state "1".

If the recorded time exceeds the value of the operand "Tag_TIME", then the query of the timer status ("MyIEC_TIMER".Q) will return the signal state "1" and the operand "Tag_Output" will be set.