XOUT

BS2 icon BS2e icon BS2sx icon BS2p icon BS2pe icon BS2px icon

XOUT Example

 

 

 

Syntax: XOUT Mpin, Zpin, [House\Command {\Cycles} {, House\Command {\Cycles}...}]

Function

Send an X-10 power-line control command (through the appropriate power-line interface).

Quick Facts

  All BS2 Models
Compatible power-line interfaces PL-513 and TW-523
Special Notes The XOUT command will stop the BASIC Stamp program until it is able to send the transmission. If there is no AC power to the power-line interface, the BASIC Stamp program will halt forever.

Explanation

XOUT lets you control appliances via signals sent through household AC wiring to X-10 modules. The appliances plugged into these modules can be switched on or off; lights may also be dimmed. Each module is assigned a house code and unit code by setting dials or switches on the module. To talk to a particular module, XOUT sends the appropriate house code and unit code. The module with the corresponding code listens for its house code again followed by a command (on, off, dim, or bright).

X-10 signals are digital codes imposed on a 120 kHz carrier that is transmitted during zero crossings of the AC line. To send X-10 commands, a controller must synchronize to the AC line frequency with 50 ms precision, and transmit an 11-bit code sequence representing the command.

XOUT interfaces to the AC power-line through an approved interface device such as a PL-513 or TW-523, available from Parallax or X-10 dealers. The hookup requires a length of four-conductor phone cable and a standard modular phone-base connector (6P4C type). Connections are shown below.

Command Value Function
UnitOn %10010 Turn on the currently selected unit.
UnitOff %11010 Turn off the currently selected unit.
UnitsOff %11100 Turn off all modules in this house code.
LightsOn %10100 Turn on all lamp modules in this house code.
Dim %11110 Reduce brightness of currently selected lamp.
Bright %10110 Increase brightness of currently selected lamp.

 

Tip:  In most applications, it's not necessary to know the code for a given X-10 instruction. Just use the command constant (UnitOn, Dim, etc.) instead. But knowing the codes leads to some interesting possibilities. For example, XORing a UnitOn command with the value %1000 turns it into a UnitOff command, and vice-versa. This makes it possible to write the equivalent of an X-10 "toggle" instruction.

Here is an example of the XOUT instruction:

Mpin    PIN     1                       ' modulation pin
Zpin    PIN     0                       ' zero-cross input

HouseA  CON     0                       ' House code A = 0 
Unit1   CON     0                       ' Unit code 1 = 0 

Main:
  XOUT Mpin, Zpin, [HouseA\Unit1]       ' Get unit 1's attention.. 
  XOUT Mpin, Zpin, [HouseA\UnitOn]      ' ..and tell it to turn on
  END

You can combine those two XOUT instructions into one like so:

  XOUT Mpin, Zpin, [HouseA\Unit1\2, HouseA\UnitOn]

Note that to complete the attention-getting code HouseA\Unit1 we tacked on the normally optional cycles entry \2 to complete the command before beginning the next one. Always specify two cycles in multiple commands unless you're adjusting the brightness of a lamp module.

Here is an example of a lamp-dimming instruction:

Mpin    PIN     1                       ' modulation pin
Zpin    PIN     0                       ' zero-cross input

HouseA  CON     0                       ' House code A = 0 
Unit1   CON     0                       ' Unit code 1 = 0 

Main:
  ' Get unit 1's attention
  XOUT Mpin, Zpin, [HouseA\Unit1]
  ' Dim halfway
  XOUT Mpin, Zpin, [HouseA\UnitOff\2, HouseA\Dim\10]
  END

The dim/bright commands support 19 brightness levels. Lamp modules may also be turned on and off using the standard UnitOn and UnitOff commands. In the example instruction above, we dimmed the lamp by first turning it completely off, then sending 10 cycles of the Dim command. This may seem odd, but it follows the peculiar logic of the X-10 system.

Go to PBASIC Language home page

Open Getting Started with Stamps in Class

Open Connection Troubleshooting

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/21/2013