Simple Time Interval Counter with RS-232 Output

The Simple Time Interval Counter uses the 14-pin 16F688 PIC, a GPS receiver 1PPS as a reference, has variable averaging time set by serial port command, and provides a 10-digit BCD output to an RS-232 port. It is a low-cost four-IC solution for determining the time difference between a locally generated 1PPS and a GPS 1PPS and logging the difference to a computer for analysis.

Demonstrates the addition of Simple Commands in page 0 memory to alter or print a single variable in a user program. By default the counter outputs a 10-digit BCD reading once per minute at 1.04ns per count resolution. By averaging more samples per update, a resolution of 250ps per count with a 250-second update period can be achieved. Per count resolution equals (1 / XO speed) / samples per update period. Sample time is set using Simple Commands by entering @@Sxx where xx = HEX 00-FF (3C default). Entering 00 results in 256 samples; 01-FF gives 1-255 samples per update. Entering @@P prints the current sample time in HEX to the serial port for verification. 

The specified maximum asynchronous TMR1 clock speed is 16.7MHz so a 16MHz XO is used, but XO's at other frequencies are usable by adjusting the sample time for the resolution desired. For users with multiple standards, the best 10 MHz source can provide the counter clock to increase accuracy and provides 100ns/sec to 391ps/256 sec resolutions. Insure the counter clock and DUT 1PPS are from different sources for proper averaging. 

Code: