X10Cmd Program

Started by gouardopatrick February 3, 2009
Hello World of BX-24 !

I have written this little program to control X10 appliance
connected to B3 House Code Device code.
The BX-24 is connected to an XM10E-120 device which send the X10
order to the main 230 V of the house

But nothing work and first I question the cabling of what Pin of BX-
24 should be connected to what pin of the XM10E-120.

I believe that what I have written in comment at the beginning of my
program is correct for the connexion.

So because nothing was working, I disconnected the XM10E-120 and put
some test point like Call PutPin (12,0) and Call PutPin (12,1) and
the Debug.Print CStr(V) increasing the V value every time I go in
the loop.
To be able to have my LED blinking and the V printing, I had to put
in Comment the 3 command Call X10Cmd.

Is this normal ?
Is the X10Cmd Command written in my program correct
Is the In/Out pin of BX-24 and XM10 correctly defined and connected ?

Thanks for your help.

Patrick.

*****************************************

Option Explicit

Public Sub Main()
'This program send data to an XM10E-120
'in order to switch On and Off radiators connected to
'X10 Appliance device with House code from A to D
'And Unit ID from 1 to 8

'Test for B3 Appliance Device

Dim V As Single
V=0.0

'House ID
Const X10_A As Byte = &H6
Const X10_B As Byte = &HE
Const X10_C As Byte = &H2
Const X10_D As Byte = &HA

'Unit ID
Const X10_1 As Byte = &HC
Const X10_2 As Byte = &H1C
Const X10_3 As Byte = &H4
Const X10_4 As Byte = &H14
Const X10_5 As Byte = &H2
Const X10_6 As Byte = &H12
Const X10_7 As Byte = &HA
Const X10_8 As Byte = &H1A

'Commands
Const X10_AllUnitsOff As Byte = &H1
Const X10_AllLightsOn As Byte = &H3
Const X10_On As Byte = &H5
Const X10_Off As Byte = &H7

'Divers
'Pin 8 for Clock from XM10E - BX-24 Input
'Pin 7 for X10 Out from XM10E - Not Used in Our Application
'Pin 6 for X10 Input of XM10E - BX-24 Output

Const Clock_Pin As Byte = 8
Const X10_Out As Byte = 7
Const X10_In As Byte = 6
'Call x10cmd(7, 8, X10_B, X10_3, 2)

Do
Debug.Print CStr(V)
V=V+1.0
Call PutPin(12, 1)
'Call x10cmd(X10_Out, Clock_Pin, X10_B, X10_On, 2)
Call Delay(1.0)
'Call x10cmd(X10_Out, Clock_Pin, X10_B, X10_Off, 2)
Call putpin(12, 0)
Call Delay(1.0)
Loop

End Sub

I haven't used X10 code in years, but below is the sub that worked for me. I used different pins. I think that your code is set up to turn on all receivers with a 'B' house code, but you may want to try different commands - see link below. My code below addressed a specific house and key code. I address the switch first, then tell it what to do.

In the following link
http://www.x10.com/technology1.htm
there is a distinction between 'off' and 'all off'. The same with on.

&H1 All Units Off
&HE All Lights Off *Try this in your code
&H3 All Lights On *Try this in your code

For testing purposed, you should also have the X10 interface and the ?lamp? attached to the same outlet. A power strip is good. When I tested X10 at the university, their electrical wiring was such that X10 didn't work. It did work at home, though it drove me nuts because my touch lamp changed brightness every time the X10 transmitted.

Hope that helps. The link above should point you in the right direction.

Thad

' _______________
'___________/ X-10 Turn On \_____________
Public Sub X10_On(ByVal House_Code As Byte, ByVal Key_Code As Byte)
Dim X10_On As Byte
X10_On = bx0000_0101
Call X10Cmd(16, 17, House_Code, Key_Code, 5)
Call Delay(0.1)
Call X10Cmd(16, 17, House_Code, X10_On, 8)
Call Delay(0.1)
End Sub
' ________________
'___________/ X-10 Turn Off \_____________
Public Sub X10_Off(ByVal House_Code As Byte, ByVal Key_Code As Byte)
Dim X10_Off As Byte
X10_Off = bx0000_0111
Call X10Cmd(16, 17, House_Code, Key_Code, 5)
Call Delay(0.1)
Call X10Cmd(16, 17, House_Code, X10_Off, 8)
Call Delay(0.1)
End Sub

--- On Mon, 2/2/09, gouardopatrick wrote:
From: gouardopatrick
Subject: [BasicX] X10Cmd Program
To: b...
Date: Monday, February 2, 2009, 8:37 PM


Hello World of BX-24 !

I have written this little program to control X10 appliance

connected to B3 House Code Device code.

The BX-24 is connected to an XM10E-120 device which send the X10

order to the main 230 V of the house

But nothing work and first I question the cabling of what Pin of BX-

24 should be connected to what pin of the XM10E-120.

I believe that what I have written in comment at the beginning of my

program is correct for the connexion.

So because nothing was working, I disconnected the XM10E-120 and put

some test point like Call PutPin (12,0) and Call PutPin (12,1) and

the Debug.Print CStr(V) increasing the V value every time I go in

the loop.

To be able to have my LED blinking and the V printing, I had to put

in Comment the 3 command Call X10Cmd.

Is this normal ?

Is the X10Cmd Command written in my program correct

Is the In/Out pin of BX-24 and XM10 correctly defined and connected ?

Thanks for your help.

Patrick.

************ ********* ********* ********* **

Option Explicit

Public Sub Main()

'This program send data to an XM10E-120

'in order to switch On and Off radiators connected to

'X10 Appliance device with House code from A to D

'And Unit ID from 1 to 8

'Test for B3 Appliance Device

Dim V As Single

V=0.0

'House ID

Const X10_A As Byte = &H6

Const X10_B As Byte = &HE

Const X10_C As Byte = &H2

Const X10_D As Byte = &HA

'Unit ID

Const X10_1 As Byte = &HC

Const X10_2 As Byte = &H1C

Const X10_3 As Byte = &H4

Const X10_4 As Byte = &H14

Const X10_5 As Byte = &H2

Const X10_6 As Byte = &H12

Const X10_7 As Byte = &HA

Const X10_8 As Byte = &H1A

'Commands

Const X10_AllUnitsOff As Byte = &H1

Const X10_AllLightsOn As Byte = &H3

Const X10_On As Byte = &H5

Const X10_Off As Byte = &H7

'Divers

'Pin 8 for Clock from XM10E - BX-24 Input

'Pin 7 for X10 Out from XM10E - Not Used in Our Application

'Pin 6 for X10 Input of XM10E - BX-24 Output

Const Clock_Pin As Byte = 8

Const X10_Out As Byte = 7

Const X10_In As Byte = 6

'Call x10cmd(7, 8, X10_B, X10_3, 2)

Do

Debug.Print CStr(V)

V=V+1.0

Call PutPin(12, 1)

'Call x10cmd(X10_Out, Clock_Pin, X10_B, X10_On, 2)

Call Delay(1.0)

'Call x10cmd(X10_Out, Clock_Pin, X10_B, X10_Off, 2)

Call putpin(12, 0)

Call Delay(1.0)

Loop

End Sub