Please login or register.

Login with username, password and session length
Pages: [1] 2

Author Topic: Arduino-Based X10 control  (Read 40509 times)

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Arduino-Based X10 control
« on: August 02, 2012, 10:43:08 PM »

Well, I just took another look at what's out there for interfacing an Arduino with a TW523 (which my XTB-IIR emulates).
It seems there have been a number of updates, including updates to the libraries to work with the newer versions (since 1.0) of the Arduino IDE.
I think I'll have to play with this again at home, and see where it gets me.
I spent a few hours this evening looking at Tom Igoe's X10 library for Arduino:
https://github.com/tigoe/x10
After a few hours of frustration, I finally got it working (It wasn't clear from most of the documentation that I needed a 10k resistor between the Zero Crossing line and +5v).
I was able to send simple on and off commands. However, I wasn't able to figure out the Extended Dim commands. I don't actually need them for my current project - turning my attic fan on and off in conjunction with my HVAC temperatures - but it would be nice to be able to send them if I need to.
The library has some "aliases" for things like "on" and "off," as well as "Extended Code". However, I can't figure out the syntax beyond that.
It looks like those aliases refer to specific binary values ("ON" sends "0b00101", and "OFF" sends "0b00111"), but I don't know what the equivalent binary code would be for the two parts of the extended dim commands. I ran out of time this evening to play with it, but I *think* I just need to convert the hex to binary, and try writing that.
Perhaps over the weekend.
« Last Edit: August 06, 2012, 09:33:22 AM by Noam »
Logged

JeffVolp

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 121
  • Posts: 2285
    • XTB Home Page
Arduino-Based X10 control
« Reply #1 on: August 03, 2012, 09:18:28 AM »

After a few hours of frustration, I finally got it working (It wasn't clear from most of the documentation that I needed a 10k resistor between the Zero Crossing line and +5v).

The X10 Protocol document shows what is required to interface to the TW523/PSC05.  That is available here:

     http://jvde.us/info/X10_protocol.pdf

Don't ignore the clamping diodes like one manufacturer did if you want a robust interface.

There is also an extended code document (Google xtdcode.pdf or xtc798.doc).  The most common extended code is 62 bits long.  The CM15A transmits it as a doublet, which will be repeated by the XTB-IIR.

Note that the real TW523/PSC05 will not receive extended codes, but the XTB-IIR will.

Jeff
Logged
X-10 automation since the BSR days

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Arduino-Based X10 control
« Reply #2 on: August 03, 2012, 12:07:49 PM »

After a few hours of frustration, I finally got it working (It wasn't clear from most of the documentation that I needed a 10k resistor between the Zero Crossing line and +5v).

The X10 Protocol document shows what is required to interface to the TW523/PSC05.  That is available here:

     http://jvde.us/info/X10_protocol.pdf

Don't ignore the clamping diodes like one manufacturer did if you want a robust interface.

There is also an extended code document (Google xtdcode.pdf or xtc798.doc).  The most common extended code is 62 bits long.  The CM15A transmits it as a doublet, which will be repeated by the XTB-IIR.

Note that the real TW523/PSC05 will not receive extended codes, but the XTB-IIR will.

Jeff
Jeff -
Thanks for your reply. I had already looked at the protocol documents, but I don't really understand them well enough yet. I took another look today, and I'm only slightly less lost.
I'd really love to find some examples of using Extended Dim commands with the library I'm using, but I haven't found any yet (While Google is my friend, it has been more like the friend who has to tell you the entire backstory on the history of restaurants, before telling you where they went for lunch yesterday).  B:(

I did find a second library here: http://code.google.com/p/arduino-x10/downloads/list , but that one looks a lot more complicated (although it can do a lot more, too). I had tried it last night, but only BEFORE I fixed my missing resistor issue. By the time I was able to send simple ON and OFF commands, I was too tired to go back and try the other library. That's on my list for this weekend.

I'm trying to decide if  want to have my current Arduino (the HVAC monitor) talk directly to the XTB-IIR, or have it talk to a second Arduino (by setting a pin high or low - using an opto-isolator would be smart), and then have the second one send the appropriate commands to the XTB-IIR. The advantages of using a second Arduino are: (1) I don't need to use as many pins on my already crowded HVAC monitor, and (2) I can add other things to the second one later on (like the "flag status" LED panel I've wanted to build for a while). I would almost be using the second Arduino like a really fancy programmable PowerFlash in that case (and if I were to add an Ethernet shield to it, now THAT would be a really cool project - I have to add that to my list!).

A third option would be to move the whole project (HVAC *and* X10) over to a Mega (I have one - that's what I've been using to build a "first draft" of anything I try), which would give me plenty of pins to use, as well as allow me to have enough extra pins to add in the Ethernet shield (or buy one these - which look REALLY cool! : http://www.freetronics.com/products/ethermega-arduino-mega-2560-compatible-with-onboard-ethernet ), and then rebuild my HVAC monitor shield on a Mega-compatible prototyping shield. I'd love to add the Ethernet capabilities at some point down the road (so the Arduino would post the data to the MySQL database via a PHP page on the server), but that's a long way off at this point.

Have any of the forum members (or non-member guests who want to become members to reply) played around with interfacing the Arduino and X10 via the TW523/PSC01/XTB-IIR, and would be willing to give me some code examples to work with?
« Last Edit: August 06, 2012, 09:38:27 AM by Noam »
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Arduino-Based X10 control
« Reply #3 on: August 06, 2012, 12:10:19 AM »

For those interested, here's an update on my Arduino/HVAC/X10 project:

Despite spending another hour or so on it, I was unable to send extended dim commands using the "simpler" library.
The more complicated one can do it (I think), but it is way more complicated for me to figure out how to adapt the examples to my needs at this time.
I decided to keep the project on a single Arduino Uno, for now. After a quick search, I learned that I can use the Analog pins as digital ones, simply by addressing them as digital pins. That gave me another 6 pins to use, which is plenty for now (until I decide to add Ethernet - but that's another story).
After doing a bit more testing on the Mega, including testing that it can talk to the XTB-IIR correctly over the analog pins (in digital mode), I bit the bullet, and attacked my carefully built HVAC project shield with the soldering iron. I had a bit of frustration because of the tight quarters (and the fact that the cheap prototyping shield I bought on eBay doesn't have an extra set of holes for each header pin), I finally had the 5 wires added to the board (4 for the X10 interface, one for a status LED I've been playing with - might as well solder a lead to the board for that, once I'm going in there).
Since I use the wires out of my spool of CAT5e cable for a lot of the hookups, I was careful to use the remaining 5 colors that weren't already in use on one of my jacks (I have three CAT5 jacks wired to the board for connecting to my furnace, 1-Wire bus, and humidity sensors), and I added the X10 communication (and that status LED pin) to the jack for the 1-Wire bus.
The next step is to run a CAT5e line from my patch panel over to the XTB-IIR with an RJ45 at one end, and an RJ11 at the other.
Then I can work on the code to turn my attic fan on and off when I need to adjust airflow in the house.
Logged

pomonabill221

  • Hero Member
  • *****
  • Helpful Post Rating: 13
  • Posts: 239
Arduino-Based X10 control
« Reply #4 on: August 06, 2012, 12:17:11 AM »

Noam...
  Just a quick and probably stupid question.
What is a "shield"?
Sounds like you are really getting into your project!  I may be interested to find out what else you, or it, can do?
Logged

dhouston

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 37
  • Posts: 2547
    • davehouston.org
Arduino-Based X10 control
« Reply #5 on: August 06, 2012, 07:36:30 AM »

@Noam
My apologies for not getting the ZarduinoTM beta hardware to you. My health issues have kept me from making much progress on that - what time I've had has been spent on the mega hardware. It would have saved you a lot of trial and error as ZBasic has low-level X-10 functions built in.

This may help...
I don't think Smarthome's 1132 is still available but its documentation gives the bit patterns you need for both standard and extended commands. You will not need their handshaking codes but only the raw bits for the extended codes.

The X10 documentation is at...

Also...
has recommended circuits for interfacing OEM equipment to the PL513/TW523 which also apply to the PSC04, PSC05, TW7223 & XM10. At minimum you need a 4.7K pullup on both ZC and Data Out (i.e. from the TW523).
Logged
This message was composed entirely from recycled letters of the alphabet using only renewable, caffeinated energy sources.
No twees, wabbits, chimps or whales died in the process.
https://www.laser.com/dhouston

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Arduino-Based X10 control
« Reply #6 on: August 06, 2012, 09:31:03 AM »

@Noam
My apologies for not getting the ZarduinoTM beta hardware to you. My health issues have kept me from making much progress on that - what time I've had has been spent on the mega hardware. It would have saved you a lot of trial and error as ZBasic has low-level X-10 functions built in.

This may help...
I don't think Smarthome's 1132 is still available but its documentation gives the bit patterns you need for both standard and extended commands. You will not need their handshaking codes but only the raw bits for the extended codes.

The X10 documentation is at...

Also...
has recommended circuits for interfacing OEM equipment to the PL513/TW523 which also apply to the PSC04, PSC05, TW7223 & XM10. At minimum you need a 4.7K pullup on both ZC and Data Out (i.e. from the TW523).

Dave -
No worries on the beta hardware. I would never want my dream projects (most of which I'm not yet smart enough to accomplish) to ever interfere with your health (or anyone else's for that matter).

Thanks for sharing those links. I had seen the second and third, but the first one was new to me.
I think the problem I'm having stems from the library itself. I took a closer look at it with my limited programming skills. It looks like it isn't set up to properly send extended commands at all. For my current project (HVAC monitor being able to control the attic fan), I don't need Extended codes. The other library I found is more complicated, but it looks like it CAN handle extended codes (I haven't tested it yet, though). That would probably be what I would use if I ever decide to build myself an Arduino based PowerFlash/Universal module.

I was able to get it to send "simple" X10 commands (on, off - which is all I need right now). I did need the pullup resistor, which is what was missing during most of my first round of testing (and the cause of the frustration).

Does anyone know (kind of a rhetorical question, as I'm SURE Jeff knows  ;)) if I can hook up two devices to the TW523 (or the TW523 port on the XTB-IIR) at the same time, and have both devices able to talk to it bi-directionally? I would guess that two devices can receive from the TW523, but can two of them be set up to write to it as well?
If I do end up building myself a Powerflash/Universal module, I probably won't need two devices to talk to it at the same time (the HVAC monitor could talk to the PowerFlash), but it would be helpful during testing and development of such a project.

Thanks.
--Noam
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Arduino-Based X10 control
« Reply #7 on: August 06, 2012, 09:45:55 AM »

Noam...
  Just a quick and probably stupid question.
What is a "shield"?
Sounds like you are really getting into your project!  I may be interested to find out what else you, or it, can do?
Bill -
A "shield" (in Arduino terms, at least), is a secondary card (call it a "daughter-board, if you want), that plugs into the top of the Arduino. Rather than trying to solder right to the Arduino's pins, or plugging in lots of messy wires to the headers, a shield lets you build your circuit separately, and simply plug it into the Arduino. (There are lots of "ready-made" shields out there, to do things like Ethernet, WiFi, 3G, Zigbee, motor control, etc).
Depnding on the pins that they use, many shields come with "stacking" headers, which allow you to piggyback one shield on top of another, all of them connecting back to the Arduino at the bottom (although I have seen projects where one shield interfaces with another directly).

It is relatively easy to make your own custom shield. If you know how to lay out and etch circuit boards, you can really make anything you want. Lacking that experience, I purchased a "prototyping" shield, which is essentially just a blank perfboard (there are some handy things like a 5v bus and a ground bus, as well as layouts for connecting a DIP IC, or an SMD one), with the headers pins to plug into the Arduino, and the headers to stack another shield on top).
Logged

dhouston

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 37
  • Posts: 2547
    • davehouston.org
Re: Arduino-Based X10 control
« Reply #8 on: August 06, 2012, 03:00:50 PM »

Does anyone know (kind of a rhetorical question, as I'm SURE Jeff knows  ;)) if I can hook up two devices to the TW523 (or the TW523 port on the XTB-IIR) at the same time, and have both devices able to talk to it bi-directionally? I would guess that two devices can receive from the TW523, but can two of them be set up to write to it as well?
It shouldn't be a problem as long as you don't try sending from both simultaneously which might result in collision-like garbage on the powerline which won't be reported by the TW523.
Logged
This message was composed entirely from recycled letters of the alphabet using only renewable, caffeinated energy sources.
No twees, wabbits, chimps or whales died in the process.
https://www.laser.com/dhouston

pomonabill221

  • Hero Member
  • *****
  • Helpful Post Rating: 13
  • Posts: 239
Re: Arduino-Based X10 control
« Reply #9 on: August 06, 2012, 03:20:54 PM »

Noam...
  Just a quick and probably stupid question.
What is a "shield"?
Sounds like you are really getting into your project!  I may be interested to find out what else you, or it, can do?
Bill -
A "shield" (in Arduino terms, at least), is a secondary card (call it a "daughter-board, if you want), that plugs into the top of the Arduino. Rather than trying to solder right to the Arduino's pins, or plugging in lots of messy wires to the headers, a shield lets you build your circuit separately, and simply plug it into the Arduino. (There are lots of "ready-made" shields out there, to do things like Ethernet, WiFi, 3G, Zigbee, motor control, etc).
Depnding on the pins that they use, many shields come with "stacking" headers, which allow you to piggyback one shield on top of another, all of them connecting back to the Arduino at the bottom (although I have seen projects where one shield interfaces with another directly).

It is relatively easy to make your own custom shield. If you know how to lay out and etch circuit boards, you can really make anything you want. Lacking that experience, I purchased a "prototyping" shield, which is essentially just a blank perfboard (there are some handy things like a 5v bus and a ground bus, as well as layouts for connecting a DIP IC, or an SMD one), with the headers pins to plug into the Arduino, and the headers to stack another shield on top).
AH, I see!  I was confused about the term "shield", and it really is a daughter board of sorts!
Thanks for explaining it!
Logged

russellc

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 3
Re: Arduino-Based X10 control
« Reply #10 on: August 06, 2012, 10:15:52 PM »

Hi, and greetings from Australia.

I don't want to muddy the waters, but I have a Home Security system based on the SC28 control console.  This unit runs the connected X10 devices in my house, and also receives the signals from the wireless door/window sensors.

Sadly, the LCD panel that provides the interface to the system has gradually lost many segments, to the point where it's not possible to make out what's going on in the house.

Since I have some experience with Arduino, and too much spare time (ask my wife), I thought I'd put some effort into replacing the controller with an Arduino.  I have bought an X10 3rd party interface module - XM10 is the part number here - and I can see a way forward using the X10 libraries available.

However, the wireless security devices - in this case 433MHz wireless reed sensors - present a different problem.  I can buy a 433MHz receiver shield for the Arduino, but Murphy dictates that the sensors will use a proprietary protocol.  Does anyone involved in this thread have any knowledge of how to receive and decode these signals?  It'd be nice if the universal remote used similar protocol, of course.

cheers,
RussellC
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Arduino-Based X10 control
« Reply #11 on: August 06, 2012, 11:39:20 PM »

Well, I e-mailed the guy who wrote the X10 libraries, and asked about Extended Dim commands. He said that he didn't put it in there, so the library doesn't support it. He said I was welcome to add the support in for it, it might be pretty easy to do. Unfortunately, "Easy" for him probably is very different from "easy for me."

Looks like I'll have to either figure it out on my own, or just figure out how to use the more complicated libraries that are out there.

On a lighter note, I added in the X10 code to my HVAC controller program, and ran a wire from the XTB-IIR back to my "HVAC-duino". Everything tested fine (it was able to send the command). Now, I have to wait for the Smarthome switches to arrive, and install them. I won't fully be able to test the logic until the switches are installed.
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Arduino-Based X10 control
« Reply #12 on: August 06, 2012, 11:42:27 PM »

However, the wireless security devices - in this case 433MHz wireless reed sensors - present a different problem.  I can buy a 433MHz receiver shield for the Arduino, but Murphy dictates that the sensors will use a proprietary protocol.  Does anyone involved in this thread have any knowledge of how to receive and decode these signals?  It'd be nice if the universal remote used similar protocol, of course.
RussellC -
Check out this Arduino thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276569350

Also, check out these libraries, I think they have RF support in them (I don't know about security, but you could always e-mail the author, and ask:
http://code.google.com/p/arduino-x10/downloads/list
Logged

JeffVolp

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 121
  • Posts: 2285
    • XTB Home Page
Re: Arduino-Based X10 control
« Reply #13 on: August 07, 2012, 12:16:57 AM »

Does anyone know (kind of a rhetorical question, as I'm SURE Jeff knows  ;)) if I can hook up two devices to the TW523 (or the TW523 port on the XTB-IIR) at the same time, and have both devices able to talk to it bi-directionally? I would guess that two devices can receive from the TW523, but can two of them be set up to write to it as well?

You can drive from more than one source if the outputs go tri-state when not active.  You could also diode OR them together, but make sure you still provide a good logic "1" when driving.

Jeff
Logged
X-10 automation since the BSR days

dhouston

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 37
  • Posts: 2547
    • davehouston.org
Re: Arduino-Based X10 control
« Reply #14 on: August 07, 2012, 07:40:37 AM »

However, the wireless security devices - in this case 433MHz wireless reed sensors - present a different problem.  I can buy a 433MHz receiver shield for the Arduino, but Murphy dictates that the sensors will use a proprietary protocol.  Does anyone involved in this thread have any knowledge of how to receive and decode these signals?  It'd be nice if the universal remote used similar protocol, of course.
The RF security protocol is just slightly different from the standard RF protocol. Both are based on the NEC IR protocol which goes back 40+ years. See...
Battery-powered security devices also append a short indication of a low battery but I cannot recall the details off the top of my head. I just got out of the hospital and am still in recovery mode.

I lost a lot of my notes, code, etc. when I lost a NAS drive a couple of years ago but there is a link to a PicBasicPro example for receiving/sending the codes on the third page cited above.
Logged
This message was composed entirely from recycled letters of the alphabet using only renewable, caffeinated energy sources.
No twees, wabbits, chimps or whales died in the process.
https://www.laser.com/dhouston
Pages: [1] 2
 

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