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

Decode Fiber Optic at 1 usec

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



Joined: 28 Jul 2004
Posts: 8

View user's profile Send private message

Decode Fiber Optic at 1 usec
PostPosted: Fri Dec 03, 2004 1:22 pm     Reply with quote

I am trying to read a fiber optic llink. There are 2 16 bit packets spaced 500 msec apart. A '0' is approx 1 usec. A "1" is approx 7 usec. The signals are built up with timers etc. I'd like get away from all that. I'm designing a hand held piece of test equipment to read an write with this link so the techs quit shotgunning the boards in the system.

This snippet seems to work down to about 5 usec with a 452 at 40 MHz. I still need to set timers (I think).

#int_ext
void isr_ext(void){
rcvbuffer<1;
rcvbuffer+=input(PIN_B0);
}

Is there something faster or a better way to do this? Rolling Eyes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 03, 2004 1:48 pm     Reply with quote

Could you describe the signal a little better. I mean electrically what does the PIC see. I assume these are pulses with a high time of 1us for a 0 and a high time of 7us for a 1. What is the inner bit time? Is it constant? What else is this PIC gotta do?
robert_terrelll
Guest







Decode Fiber Optic at 1 usec
PostPosted: Fri Dec 03, 2004 3:58 pm     Reply with quote

The rcvr is ttl. The timing moves around alittle from board to board but I think its like thiis.

It looks like a 125 KHz clock rate. Two clocks separate the two 16 bit words. And 500 msec between each update. Also the first 4 bits (MSB) are 0s (or 1 usec followed by 7 usec of low time). One's appear to be about 7 usec followed by 1 usec of low time.

They are chasing me out of here now so I"ll have to get back Monday but I really, really apriciate the help.
robert_terrell



Joined: 28 Jul 2004
Posts: 8

View user's profile Send private message

Decode Fiber Optic at 1 usec
PostPosted: Mon Dec 06, 2004 7:22 am     Reply with quote

The idea was to have a hand held battery powered device with an LCD and Keypad to both send and receive on this fiber optic link that is sending data from a high voltage device.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Dec 06, 2004 11:03 am     Reply with quote

I would use the external int as a high priority interrupt and write my own handler for it. It should only take a couple of hundred microseconds to receive the message so could just sit in the int and receive the message. Another approach might be to just delay a microsecond or so, grab the value and wait for the next int. Use a timer to "timeout" and wait for the next rising edge if you don't receive 16 bits. Make sense?
robert_terrell



Joined: 28 Jul 2004
Posts: 8

View user's profile Send private message

Decode Fiber Optic at 1 usec
PostPosted: Tue Dec 07, 2004 9:17 am     Reply with quote

Yes.
It still looks doable. The documentation I had wasn't right. The two 16 bit words are 100 usec. apart and the frames separated by 300 usec. Alittle tougher.
robert_terrell



Joined: 28 Jul 2004
Posts: 8

View user's profile Send private message

Decode Fiber Optic at 1 usec
PostPosted: Tue Jan 25, 2005 10:20 am     Reply with quote

Finally got back to this project.
This isn't eloquent but it seems to work.

Code:
#int_ext
void isr_ext(void){
   output_high(PIN_C0);
   rcvcnt++;
   rcvbuffer=rcvbuffer<<1;
   rcvbuffer=rcvbuffer|input(PIN_B0);
   set_timer0(0);
   output_low(PIN_C0);
}
#int_timer0
void timer0_isr(void){
   output_high(PIN_C1);
   if(rcvcnt==32) lrcvbuffer=rcvbuffer;
   counter=1;
   rcvcnt=0;
   output_low(PIN_C1);
}
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