Page 170 - Build Your Own Quadcopter_ Power Up Your Designs with the Parallax Elev-8
P. 170
Chapter 6: Radio-Controlled Systems and Telemetr y 149
if(phsa < 0) ‘ phsa is a phase lock loop register.
It is used to store a count
proportional to the high pulse width
leftLength := 0
phsa := 0
ifnot(ina[leftPinNumber] or not(phsa))
leftLength := ((||(phsa~)) / (clkfreq / 1_000_000))
leftTimeout := cnt
if((cnt - leftTimeout) > ((clkfreq / 100) * timeoutPeriod))
leftLength := 0
if(phsb < 0)
rightLength := 0
phsb := 0
ifnot(ina[rightPinNumber] or not(phsb))
rightLength := ((||(phsb~)) / (clkfreq / 1_000_000))
rightTimeout := cnt
if((cnt - rightTimeout) > ((clkfreq / 100) * timeoutPeriod))
rightLength := 0
I would like to point out that no assembly language code was required for this Spin
program, since all the timing was accomplished by using the built-in cog counters and
Figure 6.21 A Propeller Serial Terminal display of two servo channels.