Page 186 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 186

Ladder logic program
                                      L1  Inputs           Count                             Output    L2
                                                      PB1
                                                            up
                                              PB1                      UDC        Light   Light
                                                      PB2  Count
                                                           down      PR: 003

                                              PB2
                                                                     AC: 000
                                                      PB3
                                                           Reset
                                              PB3

                                                                      (a)


                                                        1  2  3  4  5   6
                                                  On
                                          Count up
                                                  O
                                                                           1  2  3  4
                                                  On
                                         Count down
                                                  O
                                                                       65
                                                                    5        4
                                           Counter            3  4               3   2
                                         accumulated   1  2
                                            value   0               Preset  value                   0

                                                   On
                                           Output
                                                  O
                                                  On
                                            Reset
                                                  O

                                                                      (b)
                                      Figure 8-22  Generic up/down-counter program. (a) Program. (b) Counting
                                      diagram.




                       As a result, three additional pulses of the count-up   down-counters may count below zero and begin count-
                       input (PB1) produce an accumulated value of 6 but   ing down from the largest preset value that can be set
                       no change in the output.                          for the PLC’s counter instruction. For example, a PLC
                     •  If the count-down input (PB2) is now pulsed      up/down-counter that has a maximum counter preset
                       four times, the accumulated count is reduced to    limit of 999 may count up as follows: 997, 998, 999,
                       2 (6 – 4). As a result, the accumulated count     000, 001, 002, and so on. The same counter would count
                       drops below the preset count and the output light   down in the following manner: 002, 001, 000, 999, 998,
                       switches from on to off.                          997, and so on.
                     •  Pulsing the reset input (PB3) at any time will reset the   One  application  for  an  up/down-counter  is  to  keep
                       accumulated count to 0 and turn the output light off.  count of the cars that enter and leave a parking garage.
                                                                         Figure 8-23 shows a typical PLC program that could be
                     Not all counter instructions count in the same manner.   used to implement this. The operation of the program can
                   Some up-counters count only to their preset values, and   be summarized as follows:
                   additional counts are ignored. Other up-counters keep
                   track of the number of counts received above the coun-  •  As a car enters, the enter switch triggers the up-
                   ter’s preset value. Conversely, some down-counters        counter output instruction and increments the accu-
                   will simply count down to zero and no further. Other      mulated count by 1.



                                                                                     Programming Counters  Chapter 8    167







          pet73842_ch08_156-183.indd   167                                                                              03/11/15   3:58 PM
   181   182   183   184   185   186   187   188   189   190   191