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

sending string/characters during zero crossing

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



Joined: 28 Sep 2008
Posts: 7

View user's profile Send private message Yahoo Messenger

sending string/characters during zero crossing
PostPosted: Wed Dec 10, 2008 5:20 am     Reply with quote

Hi.

I am sort of a newbie in this thing and I am looking for any help on putc/puts characters during zero crossing. I am using PIC16F877A.

I want to send:
Code:

for (Ctr1=0;Ctr1<=7;Ctr1++)
     {
       putc (TXBuffer[Ctr1]);
       Delay_us(500);
     }

Is it recommended to put it in an external interrupt rb0, like this:

Code:
#int_ext
void ext_isr(){
for (Ctr1=0;Ctr1<7;Ctr1++)
     {
       putc (TXBuffer[Ctr1]);
       Delay_us(500);
      }
}

or like this
Code:

void Xmit_at_zerocrossing()
{
   while(input(PIN_B0))
     {
      for (Ctr1=0;Ctr1<7;Ctr1++)
           {
             putc (TXBuffer[Ctr1]);
             Delay_us(500);
            }
     }
}

Or any another idea? If so, how can I test that I sent all TXBuffer[7] during zero crossing. Tnx for any reply. Any help would be very much appreciated.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 7:05 am     Reply with quote

Are you trying to inject serial characters onto the 60Hz (50Hz) power line when the power line is crossing zero? That is not going to be easy to decode. It would be easier at the peak of the sine wave where voltage is changing more slowly.
_________________
The search for better is endless. Instead simply find very good and get the job done.
red32terra



Joined: 28 Sep 2008
Posts: 7

View user's profile Send private message Yahoo Messenger

PostPosted: Wed Dec 10, 2008 2:40 pm     Reply with quote

Hi sir.
You are right. We are injecting (asynchronously) serial characters onto zero crossings of a power line (sort of a timed transmission data communication) which somehow lessen noise during transmission in the power line. Will it really be difficult to decode??? How?

There was a thesis ( http://library2.usask.ca/theses/available/etd-02162005-150411/unrestricted/akerman.pdf ) that performed this. However, he used MC68360 QUICC instead of a PIC16F877. Can I perform this using CCS and PIC16F877A??

Thank you for any reply.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 3:07 pm     Reply with quote

I didn't read the whole thesis, but reading the abstract and conclusions confirmed my suspicions.
Code:
In the tests
conducted, the noise spikes from power supply rectifier switch-off caused the most
errors. In other environments, however, it may be found that other noise spikes can cause
additional errors, such as those caused by fluorescent lights (near the zero crossings of
the 60 Hz mains signal).

This to me means that near the zero crossings is a particularly bad choice of times to send data. The peaks also seem a poor choice. In the paper they are continually testing and adaptively choosing their time slots for data transmission. If you want success I suggest you do the same.
_________________
The search for better is endless. Instead simply find very good and get the job done.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 3:26 pm     Reply with quote

Zero-crossing measurement isn't difficult to my opinion. It's generally used by circuits that perform zero voltage switching or phase-control of mains powered loads. Transformer supplied circuits can sense the mains voltage polarity at the rectifier AC input, others may use an opto-coupler to acquire it at the mains terminals directly. With a hold-off time, that surpresses possible multiple triggers at the zero crossing, no additional filtering is required, usually.
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 4:00 pm     Reply with quote

There's an application note on Microchip for X10 powerline communication:
AN236
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 4:26 pm     Reply with quote

CCS has a driver and example file to interface a PIC to an X10 TW523
device:
Quote:
c:\program files\picc\examples\ex_x10.c
c:\program files\picc\drivers\x10.c
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Wed Dec 10, 2008 5:21 pm     Reply with quote

TW523 is probably the way to go. You get the transformer isolation, a power supply for the pic and a send receive module that will speak x10 to the power line.
X10 has extended commands which you could use for customizing. The zero crossing environment isn't meant for speedy communication so messages need to be short.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 12:39 am     Reply with quote

Although the intended application has some features similar to X10 as zero crossing synchronisation, it's apparently not X10, sending full characters with FSK modulation at higher baud rate. I didn't completely understand, if the shown code is actually performing as intended, but the linked literature is clear in this respect. It reports interesting results regarding mains synchronisation effects.
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