chapter 16 timers and counters
TRANSCRIPT
![Page 1: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/1.jpg)
Chapter 16
Timer and Counter Instructions
![Page 2: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/2.jpg)
Objectives
• Describe the function of an on-delay timer.• Describe the function of an off-delay timer.• Describe in what instances one would use a retentive timer. • Describe the function of an up counter.• Describe the function of a down counter.• Describe in what instances one would use an up counter versus
a down counter.• Define preset, accumulative value, and the timer or counter
address.• Explain how the various timers and counters are reset.
![Page 3: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/3.jpg)
T4, Timer File
• The timer file stores only timer elements.• An element is a word or group of words that work together as a
unit.• A timer is made of of three pieces or words.
– Preset value– Accumulated value– Status bits
• The preset value and accumulated value are 16-bit signed integers.
• Status bits are single bits that make up one 16-bit word.• These three words work together as a unit.
![Page 4: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/4.jpg)
One Timer Element Is Made of Three 16-bit Words
![Page 5: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/5.jpg)
Timer Addressing
• Sample timer element addressT4:2– T4 = timer file 4– :2 = timer element #2 (0-255 timer elements
per file)
![Page 6: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/6.jpg)
Sub-element
• A sub-element is part of an element addressable as a unit.
• The preset value and accumulated value are sub-elements of a timer.– T4:0.PRE– T4:0.ACC
![Page 7: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/7.jpg)
Timer Status Bits
• Timers have three status bits.
• Done bit (DN) is true when the accumulated value and preset are equal.
• Timer timing bit (TT) is true when the timer is timing.
• Enable bit (EN) is true when the timer instruction is enabled or true.
![Page 8: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/8.jpg)
Timer Bit Addressing
• Status bit addresses for timer file 4, timer element 2 (T4:2) are listed below:– T4:2/DN is the address for the done bit.– T4:2/EN is the address for the enable bit.– T4:2/TT is the address for the timer timing bit.
![Page 9: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/9.jpg)
Timer File T4
![Page 10: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/10.jpg)
C5, Counter File (1 of 2)
• The counter file stores only counter elements.
• An element is a word or group of words that work together as a unit.
• A counter is made of three pieces or words.– Preset value– Accumulated value– Status bits
![Page 11: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/11.jpg)
C5, Counter File (2 of 2)
• The preset value and accumulated value are 16-bit signed integers.
• Status bits are single bits that make up one 16-bit word.
• These three words work together as a unit.
![Page 12: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/12.jpg)
One Counter Element Is Made of Three 16-bit Words
![Page 13: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/13.jpg)
Counter Addressing
• Sample counter element address C5:2– C5 = timer file 5– :2 = counter element #2 (0-255 timer
elements per file)
![Page 14: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/14.jpg)
Sub-element
• A sub-element is part of an element addressable as a unit.
• The preset value and accumulated value are sub-elements of a counter.– C5:0.PRE– C5:0.ACC
![Page 15: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/15.jpg)
Counter Status Bits (1 of 2)
• Counters have five status bits.
• Done bit (DN) is true when the accumulated value and preset are equal.
• Count up enable bit (CU) is true when the up counter is true or enabled.
• Count down enable bit (CD) is true when the count down counter is enabled or true.
![Page 16: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/16.jpg)
Counter Status Bits (2 of 2)
• The overflow bit (OV) is true when the up counter has overflowed above +32767.
• The underflow bit (UN) is true when the down counter has underflowed below -32768.
• The update accumulator bit (UA) is a high-speed counter status bit for fixed SLC 500 PLCs.
![Page 17: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/17.jpg)
Counter Status Bit Addressing
• Status bit addresses for counter file 5, counter element 0 (C5:0) are listed below:– C5:0/DN is the address for the done bit.– C5:0/CU is the address for the count up enable bit.– C5:0/CD is the address for the count down enable bit.– C5:0/OV is the address for the count up overflow bit.– C5:0/UN is the address for the count down underflow
bit.
![Page 18: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/18.jpg)
Counter File C5
![Page 19: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/19.jpg)
SLC 500 On-delay Timer
![Page 20: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/20.jpg)
SLC 500 Timer Instructions
![Page 21: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/21.jpg)
SLC 500 On-delay Timer and Associated Status Bits
![Page 22: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/22.jpg)
SLC 500 Off-delay Timer
![Page 23: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/23.jpg)
SLC 500 Retentive Timer
![Page 24: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/24.jpg)
Retentive Timer and Its Reset Instruction
![Page 25: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/25.jpg)
SLC 500 Counters
![Page 26: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/26.jpg)
SLC 500 Count Up Counter
![Page 27: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/27.jpg)
SLC 500 Count Down Counter
![Page 28: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/28.jpg)
SLC 500 Count Down Counter Instruction
![Page 29: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/29.jpg)
Reset Instruction to Reset Counter C20:7
![Page 30: Chapter 16 timers and counters](https://reader035.vdocuments.us/reader035/viewer/2022081420/55557cb5b4c9055f5f8b4fb4/html5/thumbnails/30.jpg)
Using the Clear Instruction to Clear C5:0.ACC and C5:1.ACC