waveform appears on CCP1, which obviously is an output
since we’re transmitting. The output then connects to the
CCP1 input of the receiver. Varying the duty cycle of the
first is then reported on the LCD display of the second. We
are literally conveying a broad range of numbers along a
single wire by means of a pulse duty cycle.
The steps here are quite interesting. First, the receiver is
set to react to a rising edge. This would be the start of the
pulse. Then, however, the capture module is changed to
respond to a falling edge indicating the end of the on-time.
Finally, the next rising edge signals the conclusion of the
In short, with a couple subtractions, we’ve found the
on-time and the length of the entire cycle. Dividing the
latter into the former yields the duty cycle when interpreted
as a percentage. It’s a pretty cool demonstration, so be
sure to study the source code which is heavily commented.
With that, we come to the end of this tutorial, but
certainly not the end of what can be accomplished with the
capture module. Best of all, you should be in good shape to
tackle the complete datasheet for the PIC and take on even
more advanced applications. SV
SERVO 07.2014 55
Figure 6: Schematic
for the exercises.