'=========================================================================== '=========================================================================== '== Program : X10-RF30.BSX == '== Date : October 8th, 2000 == '== Programmer : Tom Laureanno == '== lingling@edgenet.net == '== http://www3.edgenet.net/lingling == '== == '== NOTE: USE OF THIS CODE IS STRICKLY LIMITED TO INDIVIDUAL USE AND == '== IS SUBJECT TO ALL COPYRIGHT LAWS. THIS CODE IS NOT TO BE == '== MODIFIED AND SOLD IN ANY WAY. THIS IS AN ONGOING EXPERIMENTAL == '== PROJECT. USE THIS PROJECT/CODE STICKLY AT YOUR OWN RISK. == '== *** FEEL FREE TO SEND COMMENTS/SUGGESTIONS TO THE AUTHOR *** == '=========================================================================== '=========================================================================== 'Program Logic Tree Diagram ' ' |-->-- Wait for X-10 RF START signal -->--| ' |--<---------- no start signal --------<--| ' | |-- Recieved Start Signal!, Now read RF Envelope data ' | |-- Read 32 low pulses, measure lengths & assign logic level ' | | (long pulse =1, short pulse=0) ' | |-- Compare Complement bytes to Data Bytes (error checking) ->--| ' |--<---------------<------- bytes don't jive -----<----------------<--| ' | |-- Data OK! Now, assemble bits, decode and send X-10 ' | |-- Read 32 low pulses, measure lengths & assign logic level ' | | (long pulse =1, short pulse=0) ' | |-- Using logic levels of 32 bits, assemble data accordingly ' | | (Set up Nibbles for Housecode, Unitcode & Action) ' | |-- Decode Housecode, Unitcode & Action from nibbles ' | |-- Send X-10 data to TW-523 Powerline Interface ->--| ' | (Relay received RF X-10 command to Powerline) | ' | | ' |--<------------------<--------------------<------------------<--| '-------------------------------------------------------------------------- 'Allocate storage and define inputs/outputs. '-------------------------------------------------------------------------- 'Define variables for storing pulse lengths (Start pulse and Negative Pulse) StartLength var word 'Variable used to store the measured positive Start pulse length PulseLength var word 'Variable used to store a measured negative Data pulse length 'Define variables to store specific X-10 commands (HC, UC, Action, etc...) Action var nib '0=Off, 1=On, 2=Dim, 4=Bri, 5=AllOff, 6=AllOn Unitcode var nib 'Unitcode nibble built from bits of the RF envelope Housecode var nib 'House code nibble built from bits of the RF envelope HousecodeLetter var byte 'Byte to store Housecode letter (A-P) HousecodeNumber var byte 'Byte to store Housecode Number (0-15) 'Define variable for storing repeat values for X-10 commands DimBriRep var byte 'Repeat value for Dim/Bri commands DimBriRep=1 'Default = 1 OnOffRep var byte 'Repeat value for On/Off commands OnOffRep=1 'Default = 1 AllOnOffRep var byte 'Repeat value for All On/Off commands AllOnOffRep=1 'Default = 1 'Define variables for storing two 16 bit words (need 32 to store RF envelope) '*** Too bad the Stamp-IIsx doesn't allow representation of a 32 bit variable CompleteRF1 var word 'First Word for storing first 16 RF envelope bits CompleteRF2 var word 'Second Word for storing next 16 RF envelope bits '**** The following 4 byte variables are used later for error checking **** Data1 var CompleteRF1.LOWBYTE 'Data Byte from RF1 Data2 var CompleteRF2.LOWBYTE 'Data Byte from RF2 Comp1 var CompleteRF1.HIGHBYTE 'Complement Byte from RF1 Comp2 var CompleteRF2.HIGHBYTE 'Complement Byte from RF2 '************************** Set up Stamp I/O Pins ************************* RFLed con 7 'Output pin (P7) for LED Indicator RFinPin con 15 'This is the Stamp-IIsx input pin that will 'read in the RF envelope (bit stream) 'This RF envelope is received from the 'output of a TM751 daughterboard '(Pin#2 on daughterboard, near +V on Pin#1, '...Pin#4 is Ground). On the Stamp-IIsx, 'connect P0 to Pin#2 on TM741 daughterboard. 'P0 will be pin that reads in RF pulses 'Also connect a 100K resistor from 'this tie point to ground. '(Pulldowns/ups required, see wiring table below) TW523_CLK con 0 'Pin P0 on Stamp receives clock 'pulses from TW523 (pin#1) TW523_IN con 1 'Pin P1 on Stamp sends X-10 data 'pulses to the TW523 (pin#4) 'FYI, Pin#2 on TW523 is Ground! 'Also, Stamp pins #4 & #22 are Ground '------------------------------ WIRING TABLE ----------------------------- ' STAMP TW-523 TM741 BOARD OTHER (pullups/downs) -- '-------------------------------------------------------------------------- '-- 4/22 (VSS/GND) 2 (GND/Green) Pin#4 (GND) (see * below) -- '-- -- '-- 5 (P0) 1 (CLK/Yellow) 10kOhm to Vin # -- '-- -- '-- 6 (P1) 4 (IN/Black) -- '-- -- '-- 12 (P7) 1kOhm to LED+ -- '-- (LED- to GND) * -- '-- -- '-- 20 (P15) Pin#2 (RF) 100kOhm to GND * -- '-- -- '-- 24 (Vin) Pin#1 (+V) (see # above) -- '-------------------------------------------------------------------------- '** FLASH LED TWICE TO CONFIRM STARTUP UPON POWER APPLICATION OR STARTUP ** LOW RFLed:HIGH RFLed:PAUSE 200:LOW RFLed PAUSE 200:HIGH RFLed:PAUSE 200:LOW RFLed '************************************************************************** '========================================================================== '========================================================================== MAINLOOP: '*************************************************************** 'WAIT FOR START SIGNAL '(Look for a long postive Pulse roughly 8 msec or PULSIN=10000 (8ms/.8us) ) GetStart: PULSIN RFinPin, 1, StartLength IF StartLength < 10000 then GetStart '*************************************************************** '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 'START SIGNAL RECEIVED!...NOW READ X-10 RF DATA (1 low pulse at a time,x32) '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PAUSE 4 'IMPORTANT! WAIT FOR THE PREAMBLE LOW PULSE TO PASS (roughly 4ms) 'else, the next negative pulse measurement could time out (length=0) HIGH RFled 'Turn ON LED ! Indicate that the reading of RF has begun 'Read all Negative (-) pulses, measuring the pulse width. 'There is no need to measure postive pulses since the PULSIN 'command needs a falling and leading edge to measure each 'negative pulse (begins measuring at falling edge and stops 'measuring at rising/leading edge). If we tried reading a 'positive pulse right after a negative pulse measurement, we 'will end up missing the very next negative pulse (not good!) 'but instead it would measure the proceeding negative pulse 'BELEIVE IT OR NOT, A LOOP HERE WILL NOT WORK, 'MOST LIKELY DUE TO EXCESSIVE DELAYS IN FOR/NEXT LOOPS ? 'Read 32 LOW bits, measure length, & set bit to appropriate value (1 or 0) 'Below, (PulseLength/1500) returns "1" if PulseLength is >= 1500 (integer) 'Below, (PulseLength/1500) returns "0" if PulseLength is < 1500 (integer) 'Value is automatically converted to binary value when assigned to "bits" 'Yes, this is opposite to that described in the theory doc but it really 'does not matter in the end. Instead or reading the non-complementary bit 'supplied in the RF envelope, we will in fact read them since they will 'already had been complemented (something like,... complementing an already 'complemented bit yields the original bit value...) ' 'Additionally, this is the quickest method I could think of where you could 'immediately measure pulse lengths, assign a logic level according to length 'and THEN assign the logic level to a specific bit in a word.... phew... 'Any delays here could cost you a "bit",.. and losing a bit is losing alot! 'Read/Measure first 16 low pulses and assign bits in word "CompleteRF1" 'The LSB of CompleteRF1 will be the very first pulse read/measured PULSIN RFinPin, 0, PulseLength CompleteRF1.bit0 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit1 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit2 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit3 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit4 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit5 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit6 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit7 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit8 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit9 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit10 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit11 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit12 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit13 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit14 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF1.bit15 = (PulseLength/1500) 'Read/Measure next 16 low pulses but assign bits in word "CompleteRF2" 'Too bad we can not have a 32 bit variable here to use instead of two words 'The MSB of CompleteRF2 will be the very last pulse read/measured PULSIN RFinPin, 0, PulseLength CompleteRF2.bit0 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit1 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit2 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit3 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit4 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit5 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit6 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit7 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit8 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit9 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit10 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit11 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit12 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit13 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit14 = (PulseLength/1500) PULSIN RFinPin, 0, PulseLength CompleteRF2.bit15 = (PulseLength/1500) '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 'So, our RF stream (32 bits look like: ' RF2 RF1 ' ---------------- ---------------- ' MSB LSB MSB LSB ' XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX ' * # ' ' Where: "*" = Last bit read ' "#" = First bit read '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '!!!!!!!!!!!!!!!!!!!! PUT ERROR CHECKING ROUTINE HERE !!!!!!!!!!!!!!!!! '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '! Compare CompleteRF1 bits 0-7 with CompleteRF1 bits 8-15 ! '! Compare CompleteRF2 bits 0-7 with CompleteRF2 bits 8-15 ! '! ! '! IF EITHER COMPARE FAILS, THEN GOTO RF ENVELOPE READ (MAINLOOP) ! '! ! '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'Remember: ' Data1 = CompleteRF1.LOWBYTE 'Data Byte from RF1 ' Data2 = CompleteRF2.LOWBYTE 'Data Byte from RF2 ' Comp1 = CompleteRF1.HIGHBYTE 'Complement Byte from RF1 ' Comp2 = CompleteRF2.HIGHBYTE 'Complement Byte from RF2 ' 'Complement the Complemented Bytes and compare to regular data Bytes 'XORing a byte with %11111111 (or $FF) will Complement the byte 'If either compare fails, BAD DATA,...Read in next RF data command IF Data1 = (Comp1)^$FF AND Data2=(Comp2)^$FF THEN RFOK GOTO MAINLOOP RFOK: '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'Reading of X-10 RF Envelope is completed and data is OK! LOW RFled 'Turn OFF LED,... Done reading RF Envleope! 'We must now decode the RF received envelope (CompleteRF1 and CompleteRF2) '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& '& FORMAT FOR X-10 RF ENVELOPE & '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 'Format for first 16 bits => CompleteRF1 ' =========== ' ' Complement ' ------------------------------- +4 +4 ' ? ? UC3 UC HC3 HC2 HC1 HC0 ? ? UC3 UC HC3 HC2 HC1 HC0 ' X X X X X X X X X X X X X X X X ' b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 ' ' 'Format for second 16 bits => CompleteRF2 ' =========== ' ' Complement ' ------------------------------- ' OFF1 DB1 OFF1 DB1 ' ? ? ? UC1 UC0 ON0 UC2 OO0 ? ? ? UC1 UC0 ON0 UC2 OO0 ' X X X X X X X X X X X X X X X X ' b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 ' 'Therefore: ' ' CompleteRF1 ' ---------------------------- ' Housecode = b3 b2 b2 b0 ' ---------------------------- ' (b3) (b2) (b1) (b0) ' MSB LSB 'and ' ' CRF1 CompleteRF2 ' ---- -------------------- ' Unitcode = b5 b1 b4 b3 ' ---------------------------- ' (b3) (b2) (b1) (b0) ' MSB LSB ' ' ALSO!, If bit#4 of CompleteRF1 is set, add four (4) to Unitcode ' (needed to support older wall switch and keyfob remotes) ' 'and ' ' CompleteRF2.bit0 defines whether the command is either a: ' "1" --> A Dim/Bri or All On/Off command where: ' / 0 --> ALLOFF (set Action=5) ' Unitcode / 1 --> ALLON (set Action=4) ' \ 2 --> Bri (set Action=3) ' \ 3 --> Dim (set Action=2) ' or ' "0" --> An On/Off command where: ' CompleteRF2.bit2 = "0" --> ON (set Action=1) ' CompleteRF2.bit2 = "1" --> OFF (set Action=0) ' 'The Unitcode works out to be BCD but the Housecode is not easily 'decoded (that is, there is no easy algorithm). For instance, 'Housecode "M" (or 12) has the binary value "0000" while Housecode '"L" (or 11) has the binary value "1011". A lookup must therefore be 'used to decode this nibble. The Housecode nibble was built as 'described above in order to match the documented theory and appendix '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 'Build the nibble (bit by bit) that will represent the Housecode (0-15) 'Luckily enough, we can represent it in BCD format (MSB-LSB) Housecode.bit3=CompleteRF1.bit3 Housecode.bit2=CompleteRF1.bit2 Housecode.bit1=CompleteRF1.bit1 Housecode.bit0=CompleteRF1.bit0 'Build the nibble (bit by bit) that will represent the Unitcode (0-15) 'Sort of arbitrary but we want to conform with documented text Unitcode.bit3=CompleteRF1.bit5 'notice, this bit is from CompleteRF1 (?) Unitcode.bit2=CompleteRF2.bit1 Unitcode.bit1=CompleteRF2.bit4 Unitcode.bit0=CompleteRF2.bit3 'Don't forget to check bit#4 of RF1 (Older remotes,... if set, add 4 to UC) If CompleteRF1.bit4=0 then SPP Unitcode=Unitcode+4 SPP: 'Decode Housecode nibble into HousecodeLetter (A-P) LOOKUP Housecode,["M","E","C","K","O","G","A","I","N","F","D","L","P","H","B","J"], HousecodeLetter 'Decode Housecode nibble into correct HousecodeNumber (0=A, 1=B, ... 15=P) LOOKUP Housecode,[12,4,2,10,14,6,0,8,13,5,3,11,15,7,2,9], HousecodeNumber '=========================================================================== 'Now, first check CompleteRF2.bit0 to see if a Bri/Dim or All On/Off command 'If SET (1), look at Unitcode nibble and decode (Bri, Dim, AllOn or AllOff) and ' appropriately set the "Action" variable 'If NOT SET (0), then this is simply an On or Off command therefore: ' -Look at CompleteRF2.bit2 and if set (1), this is an OFF command ' (appropriately set the "Action" variable to 0) ' -Look at CompleteRF2.bit2 and if not set (0), this is an ON command ' (appropriately set the "Action" variable to 1) ' IF CompleteRF2.bit0=1 THEN DBALAO 'If bit0=1 then skip, not an ON/OFF IF CompleteRF2.bit2=0 then SKP2ON 'OFF Command Action = 0 GOTO DONE SKP2ON: 'ON Command Action = 1 GOTO DONE DBALAO: 'DBALAO = Dim, Bri, AllOn, AllOff ! 'It is assumed that it must therefore be a Dim/Bri or AllOn/Off command... 'Decode Unitcode nibble (0=ALLOFF, 1=ALLON, 2=Bri and 3=Dim) and 'Assign value to "Action" variable where Dim=2, Bri=3, AllOff=4, and AllOn=5 LOOKUP Unitcode,[4,5,3,2],Action DONE: '=========================================================================== '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ '^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MAIN DEBUG AREA ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 'Now, Display Binary Data of X-10 RF Envelope (show all bits whether 0 or 1) 'This format in in accordance to the X-10 Wireless Protocol posted on 'the internet (Dr. Ed and Paul Gumerman). This jives with Paul's format 'as described in the Appendix section of the theory notes. '(Bytes 4&3 = CompleteRF1. Bytes 2&1 = CompleteRF2) 'DEBUG bin CompleteRF1.bit15, bin CompleteRF1.bit14, bin CompleteRF1.bit13,bin CompleteRF1.bit12,bin CompleteRF1.bit11,bin CompleteRF1.bit10,bin CompleteRF1.bit9,bin CompleteRF1.bit8,bin CompleteRF1.bit7,bin CompleteRF1.bit6,bin CompleteRF1.bit5,bin CompleteRF1.bit4,bin CompleteRF1.bit3,bin CompleteRF1.bit2,bin CompleteRF1.bit1,bin CompleteRF1.bit0,CR 'DEBUG bin CompleteRF2.bit15, bin CompleteRF2.bit14, bin CompleteRF2.bit13,bin CompleteRF2.bit12,bin CompleteRF2.bit11,bin CompleteRF2.bit10,bin CompleteRF2.bit9,bin CompleteRF2.bit8,bin CompleteRF2.bit7,bin CompleteRF2.bit6,bin CompleteRF2.bit5,bin CompleteRF2.bit4,bin CompleteRF2.bit3,bin CompleteRF2.bit2,bin CompleteRF2.bit1,bin CompleteRF2.bit0,CR 'Display the Housecode Number (0-15) and Unitcode (0-15) ''DEBUG dec ?HousecodeNumber, ?Unitcode+1 'or, Display The Housecode Letter (A-P) and Unitcode (+1 so value = 1-16) 'DEBUG asc ?HousecodeLetter, ?Unitcode+1 'Also Display Action number (0=Off, 1=On, 2=Dim, 4=Bri, 5=AllOff, 6=AllOn) 'DEBUG ?Action 'DEBUG "----------------------------",CR,BELL '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ '************************************************************************* '** RELAY DECODED X-10 RF COMMAND TO THE POWERLINE VIA TW-523 INTERFACE ** '************************************************************************* ' "Action" ---> 0=Off, 1=On, 2=Dim, 4=Bri, 5=AllOff, 6=AllOn ' Use HousecodeNumber and Unitcode variables for X-10 commands '---------------------------------------------------------------------------- ' Possible values for X10 actions are: (?=either 1 or 0... see TW523 notes) '---------------------------------------------------------------------------- ' %10000 = All Lights OFF %11000 = Extended Code ' %10001 = Status OFF %11001 = Status Request ' %10010 = Unit ON %11010 = Unit OFF ' %1?011 = Preset Dim %1?011 = Preset Dim ' %10100 = All Lights ON %11100 = All Units OFF ' %10101 = Hail Ack. %11101 = Hail Request ' %10110 = Bri %11110 = Dim ' %10111 = Status ON %11111 = Extended Data ' ' Predefined XOUT actions include: ' "unitoff", "unitOn", "unitsOff", "unitsOn", "bright", "dim" '---------------------------------------------------------------------------- BRANCH Action,[ActOFF, ActON, ActDIM, ActBRI, ActALLOFF, ActALLON] ActOFF: xout TW523_IN,TW523_CLK,[HousecodeNumber\Unitcode,HousecodeNumber\unitOff] 'Could send this as many times as you like 'xout TW523_IN,TW523_CLK,[HousecodeNumber\Unitcode,HousecodeNumber\unitOff] GOTO SKP ActON: xout TW523_IN,TW523_CLK,[HousecodeNumber\Unitcode,HousecodeNumber\unitOn] 'Could send this as many times as you like 'xout TW523_IN,TW523_CLK,[HousecodeNumber\Unitcode,HousecodeNumber\unitOn] GOTO SKP ActDIM: xout TW523_IN,TW523_CLK,[HousecodeNumber\dim\DimBriRep] 'Could put a PAUSE here so repeated RF DIMs don't get sent to TW523 'PAUSE 100 GOTO SKP ActBRI: xout TW523_IN,TW523_CLK,[HousecodeNumber\bright\DimBriRep] 'Could put a PAUSE here so repeated RF BRIs don't get sent to TW523 'PAUSE 100 GOTO SKP ActALLOFF: xout TW523_IN,TW523_CLK,[HousecodeNumber\unitsOff] 'Could send this as many times as you like 'xout TW523_IN,TW523_CLK,[HousecodeNumber\unitsOff] GOTO SKP ActALLON: xout TW523_IN,TW523_CLK,[HousecodeNumber\lightsOn] 'Could send this as many times as you like 'xout TW523_IN,TW523_CLK,[HousecodeNumber\lightsOn] GOTO SKP SKP: '************************************************************************* '************************************************************************* 'PAUSE 500 'Wait a bit (lets others repeated bits pass by...) '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'Actually if this is omitted, it appears to read 'ALL RF generated signals, even repeated signals from 'remotes such as the newer palm control, HR12A 'Most repeated commands are decoded but, the delay in 'sending commands to the TW523 can sometimes be long 'enough that the Stamp will miss the next repeated command '(BTW, an On or Off action requires that two commands be 'sent to the TW523. One to Address Housecode and Unitcode, 'then another to send Housecode and Action (On or Off). 'Repeated DIMs and BRIs are almost always detected since 'the they require only one command be sent to the TW523 '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'Finished send X-10 Command to TW-523. 'Now, loop back and wait for next long positive pulse (start) GOTO MAINLOOP '========================================================================== '========================================================================== 'Program should never get here... but always good to be complete with an END statement! END