Sunteți pe pagina 1din 12

Department of Electrical Engineering

Faculty Member: Jawad Arif Dated: April 12, 2020

Semester: 8th Section: B

EE-428: Industrial Process Control

Lab 9: Counter Instructions

PLO4 PLO5 PLO8 PLO9


Name Reg. No Viva / Analysis Modern Ethics and Individual
Quiz / Lab of data in Tool Safety and Team
Performan Lab Usage Work
ce Report

5 Marks 5 Marks 5 Marks 5 Marks 5 Marks


Hassan Kamran 176530

Muhammad Ali Haider 179947

Hamza Azam Malik 192200

Abdullah Ashfaq 129399

Waleed Khan 199345


Objective
 To program and test PLC ladder programs that use counter instructions.

Introduction
PLC counter instructions are output instructions that can be used to activate or deactivate a PLC output
after a specific number of events have occurred. A counter instruction counts the number of times that the
rung in which it is contained makes transitions. Rung transitions can be caused by events such as parts
moving past a sensor or actuating a limit switch.

PLC counter instructions have the following parameters: an accumulated value and a preset value.

The accumulated value is the number of transitions made by the rung of the counter instruction since
this instruction was last reset.

The preset value specifies the final value that the accumulated value must reach. With the PLC on your
trainer, the preset value can be set between -32 768 and +32 767.

Since counter instructions are retentive, they retain their accumulated value when the rung in which they
are contained becomes false. Once the accumulated value has reached the preset value, counter
instructions continue to increase or decrease their accumulated value past the preset value.
Consequently, counter instructions must be used in conjunction with reset instructions to permit resetting
of their accumulated value to zero.

Notice that the accumulated value of counter instructions is also retained when the PLC is switched from
the Run mode to another mode or turned off. When the PLC is switched to the Run mode again or power
is restored to the PLC, counter instructions resume counting starting from the accumulated value.

Counter Instructions of the Trainer PLC

The PLC on your PLC Trainer has the following types of counter instructions:

 Count Up Instruction (CTU)

The CTU instruction increases its accumulated value by one count on each false-to- true transition of
the rung in which it is contained. When the accumulated value becomes equal to the preset value, the
Done (DN) bit of the CTU instruction is set to logic state 1. Thereafter, the CTU instruction continues
to increase its accumulated value and its DN bit remains set to logic state 1 until the associated Reset
instruction is made true. When this occurs, the accumulated value is reset to zero and the DN bit is
reset to logic state 0.

 Count Down Instruction (CTD)

The CTD instruction decreases its accumulated value by one count on each false- to-true transition
of the rung in which it is contained. When the accumulated value becomes lower than the preset
value, the Done (DN) bit of the CTD instruction is set to logic state 0. Thereafter, the CTD instruction
continues to decrease its accumulated value and its DN bit remains set to logic state 0 until the
associated Reset instruction is made true. When this occurs, the accumulated value is reset to zero
and the DN bit is reset to logic state 1.

Counter Status Bits


As Table 6-1 shows, counter instructions are represented in the memory of the trainer PLC in the
form of 3-word elements. Word 0 is the control word. Word 1 stores the preset value. Word 2 stores
the accumulated value.

Word B15 B14 B13 B12 B11 B10 B9 B8 B7 B6 B5 B4 B3 B2 B1 B0

0 CU CD DN OV UN Internal Use
1 Preset Value (PRE)
2 Accumulated Value (ACC)

Table 6-1. Data file structure of counter instructions.

Word 0 includes status bits that provide important information on the counting process. These bits are
the Count Up enable (CU) bit, the Count Down enable (CD) bit, the Done (DN) bit, the Overflow (OV)
bit, and the Underflow (UN) bit. They are described below.

Procedure:

Setting up the Equipment


1. Connect the RS-232 serial port of the computer station to the communications port of the PLC on
the PLC Trainer, using a 1761-CBL-PM02 cable.

2. Turn on the computer and start RSLogix Micro. Turn on the PLC Trainer.

3. In this exercise, you will study the operation of PLC instructions through observation of the ladder
program view, the data files of the processor, as well as the status of the lamps next to the PLC output
jacks on the trainer front panel.

The CTU Instruction


4. Create a new project having the following processor name: EXERC_6.

The project tree of processor EXERC_6 and program file LAD 2 should be displayed in the
RSLogix Micro window. Program file LAD 2 contains the main ladder program.
The next steps of this procedure consist in entering the ladder program of Figure 6-1.
Figure 6-1. The count up (CTU) instruction.

5. Select the User category of instructions by clicking the corresponding instruction category selection
tab.

Insert a new rung into program file LAD 2. In this rung, enter instruction XIC I:0/0. Then, enter
instruction CTU C5:0 by performing the following steps:

– Select the Timer/Counter category of instructions by clicking the corresponding instruction


category selection tab.
– Click the Count Up button on the instruction toolbar to insert this instruction in the rung, type:
C5:0, then press the mouse left button to enter this address.
– Double-click Preset within instruction CTU C5:0, type: 10, then press the mouse left button to
accept this value.
– Leave the Accumulated value of instruction CTU C5:0 at 0. This completes the parameter
setting for instruction CTU C5:0.

6. Select the User category of instructions by clicking the corresponding instruction category selection
tab.

Enter a new rung into program file LAD 2. In this rung, enter instruction XIC C5:0/CU. To do so,
click the Examine if Closed button on the instruction toolbar, type: C5:0/CU, then click the
mouse left button to enter this address. Enter instruction OTE O:0/0.

7. Enter a new rung into program file LAD 2. In this rung, enter instruction XIC C5:0/DN, then enter
instruction OTE O:0/1.
8. Enter a new rung into program file LAD 2. In this rung, enter instruction XIC C5:0/OV, then enter
instruction OTE O:0/2.

9. Enter a new rung into program file LAD 2. In this rung, enter instruction XIC I:0/1. Then, enter
instruction RES T4:0. To do so, select the Timer/Counter category of instructions by clicking the
corresponding instruction category selection tab. Click the Reset button on the instruction toolbar to insert
this instruction in the rung, type: C5:0, then press the mouse left button to enter this address.

10. By using the Verify Rung command, verify the rungs that have been edited. Correct any errors.

11. Save the project in a project file named EXERC_6.RSS.

12. Make sure the system communications are properly configured.

13. Download project EXERC_6 to the PLC. Go online and place the PLC in the Run mode.

14. Open data file C5 - COUNTER. Observe that the corresponding window displays the status bits of
instruction CTU C5:0, that is, the CU, DN, and OV bits, as well as the preset value and accumulated
value of this instruction.

 What is the logic state of the CU, DN, and OV status bits of instruction CTU C5:0? Why?

CU bit = 0
DN bit = 0
OV bit = 0
It is because the rung containing the CTU instruction is not TRUE yet.

15. While observing data file C5 - COUNTER and the ladder program, activate PLC input 0, using one of
the toggle switches of the trainer.

 What happens to the accumulated value upon activation of this input? Why?

The accumulated value becomes 1 because as the rung containing CTU instruction goes from
FALSE to TRUE it counts up by one.

16. Deactivate PLC input 0.

 Does the accumulated value remain at 1 even if the rung containing instruction CTU C5:0
(rung 0) becomes false?

Yes

17. Activate and deactivate PLC input 0 several times until the accumulated value is equal to the preset
value of 10. While doing this, observe that the accumulated value is increased by one count on each
false-to-true transition of the rung containing instruction CTU C5:0 (rung 0).

 Deactivate and activate PLC input 0 several times again. Is the accumulated value
increased past the preset value of 10?

Yes

18. Activate PLC input 1, using another toggle switch of the trainer.
 Does the accumulated value of instruction CTU C5:0 return to zero upon activation of PLC
input 1? Why?

Yes it does because activating input 1 makes the rung TRUE that contains the RES (reset)
instruction that resets the accumulated value and all the bit values of the counter..

19. Deactivate PLC input 0, then deactivate PLC input 1.

20. Activate PLC input 0 and observe what happens to the CU status bit of instruction CTU C5:0 and to
PLC output lamp 0 on the trainer front panel.
Record your observations below and explain why this occurs.

The CU status bit becomes 1 showing that the counter has counted up and the lamp 0 is also lit
showing the same thing

21. Deactivate PLC input 0.

 What happens to the CU status bit of instruction CTU C5:0 and to PLC output lamp 0 on
the trainer front panel? Explain.

It becomes 0 because the rung containing the CTU instruction is now FALSE and does not count
up when the transition is from TRUE to FALSE.

22. Activate and deactivate PLC input 0 several times until the accumulated value is equal to 9.

Deactivate and activate PLC input 0 once more and observe what happens to the DN status bit of
instruction CTU C5:0 and to PLC output lamp 1 on the trainer front panel.
Record your observations below and explain why this occurs.

DN status bit becomes 1 showing that the accumulated value has become equal to the preset
value. It also indicated the completion of the counting that was required to be done by this
counter instruction.

23. Deactivate and activate PLC input 0 several times again.

 Does the DN status bit remain set to logic state 1? Why?

Yes because the accumulated value has now crossed the preset value and will only be set to logic state 0
when the counter is reset.

24. Activate PLC input 1.

 What happens to the DN status bit of instruction CTU C5:0 and to PLC output lamp 1 on
the trainer front panel? Why?

DN status bit becomes 0 because the counter has been reset by activating input 1.

25. Deactivate PLC input 0, then deactivate PLC input 1.

26. Change the accumulated value of instruction CTU C5:0 to 32 767 while online. To do so, perform the
following steps:
– In rung 0 of the main ladder program, double-click Accum within instruction CTU C5:0.
– Type: 32767, then press the mouse left button to accept this value.

27. Open data file C5 - COUNTER, if it has closed. Observe that the DN status bit is at logic state 1,
since the accumulated value of 32 767 is greater than the preset value of 10.

Activate PLC input 0.

 What happens to the accumulated value and to the DN and OV status bits of instruction
CTU C5:0?

The accumulated value become -32768 and the DN and OV bits are at logic state 1.

28. Deactivate and activate PLC input 0 several times.

 Does the accumulated value continue to be increased, from -32 768 toward the maximum
positive value of +32 767, and do the DN and OV status bits remain at logic state 1?

Yes

29. Activate PLC input 1.

 What happens to the accumulated value and to the DN and OV status bits? Explain.

Accumulated value becomes 0 because the counter has been reset. The DN and OV bit also go
to the logic state 0 when the counter is reset.

30. On the PLC Trainer, make sure that all PLC inputs are deactivated.

31. Place the PLC in the Program mode and go offline. A message box should appear, asking if you
want to save the changes made to project EXERC_6. Click the No button to close the message box
without saving any changes.

The CTD Instruction


32. Modify the existing main ladder program of project EXERC_6 as indicated below in order to obtain the
ladder program shown in Figure 6-2:
Figure 6-2. The count down (CTD) instruction.

33. Using the Save As command in the File menu, save the new main ladder program in a project file
named EXERC_6a.RSS.

34. Download project EXERC_6a to the PLC of the PLC Trainer. Go online and place the PLC in the Run
mode.

35. Open data file C5 - COUNTER. Observe that the corresponding window displays the status bits of
instruction CTD C5:0, that is, the CD, DN, and UN bits, as well as the preset value and accumulated
value of this instruction.

 What is the logic state of the CD, DN, and UN bits? Why?

CD bit = 0
UN bit = 0
DN bit = 1
It is because the rung containing the CTD instruction is not yet TRUE. DN bit is 1 because the
CTD instruction keeps DN bit 1 even when the rung is FALSE.

36. While observing data file C5 - COUNTER and the ladder program, activate PLC input 0, using one of
the toggle switches of the trainer.

 What happens to the accumulated value? Why?

The accumulated value becomes -1 because the CTD instruction counts down by one when the
rung in which it is present changes its state from FALSE to TRUE.

37. Deactivate PLC input 0.

 Does the accumulated value remain at -1 even if the rung containing instruction CTD C5:0
(rung 0) becomes false?
Yes

38. Activate and deactivate PLC input 0 several times until the accumulated value is equal to the preset
value of -10. While doing this, observe that the accumulated value is decreased by one count on each
false-to-true transition of the rung containing instruction CTD C5:0 (rung 0).
Deactivate and activate PLC input 0 several times again.

 Is the accumulated value decreased past the preset value of -10?

Yes

39. Activate PLC input 1, using another toggle switch of the trainer.

 Does the accumulated value of instruction CTD C5:0 return to zero? Why?

Yes because activating input 1 makes the RES instruction rung TRUE which resets the counter’s
initial state.

40. Deactivate PLC input 0, then deactivate PLC input 1.

41. Activate PLC input 0 and observe what happens to the CD status bit of instruction CTD C5:0 and to
PLC output lamp 0 on the trainer front panel.
Record your observations below and explain why this occurs.

The CD status bit becomes 1 and the lamp 0 is also lit because as the rung containing the CTD
instruction become TRUE the counter counts down by one which is shown by CD bit.

42. Deactivate PLC input 0.

 What happens to the CD status bit of instruction CTD C5:0 and to PLC output lamp 0 on
the trainer front panel? Explain.

It becomes 0 because the counter counts down by one only when the rung containing the CTD
instruction goes from FALSE to TRUE.

43. Activate and deactivate PLC input 0 several times until the accumulated value is equal to -10.
Deactivate and activate PLC input 0 once more and observe what happens to the DN status bit of
instruction CTD C5:0 and to PLC output lamp 1 on the trainer front panel.
Record your observations below and explain why this occurs.

The DN status bit becomes 0 and the lamp 1 is OFF because the accumulated value and the
preset value became equal.

44. Deactivate and activate PLC input 0 several times again.

 Does the DN status bit remain set to logic state 0? Why?

Yes it does because once the accumulated value becomes equal to the reset value the DN status
bit becomes and remains 0.

45. Deactivate PLC input 0.


46. Activate and then deactivate PLC input 1.

 What happens to the DN status bit of instruction CTD C5:0 and to PLC output lamp 1 on
the trainer front panel?

DN status bit turns to logic state 1 and the lamp 1 is ON because the counter has been reset.

47. Change the accumulated value of instruction CTD C5:0 to -32 768 while online. To do so, perform the
following steps:

– In rung 0 of the main ladder program, double-click Accum within instruction CTD C5:0.
– Type: -32768, then press the mouse left button to accept this value.

48. Open data file C5 - COUNTER, if it has closed. Observe that the DN status bit is at logic state 0,
since the accumulated value of -32 768 is lower than the preset value. Activate PLC input 0.

 What happens to the accumulated value and to the DN and UN status bits of instruction
CTD C5:0?

Accumulated value becomes 32767.


DN bit is 0.
UN bit is 1.

49. Deactivate and activate PLC input 0 several times.

 Does the accumulated value continue to be decreased from 32 767 toward the maximum
negative value of -32 768?

Yes

 Does the DN bit remain at logic state 0 and the UN bit at logic state 1?

Yes

50. Deactivate PLC input 0.

51. Activate and then deactivate PLC input 1.

 What happens to the accumulated value and to the DN and UN status bits of instruction
CTD C5:0? Explain.

DN bit is 1.
UN bit is 0.
DN and UN bits are reset to the original logic states when the RES instruction rung is TRUE.

52. Place the PLC in the Program mode and clear the PLC memory. A message box will then appear,
asking you if you want to save the changes made to project EXERC_6a. Click the No button to close the
message box without saving any changes.

53. Close RSLogix Micro. Turn off the computer.

54. On the PLC Trainer, make sure that all PLC inputs are deactivated. Turn off the PLC Trainer.
Remove all the switch connection leads, set all the switch toggles downward, and return all the
equipment.

Conclusion
In this exercise, you familiarized yourself with the counter instructions of the trainer PLC: the count up
(CTU) instruction and the count down (CTD) instruction. You saw that these retentive-type instructions
have two parameters: an accumulated value and a preset value.

The CTU instruction increases its accumulated value by one count on each false-to-true rung transition.
When the accumulated value reaches the preset value, the Done (DN) bit is set to logic set 1. When the
associated Reset instruction is made true, the accumulated value is reset to zero and the DN bit is reset
to logic state 0.

The CTD instruction decreases its accumulated value by one count on each false-to-true rung transition.
When the accumulated value becomes lower than the preset value, the DN bit is set to logic state 0.
When the associated Reset instruction is made true, the accumulated value is reset to zero and the DN
bit is reset to logic state 1.

REVIEW QUESTIONS
1. What is the accumulated value of a counter instruction?

The accumulated value is the number of transitions made by the rung of the counter instruction since
this instruction was last reset.

2. Why are counter instructions used in conjunction with Reset instructions?

The Reset (RES) instruction must be used to reset the accumulated value of a CTU or CTD instruction.
The Reset instruction must be programmed with the same address as the CTU or CTD instruction that
you want to reset. When true, the Reset instruction resets the accumulated value to zero, and it resets to
logic state 0 the CU, CD, OV, and UN counter status bits.

3. Briefly describe the operation of the count up (CTU) instruction of the trainer PLC.

The CTU instruction increases its accumulated value by one count on each false-to- true transition of the
rung in which it is contained. When the accumulated value becomes equal to the preset value, the Done
(DN) bit of the CTU instruction is set to logic state 1. Thereafter, the CTU instruction continues to increase
its accumulated value and its DN bit remains set to logic state 1 until the associated Reset instruction is
made true. When this occurs, the accumulated value is reset to zero and the DN bit is reset to logic state
0.

4. Are the following statements about the count down (CTD) instruction of the trainer PLC
true or false? Explain.
 The CTD instruction decreases its accumulated value by one count on each true-to-false
rung transition.

FALSE. It decreases its accumulated value by one count on each FALSE to TRUE transition.

 When the accumulated value becomes lower than the preset value, the DN bit is set to
logic state 1.

TRUE. The negative accumulated value and the negative preset value in consideration for this answer.

 When the associated Reset instruction is made true, the accumulated value is reset to zero
and the DN bit is reset to logic state 0.

FALSE. When the associated Reset instruction is made true, the accumulated value is reset to
zero and the DN bit is reset to logic state 1.

5. When is the Done (DN) bit of the count up (CTU) and count down (CTD) instructions of
the trainer PLC set to logic state 0? When is it set to logic state 1?

CTU DN bit:

DN bit is 0 when the accumulated value is lower than the preset value.
DN bit is 1 when the accumulated value becomes equal or greater than the preset value.

CTD DN bit:

DN bit is 0 when the accumulated value (-ive) is lower than or equal to the preset value (-ive).
DN bit is 1 when the accumulated value (-ive) is greater than the preset value (-ive).

S-ar putea să vă placă și