Ebook Programmable logic controllers (Fifth edition): Part 1

202 19 0
Ebook Programmable logic controllers (Fifth edition): Part 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Part 1 of ebook Programmable logic controllers (Fifth edition) provide readers with content about: programmable logic controllers (PLCs) - an overview; PLC hardware components; number systems and codes; fundamentals of logic; basics of PLC programming; developing fundamental PLC wiring diagrams and ladder logic programs; programming timers; programming counters;... Please refer to the ebook for details!

Programmable Logic Controllers m This page intentionally left blank m Programmable Logic Controllers Fifth Edition Frank D Petruzella m PROGRAMMABLE LOGIC CONTROLLERS, FIFTH EDITION Published by McGraw-Hill Education, Penn Plaza, New York, NY 10121 Copyright © 2017 by McGraw-Hill Education All rights reserved Printed in the United States of America Previous editions © 2011, 2005, 1998 No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written consent of McGraw-Hill Education, including, but not limited to, in any network or other electronic storage or transmission, or broadcast for distance learning Some ancillaries, including electronic and print components, may not be available to customers outside the United States This book is printed on acid-free paper RMN/RMN ISBN 978-0-07-337384-3 MHID 0-07-337384-2 Senior Vice President, Products & Markets: Kurt L Strand Vice President, General Manager, Products & Markets: Marty Lange Vice President, Content Design & Delivery: Kimberly Meriwether David Managing Director: Thomas Timp Global Brand Manager: Raghu Srinivasan Director, Product Development: Rose Koos Product Developer: Vincent Bradshaw Marketing Manager: Nick McFadden Digital Product Developer: Amy Bumbaco, Ph.D Director, Content Design & Delivery: Linda Avenarius Executive Program Manager: Faye M Herrig Content Project Managers: Jessica Portz, Tammy Juran, Sandra Schnee Buyer: Laura M Fuller Content Licensing Specialist: Lorraine Buczek Compositor: MPS Limited Printer: R R Donnelley All credits appearing on page or at the end of the book are considered to be an extension of the copyright page Library of Congress Cataloging-in-Publication Data Petruzella, Frank D., author Programmable logic controllers / Frank D Petruzella.—Fifth edition pages cm Includes index ISBN 978-0-07-337384-3 (alk paper)—ISBN 0-07-337384-2 (alk paper) controllers I Title TJ223.P76P48 2017 629.8’95—dc23 Programmable 2015035302 The Internet addresses listed in the text were accurate at the time of publication The inclusion of a website does not indicate an endorsement by the authors or McGraw-Hill Education, and McGraw-Hill Education does not guarantee the accuracy of the information presented at these sites mheducation.com/highered m Contents Preface viii Acknowledgments xi About the Author xii Chapter Programmable Logic Controllers (PLCs): An Overview 1.1 Programmable Logic Controllers 1.2 Parts of a PLC 1.3 Principles of Operation 1.4 Modifying the Operation 11 1.5 PLCs versus Computers 11 1.6 PLC Size and Application 12 Review Questions 15 Problems 16 Chapter PLC Hardware Components 2.1 2.2 2.3 2.4 2.5 17 The I/O Section Discrete I/O Modules Analog I/O Modules Special I/O Modules I/O Specifications Typical Discrete I/O Module Specifications Typical Analog I/O Module Specifications 2.6 The Central Processing Unit (CPU) 2.7 Memory Design 2.8 Memory Types 2.9 Programming Terminal Devices 2.10 Recording and Retrieving Data 2.11 Human Machine Interfaces (HMIs) Review Questions Problems 18 22 27 31 33 33 34 Chapter 46 3.1 3.2 3.3 3.4 3.5 3.6 3.7 Number Systems and Codes Decimal System Binary System Negative Numbers Octal System Hexadecimal System Binary Coded Decimal (BCD) System Gray Code 35 36 37 39 39 39 43 45 47 47 49 49 50 51 53 3.8 ASCII Code 3.9 Parity Bit 3.10 Binary Arithmetic 3.11 Floating Point Arithmetic Review Questions Problems 54 54 55 57 59 60 Chapter 61 Fundamentals of Logic 4.1 4.2 The Binary Concept 62 AND, OR, and NOT Functions 62 The AND Function 62 The OR Function 63 The NOT Function 64 The Exclusive-OR (XOR) Function 65 4.3 Boolean Algebra 65 4.4 Developing Logic Gate Circuits from Boolean Expressions 66 4.5 Producing the Boolean Equation for a Given Logic Gate Circuit 66 4.6 Hardwired Logic versus Programmed Logic 67 4.7 Programming Word Level Logic Instructions 70 Review Questions 72 Problems 72 Chapter Basics of PLC Programming 74 5.1 Processor Memory Organization 75 Program Files 75 Data Files 75 5.2 Program Scan 78 5.3 PLC Programming Languages 81 5.4 Bit-Level Logic Instructions 83 5.5 Instruction Addressing 86 5.6 Branch Instructions 87 5.7 Internal Relay Instructions 89 5.8 Programming Examine If Closed and Examine If Open Instructions 90 5.9 Entering the Ladder Diagram 91 5.10 Modes of Operation 93 5.11 Connecting with Analog Devices 93 Review Questions 95 Problems 96 v m Chapter Developing Fundamental PLC Wiring Diagrams and Ladder Logic Programs Chapter 98 6.1 6.2 6.3 6.4 6.5 6.6 Electromagnetic Control Relays 99 Contactors 100 Motor Starters 101 Manually Operated Switches 102 Mechanically Operated Switches 103 Sensors 104 Proximity Sensor 104 Magnetic Reed Switch 107 Light Sensors 107 Ultrasonic Sensors 109 Strain/Weight Sensors 110 Temperature Sensors 110 Flow Measurement 111 Velocity and Position Sensors 111 6.7 Output Control Devices 112 6.8 Seal-In Circuits 114 6.9 Electrical Interlocking Circuits 115 6.10 Latching Relays 116 6.11 Converting Relay Schematics into PLC Ladder Programs 121 6.12 Writing a Ladder Logic Program Directly from a Narrative Description 124 6.13 Instrumentation 127 Review Questions 128 Problems 129 Chapter Programming Timers 7.1 Mechanical Timing Relays 7.2 Timer Instructions 7.3 On-Delay Timer Instruction 7.4 Off-Delay Timer Instruction 7.5 Retentive Timer 7.6 Cascading Timers Review Questions Problems Chapter Programming Counters 8.1 8.2 Counter Instructions Up-Counter One-Shot Instruction 8.3 Down-Counter 8.4 Cascading Counters 8.5 Incremental Encoder-Counter Applications 8.6 Combining Counter and Timer Functions 8.7 High-Speed Counters Review Questions Problems vi 131 132 134 135 140 144 147 151 151 156 157 159 162 166 170 173 174 177 179 179 Program Control Instructions 9.1 9.2 9.3 9.4 9.5 Program Control Master Control Reset Instruction Jump Instruction Subroutine Functions Immediate Input and Immediate Output Instructions 9.6 Forcing External I/O Addresses 9.7 Safety Circuitry 9.8 Selectable Timed Interrupt 9.9 Fault Routine 9.10 Temporary End Instruction 9.11 Suspend Instruction Review Questions Problems Chapter 10 Data Manipulation Instructions 10.1 Data Manipulation 10.2 Data Transfer Operations 10.3 Data Compare Instructions 10.4 Data Manipulation Programs 10.5 Numerical Data I/O Interfaces 10.6 Closed-Loop Control Review Questions Problems Chapter 11 Math Instructions 11.1 Math Instructions 11.2 Addition Instruction 11.3 Subtraction Instruction 11.4 Multiplication Instruction 11.5 Division Instruction 11.6 Other Word-Level Math Instructions 11.7 File Arithmetic Operations Review Questions Problems Chapter 12 Sequencer and Shift Register Instructions 12.1 Mechanical Sequencers 12.2 Sequencer Instructions 12.3 Sequencer Programs 12.4 Bit Shift Registers 12.5 Word Shift Operations Review Questions Problems 184 185 185 188 190 193 195 197 200 201 201 202 203 203 207 208 208 216 221 224 226 230 231 234 235 236 238 239 240 242 245 247 248 252 253 255 259 264 272 277 277 Contents m Chapter 13 PLC Installation Practices, Editing, and Troubleshooting 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 PLC Enclosures Electrical Noise Leaky Inputs and Outputs Grounding Voltage Variations and Surges Program Editing and Commissioning Programming and Monitoring Preventive Maintenance Troubleshooting Processor Module Input Malfunctions Output Malfunctions Ladder Logic Program 13.10 PLC Programming Software Review Questions Problems Chapter 14 Process Control, Network Systems, and SCADA 14.1 14.2 14.3 14.4 14.5 14.6 Types of Processes Structure of Control Systems On/Off Control PID Control Motion Control Data Communications Data Highway Serial Communication DeviceNet ControlNet EtherNet/IP Modbus Fieldbus PROFIBUS-DP 14.7 Supervisory Control and Data Acquisition (SCADA) Review Questions Problems Chapter 15 ControlLogix Controllers Part Memory and Project Organization Memory Layout Configuration Project Tasks Programs 281 282 284 285 285 287 288 289 291 292 292 292 294 294 299 302 302 Part Part 305 306 308 310 311 315 316 322 322 322 325 325 326 326 326 Part Part 328 331 332 333 334 334 334 335 336 336 Part Routines Tags Structures Creating Tags Monitoring and Editing Tags Array Review Questions Bit-Level Programming Program Scan Creating Ladder Logic Tag-Based Addressing Adding Ladder Logic to the Main Routine Internal Relay Instructions Latch and Unlatch Instructions One-Shot Instruction Review Questions Problems Programming Timers Timer Predefined Structure On-Delay Timer (TON) Off-Delay Timer (TOF) Retentive Timer On (RTO) Cascading of Timers Review Questions Problems Programming Counters Counters Count-Up (CTU) Counter Count-Down (CTD) Counter Combining Counter and Timer Functions Review Questions Problems Math, Comparison, and Move Instructions Math Instructions Comparison Instructions Move Instructions Combining Math, Comparison, and Move Instructions Review Questions Problems Function Block Programming Function Block Diagram (FBD) FBD Programming Review Questions Problems 337 337 340 341 342 342 344 345 345 346 347 348 350 352 353 356 356 358 358 359 362 364 365 367 367 368 368 369 371 372 373 373 374 374 376 379 380 383 383 384 384 388 394 394 Glossary 395 Index 407 Contents vii m Preface Programmable logic controllers (PLCs) continue to evolve as new technologies are added to their capabilities As PLC technology has advanced, so have programming languages and communications capabilities Today’s PLCs offer faster scan times, space efficient high-density input/ output systems, and special interfaces to allow nontraditional devices to be attached directly to the PLC Now in its Fifth Edition, changes made to the content of the text have been made solely based on reviews from current instructors and include: • material that should be added or deleted from chapters • topics requiring more in-depth coverage • increased integration of the ControlLogix platform of controllers • chapter modifications require to meet current curriculum needs The primary source of information for a particular PLC is always the accompanying user manuals provided by the manufacturer This textbook is not intended to replace the vendor’s reference material, but rather to complement, clarify, and expand on this information The text covers the basics of programmable logic controllers in a manner that complements instruction with a SLC-500 or ControlLogix platform The underlying PLC principles and concepts covered in the text are common to most manufacturers They serve to maximize the knowledge gained through on-the-job training and programs offered by different vendors The text is written in an easy-to-read style that is designed for students with no prior PLC experience For example, when the operation of a program is called for, a bulleted list is used to summarize its execution The bulled list replaces a lengthy paragraph and is especially helpful when covering the different steps related to the execution of a program Each chapter begins with a brief introduction outlining chapter coverage and learning objectives When applicable, the relay equivalent of the virtual programmed instruction is explained first, followed by the appropriate PLC instruction Chapters conclude with a set of review questions and problems The review questions are closely related to the chapter objectives and require students to recall and apply information covered in the chapter The problems range from easy to difficult, thus challenging students at various levels of competence Features new to the Fifth Edition include: • Key concepts and terms are highlighted in bold the first time they appear • New/updated photos and line art for every chapter • New topics for every chapter as requested by reviewers • Addition review questions for new topics • Updated instructor PowerPoint lessons • More than 175 SLC-500 and ControlLogix program simulation videos tied directly to the programs studied in the text In addition, students who are using McGrawHill’s Connect can watch simulated, step-by-step execution of numerous ladder logic programming examples They’re guided by an audio commentary that explains what to look for as the program is executed The videos are part of the Student Resources section of Connect viii m Chapter changes in this edition include: Chapter • • • • • Testing of field devices Extended coverage of scan cycle sequence Additional test bank questions Program video simulations New and modified line diagrams and photos Chapter • ControlLogix Base and Alias addressing • Extended coverage of DC module Sinking and Sourcing • Analog module input sensor 2-, 3-, and 4-wire connections • Scaling of PLC analog inputs and outputs • Extended coverage of Human Machine Interfaces (HMIs) • Additional chapter review questions • Additional test bank questions • Program video simulations • New and modified line diagrams and photos Chapter • • • • • • 16 bit 2’s complement Floating point arithmetic Additional chapter problems Additional test bank questions Program video simulations New and modified line diagrams and photos Chapter • • • • • Modification to hardwired programming examples Additional test bank questions Additional chapter review questions Program video simulations New and modified line diagrams and photos Chapter • • • • Electrical versus logical continuity Evaluating XIO and XIC bit instructions Rack-based versus tag-based addressing Connecting with analog devices • • • • Additional test bank questions Additional chapter review questions Program video simulations New and modified line diagrams and photos Chapter • • • • • • • • Magnetic reed float switch Resistance temperature detectors (RTDs) Electrical interlocking circuits Process instrumentation Additional test bank questions Additional chapter review questions Program video simulations New and modified line diagrams and photos Chapter • • • • • • • • Extended coverage of timer instructions ControlLogix timer instruction Reciprocating timers TON timer bit table TOF timer bit table Additional test bank questions Program video simulations New and modified line diagrams and photos Chapter • • • • • • • ControlLogix counter instruction Extended coverage of CTD instruction Additional information on incremental encoders New section on High-Speed Counter instruction Additional test bank questions Program video simulations New and modified line diagrams and photos Chapter • Extended coverage of MCR instruction • Extended coverage of Jump instruction • Extended coverage of Immediate Input and Output instructions • ControlLogix Immediate Output instruction • Additional test bank questions • Program video simulations • New and modified line diagrams and photos Preface ix m Inputs Outputs Ladder logic program L1 Input A PB1 Input A PB2 Input B Input B Reset Input C CTU COUNT-UP COUNTER Counter C5:2 Preset 10 Accumulated CTD COUNT-DOWN COUNTER Counter C5:2 Preset 10 Accumulated C5:2 Output A CU C5:2 Output B CD C5:2 Output C L2 CU Output A A Output B B Output C C DN CU DN DN Input C C5:2 RES Figure 8-25 Up/down-counter program to true, one count is subtracted from the accumulated value The operation of the program can be summarized as follows: • When the CTU instruction is true, C5:2/CU will be true, causing output A to be true • When the CTD instruction is true, C5:2/CD will be true, causing output B to be true • When the accumulated value is greater than or equal to the preset value, C5:2/DN will be true, causing output C to be true • Input C going true will cause both counter instructions to reset When reset by the RES instruction, the accumulated value will be reset to and the done bit will be reset Figure 8-26 illustrates the operation of the up/downcounter program used to provide continuous monitoring of items in process An in-feed photoelectric sensor counts raw parts going into the system, and an out-feed photoelectric sensor counts finished parts leaving the machine The number of parts between the in-feed and out-feed is indicated by the accumulated count of the counter Counts applied to the up-input are added, and counts applied to the down-input are subtracted The operation of the program can be summarized as follows: • Before start-up, the system is completely empty of parts, and the counter is reset manually to • When the operation begins, raw parts move through the in-feed sensor, with each part generating an up count • After processing, finished parts appearing at the outfeed sensor generate down counts, so the accumulated count of the counter continuously indicates the number of in-process parts • The counter preset value is irrelevant in this application It does not matter whether the counter outputs are on or off The output on-off logic is not used We have arbitrarily set the counter’s preset values to 50 The maximum speed of transitions that you can count is determined by your program’s scan time For a reliable count, your counter input signal must be fixed for one scan time If the input changes faster than one scan period, the count value will become unreliable because counts will be missed When this situation occurs, you need to use a high-speed counter input or a separate counter I/O module designed for high-speed applications Programming Counters Chapter 169 Photoelectric sensor Photoelectric sensor Material processing system Out-feed (finished parts) In-feed (raw parts) (a) Inputs Ladder logic program IN-Feed count L1 CTU COUNT-UP COUNTER Counter C5:1 Preset 50 Accumulated IN-Feed count OUT-Feed count OUT-Feed count CU DN Accumulated = No in-process parts CTD COUNT-DOWN COUNTER Counter C5:1 Preset 50 Accumulated Reset to zero RESET Reset CD DN C5:1 RES (b) Figure 8-26 8.4 In-process monitoring program (a) Process (b) Program Cascading Counters Depending on the application, it may be necessary to count events that exceed the maximum number allowable per counter instruction One way of accomplishing this count is by interconnecting, or cascading, two counters The program of Figure  8-27 illustrates the application of the technique The operation of the program can be summarized as follows: • The output of the first counter is programmed into the input of the second counter • When the accumulated value of the second counter is equal to its preset, the DN bit will be true, which allows the first counter to count 170 Chapter Programming Counters • The status bits of both counters are programmed in series to produce an output • These two counters allow twice as many counts to be measured • A CTU instruction that is reset while the counter logic remains true will result in an accumulated value of instead of Using the OSR instruction in the counter enabling logic prevents this from happening Another method of cascading counters is sometimes used when an extremely large number of counts must be stored For example, if you require a counter to count up to 250,000, it is possible to achieve this by using only two counters Figure  8-28 shows how the Ladder logic program Inputs PB1 Count button L1 C5:0/DN B3:0/0 OSR PB1 Reset button B3:0/0 C5:0/DN First counter CTU COUNT-UP COUNTER Counter C5:1 Preset 32000 Accumulated Second counter CTU COUNT-UP COUNTER Counter C5:0 Preset 32000 Accumulated OSR PB2 Output C5:1/DN CU L2 Light DN CU DN Light PB2 C5:0 RES C5:1 RES Figure 8-27 Counting beyond the maximum count L1 Count B3:0/0 OSR PB1 Output Ladder logic program Inputs Count PB2 CTU COUNT-UP COUNTER Counter C5:1 Preset 500 Accumulated L2 CU DN Light Reset C5:1 DN CTU COUNT-UP COUNTER Counter C5:2 Preset 500 Accumulated C5:1 CU DN C5:1 RES DN Reset Reset C5:2 RES C5:2 Light DN Figure 8-28 Cascading counters for extremely large counts Programming Counters Chapter 171 two counters would be programmed for this purpose The operation of the program can be summarized as follows: • Counter C5:1 has a preset value of 500 and counter C5:2 has a preset value of 500 • Whenever counter C5:1 reaches 500, its done bit resets counter C5:1 and increments counter C5:2 by • When the done bit of counter C5:1 has turned on and off 500 times, the output light becomes energized Therefore, the output light turns on after 500 × 500, or 250,000, transitions of the count input Some PLCs include a real-time clock as part of their instruction set A real-time clock allows you to display the time of day or to log data pertaining to the operation of the process The logic used to implement a clock as part of a PLC’s program is straightforward and simple to accomplish A single timer instruction and counter instructions are all you need Figure  8-29 illustrates a timer-counter program that produces a time-of-day clock measuring time in hours and minutes The operation of the program can be summarized as follows: • An RTO timer instruction (T4:0) is programmed first with a preset value of 60 seconds • The T4:0 timer times for a 60-second period, after which its done bit is set • This, in turn, causes the up-counter (C5:0) of rung 001 to increment count • On the next processor scan, the timer is reset and begins timing again • The C5:0 counter is preset to 60 counts, and each time the timer completes its time-delay period, its count is incremented • When the C5:0 counter reaches its preset value of 60, its done bit is set • This, in turn, causes the up-counter (C5:1) of rung 002, which is preset for 24 counts, to increment 1 count • Whenever the C5:1 counter reaches its preset value of 24, its done bit is set to reset itself • The time of day is generated by examining the current, or accumulated, count or time for each counter and the timer • Counter C5:1 indicates the hour of the day in 24-h military format, while the current minutes 172 Chapter Programming Counters Ladder logic program Seconds RTO RETENTIVE TIMER ON Timer T4:0 Time base 1.0 Preset 60 Accumulated 000 T4:0/DN 001 C5:0/DN 002 Minutes CTU COUNT-UP COUNTER Counter C5:0 Preset 60 Accumulated Hours CTU COUNT-UP COUNTER Counter C5:1 Preset 24 Accumulated EN DN CU DN CU DN T4:0/DN T4:0 RES C5:0/DN C5:0 RES C5:1/DN C5:1 RES 003 004 005 Figure 8-29 24-hour clock program are represented by the accumulated count value of counter C5:0 • The timer displays the seconds of a minute as its current, or accumulated, time value The 24-hour clock can be used to record the time of an event Figure 8-30 illustrates the principle of this technique In this application the time of the opening of a pressure switch is to be recorded The operation of the program can be summarized as follows: • The circuit is set into operation by pressing the reset button and setting the clock for the time of day • This starts the 24-hour clock and switches the set indicating light on • Should the pressure switch open at any time, the clock will automatically stop and the trip indicating light will switch on • The clock can then be read to determine the time of opening of the pressure switch Ladder logic program Inputs Pressure switch L1 Reset Pressure switch Outputs Internal B3:0/0 L2 Set Internal B3:0/0 Reset Internal B3:0/0 Set Internal B3:0/0 Trip Internal B3:0/0 T4:0/DN C5:0/DN Figure 8-30 Seconds RTO RETENTIVE TIMER ON Timer T4:0 Time base 1.0 Preset 60 Accumulated Minutes CTU COUNT-UP COUNTER Counter C5:0 Preset 60 Accumulated Trip EN DN CU DN Hours CTU COUNT-UP COUNTER Counter C5:1 Preset 24 Accumulated CU DN T4:0/DN T4:0 RES C5:0/DN C5:0 RES C5:1/DN C5:1 RES Monitoring the time of an event 8.5 Incremental Encoder-Counter Applications Incremental encoders are used to track motion They provide a specific number of equally spaced pulses per revolution or per inch or millimeter of linear motion Incremental encoders output pulses each time and only when the shaft is turned The incremental optical encoder shown in Figure 8-31creates a series of square waves as its shaft is rotated The encoder disk interrupts the light as the encoder shaft is rotated to produce the square wave output waveform The number of square waves obtained from the output of the encoder can be made to correspond to the mechanical movement required For example, to divide a shaft revolution into 100 parts, an encoder could be selected to supply 100 square wave-cycles per revolution By using a counter to count those cycles, we could tell how far the shaft had rotated Figure 8-32 illustrates an example of cutting objects to a specified length The object is advanced for a specified distance and measured by encoder pulses to determine the correct length for cutting Figure 8-33 shows a counter program used for length measurement This system accumulates the total length Programming Counters Chapter 173 Optical sensor Wood Light source Cutter control Optical encoder Optical disk Generated pulses Rotary encoder Pulses Figure 8-32 Cutting objects to a specified length Lines Figure 8-31 • The photoelectric sensor monitors a reference point on the conveyor When activated, it prevents the unit from counting, thus permitting the counter to accumulate counts only when bar stock is moving • The counter is reset by closing the reset button Optical incremental encoder Source: Courtesy of Nidec Avtron Automation of random pieces of bar stock moved on a conveyor The operation of the program can be summarized as follows: • Count input pulses are generated by the magnetic sensor, which detects passing teeth on a conveyor drive sprocket • If 10 teeth per foot of conveyor motion pass the sensor, the accumulated count of the counter would indicate feet in tenths Sprocket 8.6 Combining Counter and Timer Functions Many PLC applications use both the counter function and the timer function Figure  8-34 illustrates an automatic stacking program that requires both a timer and counter Magnetic sensor Photoelectric sensor Conveyor Reflector (a) Ladder logic program L1 Inputs Magnetic sensor Photo sensor Magnetic sensor Photo sensor Reset 10 counts per foot CTU COUNT-UP COUNTER Counter C5:1 Preset 10 Accumulated CU DN C5:1 RES Reset (b) Figure 8-33 174 Chapter Programmable controller Counter used for length measurement (a) Process (b) Program Programming Counters Complete stack Metal plates M1 Conveyor Sensor Light source M2 Conveyor (a) Ladder logic program L1 Inputs M2 run time TON TIMER ON DELAY Timer Time base Preset Accumulated M2 Stop Stop Start Start M1 Photo sensor Outputs L2 EN T4:1 1.0 DN M1 M2 M1 M2 M2 T4:1 Photo sensor DN Number of plates CTU COUNT-UP COUNTER Counter C5:1 Preset 15 Accumulated CU DN M2 C5:1 DN T4:1 C5:1 RES DN Stop T4:1 T4:1 RES DN Stop (b) Figure 8-34 Automatic stacking program (a) Process (b) Program Programming Counters Chapter 175 In this process, conveyor M1 is used to stack metal plates onto conveyor M2 The photoelectric sensor provides an input pulse to the PLC counter each time a metal plate drops from conveyor M1 to M2 When 15 plates have been stacked, conveyor M2 is activated for s by the PLC timer The operation of the program can be summarized as follows: • When the start button is pressed, conveyor M1 begins running • After 15 plates have been stacked, conveyor M1 stops and conveyor M2 begins running • After conveyor M2 has been operated for s, it stops and the sequence is repeated automatically • The done bit of the timer resets the timer and the counter and provides a momentary pulse to automatically restart conveyor M1 Figure 8-35 shows a motor lock-out program This program is designed to prevent a machine operator from starting a motor that has tripped off more than times in an hour The operation of the program can be summarized as follows: • The normally open overload (OL) relay contact momentarily closes each time an overload current is sensed Ladder logic program L1 Inputs Start OL Stop T4:0 Lock-out light Motor EN Stop Motor Motor OL Start T4:0 DN OL T4:0 Reset PB EN T4:1 DN OL OL relay T4:1 TON TIMER ON DELAY Timer Time base Preset Accumulated T4:0 300 hr TON TIMER ON DELAY Timer Time base Preset Accumulated T4:1 3600 Lock-out light EN DN EN CTU COUNT-UP COUNTER Counter C5:0 Preset Accumulated DN CU DN C5:0 RES DN Reset-PB C5:0 Lock-out light L DN Reset-PB Lock-out L light U Figure 8-35 Motor lock-out program Source: This material and associated copyrights are proprietary to, and used with the permission of Schneider Electric 176 Chapter Programming Counters Outputs L2 Ladder logic program Inputs L1 Off timer TON TIMER ON DELAY Timer Time base Preset Accumulated Start SW On Start SW Start SW T4:1 Sensor Sensor DN Start SW EN T4:1 1.0 60 DN Total parts CTU COUNT-UP COUNTER Counter C5:1 Preset Accumulated CU DN C5:1 RES Figure 8-36 Product flow rate program Source: Photo courtesy Omron Industrial Automation, www.ia.omron.com • Every time the motor stops due to an overload condition, the motor start circuit is locked out for 5 min • If the motor trips off more than times in an hour, the motor start circuit is permanently locked out and cannot be started until the reset button is actuated • The lock-out pilot light is switched on whenever a permanent lock-out condition exists Figure  8-36 shows a product part flow rate program This program is designed to indicate how many parts pass a given process point per minute The operation of the program can be summarized as follows: • When the start switch is closed, both the timer and counter are enabled • The counter is pulsed for each part that passes the parts sensor • The counting begins and the timer starts timing through its 1-minute time interval • At the end of minute, the timer done bit causes the counter rung to go false • Sensor pulses continue but not affect the PLC counter • The number of parts for the past minute is represented by the accumulated value of the counter • The sequence is reset by momentarily opening and closing the start switch A timer is sometimes used to drive a counter when an extremely long time-delay period is required For example, if you require a timer to time to 1,000,000 s, you can achieve this by using a single timer and counter Figure 8-37 shows how the timer and counter would be programmed for such a purpose The operation of the program can be summarized as follows: • Timer T4:0 has a preset value of 10,000, and counter C5:0 has a preset value of 100 • Each time the timer T4:0 input contact closes for 10,000 s, its done bit resets timer T4:0 and increments counter C5:0 by • When the done bit of timer T4:0 has turned on and off 100 times, the output light becomes energized • Therefore, the output light turns on after 10,000 × 100, or 1,000,000, seconds after the timer input contact closes 8-7 High-Speed Counters The maximum counting frequency of a traditional PLC’s counter is limited by the scan time of the processor When the frequency of the input signal is higher than that of the scan time, it is necessary to utilize a high-speed counter (HSC), to avoid errors For example, using an incremental encoder in a length-measuring application generally requires the use of a high-speed counter The Programming Counters Chapter 177 Ladder logic program Input Timer input T4:0 L1 DN S1 Timer input T4:0 TON TIMER ON DELAY Timer Time base Preset Accumulated Output EN T4:0 1.0 10000 CTU COUNT-UP COUNTER Counter C5:0 Preset 100 Accumulated DN Timer input L2 DN Light CU DN C5:0 RES Light C5:0 DN Figure 8-37 Timer driving a counter to produce an extremely long time-delay period HSC High-speed counter Type Up Counter C5:0 Preset Accum Figure 8-38 CU CD DN • Program for Problem HSC instruction may be imbedded in the CPU, or fixed hardware, or a separate module Figure 8-38 shows a high-speed up-counter instruction for an Allen-Bradley MicroLogix controller This particular controller has an imbedded high-speed counter that is able to perform counts of events between the scan of the program Then, when the program actually scans through it can see the count value that the counter has reached • The controller has one 20 KHz high-speed counter, which means it would be able to count 20,000 pulses per second • The high-speed counter operates independently of the controller scan • The HSC instruction is used to configure, control, and monitor the controller’s internal hardware 178 • Chapter Programming Counters • • • counter Only one HSC instruction can be used in a program The high-speed counter instruction address is fixed at C5:0 This counter instruction can be programmed as either an up-counter or bidirectional (Up/Down) counter The hardware counter’s accumulator increments or decrements in response to external input signals The input filter response time is the time from the external input voltage reaching an on or off state to the micro controller recognizing that change of state The higher you set the response time, the longer it takes for the input state change to reach the micro controller However, setting higher response times also provides better filtering of high frequency noise When the high-speed counter is enabled, data table counter C5:0 is used by the ladder program for monitoring the high-speed counter accumulator and status CHAPTER REVIEW QUESTIONS Name the three forms of PLC counter instructions, and explain the basic operation of each State four pieces of information usually associated with a PLC counter instruction In a PLC counter instruction, what rule applies to the addressing of the counter and reset instructions? When is the output of a PLC counter energized? When does the PLC counter instruction increment or decrement its current count? The counter instructions of PLCs are normally retentive Explain what this means a Compare the operation of a standard Examineon contact instruction with that of an off-to-on transitional contact b What is the normal function of a transitional contact used in conjunction with a counter? Explain how an OSR (one-shot rising) instruction can be used to freeze rapidly changing data Identify the type of counter you would choose for each of the following situations: a Count the total number of parts made during each shift b Keep track of the current number of parts in a stage of a process as they enter and exit c There are 10 parts in a full hopper As parts leave, keep track of the number of parts remaining in the hopper 10 Describe the basic programming process involved in the cascading of two counters 11 a When is the overflow bit of an up-counter set? b When is the underflow bit of a down-counter set? 12 Describe two common applications for counters 13 What determines the maximum speed of transitions that a PLC counter can count? Why? CHAPTER PROBLEMS Study the ladder logic program in Figure 8-39, and answer the questions that follow: a What type of counter has been programmed? b When would output O:2/0 be energized? c When would output O:2/1 be energized? Ladder logic program I:1/1 CTU COUNT-UP COUNTER Counter C5:1 Preset 50 Accumulated Rung CU DN C5:1/DN O:2/0 C5:1/DN O:2/1 I:1/2 C5:1 Rung Rung Res Rung Figure 8-39 Program for Problem d Suppose your accumulated value is 24 and you lose ac line power to the controller When power is restored to your controller, what will your accumulated value be? e Rung goes true and, while it is true, rung goes through five false-to-true transitions of rung conditions What is the accumulated value of the counter after this sequence of events? f When will the count be incremented? g When will the count be reset? Study the ladder logic program in Figure 8-40, and answer the questions that follow: a Suppose the input pushbutton is actuated from off to on and remains held on How will the status of output B3:0/9 be affected? b Suppose the input pushbutton is now released to the normally off position and remains off How will the status of output B3:0/9 be affected? Study the ladder logic program in Figure 8-41, and answer the questions that follow: a What type of counter has been programmed? b What input address will cause the counter to increment? Programming Counters Chapter 179 Input L1 B3:0/1 B3:0/9 Input Input Figure 8-40 B3:0/1 Program for Problem Ladder logic program I:2/6 CTU COUNT-UP COUNTER Counter C5:2 Preset 25 Accumulated CU DN I:3/8 CTD COUNT-DOWN COUNTER Counter C5:2 Preset 25 Accumulated C5:2 CU DN O:6/2 DN I:4/1 C5:2 RES Figure 8-41 Program for Problem c What input address will cause the counter to decrement? d What input address will reset the counter to a count of zero? e When would output O:6/2 be energized? f Suppose the counter is first reset, and then input I:2/6 is actuated 15 times and input I:3/8 is actuated times What is the accumulated count value? Design a PLC program and prepare a typical I/O connection diagram and ladder logic program for the following counter specifications: • Counts the number of times a pushbutton is closed • Decrements the accumulated value of the counter each time a second pushbutton is closed 180 Chapter Programming Counters • Turns on a light anytime the accumulated value of the counter is less than 20 • Turns on a second light when the accumulated value of the counter is equal to or greater than 20 • Resets the counter to when a selector switch is closed Design a PLC program and prepare a typical I/O connection diagram and ladder logic program that will execute the following control circuit correctly: • Turns on a nonretentive timer when a switch is closed (preset value of timer is 10 s) • Resets timer automatically through a programmed transitional contact when it times out • Counts the number of times the timer goes to 10 s • Resets counter automatically through a second programmed transitional contact at a count of • Latches on a light at the count of • Resets light to off and counter to when a selector switch is closed Design a PLC program and prepare a typical I/O connection diagram and ladder logic program that will correctly execute the industrial control process in Figure 8-42 The sequence of operation is as follows: • Product in position (limit switch LS1 contacts close) • The start button is pressed and the conveyor motor starts to move the product forward toward position A (limit switch LS1 contacts open when the actuating arm returns to its normal position) • The conveyor moves the product forward to position A and stops (position detected by off-to-on output pulses from the encoder, which are counted by an up-counter) • A time delay of 10 s occurs, after which the conveyor starts to move the product to limit switch LS2 and stops (LS2 contacts close when the actuating arm is hit by the product) Position A LS2 LS1 Forward Encoder Figure 8-42 Control process for Problem Inputs Ladder logic program L1 Input A PB1 Input A PB2 Input B Input B Reset Input C Outputs CTU COUNT-UP COUNTER Counter C5:2 Preset 10 Accumulated CTD COUNT-DOWN COUNTER Counter C5:2 Preset 10 Accumulated L2 CU Output A A Output B B Output C C DN CU DN Output A C5:2 CU Output B C5:2 CD Output C C5:2 DN Input C C5:2 RES Figure 8-43 Program for Problem • An emergency stop button is used to stop the process at any time • If the sequence is interrupted by an emergency stop, counter and timer are reset automatically Answer the following questions with reference to the up/down-counter program shown in Figure 8-43 Assume that the following sequence of events occurs: • Input C is momentarily closed • 20 on/off transitions of input A occur • on/off transitions of input B occur As a result: a What is the accumulated count of counter CTU? b What is the accumulated count of counter CTD? c What is the state of output A? d What is the state of output B? e What is the state of output C? Write a program to implement the process illustrated in Figure 8-44 An up-counter must be programmed as part of a batch-counting operation to sort parts automatically for quality control The counter is installed to divert part out of every Quality control line Parts conveyer line Proximity switch Figure 8-44 Gate solenoid drive Control process for Problem Programming Counters Chapter 181 Through-beam sensor Figure 8-45 Spool motor drive Control process for Problem 10 1000 for quality control or inspection purposes The circuit operates as follows: • A start/stop pushbutton station is used to turn the conveyor motor on and off • A proximity sensor counts the parts as they pass by on the conveyor • When a count of 1000 is reached, the counter’s output activates the gate solenoid, diverting the part to the inspection line • The gate solenoid is energized for s, which allows enough time for the part to continue to the quality control line • The gate returns to its normal position when the 2-s time period ends • The counter resets to and continues to accumulate counts • A reset pushbutton is provided to reset the counter manually Write a program that will increment a counter’s accumulated value count every 60 s A second counter’s accumulated value will increment count every time the first counter’s accumulated value reaches 60 The first counter will reset when its accumulated value reaches 60, and the second counter will reset when its accumulated value reaches 12 10 Write a program to implement the process illustrated in Figure 8-45 A company that makes electronic assembly kits needs a counter to count and control the number of resistors placed into each Cartons of ceiling tile kit The controller must stop the take-up spool at a predetermined amount of resistors (100) A worker on the floor will then cut the resistor strip and place it in the kit The circuit operates as follows: • A start/stop pushbutton station is used to turn the spool motor drive on and off manually • A through-beam sensor counts the resistors as they pass by • A counter preset for 100 (the amount of resistors in each kit) will automatically stop the take-up spool when the accumulated count reaches 100 • A second counter is provided to count the grand total used • Manual reset buttons are provided for each counter 11 Write a program that will latch on a light 20 s after an input switch has been turned on The timer will continue to cycle up to 20 s and reset itself until the input switch has been turned off After the third time the timer has timed to 20 s, the light will be unlatched 12 Write a program that will turn a light on when a count reaches 20 The light is then to go off when a count of 30 is reached 13 Write a program to implement the box-stacking process illustrated in Figure 8-46 This application requires the control of a conveyor belt that feeds a mechanical stacker The stacker can stack various numbers of cartons of ceiling tile onto each pallet (depending on the pallet size and the preset value of the counter) When the required number of cartons has been stacked, the conveyor is stopped until the loaded pallet is removed and an empty pallet is placed onto the loading area A photoelectric sensor will be used to provide count pulses to the counter after each carton passes by In addition to a conveyor motor start/stop station, a remote reset button is provided to allow the operator to reset the system from the forklift after an empty pallet is placed onto the loading area Reflector Stacker Sensor Figure 8-46 182 Chapter Control process for Problem 13 Programming Counters Pallet The operation of this system can be summarized as follows: • The conveyor is started by pressing the start button • As each box passes the photoelectric sensor, a count is registered • When the preset value is reached (in this case 12), the conveyor belt turns off • The forklift operator removes the loaded pallet • After the empty pallet is in position, the forklift operator presses the remote reset button, which then starts the whole cycle over again 14 Write a program to operate a light according to the following sequence: • A momentary pushbutton is pressed to start the sequence • The light is switched on and remains on for s • The light is then switched off and remains off for 2 s • A counter is incremented by after this sequence • The sequence then repeats for a total of counts • After the fourth count, the sequence will stop and the counter will be reset to zero Programming Counters Chapter 183 ... Problems vi 13 1 13 2 13 4 13 5 14 0 14 4 14 7 15 1 15 1 15 6 15 7 15 9 16 2 16 6 17 0 17 3 17 4 17 7 17 9 17 9 Program Control Instructions 9 .1 9.2 9.3 9.4 9.5 Program Control ... Figure 1- 14 DC COM 240 VAC 10 11 12 13 14 15 240 VAC output module L1 VAC IN M IN OUT OUT IN OUT IN OUT IN R IN 11 OUT OUT 11 IN 13 Y IN 15 OUT 13 OUT 15 DC COM OUT OUT OUT OUT OUT OUT 10 OUT 12 ... shown in Figure 1- 30 Write a program for the relay ladder diagram shown in Figure 1- 31 120 VAC PB1 S1 PS1 S2 TS1 L1 S3 Figure 1- 31 Circuit for Problem 12 0 VAC S1 LS1 L1 LS2 Figure 1- 30 16 Circuit

Ngày đăng: 21/10/2022, 21:21

Tài liệu cùng người dùng

Tài liệu liên quan