[go: up one dir, main page]

0% found this document useful (0 votes)
57 views22 pages

Lab 4

1. The document describes the objectives and equipment for a lab on implementing ladder logic for timer operations on a PLC using TIA Portal. 2. It explains how to use TP and TON instructions to generate pulse and on-delay timing functions by setting outputs for a programmed duration when inputs change state. 3. Parameters like IN, PT, Q and ET are used to control the timing instructions and their values are updated in instance data based on the status of the inputs over time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views22 pages

Lab 4

1. The document describes the objectives and equipment for a lab on implementing ladder logic for timer operations on a PLC using TIA Portal. 2. It explains how to use TP and TON instructions to generate pulse and on-delay timing functions by setting outputs for a programmed duration when inputs change state. 3. Parameters like IN, PT, Q and ET are used to control the timing instructions and their values are updated in instance data based on the status of the inputs over time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

PLC & Industrial Drives LAB Lab 4

Implementation of LADDER Logic for Timer Operations on PLC


using TIA Portal.

Objectives

 The objective of this lab is to learn the bit wise control of input/output ports of PLC.
 Basic Logic Functions of PLC using TIA Portal.

List of Equipment/Software
Following equipment/software is required:
 S7 1512C PLC Module
 TIA Portal v17 Software
 ASIMA Module
 PC

Timer operations

This section contains information on the following topics:


1. TP: Generate pulse
You can use the "Generate pulse" instruction to set the Q output for a programmed duration. The
instruction is started when the result of logic operation (RLO) at input IN changes from "0" to "1"
(positive signal edge). The programmed time PT begins when the instruction starts. Output Q is set
for the duration PT, regardless of the subsequent course of the input signal. While the time PT is
running, the detection of a new positive signal edge at the IN input has no influence on the signal
state at the Q output.
You can scan the current time value at the ET output. The timer value starts at T#0s and ends when
the value of the time duration PT is reached. When the time PT has elapsed and the signal state at
input IN is "0", the ET output is reset. 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 PT has expired.
The "Generate pulse" instruction can be placed within or at the end of the network. It requires a
preceding logic operation.
Each call of the "Generate pulse" 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 TP_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 TP_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
Page | 1
PLC & Industrial Drives LAB Lab 4
An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TP_TIME or TP_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 TP_TIME, TP_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 pulse" is updated according to the following rules:
 IN input
The "Generate pulse" 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 started. After the "Generate pulse" 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 pulse" 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.
Parameter
The following table shows the parameters of the "Generate pulse" instruction:
Data type Memory area
ParametersDeclaration S7- Description
S7-1500 S7-1200 S7-1500
1200
I, Q, M, D, L I, Q, M, D, L,
IN Input BOOL BOOL Start input
or constant P, or constant
Duration of the pulse
TIME, I, Q, M, D, L I, Q, M, D, L, P The value of the PT
PT Input TIME
LTIME or constant or constant parameter must be
positive.
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L, P Pulse output
TIME,
ET Output TIME I, Q, M, D, L I, Q, M, D, L, P Current time value
LTIME
Table 1: Parameters of TP

Page | 2
PLC & Industrial Drives LAB Lab 4
Pulse timing diagram
The following figure shows the pulse timing diagram of the "Generate pulse" 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"
PT Tag_PresetTime T#10s
Q Tag_Status TRUE
ET Tag_ElapsedTime from T#0s => T#10s
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time programmed for
the PT parameter is started and the "Tag_Status" operand is set to "1". The current time value is
stored in the "Tag_ElapsedTime" operand. When the time expires, the "Tag_Status" operand is reset
to signal state "0".
2. TON: Generate on-delay
You can use the "Generate on-delay" instruction to delay setting of the Q output by the programmed
time PT. The instruction is started when the result of logic operation (RLO) at input IN changes
from "0" to "1" (positive signal edge). The programmed time PT begins when the instruction starts.
When the time PT has elapsed, the output Q has the signal state "1". Output Q remains set as long as
the start input is still "1". When the signal state at the start input changes from "1" to "0", the Q
output is reset. The timer function is started again when a new positive signal edge is detected at the
start input.

Page | 3
PLC & Industrial Drives LAB Lab 4
The current time value can be queried at the ET output. The timer value starts at T#0s and ends
when the value of the time duration PT is reached. The ET output is reset as soon as the signal state
at the IN input changes to "0". 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 PT has expired.
The "Generate on-delay" instruction can be placed within or at the end of the network. It requires a
preceding logic operation.
Each call of the "Generate on-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 TON_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 TON_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, TON_TIME or
TON_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 TON_TIME, TON_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 on-delay" is updated according to the following rules:
 IN input
The "Generate on-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 "0" to "1", there is a positive signal edge and the time
measurement is started. After the "Generate on-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.

Page | 4
PLC & Industrial Drives LAB Lab 4
The internal parameters of the "Generate on-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.
Parameter
The following table shows the parameters of the "Generate on-delay" instruction:
Data type Memory area
ParametersDeclaration S7- Description
S7-1500 S7-1200 S7-1500
1200
I, Q, M, D, L I, Q, M, D, L,
IN Input BOOL BOOL Start input
or constant P, or constant
Duration of the on-delay
TIME, I, Q, M, D, L I, Q, M, D, L, P The value of the PT
PT Input TIME
LTIME or constant or constant parameter must be
positive.
Output that is set when
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L, P
the time PT expires.
TIME,
ET Output TIME I, Q, M, D, L I, Q, M, D, L, P Current time value
LTIME
Table 2: Parameters of TON

Pulse timing diagram


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

Example
The following example shows how the instruction works:

Page | 5
PLC & Industrial Drives LAB Lab 4
The following table shows how the instruction works using specific operand values:
Parameters Operand Value
IN Tag_Start Signal transition "0" => "1"
PT Tag_PresetTime T#10s
Q Tag_Status FALSE; after 10 s => TRUE
ET Tag_ElapsedTime from T#0s => T#10s
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time programmed for
the PT parameter is started. When the time duration expires, the "Tag_Status" operand is set to the
signal state "1". The Tag_Status operand remains set to "1" as long as the Tag_Start operand has
signal state "1". The current time value is stored in the "Tag_ElapsedTime" operand. When the
signal state at the operand "Tag_Start" changes from "1" to "0", the "Tag_Status" operand is reset.
3. TOF: Generate off-delay
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 ET output. 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 switches to "1"
before the 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:
Page | 6
PLC & Industrial Drives LAB Lab 4
 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.
Parameters
The following table shows the parameters of the "Generate off-delay" instruction:
Data type Memory area
ParametersDeclaration S7- Description
S7-1500 S7-1200 S7-1500
1200
I, Q, M, D, L I, Q, M, D, L,
IN Input BOOL BOOL Start input
or constant P, or constant
Duration of the off delay
TIME, I, Q, M, D, L I, Q, M, D, L, P The value of the PT
PT Input TIME
LTIME or constant or constant parameter must be
positive.
Output that is reset when
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L, P
the time PT expires.
TIME,
ET Output TIME I, Q, M, D, L I, Q, M, D, L, P Current time value
LTIME
Table 3: Parameter of TOF

Pulse timing diagram


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

Page | 7
PLC & Industrial Drives LAB Lab 4

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 too FALSE. The current time value is stored in the "Tag_ElapsedTime" operand.
4. TONR: Time accumulator
The instruction "Time accumulator" is used to accumulate time values within a period set by the
parameter PT. When the signal state at the IN-input changes from "0" to "1" (positive signal edge),
the time measurement is executed and the time PT starts. While the time PT is running, the time
values are accumulated that are recorded when the IN input has signal state "1". The accumulated
time is written to the ET output and can be queried there. When the duration PT expires, the output
Q has signal state "1". The Q parameter remains set to "1", even when the signal state at the IN-
parameter changes from "1" to "0" (negative signal edge).
The R input resets the ET and Q outputs regardless of the signal state of the start input.
The "Time accumulator" instruction can be placed within or at the end of the network. It requires a
preceding logic operation.
Page | 8
PLC & Industrial Drives LAB Lab 4
Each call of the "Time accumulator" instruction must be assigned 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 TONR_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 TONR_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, TONR_TIME or
TONR_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 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.

Page | 9
PLC & Industrial Drives LAB Lab 4
Parameters
The following table shows the parameters of the "Time accumulator" instruction:
Data type Memory area
ParametersDeclaration S7- Description
S7-1500 S7-1200 S7-1500
1200
I, Q, M, D, L I, Q, M, D, L,
IN Input BOOL BOOL Start input
or constant P, or constant
I, Q, M, D, L I, Q, M, D, L, P
R Input BOOL BOOL Reset input
or constant or constant
Maximum duration of
time recording
TIME, I, Q, M, D, L I, Q, M, D, L, P
PT Input TIME The value of the PT
LTIME or constant or constant
parameter must be
positive.
Output that is set when
Q Output BOOL BOOL I, Q, M, D, L I, Q, M, D, L, P
time PT expires.
TIME,
ET Output TIME I, Q, M, D, L I, Q, M, D, L, P Accumulated time
LTIME
Table 4: Parameters of TONR

Pulse timing diagram


The following figure shows the pulse timing diagram of the "Time accumulator" instruction:

Page | 10
PLC & Industrial Drives LAB Lab 4
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"
PT Tag_PresetTime T#10s
Q Tag_Status FALSE; after 10 s => TRUE
Signal transition from "0" => "1"
The time T#10s expires.
After 5 s signal transition from "1" => "0":
ET Tag_ElapsedTime The time at the "Tag_ElapsedTime" operand remains at T#5s.
After approx. 2 s, renewed signal transition from "0" => "1":
The time at the "Tag_ElapsedTime" operand continues to run at
T#5s.
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time programmed for
the PT parameter is started. The time continues to run as long as the "Tag_Start" operand has the
signal state "1". When the signal state of the "Tag_Start" operand changes from "1" to "0", the time
stops and the current time value at the Tag_ElapsedTime operand is recorded. When the signal state
at the "Tag_Start" operand changes again from "0" to "1", the time continues to run starting at the
time value that was recorded at the transition from "1" to "0". When the time value specified for the
PT parameter is reached, the "Tag_Status" operand is set to the signal state "1". The current time
value is stored in the "Tag_ElapsedTime" operand.
5. ---(TP)---: Start pulse timer
Use the "Start pulse timer" instruction to start an IEC timer with a specified duration as pulse. The
IEC timer is started when the result of logic operation (RLO) changes from "0" to "1" (positive
signal edge). The IEC timer runs for the specified time regardless of any subsequent changes in the
RLO. The run of the IEC timer is also not affected by the detection of a new positive signal edge. As
long as the IEC timer is running, the querying of the timer status for "1" returns the signal state "1".
When the IEC timer has expired, the timer status returns the signal state "0".
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".
Specify the duration of the pulse under the instruction at <Operand1> (duration) and specify the IEC
time to be started above the instruction at <Operand2> (IEC time).
The execution of the "Start pulse timer" instruction can be placed only at the end of the network. It
requires a preceding logic operation.
Note
You can start and query the IEC timer at various execution levels, as each querying of the outputs Q

Page | 11
PLC & Industrial Drives LAB Lab 4
or ET updates the IEC_TIMER structure.
For S7-1200 CPU
The instruction "Start pulse timer" stores its data in a structure of the data type IEC_TIMER or
TP_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 TP_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The instruction "Start pulse timer" stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TP_TIME or TP_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 TP_TIME, TP_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 "Start pulse timer" is updated according to the following rules:
 IN input
The "Start pulse timer" 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 started. After the "Start pulse timer" 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 "Start pulse timer" 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.
Parameters
The following table shows the parameters of the "Start pulse timer" instruction:
Data type Memory
Parameters Declaration Description
S7-1200 S7-1500 area

Page | 12
PLC & Industrial Drives LAB Lab 4
Data type Memory
Parameters Declaration Description
S7-1200 S7-1500 area
I, Q, M, D, Duration with
<Time
Input TIME TIME, LTIME L or which the IEC
duration>
constant timer runs.
IEC_TIMER,
IEC_TIMER, IEC timer that is
<IEC timer> InOut IEC_LTIMER, D, L
TP_TIME started.
TP_TIME, TP_LTIME
Table 5: Parameters of Start Pulse Timer

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 "Start pulse timer" instruction is executed when the signal state of the operand "Tag_Input"
changes from "0" to "1". The timer "DB1”. MyIEC_TIMER is started for the time stored in the
operand "TagTime".

As long as the timer "DB1". MyIEC_TIMER is running, the timer status ("DB1”. MyIEC_TIMER)
has signal state "1" and the operand "Tag_Output" is set. When the IEC timer has expired, the signal
state of the time status changes back to "0" and the "Tag_Output" operand is reset.
6. ---(TON)---: Start on-delay timer
You can use the "Set output" instruction to set the signal state of a specified operand to "1".

Page | 13
PLC & Industrial Drives LAB Lab 4
The instruction is only executed if the result of logic operation (RLO) at the input of the coil is "1".
If power flows to the coil (RLO = "1"), the specified operand is set to "1". If the RLO at the input of
the coil is "0" (no signal flow to the coil), the signal state of the specified operand remains
unchanged.
Parameters
The following table shows the parameters of the "Start on-delay timer" instruction:
Data type Memory
Parameters Declaration Description
S7-1200 S7-1500 area
I, Q, M, D, Duration with
<Time
Input TIME TIME, LTIME L or which the IEC
duration>
constant timer runs.
IEC_TIMER,
IEC_TIMER, IEC_LTIMER, IEC timer that is
<IEC timer> InOut D, L
TON_TIME TON_TIME, started.
TON_LTIME
Table 6: Parameters of Start ON-Delay Timer

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 "Start on-delay timer" instruction is executed when the signal state of the operand "Tag_Input"
changes from "0" to "1". The "MyIEC_TIMER timer is started for the time stored in the "TagTime"
operand.

Page | 14
PLC & Industrial Drives LAB Lab 4
If the timer "MyIEC_TIMER" has expired and the operand "Tag_Input" has the signal state "1",
querying the timer status ("MyIEC_TIMER). Q) returns signal state "1" and the "Tag_Output"
operand is set. When the signal state of the operand "Tag_Input" changes to "0", the querying of the
timer status returns the signal state "0" and the operand "Tag_Output" is reset.
7. ---(TOF)---: Start off-delay timer
Use the "Start off-delay timer" instruction to start an IEC timer with a specified duration as on-
delay. The query of the timer status returns the signal state "1" if the result of logic operation (RLO)
at the input of the instruction has the signal state "1". When the RLO changes from "1" to "0"
(negative signal edge), the IEC timer starts with the specified time. The timer status remains at
signal state "1" as long as the IEC timer is running. When the timer has run out and the RLO at the
input of the instruction has the signal state "0", the timer status is set to the signal state "0". If the
RLO changes to "1" before the time expires, the IEC timer is reset and the timer status remains at
signal state "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".
Specify the duration of the OFF delay under the instruction at <Operand1> (duration) and specify
the IEC time to be started above the instruction at <Operand2> (IEC time).
The "Start off-delay timer" instruction can be placed only at the end of the network. It requires a
preceding logic operation.
Note
You can start and query the IEC timer at various execution levels, as each querying of the outputs Q
or ET updates the IEC_TIMER structure.
For S7-1200 CPU
The instruction "Start off-delay timer" stores its data in a structure of the data type IEC_TIMER or
TOF_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 TOF_TIME or IEC_TIMER in the "Static" section of a
block (for example, #MyIEC_TIMER)
For S7-1500 CPU
The "Start off-delay timer" instruction stores its data in a structure of the data type IEC_TIMER,
IEC_LTIMER, TOF_TIME or TOF_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 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 "Start off-delay timer" is updated according to the following rules:
 IN input
The "Start off-delay timer" 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 "Start off-delay timer" 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.
Page | 15
PLC & Industrial Drives LAB Lab 4
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 "Start off-delay timer" 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.
Parameters
The following table shows the parameters of the "Start off-delay timer" instruction:
Data type Memory
Parameters Declaration Description
S7-1200 S7-1500 area
I, Q, M, D, Duration with
<Time
Input TIME TIME, LTIME L or which the IEC
duration>
constant timer runs.
IEC_TIMER,
IEC_TIMER, IEC_LTIMER, IEC timer that is
<IEC timer> InOut D, L
TOF_TIME TOF_TIME, started.
TOF_LTIME
Table 7: Parameters of Start Off-Delay Timer

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:

Page | 16
PLC & Industrial Drives LAB Lab 4
Example
As long as timer #MyIEC_TIMER is running, the query of the time status (#MyIEC_TIMER.Q)
returns the signal state "1" and operand "Tag_Output" is set. If the timer has expired and the operand
"Tag_Input" has the signal state "0", the query of the timer status returns the signal state "0". If the
signal state of the operand "Tag_Input" changes to "1" before timer #MyIEC_TIMER expires, the
timer is reset. When the signal state of the operand "Tag_Input" is "1", the query of the timer status
returns the signal state "1".
The following example shows how the instruction works:

The "Start off-delay timer" instruction is executed when the signal state of the operand "Tag_Input"
changes from "1" to "0". The timer #MyIEC_TIMER is started for the time stored in the operand
"TagTime".

8. ---( TONR )---: Time accumulator


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 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 time to be
started above the instruction at <Operand2> (IEC time).
The "Time accumulator" instruction can be placed only at the end of the network. It requires a
preceding logic operation.
Note
You can start and query the IEC timer at various execution levels, as each querying 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:

Page | 17
PLC & Industrial Drives LAB Lab 4
 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.
Parameters
The following table shows the parameters of the "Time accumulator" instruction:
Data type Memory
Parameters Declaration Description
S7-1200 S7-1500 area
I, Q, M, D, Duration with
<Time
Input TIME TIME, LTIME L or which the IEC
duration>
constant timer runs.
IEC_TIMER,
IEC_TIMER, IEC_LTIMER, IEC timer that is
<IEC timer> InOut D, L
TONR_TIME TONR_TIME, started.
TONR_LTIME
Table 8: Parameters of Time Accumulator

Page | 18
PLC & Industrial Drives LAB Lab 4
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 executes on 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 "TagTime", then the query of the timer status
("MyIEC_TIMER) will return the signal state "1" and the operand "Tag_Output" will be set.
9. ---(RT)---: Reset timer
You can use the "Reset timer" instruction to reset an IEC timer to "0". The instruction is only
executed if the result of logic operation (RLO) at the input of the coil is "1". If current is flowing to
the coil (RLO is "1"), the structure components of the timer in the specified data block are reset to
"0". If the RLO at the input of the instruction is "0", the timer remains unchanged.
The instruction does not influence the RLO. The RLO at the input of the coil is sent directly to the
output of the coil.
You assign the "Reset timer" instruction an IEC timer that has been declared in the program.
Updating of the actual values

Page | 19
PLC & Industrial Drives LAB Lab 4
The instruction data is updated only when the instruction is called and not each time the assigned
IEC timer is accessed. Querying the data is only identical from the call of the instruction to the next
call of the instruction.
Parameter
The following table shows the parameters of the "Reset timer" instruction":
Data type Memory
Parameter Declaration Description
S7-1200 S7-1500 area
IEC_TIMER, IEC_TIMER, IEC_LTIMER,
TP_TIME, TP_TIME, TP_LTIME,
<IEC IEC timer
Output TON_TIME, TON_TIME, TON_LTIME, D, L
timer> that is reset.
TOF_TIME, TOF_TIME, TOF_LTIME,
TONR_TIME TONR_TIME, TONR_LTIME
You can find additional information on valid data types under "See also".
Example
The following example shows how the instruction works:

The "Generate on-delay" instruction executes when the signal state of the "Tag_Input_1" operand
changes from "0" to "1". The timer stored in the "TON_DB" instance data block starts running for
the time duration specified by operand "Tag_PT".

If operands "Tag_Input_2" and "Tag_Input_3" have the signal state "1", the "Reset timer"
instruction is executed and the timer stored in the "TON_DB" data block.
10. ---(PT)---: Load time duration
You can use the "Load time duration" instruction to set the time for an IEC timer. The instruction is
executed in every cycle when the result of logic operation (RLO) at the input of the instruction has
the signal state "1". The instruction writes the specified time to the structure of the specified IEC
timer.
Specify the duration that is loaded under the instruction at <Operand1> (duration) and specify the
IEC time to be started above the instruction at <Operand2> (IEC time).
You assign an IEC timer declared in the program to the "Load time duration" instruction.
Note
If the specified IEC timer is running while the instruction executes, the instruction overwrites the
current time of the specified IEC timer. This can change the timer status of the IEC timer.
Updating of the actual values
The instruction data is updated only when the instruction is called and each time the assigned IEC
timer is accessed. The query on Q or ET (for example, "MyTimer”. Q or "MyTimer".ET) updates
the IEC_TIMER structure.
Parameter
The following table shows the parameters of the "Load time duration" instruction:
Page | 20
PLC & Industrial Drives LAB Lab 4
Data type Memory
Parameter Declaration Description
S7-1200 S7-1500 area
I, Q, M, Duration with
<Time
Input TIME TIME, LTIME D, L or which the IEC
duration>
constant timer runs.
IEC_TIMER,
IEC_TIMER, IEC_LTIMER, TP_TIME,
TP_TIME, TP_LTIME, TON_TIME, IEC timer, the
<IEC
Output TON_TIME, TON_LTIME, TOF_TIME, D, L duration of
timer>
TOF_TIME, TOF_LTIME, which is set.
TONR_TIME TONR_TIME,
TONR_LTIME
Table 9: Parameters of Load Time Duration

You can find additional information on valid data types under "See also".
Example
The following example shows how the instruction works:

The "Generate on-delay" instruction executes when the signal state of the "Tag_Input_1" operand
changes from "0" to "1". The IEC timer stored in the instance data block "TON_DB" is started with
the time duration that is specified by the operand "Tag_PT".

The "Load time duration" instruction is executed when the operand "Tag_Input_2" has the signal
state "1". The instruction writes the time duration "Tag_PT_2" in the instance data block
"TON_DB" and at the same time overwrites the value of the operand "Tag_PT" within the data
block. The signal state of the timer status may therefore change at the next query or when
"MyTimer”. Q or "MyTimer".ET are accessed.

Page | 21
PLC & Industrial Drives LAB Lab 4
Task1: Write a ladder logic program to start a motor with 20sec delay after the start
push button is pressed (Note: using ON-delay Timer).
Task2: Make a program to stop motor used in task 1 after 30sec (NOTE: using Off
delay timer).
Task3: Using a push button reset both timers used in task 1 & task 2 using TR
assignment.
Task4: Write running light circuit program in which 10 LEDs turn on and off
sequentially with 5 sec delays.
Task5: Write a ladder logic program to control the traffic flow during the road
underwork. If the traffic light system is switched on both traffic light must initially
indicate red for 10 sec. Then both of the traffic lights will indicate Green for 5sec
reciprocally, after every mutual phase of Red. When the traffic light signal is switched
off with pish button both traffic lights must indicate Red for 10sec.
Task6: A pedestrian light system is controlled with a PLC system. (Note: When
pushbutton -S2 is pressed, the traffic lights for vehicles are switched to "amber
flashing light". If pushbutton -S3 is activated afterwards, the automatic mode is
started and all the traffic lights switch to "red". After a certain delay period and a short
amber phase, the traffic lights for vehicles switch to "green". When requested by
pedestrians by pressing pushbutton-S1, the traffic lights for vehicles switch to "red"
after a certain delay time and a short amber phase and then back to "green". The
pedestrian lights switch to "red" after an adequately long green phase. You must
always be able to switch off the control with pushbutton S0.)
Task7: Make a ladder logic program for two-way traffic light signals.
Task8: The collecting belt conveyor can be loaded via four feeding conveyors. The
feeding conveyors must only be corrected of switched on when the conveyor monitor
indicates a correct closed-circuit condition for the collecting belt conveyor. (Note: To
prevent the collecting belt conveyor from being overloaded, only two feeding
conveyors must be switches on simultaneously. If two conveyors load the collecting
belt conveyor simultaneously, the connection of the other two conveyors must be
prevented with an appropriate lock. The closed-circuit condition of the four feeding
conveyors must be indicated with the pilot lamps-P1 to -P4.)

Page | 22

You might also like