Page 235 - Making PIC Microcontroller Instruments and Controllers
P. 235

UNDERSTANDING THE  GOUNTERS:

                   COUNTING MARBLES
















                   Proiect  3


                   As you may have  guessed,  this is not really about counting marbles. It is about count
                   iog pulses  that may represent any number of thjngs you are intercsted in counting.
                   These  pulses  may come slow or fast,  regnlarly or landonrly, or in some  other way, and
                   we need to know how to handle  them h  all situations. We use the counters  for count
                   ing the events. The marbles  just happen to be an interesring medium for us to  play wiih:
                   They are easily  obtained, are easy to handle, and are inexpensjve  (and  they do ro11l).
                   See Figure l7.l.
                     You need  to know a few things about this  problem  beiore we stafl, however They are
                   r  Thic i( nol trivial by a long.horl
                   I  There is a limit  to how fast the marbles  can  go by in the redl world, and the  programs
                     we create have to be faster  than that,
                   I  There is a considerable difference between counting marbles that go by one at a
                     time in an orderly fashion and those that go by one  next to the other, helter skelier,
                     fast. In this project, we will  count rhem  one by one, and then h  the later parl of the
                     project we will  count them  going by much taster
                                                              "real-world"
                   I  Signal bouce or signaljitter is a  problem  in any   situation. Especially
                     so with these shiny glass  marbles.
                   I  As can be expected,  therc are many ways to get  ajob like  this one done  meaning
                     that not everything wiil  have been explored when we are done with this chapter

                     We have asked for and been  given the following  assurances  from Mr  Marbles the
                   owner ard manager  of ihe local Marbles Inc. plant. These  assurances arc designed to
                   make  the specincadons of the project more  complete and fo make our task easier.  (In
                   other words, we have been  given the parameters  ior what we are to do.)
   230   231   232   233   234   235   236   237   238   239   240