23 Ekim 2017 Pazartesi

IRIGB Time Code Display

Years ago, I have designed an IRIGB decoder with PIC16F88  using CCS compiler. I updated the code for XC8.

Proteus: First stage is a comparator to remove sine waves below 1.2V (two reference diodes). Second stage is a "missing pulse detector" to create train of pulses with 2ms, 5ms and 8ms DC level shift modulated (DCLS) IRIGB code. Once we have pulses we can measure pulse width using a PIC18F24K20 CCP2 and TIMER1.


MCC: 8MHz internal oscillator. CCP2 rising edge and interrupt. Timer1 works with CCP2,  no need for timer interrupt. 



XC8: inside ccp2.c we can add our code to measure pulse width. transition from rising to falling works only if I disable with CCP2CON=0x00; ccp_delta is pulse width. 

main.c has a switch statement counts hours, minutes and seconds according to pulse widths in IRIGB format.


-------ccp2.c--------------

void CCP2_CallBack(uint16_t capturedValue)
{
    // Add your code here
static int t1_rising_edge;  //define static to keep the value

if(CCP2CON==0x05)
  {
    t1_rising_edge = capturedValue;
    CCP2CON=0x00;
    CCP2CON=0x04;
   
  }
else
  {
   ccp_delta = capturedValue - t1_rising_edge;
   got_pulse_width = 1;
   CCP2CON=0x00;
   CCP2CON = 0x05;   
  }
    
}


download the example hex file and irigb.wav to feed the circuit. make 3volt amplitude.

Hiç yorum yok:

Yorum Gönder