Issue
113 December 1999
Being
Cool is Easy
A
Temperature-Sensing Control Device
OVERVIEW
OF THE SENSOR
Refer
to the block diagram of the X-10 temperature sensor
in Figure 1. The PIC16C73A microcontroller is central
to the sensor and controls its other elements. The PICs
on-chip program memory contains the X-10 temperature
sensor software. There are two main elements of the
softwarea background component and a foreground
component (see Figure 2).
|

(Click here to enlarge)
|
Figure
1The PIC16C73A reads local temperature from
the DS1820 and responds to controller requests
via the TW-523. The optional LCD displays local
temperature, controller requests, and sensor responses. |
|

(Click
here To enlarge)
|
Figure 2These are the two main elements of
the temperature sensor software. The foreground
loop on the left manages the DS1820 and the LCD.
The background interrupt- driven task on the right
receives and transmits X-10 commands via the TW-523.
|
The
main foreground loop is entered on powerup after completing
initialization. In this main loop, the temperature is
read from the DS1820 digital thermometer once every
2 s and displayed on the LCD. The temperature display
alternates between Fahrenheit and Celsius. The temperature
is also saved for use by the background component.
The
PICs interrupt drives the background component,
which controls the X-10 input and output interface via
the TW-523 two-way power line interface module. There
are two interrupt sources: an external interrupt generated
from the TW-523 zero-crossing signal and an internal
interrupt generated from PICs Timer0.
The
zero-crossing signal is used to synchronize the sampling
of the TW-523 Rx output and control of the TW-523 Tx
input. The software sets up the PICs internal
Timer0 to create a sequence of precise internal interrupts
synchronized with the zero-crossing signal for this
purpose.
The
background component of the software monitors the TW-523
Rx output. X-10 transmissions are received bit-by-bit
and reassembled. When a query request is recognized,
it is compared to the temperature reading that was saved
in the main foreground loop. The appropriate response
is generated and subsequently transmitted bit-by-bit
through control of the TW-523 Tx input (see Figure 5).
THE
MICROCONTROLLER
When
I started the X-10 temperature sensor, I had two different
PIC microcontrollers on-handthe 16C84 and
the 16C73A (see Figure 3). The only choice was
the 16C73A because the 16C84 had insufficient
I/O.
|

(Click
here to enlarge)
|
Figure
3The PIC16C73A is wired directly to the DS1820,
LCD, and two of the three TW-523 signals. The TW-523
Tx input is controlled indirectly through Q1. |
The
software for the X-10 temperature sensor was developed
using Microchips MPLAB Integrated Development
Environment (IDE) in combination with Microchips
PICSTART Plus programmer. The MPLAB IDE software, information
on the PICSTART Plus, and datasheets for the PIC microcontrollers
are available from Microchips web site.