X10 Community Forum

🔌General Home Automation => Original ActiveHome => Topic started by: sarahlj16 on February 10, 2010, 10:19:31 AM

Title: Developing my own X10 Controller Software
Post by: sarahlj16 on February 10, 2010, 10:19:31 AM
Hi guys,

I am a newB to X10. I'm an embedded design engineer. Apologies if I'm in the wrong forum.

I am looking to provide the interface to an X10 controller in place of the PC. I essentially have a bit of kit with a microprocessor,a serial port and some inputs. I have read the communication protocol document and begun communicating with the X10 controller (CM11/CM12).  Well kind of!

After power up, I receive the byte 0xa5 every second (Power Fail Download Poll Code). I understand the controller is wanting a response followed by a 42 byte macro.

The problem is that I don't want to use macros. I just want to be able to send commands to the controller whenever I like.

Should I send a blank macro? Then just send commands when I want.

Thanks for any help
Sarah
Title: Re: Developing my own X10 Controller Software
Post by: Brian H on February 10, 2010, 12:57:51 PM
0xa5 is the Set Interface Clock request.
I believe it will not stop until you set the clock.
Then it will be ready to process other things.
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 10, 2010, 02:50:36 PM
Hi guys,

I am a newB to X10. I'm an embedded design engineer. Apologies if I'm in the wrong forum.

I am looking to provide the interface to an X10 controller in place of the PC. I essentially have a bit of kit with a microprocessor,a serial port and some inputs. I have read the communication protocol document and begun communicating with the X10 controller (CM11/CM12).  Well kind of!

After power up, I receive the byte 0xa5 every second (Power Fail Download Poll Code). I understand the controller is wanting a response followed by a 42 byte macro.

The problem is that I don't want to use macros. I just want to be able to send commands to the controller whenever I like.

Should I send a blank macro? Then just send commands when I want.

Thanks for any help
Sarah

Sending one byte of 0x9b to the CM11A should stop the 0xa5 polling.  You may need to wait a few hundred milliseconds before sending it another command.

If you haven't already done so, download http://www.heyu.org/docs/protocol.txt which contains a number of corrections to X-10's original protocol document (including the above tip).

That 42 byte macro mentioned in the protocol is only for the CM10A (the older device without clock or battery backup sold primarily as the IBM HD16 Home Director).  The CM11A macros are different and described further down in the document.

Title: Re: Developing my own X10 Controller Software
Post by: halju on February 10, 2010, 04:41:55 PM
I have the RCA CM11a/HC60RX and its sending out 0xFC (decimal 252). i've searched the updated protocol that was posted, and i cant find a reasoning for this number. Do you have any idea what it means?
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 10, 2010, 09:18:25 PM
I have the RCA CM11a/HC60RX and its sending out 0xFC (decimal 252). i've searched the updated protocol that was posted, and i cant find a reasoning for this number. Do you have any idea what it means?

I have no idea.  The CM11A has probably gotten into an unstable state (or has gone bad).

Try unplugging from AC, removing the batteries, and letting it sit for one hour.  It would probably then be a good idea to temporarily operate the CM11A with ActiveHome (or other similar program) long enough to reset the clock and erase the EEPROM memory.
Title: Re: Developing my own X10 Controller Software
Post by: sarahlj16 on February 11, 2010, 04:36:52 AM
Thanks everyone, I have downloaded the corrected document. I shall hopefully make more progress today....
Title: Re: Developing my own X10 Controller Software
Post by: sarahlj16 on February 11, 2010, 05:42:27 AM
Hi,

Just to clarify. After I have responded to the 0xa5 command with 0x9b. Do I have to set anything else up or can I just start sending house/device and functions codes like example 3.14  protocol document?

I don't want to use macros as my development kit will determine what action needs to be taken and when.

Thanks

Sarah
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 11, 2010, 10:47:03 AM
Hi,

Just to clarify. After I have responded to the 0xa5 command with 0x9b. Do I have to set anything else up or can I just start sending house/device and functions codes like example 3.14  protocol document?

I don't want to use macros as my development kit will determine what action needs to be taken and when.

Thanks

Sarah

You should be able to start sending the house/device and function codes.
Title: Re: Developing my own X10 Controller Software
Post by: sarahlj16 on February 11, 2010, 11:02:20 AM
Oh, I've sent 0x04, 0x66 after the 0x9b (wait 100ms) and I get no reply.

I will keep investigating. I must be doing something wrong!!

Thanks for your reply....
Title: Re: Developing my own X10 Controller Software
Post by: sarahlj16 on February 11, 2010, 11:37:41 AM
I've got this sorted now. Thanks for the help.....
Title: Re: Developing my own X10 Controller Software
Post by: pconroy on February 12, 2010, 10:10:43 PM
Its kinda' fun when it works, isn't it?

Charles - your docs are excellent, I've been devouring them.
Thanks for taking the time to put them together.

Title: Re: Developing my own X10 Controller Software
Post by: halju on February 21, 2010, 10:09:57 AM
Sarah- After you sent the 0x04 and 0x66 what did you do? I'm at that same point.

Charles- Thanks for all your help, i took your advice and ordered a new Controller, now im getting the 0xa5. So i feel im finally going in the direction
Title: Re: Developing my own X10 Controller Software
Post by: halju on February 21, 2010, 11:04:47 AM
Well i got past sending 04 66 and I've got the check some. However, when i send 00 i get nothing. After reading the document i believe im supposed to be getting the 0x55 then i can send the function code to turn on the light 0x06 0x62.  any insight on sending the 0x00?
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 21, 2010, 02:07:15 PM
Well i got past sending 04 66 and I've got the check some. However, when i send 00 i get nothing. After reading the document i believe im supposed to be getting the 0x55 then i can send the function code to turn on the light 0x06 0x62.  any insight on sending the 0x00?

I assume that you have verified that your CM11A is working properly (by testing it under ActiveHome 1.42 or other software) and are doing the following:
   write 0x04,0x66
   read back checksum  (0x6a)
   write 0x00
   try to read back 0x55

The CM11A should start sending out the X10 signal on the AC powerline once you write the 0x00, and a module set for housecode|unit A1 should respond even though you don't read the 0x55.  Does it?

Have you tried sending the command more than one time in a row?  If you use the abbreviated method for halting the 0xa5 poll for a clock update and don't wait long enough (1-2 seconds) after that, the next command will often fail.

 
Title: Re: Developing my own X10 Controller Software
Post by: halju on February 21, 2010, 05:44:14 PM
I just ran it with Active Home, i have Version 1.4 (B2.0.70) and it works correctly.

Im running it with my homemade program and I'm getting the 0xA5 and i stop it with the 0x9b. I then waited a few seconds and then sent 0x04, 0x66. After recieving a check sum of 6A, i sent the 0x00. i didnt get anything back. I moved past it like you mentioned and went on to send the 0x06, 0x62 and im using the XPS3 Fluorescent wall switch (WS13A)  im not getting a response out of it. I made a program to show the input/output...

Byre Received at 5:34:43 PM : 498 msec: A5
Byre Received at 5:34:45 PM : 339 msec: A5
Byre Received at 5:34:47 PM : 181 msec: A5
Sent at 5:34:48 PM : 668 msec: 9b
Sent at 5:35:44 PM : 934 msec: 0466
Byre Received at 5:35:45 PM : 43 msec: 6A
Sent at 5:36:04 PM : 199 msec: 00
Sent at 5:36:32 PM : 206 msec: 0662
Byre Received at 5:36:32 PM : 314 msec: 68
Sent at 5:36:36 PM : 285 msec: 00
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 21, 2010, 06:41:00 PM

It's possible that sending the 0x9b to stop the 0xa5 poll isn't sufficient if the CM11A clock isn't already set to a valid (although incorrect) date and time.

Let's try sending a valid time update:
  send  0x9b 0x2e 0x06 0x09 0x3e 0x01 0x00   (7 bytes, representing Sunday, Day 062, 18:06:46 - see protocol section 8)
  read back checksum  (0x7c - the sum of the 6 bytes following the 0x9b)
  send 0x00
  read back 0x55

Then try sending your commands again.

Title: Re: Developing my own X10 Controller Software
Post by: halju on February 21, 2010, 07:42:13 PM
im getting the check sum 0x7c but still not getting the 0x55 after i send 0x00  B:(
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 22, 2010, 08:53:26 AM
im getting the check sum 0x7c but still not getting the 0x55 after i send 0x00  B:(

When you;
   send 0x04,0x66
   receive 0x6a
   send 0x00

The 0x55 won't be returned until after the X10 transmission is completed, which will take about 0.7 seconds.  Your read function may be timing out before then.  If your read function is not a blocking read (i.e., it sits and waits for a byte to be available) with an adjustable timeout, try reading up to 10 times with a 0.1 second delay between tries.
Title: Re: Developing my own X10 Controller Software
Post by: halju on February 22, 2010, 01:08:41 PM
I'll extend the read time. What about sending the 0x00? Is there a time i should wait in between reading the checksum?
Like you said send the 0x9b then wait about 1-2 seconds
then send 0x04 0x66 and i receive the 0x6a about 1-2 milliseconds later
what is the time guidelines i should use when sending the 0x00? I'm using a homemade program similar to hyper-terminal, I almost think I'm not sending the 0x00 fast enough. it usually takes me 2-3 seconds to send the 0x00. is this to long?

also thanks for all your help so far, i really appreciate it
Title: Re: Developing my own X10 Controller Software
Post by: pconroy on February 22, 2010, 07:23:08 PM
The other thing you can do - I think - is loop a few times.

Send an 0x00.
Wait for an 0x55.
If you don't get it - sleep a smidge (or delay) and then loop again.

Make sure you code a loop exit...  :)


Also - if you're just trying to get things working - go ahead and put some lengthy delays in your code. Sleep a second or two.
Once you're happy your sending the right bytes, calculating the checksums, etc - then you can start trimming them down.

That's what I'd do.


I don't know if you can do this in your programming language - but I found it easier (for me at least) to dedicate a thread to servicing the port.
Input is thrown into a circular buffer as it comes in.  My other threads can pick it out at their leisure.  I really did this because my Powerlinc serial controller seems fond of sending garbage and I was tired of weeding thru it.  It's made my CM11A stuff easier, for me at least.

Just a thought.
Title: Re: Developing my own X10 Controller Software
Post by: halju on February 22, 2010, 09:26:59 PM
Thank you everyone!!!! i was able to get it working!
thanks!!
Title: Re: Developing my own X10 Controller Software
Post by: Charles Sullivan on February 22, 2010, 10:37:02 PM
Thank you everyone!!!! i was able to get it working!
thanks!!

 :)%
Please enlighten us as to what you did differently to get it working.