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

L1    Inputs                  Ladder logic program              Outputs   L2
                                                                CTU
                                     PB1            Input A     COUNT-UP COUNTER
                                                                Counter                  C5:2  CU
                                          Input A               Preset                         10  Output A  A
                                                                Accumulated               0
                                     PB2                                              DN

                                           Input B                                           Output B  B
                                                                CTD
                                                    Input B
                                     Reset                      COUNT-DOWN COUNTER
                                                                Counter                  C5:2  CU
                                          Input C               Preset                        10  Output C  C
                                                                Accumulated               0
                                                                                      DN

                                                    C5:2                     Output A
                                                        CU
                                                    C5:2                     Output B
                                                        CD
                                                    C5:2                     Output C
                                                       DN
                                                    Input C                    C5:2
                                                                               RES

                                 Figure 8-25  Up/down-counter program.




                   to true, one count is subtracted from the accumulated   The operation of the program can be summarized as
                   value.  The operation of the program can be summa-    follows:
                   rized as follows:                                       •  Before start-up, the system is completely empty of
                                                                             parts, and the counter is reset manually to 0.
                     •  When the CTU instruction is true, C5:2/CU will be
                       true, causing output A to be true.                  •  When the operation begins, raw parts move through
                     •  When the CTD instruction is true, C5:2/CD will be    the in-feed sensor, with each part generating an up
                       true, causing output B to be true.                    count.
                     •  When the accumulated value is greater than or equal   •  After processing, finished parts appearing at the out-
                       to the preset value, C5:2/DN will be true, causing    feed sensor generate down counts, so the accumu-
                       output C to be true.                                  lated count of the counter continuously indicates the
                                                                             number of in-process parts.
                     •  Input C going true will cause both counter instruc-
                       tions to reset. When reset by the RES instruction,   •  The counter preset value is irrelevant in this
                       the accumulated value will be reset to 0 and the      application. It does not matter whether the counter
                       done bit will be reset.                               outputs are on or off. The output on-off logic is not
                                                                             used. We have arbitrarily set the counter’s preset
                     Figure 8-26 illustrates the operation of the up/down-   values to 50.
                   counter program used to provide continuous monitor-     The maximum speed of transitions that you can count
                   ing of items in process. An in-feed photoelectric sensor   is determined by your program’s scan time. For a reli-
                   counts raw parts going into the system, and an out-feed   able count, your counter input signal must be fixed for one
                   photoelectric sensor counts finished parts leaving the   scan time. If the input changes faster than one scan period,
                   machine.  The number of parts between the in-feed     the count value will become unreliable because counts
                   and out-feed is indicated by the accumulated count of   will be missed. When this situation occurs, you need to
                   the counter. Counts applied to the up-input are added,   use a high-speed counter input or a separate counter I/O
                   and counts applied to the down-input are subtracted.   module designed for high-speed applications.



                                                                                     Programming Counters  Chapter 8    169







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