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

Photoelectric
                                                                      sensor


                                                                  Material
                                               Photoelectric  processing system
                                                  sensor



                                                                                       Out-feed
                                                                                     (finished parts)




                                                            In-feed
                                                           (raw parts)
                                                                   (a)

                                         Inputs                       Ladder logic program
                                 L1                      IN-Feed
                                                          count
                                                                       CTU
                                           IN-Feed                     COUNT-UP COUNTER         CU
                                            count                      Counter         C5:1
                                                                       Preset           50      DN
                                                                       Accumulated       0
                                           OUT-Feed
                                             count
                                                        OUT-Feed   Accumulated = No. in-process parts
                                                          count
                                            Reset to                   CTD
                                             zero                      COUNT-DOWN COUNTER       CD
                                                                       Counter         C5:1     DN
                                                                       Preset           50
                                                                       Accumulated       0
                                                          RESETReset
                                                                                               C5:1
                                                                                               RES

                                                                  (b)
                                 Figure 8-26  In-process monitoring program. (a) Process. (b) Program.



               8.4  Cascading Counters                                 •  The status bits of both counters are programmed in
                                                                          series to produce an output.
               Depending on the application, it may be necessary to count
               events that exceed the maximum number allowable per coun-  •  These two counters allow twice as many counts to
               ter instruction. One way of accomplishing this count is by   be measured.
               interconnecting, or cascading, two counters. The program   •  A CTU instruction that is reset while the counter
               of Figure 8-27 illustrates the application of the technique.   logic remains true will result in an accumulated value
               The operation of the program can be summarized as follows:  of 1 instead of 0. Using the OSR instruction in the
                                                                          counter enabling logic prevents this from happening.
                 •  The output of the first counter is programmed into   Another method of cascading counters is sometimes
                    the input of the second counter.
                                                                     used when an extremely large number of counts must
                 •  When the accumulated value of the second counter   be stored. For example, if you require a counter to
                    is equal to its preset, the DN bit will be true, which   count up to 250,000, it is possible to achieve this by
                    allows the first counter to count.               using only two counters. Figure 8-28 shows how the



               170        Chapter 8  Programming Counters







          pet73842_ch08_156-183.indd   170                                                                              03/11/15   3:58 PM
   184   185   186   187   188   189   190   191   192   193   194