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 controller for the pic

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



Joined: 29 Jan 2004
Posts: 2

View user's profile Send private message

x10 controller for the pic
PostPosted: Thu Jan 29, 2004 4:37 pm     Reply with quote

Hello,
Can any body let me know what he problem could be.
Any way here is what i am doing

I actually am interfacing a pic micro with a PSC04 X10 controller

(Micro side)
B0 <------ -----------Zero crossing detect from psc04 ( X10 remote controller) connected to a pull up.Black wire 1 of RJ11
B2 -------------------> Input to x10 controller pin 4(yellow) of RJ11
gnd ------------------ gnd of PSC , pins 2 and 3 of telephone jack

I plug the x10 controller and the lampmodule lm 465 in the same power bar and i see the zerocrossing and the pulses getting transmitted but the incandescent table lamp shows no change.

then the code using a driver x10.c from ccs compiler

i did in the main function

while (true)
{
// address command
x10_write(house_code,2); // functions defined in x10.c
x10_write(house_code,2); // house code A, key code 2

//Send the off command

x10_write_bits(7,4,1);
x10_write_bits(house_code,4,0);
x10_write_bits(28,5,0);
x10_write_bits(0,6,1); // silence for 6 cycles
//2nd time
x10_write_bits(7,4,1);
x10_write_bits(house_code,4,0);
x10_write_bits(28,5,0); //off command code is 00111 <- compute this way
x10_write_bits(0,6,1);

delay_ms(10000);
//send the on command
x10_write_bits(7,4,1);
x10_write_bits(house_code,4,0);
x10_write_bits(20,5,0); //on command code is 00101
x10_write_bits(0,6,1); //6 cycles of 0's for pause

x10_write_bits(7,4,1);
x10_write_bits(house_code,4,0);
x10_write_bits(20,5,0);
x10_write_bits(0,6,1);

// delay_ms(10000);
}
_________________
SNATH
dyeatman



Joined: 06 Sep 2003
Posts: 1938
Location: Norman, OK

View user's profile Send private message

X10 from PIC
PostPosted: Thu Jan 29, 2004 7:20 pm     Reply with quote

One thing I see immediately is that you are transmitting an ON immediately followed by an OFF without allowing time for the module to react to the command. If you are firing a relay based module the relay won't have time to move it's contacts before you turn it back off.

Also, without doing some checking to confirm, I believe the protocol requires a certain minimum number of AC zero crossings between successive commands. It looks like you may be accomplishing this with the zero writing but I am not that familiar enough with the PIC X10 code to be sure.... A longer delay would be better.

Dave
sainath



Joined: 29 Jan 2004
Posts: 2

View user's profile Send private message

Re: X10 from PIC
PostPosted: Fri Jan 30, 2004 12:52 pm     Reply with quote

Thanks ,
I removed the off and now transmitting only the ON command and also put in the delay. still no luck. Is there an easy way of verifying what command i am actually sending on to the psc04 .

the x10 functions are :
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};


void wait_for_zero_cross() {

if(input(X10_ZERO_CROSS))
while(input(X10_ZERO_CROSS)) ;
else
while(!input(X10_ZERO_CROSS)) ;
}

void x10_write_bits(BYTE data, BYTE n, BYTE start) {
BYTE i;
BOOLEAN the_bit;

for(i=1;i<=n;++i) {
wait_for_zero_cross();
the_bit=shift_right(&data,1,0);
output_bit(X10_FROM_PIC, the_bit);
delay_ms(1);
output_low(X10_FROM_PIC);
if(start==0) {
wait_for_zero_cross();
output_bit(X10_FROM_PIC, !the_bit);
delay_ms(1);
output_low(X10_FROM_PIC);
}
}
}

void x10_write(BYTE house_code, BYTE key_code) {
BYTE i;

i=0;
while (X10_HOUSE_CODES[i]!=house_code)
i++;
house_code=i;
if(key_code<16) {
i=0;
while (X10_KEY_CODES[i]!=key_code)
i++;
key_code=i;
}
x10_write_bits(7,4,1);
x10_write_bits(house_code,4,0);
x10_write_bits(key_code,5,0);
x10_write_bits(0,6,1);
}



dyeatman wrote:
One thing I see immediately is that you are transmitting an ON immediately followed by an OFF without allowing time for the module to react to the command. If you are firing a relay based module the relay won't have time to move it's contacts before you turn it back off.

Also, without doing some checking to confirm, I believe the protocol requires a certain minimum number of AC zero crossings between successive commands. It looks like you may be accomplishing this with the zero writing but I am not that familiar enough with the PIC X10 code to be sure.... A longer delay would be better.

Dave

_________________
SNATH
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