Positron Compiler Documentation

Xin

Positron8 · Revision 4.0.6.5 · PDF pages 204–205

Xin DataPin, ZeroPin, {Timeout, Timeout Label}, [Variable{,...}]

Receive X-10 data and store the House Code and Key Code in a variable.

DataPin is a constant (0 - 15), Port.Bit, or variable, that receives the data from an X-10 interface. This pin is automatically made an input to receive data, and should be pulled up to 5 Volts with a 4.7KΩ resistor. ZeroPin is a constant (0 - 15), Port.Bit, or variable, that is used to synchronise to a zero-cross event. This pin is automatically made an input to received the zero crossing timing, and should also be pulled up to 5 Volts with a 4.7KΩ resistor. Timeout is an optional value that allows program continuation if X-10 data is not received within a certain length of time. Timeout is specified in AC power line half-cycles (approximately 8.33 milliseconds). Timeout Label is where the program will jump to upon a timeout.

  Dim wHouseKey as Word
  Cls
MyLoop:
' Receive X-10 data, go to NoData if none
  Xin PORTA.2, PORTA.0, 10, NoData, [wHouseKey]
' Display X-10 data on an LCD
  Print At 1, 1, "House=", Dec wHouseKey.Byte1,"Key=", Dec wHouseKey.Byte0
  GoTo MyLoop                 ' Do it forever
NoData:
  Print "No Data"
  Stop

Xout and Xin Declares In order to make the Xin command's results more in keeping with the BASIC Stamp interpreter, two declares have been included for both Xin and Xout These are.

Declare Xout_Translate = On/Off, True/False or 1/0

and

Declare Xin_Translate = On/Off, True/False or 1/0

Xin processes data at each zero crossing of the AC power line as received on ZeroPin. If there are no transitions on this line, Xin will effectively wait forever.

Xin is used to receive information from X-10 devices that can transmit the appropriate data. X- 10 modules are available from a wide variety of sources under several trade names. An interface is required to connect the microcontroller to the AC power line. The TW-523 for two-way X-10 communications is required by Xin. This device contains the power line interface and isolates the microcontroller from the AC line.

View original PDF page 204Open page in PDFOriginal PDF page 204

If Variable is a Word sized variable, then each House Code received will be stored in the upper 8-bits of the Word And each received Key Code will be stored in the lower 8-bits of the Word variable. If Variable is a Byte sized variable, then only the Key Code will be stored.

The House Code is a number between 0 and 15 that corresponds to the House Code set on the X-10 module A through P.

The Key Code can be either the number of a specific X-10 module or the function that is to be performed by a module. In normal operation, a command is first sent, specifying the X-10 module number, followed by a command specifying the desired function. Some functions operate on all modules at once so the module number is unnecessary. Key Code numbers 0-15 correspond to module numbers 1-16.

Warning. Under no circumstances should the microcontroller be connected directly to the AC power line. Voltage potentials carried by the power line will not only instantly destroy the microcontroller, but could also pose a serious health hazard.

See also : Xout.

View original PDF page 205Open page in PDFOriginal PDF page 205