Page 175 - Build Your Own Quadcopter_ Power Up Your Designs with the Parallax Elev-8
P. 175

154     Bu il d  Y o ur  O w n  Q u a d c o p t e r


                             NEG_DETECT              long    %01100 << 26
                             tmp1                    res     1
                             tmp2                    res     1
                             mask                res     1           ‘ mask for frequency input
                                                                          pin

                             cyclepntr           res     1           ‘ hub address of cycle
                                                                          count

                             cycles              res     1           ‘ cycles in input period

                                                 fit     492

                             DAT

                                This program utilizes both the A and B cog counters as noted in Jon’s comments. I will
                             not step through all the assembly language lines as I have done in several previous programs.
                             However, I will mention that using either assembly language or C language routines is the
                             only way to handle very high-speed measurements, such as those made by this program.
                             I have not done it myself, but Jon estimates that this program could measure frequencies
                             as high as 40 MHz, which is incredible considering that the Prop clock rate is only 80 MHz.
                                The other Spin program that is used in this frequency-measuring application is named
                             jm_txserial, which is Jon’s adaptation of a fairly standard Spin program named Full_Duplex.
                             It is a common and recommended procedure to use existing open source code and adapt it
                             to your purposes, as Jon has done in this case. I will not discuss jm_txserial specifically other
                             than to say it is a highly efficient communications program that communicates to the PSerT
                             program to display the main program results.




























                             Figure 6.22  Measuring the throttle channel pulse frequency.
   170   171   172   173   174   175   176   177   178   179   180