Insteon Programming · PLM Basics · X10 · PLM Receiving · Insteon Commands · Ramp Rates · Devices · i2cs · Deus Ex Machina

Sending X10 Commands with the PLM

This isn't too bad, but there are a couple quirks to be aware of. One limitation is that sending X10 codes breaks if you go too fast. I added a Wait subroutine (see the end of this page). The PLM seems to need a 500 millisecond pause between X10 commands. Lower delays didn't seem to work.

Also, the indexes are odd. I set up two arrays with the necessary values (see below).

The following also assumes that

house = the X10 house code as an integer, 0 = A, etc
device = the X10 device code as an integer

Put this in the declarations area of your form/module:

Public PLM_X10_House(16) as Byte
Public PLM_X10_Device(16) as Byte

Set the values for those areas somewhere convenient (like Form1.Load):

PLM_X10_House(1) = 96  ' House code A
PLM_X10_House(2) = 224  ' House code B
PLM_X10_House(3) = 32  ' House code C
PLM_X10_House(4) = 160  ' House code D
PLM_X10_House(5) = 16  ' House code E
PLM_X10_House(6) = 144 ' House code F
PLM_X10_House(7) = 80 ' House code G
PLM_X10_House(8) = 208  ' House code H
PLM_X10_House(9) = 112 ' House code I
PLM_X10_House(10) = 240 ' House code J
PLM_X10_House(11) = 48  ' House code K
PLM_X10_House(12) = 176 ' House code L
PLM_X10_House(13) = 0 ' House code M
PLM_X10_House(14) = 128  ' House code N
PLM_X10_House(15) = 64  ' House code O
PLM_X10_House(16) = 192  ' House code P

PLM_X10_Device(1) = 6
PLM_X10_Device(2) = 14
PLM_X10_Device(3) = 2
PLM_X10_Device(4) = 10
PLM_X10_Device(5) = 1
PLM_X10_Device(6) = 9
PLM_X10_Device(7) = 5
PLM_X10_Device(8) = 13
PLM_X10_Device(9) = 7
PLM_X10_Device(10) = 15
PLM_X10_Device(11) = 3
PLM_X10_Device(12) = 11
PLM_X10_Device(13) = 0
PLM_X10_Device(14) = 8
PLM_X10_Device(15) = 4
PLM_X10_Device(16) = 12

To send an X10 On command:

Dim data(3) as Byte

data(0) = 2   ' start first message: send X10 address only
data(1) = 99  ' 0x063 = Send X10
data(2) = PLM_X10_House(house + 1) + PLM_X10_Device(device)  ' X10 address (house + device)
data(3) = 0   ' flag = this is the address
SerialPLM.Write(data, 0, 4)
Wait(500)
data(0) = 2   ' start second message: send X10 house + command
data(1) = 99  ' 0x063 = Send X10
data(2) = PLM_X10_House(house + 1) + 2   ' X10 address (house + command)
data(3) = 128 ' flag = this is house + address
SerialPLM.Write(data, 0, 4)

To send an X10 Off command:

Dim data(3) as Byte

data(0) = 2   ' start first message: send X10 address only
data(1) = 99  ' 0x063 = Send X10
data(2) = PLM_X10_House(house + 1) + PLM_X10_Device(device)  ' X10 address (house + device)
data(3) = 0   ' flag = this is the address
SerialPLM.Write(data, 0, 4)
Wait(500)
data(0) = 2   ' start second message: send X10 house + command
data(1) = 99  ' 0x063 = Send X10
data(2) = PLM_X10_House(house + 1) + 3   ' X10 address (house + command)
data(3) = 128 ' flag = this is house + address
SerialPLM.Write(data, 0, 4)

To send an X10 Bright command:

Dim data(3) as Byte
Dim Level as integer ' the amount to brighten (on a scale 0-100)
Dim i as Short

data(0) = 2   ' start first message: send X10 address only
data(1) = 99  ' 0x063 = Send X10
data(2) = PLM_X10_House(house + 1) + PLM_X10_Device(device)  ' X10 address (house + device)
data(3) = 0   ' flag = this is the address
SerialPLM.Write(data, 0, 4)
For i = 1 To Int(Level * 0.22)
     Wait(500)
     ' brighten repeatedly to get to Level. 22 levels = 100%
     ' just send house + command (faster to not repeat address)
     data(0) = 2   ' start second message: send X10 house + command
     data(1) = 99  ' 0x063 = Send X10
     data(2) = PLM_X10_House(house + 1) + 5   ' X10 address (house + command)
     data(3) = 128 ' flag = this is house + address
     SerialPLM.Write(data, 0, 4)
Next i

To send an X10 Dim command:

Dim data(3) as Byte
Dim Level as integer ' the amount to brighten (on a scale 0-100)
Dim i as Short

data(0) = 2   ' start first message: send X10 address only
data(1) = 99  ' 0x063 = Send X10
data(2) = PLM_X10_House(house + 1) + PLM_X10_Device(device)  ' X10 address (house + device)
data(3) = 0   ' flag = this is the address
SerialPLM.Write(data, 0, 4)
For i = 1 To Int(Level * 0.22)
     Wait(500)
     ' brighten repeatedly to get to Level. 22 levels = 100%
     ' just send house + command (faster to not repeat address)
     data(0) = 2   ' start second message: send X10 house + command
     data(1) = 99  ' 0x063 = Send X10
     data(2) = PLM_X10_House(house + 1) + 4   ' X10 address (house + command)
     data(3) = 128 ' flag = this is house + address
     SerialPLM.Write(data, 0, 4)
Next i

Put this somewhere to call the delays

   Public Sub Wait(ByVal Milliseconds As Integer)
       Dim time As Date
       time = Now.AddMilliseconds(Milliseconds)
       Do While time > Now
           Application.DoEvents()
       Loop
   End Sub