157
OpenX10
Type
Subroutine
Invocation
OpenX10(channel, inQueue, outQueue)
Parameter
Method
Type
Description
channel
ByVal
Byte
The X-10 communication channel to open.
inQueue
ByRef
array of Byte
The queue for incoming X-10 data.
outQueue
ByRef
array of Byte
The queue for outgoing X-10 data.
Discussion
This subroutine prepares an X-10 communication channel for use. After the channel is opened you can
send arbitrary X-10 command bit streams, which you must create in low-level form, by simply adding the
constitutent bytes to the outgoing queue. Similarly, the incoming queue will receive raw X-10 data which
you must decode. Each X-10 command begins with the bit sequence 1110 which is followed by
additional bit pairs. The bit pair 01 represents a logic zero while the bit pair 10 represents a logic one.
The bit pair 11 is invalid and the bit pair 00 signifies the end of a command bit stream and also represents
the idle condition. Additional information on X-10 commands may be found in various places on the
Internet.
If the specified channel is already open or if the channel number is invalid, it has no effect. The
supported channel numbers are 1-2. The channel must have been previously configured by a call to
DefineX10(). Also, the queues specified for the receive and transmit channels each must have been
previously initialized by calling OpenQueue(). If you set up a transmit-only or receive-only serial channel
you may use the value 0 for the unused queue. If you provide the value 0 for both queues, the channel
will not be opened.
Example
Dim outQueue(1 to 40) as Byte
Call OpenX10(1, 0, outQueue)
The code above prepares channel 1 as for transmit-only operation. If you wanted reception as well, you
would have to declare and initialize a second queue and define the receive pin.
Resource Usage
X-10 communication requires the use of the Int0 line to which the X-10 zero-crossing signal must be
connected. When one or more of the X-10 channels are open any task that waits for Int0 using
WaitForInterrupt() will be suspended indefinitely. When all X-10 channels are closed, Int0 will
For native code devices, the following ISRs are required.
ISRs Required
Underlying CPU
ISR Name
mega644P
Timer0_CompB, INT0
mega1281
Timer2_CompB, INT0
mega1280
Timer2_CompB, INT0