View previous topic :: View next topic |
Author |
Message |
reyes33d88
Joined: 18 Apr 2013 Posts: 7
|
X10.c troubles |
Posted: Thu May 30, 2013 2:03 pm |
|
|
Hi guys, I have the next code:
Code: |
void main()
{
set_tris_b (0x00); ///PUERTO B COMO SALIDA
while(1){
if(input(pin_a0)){ //LA INFORMACIÓN LE LLEGARÁ POR A0
x10_read( 'A', 1); //LEE LA DIRECCIÓN A 1
delay_ms(50); //ESPERA 50 ms, T=0.01666 X 3 = 50 X 10-3
x10_read( 'A', 20); // SE LE ENVÍA LA INSTRUCCIÓN DE ENCENDIDO A LA UNIDAD A 1
output_high(Pin_B2);
}
else
output_high(Pin_B2);
}
} |
My main trouble is when I send another code like A 2, and after A 20, but the system do the same if I send any command, what can I do? Thank you |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu May 30, 2013 3:34 pm |
|
|
I don't understand what your problem is. Please tell what you want to happen and what you see that happens.
Have a look at your output to B2, it never goes low again. |
|
|
reyes33d88
Joined: 18 Apr 2013 Posts: 7
|
|
Posted: Thu May 30, 2013 5:32 pm |
|
|
Thank you, well, I sent the command A 1 after the instruction, and all is well, but when I sent another command like A 2, the receiver do the same like A 1, this is my problem. |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Thu May 30, 2013 10:12 pm |
|
|
I have not played with that, but do you need to have a delay after the second one before setting the pin high so it can complete sending? Also, if you are sending, why are you calling "x10_read()" - isn't there a write command or am I missing what you are trying to do ?
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri May 31, 2013 5:34 am |
|
|
Mikey has a good point. The driver being used in the CCS x10.c from the driver directory. Here are defined functions for writing, reading and testing if data is ready to be read.
The program as shown here is wrong as it used the read function for writing. The read function expects pointers as parameters, not the values as given here, those will lead to random memory corruption bugs.
I recommend the topic starter to have a look at the CCS provided example program EX_X10.C, it is located in the PICC\Examples directory where you installed the compiler. |
|
|
reyes33d88
Joined: 18 Apr 2013 Posts: 7
|
|
Posted: Fri May 31, 2013 1:22 pm |
|
|
Thanks for your comments, then that means that with this program only can a X10 transmitter? a receiver can not be programmed with this library? If so, I can not say that I will program a pic, which will drive A 2 and do a light on? was needed for this transceiver TW523?, is that they are many questions, but any of you have done something like that for, thank you very much for your attention |
|
|
javi.ar
Joined: 17 Feb 2006 Posts: 59 Location: Argentina
|
|
Posted: Wed Jun 05, 2013 9:35 pm |
|
|
One question, I am also dealing with x10 , I have the trouble with the detector of the presence of the 120khz , did you made some progress with it? Thanks a lot. |
|
|
reyes33d88
Joined: 18 Apr 2013 Posts: 7
|
|
|
|