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

Problem receiving pulses

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







Problem receiving pulses
PostPosted: Wed Apr 11, 2007 6:54 pm     Reply with quote

Hi there!
Am trying to received pulses in sync with 60hz 50% duty cycle square wave. The pulses arrived right after rising edge of square wave or right after falling edge of square wave. This edge correspond to zero crossing. I can't received the pattern that I send which is "0110100110". This correspond to binary "01101' transmitted using x10 protocol. That is 01 correspond to 0 and 10 correspond to 1. What could be wrong? Here is the code:

#include <16F628A.h>
#include <STDLIB>
#fuses INTRC,NOWDT,NOPROTECT
#use delay(clock=4000000)

/**********************************************************************\
* *
* M A I N R O U T I N E *
* *
\*********************************************************************/

void main()
{

boolean hc1,hc2,hc3,hc4,hc5,hc6,hc7,hc8,hc9,hc10=0;


output_B(0x00); // initialize port B



while(input(PIN_A0)) // A0 input 1st zero crossing of AC line
hc1=input(PIN_A1); // A1 input pulse corresponding to 1st zero crossing
while(!input(PIN_A0)) // A0 input 2nd zero crossing of AC line
hc2=input(PIN_A1); //A1 input pulse corresponding to 2nd zero crossing
while(input(PIN_A0)) // A0 input 3rd zero crossing of AC line
hc3=input(PIN_A1);//A1 input pulse corresponding to 3rd zero crossing
while(!input(PIN_A0)) // A0 input 4th zero crossing of AC line
hc4=input(PIN_A1); A1 input pulse corresponding to 4th zero crossing
while(input(PIN_A0)) // A0 input 5th zero crossing of AC line
hc5=input(PIN_A1);//A1 input pulse corresponding to 5th zero crossing
while(!input(PIN_A0))// A0 input 6th zero crossing of AC line
hc6=input(PIN_A1);//A1 input pulse corresponding to 6th zero crossing
while(input(PIN_A0)) // and so on...
hc7=input(PIN_A1);//and so on...
while(!input(PIN_A0))
hc8=input(PIN_A1);
while(input(PIN_A0))
hc9=input(PIN_A1);
while(!input(PIN_A0))
hc10=input(PIN_A1);


output_bit(PIN_B0, hc1); // to display in LED the received pulses
output_bit(PIN_B1, hc3);
output_bit(PIN_B2, hc5);
output_bit(PIN_B3, hc7);
output_bit(PIN_B4, hc9);

delay_ms(1000); //to make LED visible for 1 sec.
output_b(0x00);



}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 11, 2007 7:41 pm     Reply with quote

Are you using an X10 module that is intended for a computer interface
to the power line ? If so, look these CCS files:

CCS driver for the TW523:
c:\program files\picc\drivers\x10.c

Example file that calls that driver:
c:\program files\picc\examples\ex_x10.c
pete
Guest







Re: Receiving pulses
PostPosted: Wed Apr 11, 2007 10:45 pm     Reply with quote

Yes I have seen that. Actually I don't have to use X10 exactly since that protocol is sending start code, housecode and keycode/function code and this being sent twice. Forget x10 protocol. I am just interested to the code to receive the pulses as i have described above. What could be wrong with that code?Thanks...
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