0% found this document useful (0 votes)
11 views9 pages

Lab4 COUNTER

Uploaded by

ductuan.12011996
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views9 pages

Lab4 COUNTER

Uploaded by

ductuan.12011996
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

INTERNATIONAL UNIVERSITY

SCHOOL OF ELECTRICAL ENGINEERING

Programmable Logic Control (PLC) Lab-EEAC007IU

LAB 4: COUNTER

Full name: …………………………………………


Student’s ID: ……………………………………….
Class/Group: ……………………………………....
Date: ……………………………………………….

Programmable Logic Control (PLC) Lab Page 1 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

I. OBJECTIVES
 Understand the counter types of PLC s7-1200
 Apply the knowledge to several examples and experiments

II. INTRODUCTION
Counters are provided as built-in elements in PLC. Counters compare an accumulated value to
a preset value to control circuit functions. Control applications that commonly use counters
include the following:
 Count to a preset value and cause an event to occur
 Cause an event to occur until the count reaches a preset value
There are 3 main counters:
1. CTU (Counter Up)
2. CTD (Counter Down)
3. CTUD (Counter Up and Down)
Counters are represented by boxes in ladder logic. Counters increment/decrement one point
each time the input transitions from off (logic 0) to on (logic 1). The counters are reset when a
RESET instruction is executed. In Siemens, counters are depicted as

a) b) c)
Figure 1. a) Counter up, b) Counter Up/Down, c) Counter Down

Further information of the three counters are summarized in the table below

Programmable Logic Control (PLC) Lab Page 2 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

Input /Output Data Type Description


CU, CD Bool Counting up, Counting
down
R (CTU, CTD) Bool Reset the value to 0
LOAD (CTU, CTD) Bool Assign a preset count value
to current count value
PV SInt, Int, DInt,… Preset count value
Q,QU Bool True if CV ≥ PV
QD Bool True if CV ≤ 0
CV SInt, Int, DInt,… Current count value
Table 1.
1. CTU (Count up)
"Count up" instruction is used to increment the value at output CV. When the signal state at the
CU input changes from "0" to "1"-PGT (positive signal edge), the instruction is executed and
the current counter value at the CV output is incremented by one. 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 output CV. When the high limit is reached, the signal state at the CU
input no longer has an effect on the instruction.

The counter status is shown through the Q output. The signal state at the Q output is
determined by the PV parameter. 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.

2. CTD (Count down)


"Count down" instruction is used to decrement the value at output CV. When the signal state at
the CD input changes from "0" to "1", the instruction is executed and the current counter value
at the CV output is decremented by one. Each time a positive signal edge is detected, the
counter value is decremented until it reaches the low limit 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.

Programmable Logic Control (PLC) Lab Page 3 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

The counter status can be shown through 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 Load input changes to "1". As long as the Load input has signal state "1",
the signal state at the CD input has no effect on the instruction.

3. CTUD: Count Up/Down


"Count up and down" instruction is used 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 is reached, the counter value is no longer incremented
on a positive signal edge. The counter value is no longer decremented once the low limit of the
specified data type has been reached. When the signal state at the Load input changes to "1",
the counter value at the CV output is set to the value of the PV parameter. As long as the Load
input has 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 signal state of the CU, CD and
Load inputs has no effect on the "Count up and down" instruction.

The status of the up counter can be shown 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". On the other hand, the status of the down
counter can be found 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".

Programmable Logic Control (PLC) Lab Page 4 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

III. EXERCISES (PRE-LAB)


Exercise 1. Build up the following ladder logic diagram

Write down the operation of the above circuit. Verify the results using the LEDs or alternative
outputs. Draw the logic waveforms at CU, R, Q, CV. Demonstrate it to the instructor.
Ans:

Exercise 2. Build up the following ladder logic diagram

Write down the operation of the above circuit. Verify the results using the LEDs or alternative
outputs. Draw the logic waveforms at CU, LD(LOAD), Q, CV. Demonstrate it to the
instructor.
Ans:

Programmable Logic Control (PLC) Lab Page 5 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

Exercise 3. Build up the following ladder logic diagram

Write down the operation of the above circuit. Verify the results using the LEDs or alternative
outputs. Draw the logic waveforms at CU, CD, R, LD (LOAD), QU, QD, CV. Demonstrate it
to the instructor.
Ans:

IV. Experiments
Experiment 1. Package Counter
A conveyor belt operated by a motor M is used to transport the products. The product is packed
inside a blank box whose maximum capacity is 10 products/box. The box will be moved along
the belt until it is full of 10 products. The conveyor belt is stopped and the operator will put
into a new blank box. The belt continues working after the operator presses the button S1.

Programmable Logic Control (PLC) Lab Page 6 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

The procedure keeps repeating and is stopped when a button S0 is pressed. Known that before
the product is packed inside the box, it needs to pass through a light sensor S2. Write a LAD
algorithm to describe the operation of the package counter.

Figure 1. Package counter

Experiment 2. Underground Car parking


An underground garage has 20 parking spaces available. In the front door of the garage, there
are two lights: red and blue to indicate the state of the garage: full and empty. The blue light
indicates that the garage still has available spaces while the red light indicates that the garage is
full. Given that the garage only allows one path of car moving; S1 and S2 are two sensors
used to indicate number of cars moving in/out.

Figure 2. Underground Car parking


Write a LAD algorithm to assist the operation of the underground garage.

Experiment 3. Dual conveyor belt fruit packing system


The conveyor belt shown in Figure 3 has two parts. The first part provides the box while the
second one provides the fruit.

Programmable Logic Control (PLC) Lab Page 7 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

Figure 3. Dual conveyor belt fruit packing system


Press START to let the first belt run. If position sensor is triggered, the box goes to the chosen
position and the belt will stop. Counter will then start counting the number of boxes which can
be set in advance. After that, the second belt starts running and it will move the fruit into the
box. The second sensor will detect 3 fruits (this number can be set up). During this time, the
belt stops and the conveyor belt will start moving again only the number of fruits packed in the
box is 3. The procedure repeats until it reaches the set number of boxes or press STOP button.

Write a LAD algorithm to the above system. Verify your results and show to the instructor.

Experiment 4. Liquid blending control system


The Liquid blending control system is shown in Figure 4 below.

Figure 4. Liquid blending control system

When pressing START, motor K1 rotates. As a result, liquid A firstly flows into a tank in
approximately 5s (S1 is detected) and liquid B will come next in line until the tank is full
(sensor S2 is detected). If the tank is full, motor K3 will rotate to mix the two liquids together
in 10s. After 10s, the valve K4 is opened to transfer all mixed liquid in the tank to another tank

Programmable Logic Control (PLC) Lab Page 8 of 9


INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING

completely. A whole procedure repeats and it is only stopped in emergency case when pressing
STOP button.

Write a LAD algorithm to the above system. Verify your results and show to the instructor.

Experiment 5: Automatic Sliding Door

Write a LAD algorithm to perform the following activities:


 When someone enters the infrared sensing field, open motor starts working to open the
door automatically till the door touches the opening limit switch
 If the door touches the opening limit switch for 7 seconds (or 7 counts) and nobody
enters the sensing field, the closing motor starts working to close the door automatically
till the closing limit switch touched together
 Stop the closing action immediately if someone enters the sensing field during the door
closing process

Programmable Logic Control (PLC) Lab Page 9 of 9

You might also like