CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

X10 Newbie question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

X10 Newbie question
PostPosted: Sun May 23, 2010 8:27 pm     Reply with quote

Hi Everyone,

I have tried using the X10 code from the drivers and examples.

I have a light connected to an X10 socket with an address of A1.

Using EX_X10.C, what do you enter in the terminal?

I have tried 'A' '1' and a considerable number of other combinations.

The light is on, and stays on. I am using the same pins as ex_x10, and the PSC05 blinks on command. I have a pull up on zero crossing pin. The scope shows everything you would expect.

Any ideas what I have to enter to make the light go off? There is lots of info on the web, but it is not making sense to me. I have searched this forum and do not see anything that helps. It looks like everyone thinks this X10 is easy, so I am missing something. Can anyone help me out?

Thanks,

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 24, 2010 12:43 am     Reply with quote

Quote:

Using EX_X10.C, what do you enter in the terminal?
I have tried 'A' '1' and a considerable number of other combinations.


To get the device address, Ex_x10.c calls getc() and gethex() as shown
below:
Quote:

house_code = getc();
if((house_code>='A') && (house_code<='P')) {
putc(house_code);
key_code=gethex();


The gethex() routine is in this file:
Quote:
c:\program files\picc\drivers\input.c

gethex() can either get 1 hex digit with the Enter pressed after it,
or it can get two hex digits (with no Enter key).

This fits the comments at the top of Ex_x10.c, which are:
Quote:

//// This program will accept and send three character codes of the
//// form xyy where x is A-P and yy is 00-1F.
//// Key codes 00-0F are translated to the key number.

So you should be able to type in "A01" (with no Enter) and have it work.
Or, you could type "A1" with the Enter key pressed.
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Mon May 24, 2010 7:18 am     Reply with quote

Thank you for your help PCM Programmer.

Your explanation as usual is very clear and helpful.

If I send A1 or A01 I see the data transmitted, but the light remains on.

If I send A20 which I read somewhere was the magic code for OFF the light stays on.

I guess I am unsure how this protocol works. If you send A1 and it is on, does that turn it off? Conversely, if you send A1 and it is off, does that turn it on?

Should there not be a command sent to the addressed device (i.e. House Code 'A" device '1' Command 'ON")?

I know this is not a CCS question, but I am hoping someone has tried this and can answer me.

Thanks in advance,

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon May 24, 2010 7:57 am     Reply with quote

Code:
/// Ex of house wiring signal
///           _   _   _   _   _   _   _   _   _
///         b b b b b b b b b b b b b b b b b b
/// 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1
/// 1 1 1 0
/// \     / \             / \                 /
///  1110    0  1   1   0    1  1   1   0   0
///  start     house 'A'      key '2'
///  code      code           code
///
///         X10 lookup table 5bits Ex 13=00000
char const X10_HOUSE_CODES[16] = {'M','N','O','P','C','D','A','B','E',
                                  'F','G','H','K','L','I','J'};

byte const X10_KEY_CODES[16] = {13,14,15,16,3,4,1,2,5,6,7,8,11,12,9,10};
#define All_Units_Off  0x10
#define All_Lights_On  0x18
#define Unit_On        0x14
#define Unit_Off       0x1C
#define Unit_Dim       0x12
#define Unit_Bright    0x1A
#define All_Lights_Off 0x16
///  except for the start code and the stop code
///  X10 protocol has each bit followed on the next zero crossing
///   by its complement
///  X10 bits are sent lsb first


Well a few things to notice
The codes are sent lsb..msb
The key code ex "2" is not sent as "2" it is looked up in the table
KEY_CODES so "2" is position 7 in the table so it is sent as "7"
The house code Ex a is not sent as "A" it is sent as "6"
There is a different code for on and off
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Mon May 24, 2010 8:47 am     Reply with quote

Thanks Douglas!

Your explanation is helping.

Using the CCS test program, if I send A01 and it is on, will the light then go off?

Or do you A01 then A1C (Address house A unit 1, then tell it Unit_Off)?

Thanks,

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon May 24, 2010 12:28 pm     Reply with quote

My code predates the CCS example. I haven't looked at the CCS code.
Basically the data placed on the house wiring is what counts.
<start code> <house code><key code><stop code>

A specific unit is selected by
<start code> <house code><key code><stop code>
where key code is the unit number ( your light)
A specific unit is commanded by
<start code> <house code><key code><stop code>
where key_code is now the command ( on off)

All on and all off don't require a pre-selection of a specific unit.

If you research x10 on the web the sequences will be explained including any repeats for redundancy.
The CCS code probably uses look up tables to go from the real world to the x10 world where house numbers are no longer "A" "B" and units aren't just 1 or 2 or 3
If you are using CCS code see it as an opportunity to learn X10. CCS usually has writers cramp so the lack of CCS explanation is your opportunity to learn a lot more.
The commands do not toggle units. If an on command is sent twice it makes no difference. For on if the unit was off it goes on if on it stays on.
Same for most commands.
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Mon May 24, 2010 1:08 pm     Reply with quote

Awesome, thank you Douglas, you have put the missing pieces into place!

I must have a problem somewhere, because I have tried what this and the light still will not go off Very Happy

I have ordered an X10 controller to see if that works. I am suspecting RF filters on power bars that appear randomly around my house Confused

Anyways, thanks again for replying. There is so much to learn and do, it is easy to get bogged down on the simple things.

On a great note, my home automation system is now reading DS18B20's, measuring my sump hole, checking the AC voltages, and outputting to a web page (complete with eMail on events).

Many thanks to CCS for their EzWebLynx product and Darren who has awesome support for their product.

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Mon May 24, 2010 1:38 pm     Reply with quote

Topic closed.

I did some thinking about the fact that everyone found this easy.

I took the new X10 receptical, an put it in series with a new X10 switch.

Receptical is A1 switch is A2.

I told the receptical to turn off - nothing.

I told the switch to turn off and off it went!!! Very Happy

Looks like a bad X10 receptical!!!

On to control the rest of my world, thank you everyone!

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Mon May 24, 2010 1:45 pm     Reply with quote

Which hardware do you use for X10 ?

Could you give a schematic?
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Mon May 24, 2010 7:51 pm     Reply with quote

Hi Tesla80,

I used a PSC05 two-way (transmit/receive) module I got of eBay for $10.

This unit has an RJ-11 phone connector on it. it uses a type of serial data that is NOT RS235, the voltages are TTL.

If you look at the CCS example code for X10, it indicates that :

//// Configure the CCS prototype card as follows: ////
//// Connect pin B0 to TW523 pin 1 ////
//// pin B1 3 ////
//// pin B2 4 ////
//// GND 2 ////

And that is what I did. You need a pull up on the zero crossing input to the PIC.

That is all there really is :-)

The tough part I found was that there was limited info on what had to be sent to turn on/off devices, which everyone helped out here. Having a bad X10 device new out of the box did not help
Mad

It really is rather easy once you get working hardware.

If you need help feel free to ask, and I will try to help.

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Tue May 25, 2010 10:25 am     Reply with quote

Thanks Steven,

I'm interesting in powerline communications as hobby.
I've tried to design a X10 hardware using capacitor and isolation transformer for transmit, a filter for detecting of burst signals... And Microchip have application notes about that.

But I think X10 is so slow. On 60Hz it is 60bps, if a character has 8 bit, we can send only 7.5 characters per second, right?

I think to order a TDA5051AT chip.
Quote:

The TDA5051A is a modem IC, specifically dedicated to ASK transmission by means of the home power supply network, at 600 baud or 1200 baud data rate. It operates from a single 5 V supply.

If we use modbus rtu as protocol, if a character is 8 bit.
We can send 1200/8 = 150 characters per second.
Right?

This is a good idea too: http://nutsandboltsandflyingsparks.blogspot.com/2010/01/mains-is-pain.html

Anyway, It would be good to see what is there in the box of PSC05 module Smile
smanzer



Joined: 14 Sep 2009
Posts: 24
Location: Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Wed May 26, 2010 1:41 pm     Reply with quote

Hi Tesla80,

The schematic for the PSC05 and PSC04 can be found at:

http://www.x10pro.com/pro/pdf/technote.pdf

X10 for communication would be too slow for most systems. I know you can buy ethernet over power devices (10Meg) so it certainly is possible!!

I just want lights to go on and off so my hydro bills go down and convienience goes up :-)

Steven
_________________
"I am always doing that which I can not do, in order that I may learn how to do it."
- Pablo Picasso
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group