circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

January 2006, Issue 186

Electronic Scarecrow


X10 INTERFACE

The well-documented X10 power line carrier system has been in use for many years. The PL-513 transmitter, which supplies a 60-Hz line zero-crossing signal to the MC9S08GT16 microcontroller, expects a gate signal to enable its 120-kHz carrier output. The output is designed to work with a three-phase power system, so the protocol specifies a 1 to be three identical 1-ms wide output pulses spaced 2.778 ms (1/360 Hz) apart, which represents each phase’s zero crossing locations. A 0 occupies the same time interval without any output pulses.

The main program loop calls a routine to store all of the bits for a command in a buffer. They’re pulled out one at a time at each zero crossing. The power line status is monitored by comparing the zero crossing rate to a 360-Hz timer overflow, which is also used to call the push button switch debounce routine.

The real-time clock routine counts the number of zero crossings during a 24-h period whenever the 60-Hz signal is valid. If it’s off from the expected value, the error is used to adjust the MC13192’s oscillator trim register to try to get an accurate time. The real-time clock is based on the 32786.9-Hz (16 MHz/488) CLKO signal divided down by 32,768, which is slightly faster than 1 Hz. It has to adjust its concept of a day to 86449.8 counts ((16 MHz/488/32,768) × 86,400 seconds per day) to compensate for this. After doing so, the time of day should be as accurate as a line-powered clock.