View previous topic :: View next topic |
Author |
Message |
robert_terrell
Joined: 28 Jul 2004 Posts: 8
|
Decode Fiber Optic at 1 usec |
Posted: Fri Dec 03, 2004 1:22 pm |
|
|
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? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Dec 03, 2004 1:48 pm |
|
|
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 |
Posted: Fri Dec 03, 2004 3:58 pm |
|
|
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
|
Decode Fiber Optic at 1 usec |
Posted: Mon Dec 06, 2004 7:22 am |
|
|
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
|
|
Posted: Mon Dec 06, 2004 11:03 am |
|
|
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
|
Decode Fiber Optic at 1 usec |
Posted: Tue Dec 07, 2004 9:17 am |
|
|
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
|
Decode Fiber Optic at 1 usec |
Posted: Tue Jan 25, 2005 10:20 am |
|
|
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);
}
|
|
|
|
|