X10 Community Forum

🔌General Home Automation => Original ActiveHome => Topic started by: Stevena on February 18, 2007, 06:06:12 PM

Title: CM11a with VB 2005
Post by: Stevena on February 18, 2007, 06:06:12 PM
I am a novice programmer and am trying to send commands to the cm11a. I can send commands and get it to respond but I'm sure I am sending the addresses and command incorrectly because modules aren't triggered. I don't understand the protocol or how to use it with VB. Can someone provide me with a sample code for this. A simple sample should make it clear to me.

Thanks
Title: Re: CM11a with VB 2005
Post by: Brian H on February 19, 2007, 12:16:05 PM
Have you downloaded the CM11 protocol information from the X10 web site as a start?
Title: Re: CM11a with VB 2005
Post by: Stevena on February 22, 2007, 01:01:08 PM
Yes, I have it but I don't quite understand it. How do you get from 01100110 to 0x04,0x66 for A1. Do you send that as a string? I get back 165 or A6 in hex
Title: Re: CM11a with VB 2005
Post by: Charles Sullivan on February 22, 2007, 05:21:54 PM
Yes, I have it but I don't quite understand it. How do you get from 01100110 to 0x04,0x66 for A1. Do you send that as a string? I get back 165 or A6 in hex

I don't do VB so can't give programming instructions.  But the 01100110 is the address byte, 0x66, for A1.  The 0x04 is the "header" byte which tells the CM11A the following byte is an address like A1 rather than a function like A-On.

You would write this to the CM11A as a string of two pure binary bytes, i.e., (04)(66).  You should then read back from the CM11A a binary byte representing the 8-bit checksum of the bytes you wrote, i.e. (0x04 + 0x66) & 0xFF  = 0x6A.

If the checksum is correct, write a single byte of 0x00 to tell the CM11A to transmit the address over the power line.  When the CM11A has successfully completed the transmission, you will read the byte 0x55 from the CM11A indicating it is ready to receive the next command, which could be another address on the same housecode or a function.

Except for Dim, Bright, and Extended Code functions, the header byte for functions is 0x06.  So that for A-On you would send the string (06)(62); for A-Off the string is (06)(63).

Good luck.


Title: Re: CM11a with VB 2005
Post by: Stevena on February 22, 2007, 07:13:47 PM
Thanks, it's a little more clear now, I'll give it another try.
Title: Re: CM11a with VB 2005
Post by: Stevena on February 25, 2007, 04:15:34 PM
Still no luck. The cm11a always sends back a string of 165.
Title: Re: CM11a with VB 2005
Post by: Charles Sullivan on February 25, 2007, 05:13:26 PM
Still no luck. The cm11a always sends back a string of 165.

Ahah!  You had me confused there for a while.  165 = 0xA5, not 0xA6.

When the CM11A is first powered up, or if there's any momentary interruption of AC power, it will poll the PC with a continuous stream of 0xA5 once a second, which is its request for a clock update from the PC.   Until that request is satisfied it will accept no other commands.

You can satisfy this request by sending a single byte of 0x9B and waiting for a second or so.  This doesn't set the clock but will stop the polling.  Once you've gotten in a little deeper you can work up the VB code for actually setting the clock (per section 8 of the X10 protocol document).

Title: Re: CM11a with VB 2005
Post by: Stevena on March 01, 2007, 01:29:47 AM
Thanks Charles, I'll see if this gets me a little farther.
Title: Re: CM11a with VB 2005
Post by: Stevena on March 01, 2007, 01:55:32 AM
Ok maybe I don't understand. How exactly do I send 9B. I've been trying to send the 04 and 66 in two seperate string pairs. I'm sure I'm doing this wrong too.
Title: Re: CM11a with VB 2005
Post by: Charles Sullivan on March 01, 2007, 08:23:39 AM
Ok maybe I don't understand. How exactly do I send 9B. I've been trying to send the 04 and 66 in two seperate string pairs. I'm sure I'm doing this wrong too.

This is a Visual Basic  programming question and I have no knowledge whatsoever of that language.  Sorry.

Title: Re: CM11a with VB 2005
Post by: pegas on March 07, 2007, 12:01:03 AM
If you still need to see how to handle hexa vanues in VB, post the code snippet here, I might be able to fix it. ;D