0% found this document useful (0 votes)
14 views8 pages

PLC Lab 6

Uploaded by

erengoculu
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)
14 views8 pages

PLC Lab 6

Uploaded by

erengoculu
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/ 8

PLC AUTOMATION SYSTEM LABORATORY

Lab 6 : Counter

OBJECTIVES
 To study the operation of different types of counters.
 To use the PLC counters and timers in a process control.
COUNTER INSTRUCTION

1. CTU: Count up
Description
You can use the "Count up" instruction to increment the value at output CV. When the
signal state at the CU input changes from "0" to "1" (positive signal edge), the
instruction executes and the current counter value at the CV output is incremented by
one. When the instruction executes for the first time, the current counter value at the
CV output is set to zero. The counter value is incremented each time a positive signal
edge is detected, until it reaches the high limit for the data type specified at the CV
output. When the high limit is reached, the signal state at the CU input no longer has
an effect on the instruction.
You can scan the counter status at the Q output. The signal state at the Q output is
determined by the parameter PV. If the current counter value is greater than or equal to
the value of the PV parameter, the Q output is set to signal state "1". In all other cases,
the Q output has signal state "0".
The value at the CV output is reset to zero when the signal state at input R changes to
"1". As long as the R input has signal state "1", the signal state at the CU input has no
effect on the instruction.

Note
Only use a counter at a single location in the program to avoid risk of counting errors

Each call of the "Count up" instruction must be assigned an IEC counter in which the
instruction data is stored. An IEC counter is a structure with one of the following data
types:
For S7-1200 CPU
Data block of system data type IEC_counter
Local tag
(global DB)

 CTU_SINT / CTU_USINT
 CTU_INT / CTU_UINT
 IEC_SCOUNTER /
 CTU_DINT / CTU_UDINT
IEC_USCOUNTER
 IEC_SCOUNTER /
 IEC_COUNTER / IEC_UCOUNTER
IEC_USCOUNTER
 IEC_DCOUNTER /
 IEC_COUNTER / IEC_UCOUNTER
IEC_UDCOUNTER
 IEC_DCOUNTER /
IEC_UDCOUNTER

You can declare an IEC counter as follows:


 Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
 Declaration as a local tag of the type CTU or IEC_COUNTER in the "Static" section
of a block (for example, #MyIEC_COUNTER)

When you insert the instruction in the program, the "Call options" dialog opens in
which you can specify whether the IEC counter is stored in its own data block (single
instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find it in the project tree in the "Program resources"
folder under "Program blocks > System blocks". For additional information on this
topic, refer to "See also".

The execution of the "Count up" instruction requires a preceding logic operation. It
can be placed within or at the end of the network.

Parameter
The following table shows the parameters of the "Count up" instruction:

Parameter Declaration Data type Memory area Description


I, Q, M, D, L or
CU Input BOOL Count input
constant

I, Q, M, T, C, D,
R Input BOOL Reset input
L, P or constant

Value at which
I, Q, M, D, L, P
PV Input Integers the output Q is
or constant
set.
Q Output BOOL I, Q, M, D, L Counter status
Integers, CHAR, Current counter
CV Output I, Q, M, D, L, P
DATE value
You can select the data type for the instruction from the "<???>" drop-down list of the
instruction box.
For additional information on valid data types, refer to "See also".

Example
The following example shows how the instruction works:

When the signal state of the "TagIn_1" operand changes from "0" to "1", the "Count
up" instruction executes and the current counter value of the operand "Tag_CV" is
incremented by one. With each additional positive signal edge, the counter value is
incremented until the high limit value of the data type (INT = 32767) is reached.
The value of the PV parameter is adopted as the limit for determining the "TagOut"
output. The "TagOut" output has signal state "1" as long as the current counter value is
greater than or equal to the value of the "Tag_PV" operand. In all other cases, the
"TagOut" output has signal state "0".

2. CTD: Count down


Description
You can use the "Count down" instruction to decrement the value at output CV. When
the signal state at the CD input changes from "0" to "1" (positive signal edge), the
instruction executes and the current counter value at the CV output is decremented by
one. When the instruction executes the first time, the counter value of the CV
parameter is set to the value of the PV parameter. Each time a positive signal edge is
detected, the counter value is decremented until it reaches the low limit value of the
specified data type. When the low limit is reached, the signal state at the CD input no
longer has an effect on the instruction.
You can scan the counter status at the Q output. If the current counter value is less
than or equal to zero, the Q output is set to signal state "1". In all other cases, the Q
output has signal state "0".
The value at the CV output is set to the value of the PV parameter when the signal
state at the LD input changes to "1". As long as the LD input has signal state "1", the
signal state at the CD input has no effect on the instruction
Note
Only use a counter at a single location in the program to avoid risk of counting errors

Each call of the "Count down" instruction must be assigned an IEC counter in which
the instruction data is stored. An IEC counter is a structure with one of the following
data types:
For S7-1200 CPU
Data block of system data type IEC_counter
Local tag
(global DB)
 CTD_SINT / CTD_USINT
 CTD_INT / CTD_UINT
 IEC_SCOUNTER /
 CTD_DINT / CTD_UDINT
IEC_USCOUNTER
 IEC_SCOUNTER /
 IEC_COUNTER / IEC_UCOUNTER
IEC_USCOUNTER
 IEC_DCOUNTER /
 IEC_COUNTER / IEC_UCOUNTER
IEC_UDCOUNTER
 IEC_DCOUNTER /
IEC_UDCOUNTER

You can declare an IEC counter as follows:


 Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
 Declaration as a local tag of the type CTD or IEC_COUNTER in the "Static" section
of a block (for example, #MyIEC_COUNTER)

When you insert the instruction in the program, the "Call options" dialog opens in
which you can specify whether the IEC counter is stored in its own data block (single
instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find it in the project tree in the "Program resources"
folder under "Program blocks > System blocks". For additional information on this
topic, refer to "See also".
The execution of the "Count down" instruction requires a preceding logic operation. It
can be placed within or at the end of the network

Parameter
The following table shows the parameters of the "Count down" instruction:

Parameter Declaration Data type Memory area Description


I, Q, M, D, L or
CD Input BOOL Count input
constant

I, Q, M, T, C, D,
LD Input BOOL Load input
L, P or constant

Value at which
I, Q, M, D, L, P
PV Input Integers the output Q is
or constant
set.
Q Output BOOL I, Q, M, D, L Counter status
Integers, CHAR, Current counter
CV Output I, Q, M, D, L, P
DATE value
You can select the data type for the instruction from the "<???>" drop-down list of the
instruction box.
For additional information on valid data types, refer to "See also".

Example
The following example shows how the instruction works:

When the signal state of the "TagIn_1" operand changes from "0" to "1", the "Count
down" instruction is executed and the value at the "Tag_CV" output is decremented by
one. With each additional positive signal edge, the counter value is decremented until
the low limit of the specified data type (INT = -32768) is reached.
The "TagOut" output has signal state "1" as long as the current counter value is less
than or equal to zero. In all other cases, the "TagOut" output has signal state "0".

3. CTUD: Count up and down


Description
You can use the "Count up and down" instruction to increment and decrement the
counter value at the CV output. If the signal state at the CU input changes from "0" to
"1" (positive signal edge), the current counter value is incremented by one and stored
at the CV output. If the signal state at the CD input changes from "0" to "1" (positive
signal edge), the counter value at the CV output is decremented by one. If there is a
positive signal edge at the CU and CD inputs in one program cycle, the current counter
value at the CV output remains unchanged.
The counter value can be incremented until it reaches the high limit of the data type
specified at the CV output. When the high limit value is reached, the counter value is
no longer incremented on a positive signal edge. When the low limit of the specified
data type is reached, the counter value is not decremented any further.
When the signal state at the LD input changes to "1", the counter value at the CV
output is set to the value of the PV parameter. As long as the LD input has the signal
state "1", the signal state at the CU and CD inputs has no effect on the instruction.
The counter value is set to zero when the signal state at the R input changes to "1". As
long as the R input has signal state "1", a change in the the signal state of the CU, CD
and LD inputs has no effect on the "Count up and down" instruction.
You can scan the current status of the up counter at the QU output. If the current
counter value is greater than or equal to the value of the PV parameter, the QU output
is set to signal state "1". In all other cases, the QU output has signal state "0".
You can scan the current status of the down counter at the QD output. If the current
counter value is less than or equal to zero, the QD output is set to signal state "1". In
all other cases, the QD output has signal state "0".
Note
Only use a counter at a single location in the program to avoid risk of counting errors.

Each call of the "Count up and down" instruction must be assigned an IEC counter in
which the instruction data is stored. An IEC counter is a structure with one of the
following data types:
For S7-1200 CPU

Data block of system data type IEC_counter


Local tag
(global DB)

 CTUD_SINT / CTUD_USINT
 CTUD_INT / CTUD_UINT
 IEC_SCOUNTER /
 CTUD_DINT / CTUD_UDINT
IEC_USCOUNTER
 IEC_SCOUNTER /
 IEC_COUNTER / IEC_UCOUNTER
IEC_USCOUNTER
 IEC_DCOUNTER /
 IEC_COUNTER / IEC_UCOUNTER
IEC_UDCOUNTER
 IEC_DCOUNTER /
IEC_UDCOUNTER

You can declare an IEC counter as follows:


 Declaration of a data block of system data type IEC_COUNTER (for example,
"MyIEC_COUNTER")
 Declaration as a local tag of the type CTUD or IEC_COUNTER in the "Static" section
of a block (for example, #MyIEC_COUNTER)

When you insert the instruction in the program, the "Call options" dialog opens in
which you can specify whether the IEC counter is stored in its own data block (single
instance) or as a local tag (multiple instance) in the block interface. If you create a
separate data block, you will find it in the project tree in the "Program resources"
folder under "Program blocks > System blocks". For additional information on this
topic, refer to "See also".
The execution of the "Count up and down" instruction requires a preceding logic
operation. It can be placed within or at the end of the network.

Parameter
The following table shows the parameters of the "Count up and down" instruction:

Parameter Declaration Data type Memory area Description


I, Q, M, D, L or
CU Input BOOL Count up input
constant
I, Q, M, D, L or Count down
CD Input BOOL
constant input

I, Q, M, T, C, D,
R Input BOOL Reset input
L, P or constant
I, Q, M, T, C, D,
LD Input BOOL Load input
L, P or constant
Value at which
I, Q, M, D, L, P
PV Input Integers the output QU is
or constant
set.
Status of the
QU Output BOOL I, Q, M, D, L
counter up
Status of the
QD Output BOOL I, Q, M, D, L
down-counter
Integers, CHAR, Current counter
CV Output I, Q, M, D, L, P
DATE value

You can select the data type for the instruction from the "<???>" drop-down list of the
instruction box.
For additional information on valid data types, refer to "See also".

Example
The following example shows how the instruction works:

If the signal state at the "TagIn_1" or "TagIn_2" input changes from "0" to "1"
(positive signal edge), the "Count up and down" instruction is executed. When there is
a positive signal edge at the "TagIn_1" input, the current counter value is incremented
by one and stored at the "Tag_CV" output. When there is a positive signal edge at the
"TagIn_2" input, the counter value is decremented by one and stored at the "Tag_CV"
output. When there is a positive signal edge at the CU input, the counter value is
incremented until it reaches the high limit of 32767. If input CD has a positive signal
edge, the counter value is decremented until it reaches the low limit value of INT = -
32768.
The "TagOut" output has signal state "1" as long as the current counter value is greater
than or equal to the value at the "Tag_PV" input. In all other cases, the "TagOut"
output has signal state "0".
The "TagOut_QD" output has signal state "1" as long as the current counter value is
less than or equal to zero. In all other cases, the "TagOut_QD" output has signal state
"0".
EXPERIMENTAL WORK

A PLC-controlled system operates as follows. If the Start button is pressed, MV1 will be opened and
dye starts to fill the tank. At the same time mixing-motor begins to run. As the level of the dye passes
TBL2 and reaches to TBL1, MV1 will be closed and mixing-motor will stop. Then MV2 will be opened
and dye begins to run out of the container. After the level of the dye reaches to the below of TBL2, MV2
will be closed. The operator will determine the number of operation times will be repeated by using HMI
interface. Then the system will stop.

We can observe the stopping of the system with the lamp and the buzzer.

After the system stops, buzzer will continue to run for 2 sec and then it stops. But the lamp continues to
light until the reset button is pressed. When the reset button is pressed, the system will be ready to
begin the same process again. Use the HMI interface to show which process is applied. Construct a
LAD diagram and HMI interface for this system.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy