Please login or register.

Login with username, password and session length

Author Topic: Controlling CM11 with own program  (Read 37594 times)

Richard S

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 1
Controlling CM11 with own program
« on: April 21, 2006, 03:48:24 AM »

Hi,

I am trying to communicate with CM11 with my own program

I am using the CM11 protocol documents available on the Internet

The CM11 responds to the Header:Code with the correct checksum. However when I send 0X00 to it to acknowledge this I get nothing back from the CM11. I am expecting 0x55

Are there any known issues here e.g. timing of sending 0x00,  Is 0x00 the correct value to send etc.

The CM11 does not have any batteries in - is this relevant

If anyone can point me to some working code in C or BASIC that would be useful

Many Thanks

Richard
Logged

Dan Lawrence

  • Hero Member
  • *****
  • Helpful Post Rating: 68
  • Posts: 3991
Re: Controlling CM11 with own program
« Reply #1 on: April 21, 2006, 03:35:28 PM »

The CM11A does have batteries. I still have mine put away, and there is a battery compartment with AAA batteries.
Logged
I don't SELL this stuff... BUT I sure do ENJOY using it!!!

Charles Sullivan

  • Hero Member
  • *****
  • Helpful Post Rating: 94
  • Posts: 1565
    • HEYU - X10 Automation for Linux, Unix, and Mac OSX
Re: Controlling CM11 with own program
« Reply #2 on: April 25, 2006, 08:07:52 PM »

Richard S:
If your "CM11" has no batteries, it's not a CM11 but probably a CM10 (IBM Home Director HD16).  What does the label say?

If so, it will poll the PC for a restart when AC power has been interrupted and will accept no commands until you do this.  You can restart the CM10 by sending it a 0xFB byte immediately followed by 42 bytes of 0x00.
Logged
Yesterday it worked.
Today it doesn't work.
X10 on Windows is like that.

HEYU - X10 Automation for Linux, Unix, and Mac OS X     http://www.heyu.org

billy

  • Sr. Member
  • ****
  • Helpful Post Rating: 7
  • Posts: 110
Re: Controlling CM11 with own program
« Reply #3 on: April 28, 2006, 12:50:19 PM »

The CM11 does not have any batteries in - is this relevant

I think Richard means he does not have the batteries installed in the CM11.
Logged
"I would rather live my life as if there is a God and die to find out there isn't, than live my life as if there isn't and die to find out there is."  Albert Camus

Charles Sullivan

  • Hero Member
  • *****
  • Helpful Post Rating: 94
  • Posts: 1565
    • HEYU - X10 Automation for Linux, Unix, and Mac OSX
Re: Controlling CM11 with own program
« Reply #4 on: April 28, 2006, 01:37:46 PM »

Richard S:  If your unit has a battery compartment but no batteries installed, then the answer to your question is that a CM11A will transmit and receive signals just fine without batteries.  The batteries are only required to maintain the clock when it's disconnected from the AC line.   (There will be a problem if batteries are installed but they're dead.)

Yes, the 0x00 is the correct byte to write to the CM11A after you receive back the correct checksum.  Is the CM11A actually sending out a signal despite the missing 0x55?  Try sending an All-Lights-On.  If no signal is being sent, you might try adding a short delay of about 10 milliseconds between receiving the checksum and sending the 0x00.
Logged
Yesterday it worked.
Today it doesn't work.
X10 on Windows is like that.

HEYU - X10 Automation for Linux, Unix, and Mac OS X     http://www.heyu.org

tnt

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 4
CM11 A + RCS NOT WORK MACROS
« Reply #5 on: May 16, 2006, 02:04:43 PM »

Please, HELP ME!!, alive in Argentina and I have installed X10 system with 8R5PX X10 Controller Relay of RCS: http://HTTP://www.resconsys.com/products/relay/8%20Channel.htm to which when him send macros created with Activates Home 1.4 for my CM11A, they do not work (single the first order is executed). But if it works, if the macros I create with Home Seer, the problem is that they are not possible to be lowered to the interface with that software, somebody can help me?

Tank you and sorry for my bad english
Logged

Charles Sullivan

  • Hero Member
  • *****
  • Helpful Post Rating: 94
  • Posts: 1565
    • HEYU - X10 Automation for Linux, Unix, and Mac OSX
Re: Controlling CM11 with own program
« Reply #6 on: May 16, 2006, 02:55:09 PM »

tnt:
Do yourself a favor and buy an X10 Maxi-Controller.  Then you'll know _exactly_ what signals you're sending to the 8R5PX.
Logged
Yesterday it worked.
Today it doesn't work.
X10 on Windows is like that.

HEYU - X10 Automation for Linux, Unix, and Mac OS X     http://www.heyu.org

tnt

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 4
Thank you Charles
« Reply #7 on: May 16, 2006, 09:37:17 PM »

Dear Charles. Thanks for the answer, I have maxi to controler but equal it does not work, so time I did not know to express, that commandos sent, but rcs does not interpret the macros recorded with activate home, but if the done ones with home to seer
Logged

hkactive

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 50
Re: Controlling CM11 with own program
« Reply #8 on: May 31, 2006, 04:37:11 PM »

Richard, programming the CM11A is no easy task. I couldn't find any really definitive help on the web. But I was able to piece together enough to finally get the CM11A working like a charm. The following hints should give you a big head start.

There is no such thing as a timing issue.

Please, do not try any tricks to make it work. Some have tried some tricks; e.g. for x = 0 1000000; next  -- to get it to respond and produce feedback. Go ahead if you feel like it, but you have been warned. You can get it to halfway work. But you will drive yourself crazy.

Just set up your software correctly using the MsComm Component.

Here are some general guidelines to follow using VB6:

(1) Set your Send Threshhold to 1.
(2) Set your Receive Threshhold to 1.
(3) Set the input mode to Binary instead of Text
(4) Set your settings according to specs: 4800, N, 8, 1

 You can set it up with Text Mode. But this bombs on one of the house codes. Just one. But it does bomb.

Initialize the HouseAddress (HouseCode and Device Code)  first on the  CiM11A using hex code 4 as per the CM11A_protocol.txt.

 .ouput = Chr$(&H4) & Chr$("&H" & strHouseCode & strDeviceCode)   Both of these variables need to be strings and already converted to Hex$ values.
Read the documentation!

   0x04 in binary is 100, this is the value you want to use for initialization. Don't get this confused with sending a Housecode

Initialize the function command first with the following. You'll only want to do this after verifying that the checksums match.
 
PseudoCode:
Extract CM11a Checksum
Check the sum of the initialization string to see that it matches.
If it matches, initialiize the function wtih the following.

Send a function using Hex$ 6 (binary 110):
  .output = chr$(&H6) & chr$(&H0)

Again, don't confuse the 0x06 value with a house code. And you do need the 0x00 in there following the 0x06!

Again, after sending this initialization string, you'll receive another input in the OnCom even: the CM11a responding to the initialiation string. See if you can't stop your program using the debug mode to query the value. After you see a few returns you should see a pattern. Based on your observations, you should be able to write code to deal with the buffer return from the CM11a after the function initialization string.

Preceding the Function call with this output forces the CM11 to respond with a checksum, which you can detect in the OnComm Event and program accordingly before sending your function command:

For example, after you pickup the right checksum from the OnComm Event, then send the command:
  .output = Chr$(&h6) & chr$("&H" & strHouseCode & strHouseCommand)

Both variables need to be in Hex$: e. g. the housecode and the HouseCommand ( "2", "3", etc.......)


Check your checkum values. The documentation tells you what to look for.
All checksum values should be detected in the OnComm event. Once you receive a correct checksum in response to the above. Program your code to repsond appropriately.

But how do I get the checksum?
Declare at least 2 variables in the OnComm event to pick up the responses from the CM11:
Dim strBuffer as string, bytereceived() as byte

The second variable is a byte array. You will pick up different bounds on the array depending on what the CM11A sends:
Basically your array will have a boundary with 1 value or more. Use the values produced from the input with 2 values to extract your checksums.
If the boundary of the array has 2 values, extract the first value from the Buffer to obtain the checksum:

For example:

bytereceived() = .input

In essence an OnCom event receives the binary output from the CM11A. This data is transmitted as a binary array. If you want to verify this, you can declare a variant variable and have the input assigned to the variant. And then just use the varType function to find out exactly what type of data your storing.

Dim varReceived as variant
varReceived = .input
debug.print vartype(varReceived)

You should see an output of a number in the 8 or 9000 range. Consult your MSDN documention on the varType function to see exactly what the number means.

bytereceive(0)  should be the check sum. You'll have to convert it into a Hex$. It's a binary value that you'll convert to a Hex$ value that you can understand and that corresponds with the documentation of the CM11A protocol.txt

But that's a start. I'm not gong to do all the work for you. I wouldn't want to take away all the fun. But it doesn't seem that many people have gotten past the initial stage of figuring out how to send the basic commands. But this should give you a good head start.

You can do further checks on the byte array boundary count to respond to different situations. But I'll leave that programming to you. But the general principle is to initiate an output, get the feedback from the CM11 in the OnCommEvent and put your code in the OnComm Event to deal with the various input strings you extract from using the mscomm.input value inside the OnComm Event.

And another good hint would be to use the ComEvSend and the ComEvReceive constants that come built in with the MSComm control within the OnComm event. But the ComEvReceive should take care of about 99% of what you want done.

Also, there are a few situations that will pop up when you unplug your CM11A, a radio frequency device has sent a signal to the CM11a (e.g. RR501), etc. Two of the byte values that you'll have to write special code for are "5A" and "A5." Just read the CM11A_protocol.txt. Search for these values, and the documentation should tell you how to respond. All these responses should be dealt with within the OnCom subroutine.

Hank


 










« Last Edit: June 01, 2006, 03:17:50 PM by hkactive »
Logged
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.