Issue
113 December 1999
Being
Cool is Easy
A
Temperature-Sensing Control Device
PROCESSING
REQUESTS
The
X-10 sensor recognizes a request when it receives two
consecutive On commands for the selected House Code.
Remember from the example in Table 1 that one On command
requires two X-10 transmissions. The first provides
the Key Code and the second provides the Function Code
(On in this case). Combining the two Key Codes forms
the query value. In the example of Table 1, the Key
Codes of 7 and 5 represent a query value of 75°F.
The
query value is compared to the last local temperature
read from the DS1820, if any. If the local temperature
is greater than or equal to the query value, a response
of Unit 16 On is created. Otherwise, a response of Unit
16 Off is created. An internal software flag is set
indicating that a response is ready to be transmitted.
If
the sensor detects an error during DS1820 communication,
all queries are ignored and no response is generated
or transmitted.
TRANSMITTING
RESPONSES
As
in receiving X-10 commands, transmission must be synchronized
to the zero crossing event. The TW-523 Tx input controls
when a high-frequency (120 KHz) carrier is superimposed
onto the power line. A "1" is represented
by a 120-KHz burst and a "0" is represented
by no burst. The TW-523 Tx input is driven by the 16C73A
RA2 output through Q1.
For
single-phase residential power, this burst begins at
zero crossing and lasts for 1 ms. A three-phase setup
requires three 1-ms bursts during each half cycle. The
temperature sensor is designed to work in a three-phase
setup.
The
first burst begins at zero crossing. Subsequent Timer0
interrupts control when that burst ends or when the
remaining two bursts begin and end. See Figure 6 for
the exact timing.
The
TW-523 doesnt handle the duplicate transmissions
on outgoing commands as it does for incoming transmissions.
The X-10 software must handle transmitting each command
twice with a gap of at least three cycles between pairs.
I
use 10 half cycles between groups so it takes a total
of 108 half cycles (zero crossing interrupts) to transmit
a complete response. Breaking down the 108 figure, you
get 44 half cycles per group of two (11 cycles × 2 zero
crossings/cycle × 2 transmissions), 10 half cycle gaps
between codes, × 2 codes (Unit/Key Code and Unit/Function
Code).
SYNCHRONIZATION
OF TEMPERATURE MONITORING
Remember
from the high-level software flow in Figure 2 that DS1820
communication takes place in the main foreground loop
and the interrupt-driven background loop deals with
the TW-523. The DS1820 communication requires precise
timing. A zero crossing or Timer0 interrupt during DS1820
communication would disturb this timing.
One
way to deal with this would be to disable interrupts
during the periods of time-critical DS1820 communication.
However, this technique disturbs the precise timing
required for the TW-523 interface.
The
solution is to synchronize the time-critical DS1820
code with the zero crossing and Timer0 interrupts. Note
in Figure 6 that there are three intervals in each half
cycle between transmission bursts where no interrupts
occur. The intervals are 1.778 ms longmore than
enough time to deal with time-critical DS1820 communication.
|

(Click
here to enlarge)
|
Figure
6Transmission of each bit of an X-10 command
starts at the zero crossing and lasts for 1000
µs. There are three transmissions of each bit,
one for each phase of a three-phase setup. Received
data is sampled at 600 µs after zero crossing. |
An
interrupt synchronization subroutine is called just
before all time-critical DS1820 code. This subroutine
sets an internal flag then waits for that flag to be
reset.
The
16C73A interrupt handler resets this flag at the
start of each 1.778-ms interval. The interrupt synchronization
subroutine has a 3-ms timeout for protection against
a situation where the zero crossing interrupt has been
lost.