Monday, 13 February 2017

PIC16F876A PURE SINE WAVE INVERTER

source code
#include <16F876A.h>
#device *=16
#device ADC=8
#fuses HS,WDT,PUT,BROWNOUT,NOPROTECT,NOLVP,NOCPD
#use delay(clock=20000000, RESTART_WDT)
#use fast_io(B)
#use fast_io(C)

#define ab_chan      0
#define stdby_chan   1
#define i_chan       2
#define acc_chan     3
#define v_chan       4

const long sine_wave[32] = {81,162,241,318,392,462,527,588,642,691,733,768,795,  // sine wave constants;
                            815,827,831,827,815,795,768,733,691,642,588,527,462,
                            392,318,241,162,81,0};
const int volt_sine_ref[32] = {0,5,9,14,18,23,27,31,34,37,40,42,44,46,47,48,48,
                               48,47,46,44,42,40,37,34,31,27,23,18,14,9,5};
//const int delta_v_h[16] = {7,7,6,6,6,5,5,5,4,4,4,3,3,3,2,2};
//const int delta_v_l[16] = {3,3,3,3,3,3,3,2,2,2,2,1,1,1,0,0};
const int delta_corr[32] = {3,6,9,12,15,18,20,23,25,27,28,30,31,31,32,32,32,31,
                            31,30,28,27,25,23,20,18,15,12,9,6,3,0};


int index, sine_pol, inv_mode, stdby_mode, stdby, i, inv_on, inv_off;
int low_curr_h, low_curr_l, over_curr, short_curr, high_ab, stdby_go_blink;
int low_acc, high_acc, high_t_stop, high_t_blink, low_curr;
int low_acc_delay, acc_avg_counter, volt_ref_counter, volt_l_avg_counter, volt_h_avg_counter;
int volt_h, volt_l, volt_h_avg, volt_l_avg, delta;
int acc_v, acc_v_avg, volt_a, volt_b, stdby_i, stdby_i_h, stdby_i_l, stdby_i_avg_counter;
int volt_ref, volt_ref_avg, curr_h, curr_l, curr_h_avg, curr_l_avg;
signed int delta_h_v, delta_l_v, delta_h_ref, delta_l_ref, volt_ref_delta;
signed long int level_corr[32];
signed int shape_corr[32];
long int pwm_pos, pwm_neg;
long int volt_h_temp, volt_l_temp, volt_ref_temp, acc_v_temp, over_curr_delay;
long int stdby_delay, stdby_go_delay, high_t_delay, curr_h_temp, curr_l_temp, stdby_i_temp;
const long pwm_max=1023;
const int curr_l_max=32, short_curr_l=16, ab_max=96, volt_ref_const_h=168, volt_ref_const_l=87;
const int stdby_i_h_max=239, stdby_i_h_min=143, stdby_max=253, stdby_min=2;
const int curr_h_max=223, curr_h_min=143, curr_l_min=111, short_curr_h=239;
const int acc_max_l=92, acc_max_h=98, acc_min_l=60, acc_min_h=66;


#separate
void sine_pwm_start(void)                                                        // Start mode;
{
   set_pwm1_duty((sine_wave[index]+level_corr[index])>>1);                       // positive start sine half wave;
   output_high(PIN_C1);                                                          // A=1;
   output_low(PIN_C0);                                                           // Z=0;
   output_low(PIN_B1);
   set_adc_channel(ab_chan);
   delay_us(10);
   read_adc(ADC_START_ONLY);
   delay_us(20);
   volt_a=read_adc(ADC_READ_ONLY);
   if(volt_a>=ab_max) {
      high_ab++;
      if(high_ab>8) break;
   }
   else high_ab=0;
   output_low(PIN_C3);
   set_adc_channel(i_chan);
   delay_us(10);
   read_adc(ADC_START_ONLY);
   delay_us(20);
   curr_h=read_adc(ADC_READ_ONLY);
   if(curr_h>=short_curr_h) {
      short_curr++;
      if(short_curr>8) break;
   }
   else {
      short_curr=0;
      if(curr_h>curr_h_max) over_curr_delay++;
      else over_curr_delay=0;
   }
}


#separate
void sine_pwm_norm(void)                                                         // Normal mode;
{
   switch (sine_pol) {
      case 0:                                                                    // negative sine half wave;
         set_adc_channel(v_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_l=read_adc(ADC_READ_ONLY);
         volt_l_temp+=volt_l;
         pwm_neg=sine_wave[index] + shape_corr[index] + level_corr[index];
         if(pwm_neg>pwm_max) pwm_neg=pwm_max;
         //if(pwm_neg<0) pwm_neg=0;
         set_pwm1_duty(pwm_neg);
         output_low(PIN_C1);                                                     // A=0;
         output_low(PIN_C0);                                                     // Z=0;
         output_high(PIN_B1);
         //set_pwm2_duty(volt_l);
         set_adc_channel(ab_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_b=read_adc(ADC_READ_ONLY);
         if(volt_b>=ab_max) {
            high_ab++;
            if(high_ab>4) break;
         }
         else high_ab=0;
         output_low(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_l=read_adc(ADC_READ_ONLY);
         if(curr_l<=short_curr_l) {
            short_curr++;
            if(short_curr>4) break;
         }
         else {
            short_curr=0;
            if(curr_l<curr_l_max){
               over_curr_delay++;
               //level_corr[index+1]-=delta_corr[index+1];
            }
            else over_curr_delay=0;
         }
         output_high(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_h=read_adc(ADC_READ_ONLY);
         curr_h_temp+=curr_h;
         /*if(index) {
            delta_l_v=(127-volt_sine_ref[index])-volt_l;
            delta=delta_corr[index-1]>>2;
            if(delta_l_v>delta) shape_corr[index-1]--;
            else if(delta_l_v<-delta) shape_corr[index-1]++;
         }*/
         if(index==31) {
            curr_h_avg=curr_h_temp>>5;
            if((curr_h_avg<stdby_i_h)&&(!inv_on)) low_curr_l=1;
            else low_curr_l=0;
            volt_l_avg=volt_l_temp>>5;
            delta_l_ref=volt_l_avg-(volt_ref_const_l-volt_ref_delta);
            if(delta_l_ref>2) for(i=0; i<32; i++) level_corr[i]+=delta_corr[i]>>1;
            else if(delta_l_ref<-2) for(i=0; i<32; i++) level_corr[i]-=delta_corr[i]>>1;
            curr_h_temp=0;
            volt_l_temp=0;
            high_ab=0;
            short_curr=0;
            sine_pol=1;
         }
         break;
      case 1:                                                                    // positive sine half wave;
         set_adc_channel(v_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_h=read_adc(ADC_READ_ONLY);
         volt_h_temp+=volt_h;
         pwm_pos=sine_wave[index] + shape_corr[index] + level_corr[index];
         if(pwm_pos>pwm_max) pwm_pos=pwm_max;
         //if(pwm_pos<0) pwm_pos=0;
         set_pwm1_duty(pwm_pos);
         output_high(PIN_C1);                                                    // A=1;
         output_low(PIN_C0);                                                     // Z=0;
         output_low(PIN_B1);
         //set_pwm2_duty(volt_h);
         set_adc_channel(ab_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_a=read_adc(ADC_READ_ONLY);
         if(volt_a>=ab_max) {
            high_ab++;
            if(high_ab>4) break;
         }
         else high_ab=0;
         output_low(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_h=read_adc(ADC_READ_ONLY);
         if(curr_h>=short_curr_h) {
            short_curr++;
            if(short_curr>4) break;
         }
         else {
            short_curr=0;
            if(curr_h>curr_h_max) {
               over_curr_delay++;
               //level_corr[index+1]-=delta_corr[index+1];
            }
            else over_curr_delay=0;
         }
         output_high(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_l=read_adc(ADC_READ_ONLY);
         curr_l_temp+=curr_l;
         /*if(index) {
            delta_h_v=(127+volt_sine_ref[index])-volt_h;
            delta=delta_corr[index-1]>>2;
            if(delta_h_v>delta) shape_corr[index-1]++;
            else if(delta_h_v<-delta) shape_corr[index-1]--;
         }*/
         if(index==31) {
            curr_l_avg=curr_l_temp>>5;
            if((curr_l_avg>stdby_i_l)&&(!inv_on)) low_curr_h=1;
            else low_curr_h=0;
            volt_h_avg=volt_h_temp>>5;
            delta_h_ref=(volt_ref_const_h+volt_ref_delta)-volt_h_avg;
            if(delta_h_ref>2) for(i=0; i<32; i++) level_corr[i]+=delta_corr[i]>>1;
            else if(delta_h_ref<-2) for(i=0; i<32; i++) level_corr[i]-=delta_corr[i]>>1;
            curr_l_temp=0;
            volt_h_temp=0;
            high_ab=0;
            short_curr=0;
            sine_pol=0;
         }
         break;
   }
}


#separate
void sine_pwm_stop(void)                                                         // Stop mode;
{
   set_pwm1_duty((sine_wave[index]+level_corr[index])>>1);                       // negative stop sine half wave;
   output_low(PIN_C1);                                                           // A=0;
   output_low(PIN_C0);                                                           // Z=0;
   output_high(PIN_B1);
   set_adc_channel(ab_chan);
   delay_us(10);
   read_adc(ADC_START_ONLY);
   delay_us(20);
   volt_b=read_adc(ADC_READ_ONLY);
   if(volt_b>=ab_max) {
      high_ab++;
      if(high_ab>4) break;
   }
   else high_ab=0;
   output_low(PIN_C3);
   set_adc_channel(i_chan);
   delay_us(10);
   read_adc(ADC_START_ONLY);
   delay_us(20);
   curr_l=read_adc(ADC_READ_ONLY);
   if(curr_l<=short_curr_l) {
      short_curr++;
      if(short_curr>4) break;
   }
   else {
      short_curr=0;
      if (curr_l<curr_l_max){
         over_curr_delay++;
         //shape_corr[index+1]-=delta_i[index+1];
      }
      else over_curr_delay=0;
   }
}


#separate
void sine_pwm_stdby(void)                                                        // Standby mode;
{
   switch (stdby_mode) {
      case 0:
         sine_pwm_start();
         if(index==31) {
            high_ab=0;
            short_curr=0;
            stdby_mode++;
         }
         break;
      case 1:                                                                    // negative sine half wave;
         pwm_neg=sine_wave[index] + level_corr[index];
         if(pwm_neg>pwm_max) pwm_neg=pwm_max;
         //if(pwm_neg<0) pwm_neg=0;
         set_pwm1_duty(pwm_neg);
         output_low(PIN_C1);                                                     // A=0;
         output_low(PIN_C0);                                                     // Z=0;
         output_high(PIN_B1);
         set_adc_channel(v_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_l=read_adc(ADC_READ_ONLY);
         volt_l_temp+=volt_l;
         set_adc_channel(ab_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_b=read_adc(ADC_READ_ONLY);
         if(volt_b>=ab_max) {
            high_ab++;
            if(high_ab>4) break;
         }
         else high_ab=0;
         output_low(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_l=read_adc(ADC_READ_ONLY);
         if(curr_l<=short_curr) {
            short_curr++;
            if(short_curr>4) break;
         }
         else {
            short_curr=0;
            if (curr_l<curr_l_max){
               over_curr_delay++;
               //shape_corr[index+1]-=delta_i[index+1];
            }
            else over_curr_delay=0;
         }
         output_high(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_h=read_adc(ADC_READ_ONLY);
         curr_h_temp+=curr_h;
         if(index==31) {
            curr_h_avg=curr_h_temp>>5;
            if(curr_h_avg>=stdby_i_h) stdby=0;
            volt_l_avg=volt_l_temp>>5;
            delta_l_ref=volt_l_avg-(volt_ref_const_l-volt_ref_delta);
            if(delta_l_ref>2) for(i=0; i<32; i++) level_corr[i]+=delta_corr[i]>>1;
            if(delta_l_ref<-2) for(i=0; i<32; i++) level_corr[i]-=delta_corr[i]>>1;
            curr_h_temp=0;
            volt_l_temp=0;
            high_ab=0;
            short_curr=0;
            stdby_mode++;
         }
         break;
      case 2:                                                                    // positive sine half wave;
         pwm_pos=sine_wave[index] + level_corr[index];
         if(pwm_pos>pwm_max) pwm_pos=pwm_max;
         //if(pwm_pos<0) pwm_pos=0;
         set_pwm1_duty(pwm_pos);
         output_high(PIN_C1);                                                    // A=1;
         output_low(PIN_C0);                                                     // Z=0;
         output_low(PIN_B1);
         set_adc_channel(v_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_h=read_adc(ADC_READ_ONLY);
         volt_h_temp+=volt_h;
         set_adc_channel(ab_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_a=read_adc(ADC_READ_ONLY);
         if(volt_a>=ab_max) {
            high_ab++;
            if(high_ab>4) break;
         }
         else high_ab=0;
         output_low(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_h=read_adc(ADC_READ_ONLY);
         if(curr_h>=short_curr_h) {
            short_curr++;
            if(short_curr>4) break;
         }
         else {
            short_curr=0;
            if(curr_h>curr_h_max) {
               over_curr_delay++;
               //shape_corr[index+1]-=delta_i[index+1];
            }
            else over_curr_delay=0;
         }
         output_high(PIN_C3);
         set_adc_channel(i_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         curr_l=read_adc(ADC_READ_ONLY);
         curr_l_temp+=curr_l;
         if(index==31) {
            curr_l_avg=curr_l_temp>>5;
            if((curr_l_avg<=stdby_i_l)) stdby=0;
            volt_h_avg=volt_h_temp>>5;
            delta_h_ref=(volt_ref_const_h+volt_ref_delta)-volt_h_avg;
            if(delta_h_ref>2) for(i=0; i<32; i++) level_corr[i]+=delta_corr[i]>>1;
            else if(delta_h_ref<-2) for(i=0; i<32; i++) level_corr[i]-=delta_corr[i]>>1;
            curr_l_temp=0;
            volt_h_temp=0;
            high_ab=0;
            short_curr=0;
            stdby_mode++;
         }
         break;
      case 3:
         sine_pwm_stop();
         if(index==31) {
            high_ab=0;
            short_curr=0;
            stdby_mode=0;
            inv_mode++;
         }
         break;
   }
}


#int_timer0
void sine_pwm(void)
{
   restart_wdt();
   clear_interrupt(int_timer0);
   set_timer0(60);
   if((!low_acc)&&(!high_acc)&&(!inv_off)) {                                     // check acc value and inverter state;
      switch (inv_mode) {                                                        // check invereter mode;
         case 0:                                                                 // start mode;
            sine_pwm_start();
            if(index==31) {
               high_ab=0;
               short_curr=0;
               sine_pol=0;
               inv_mode++;
            }
            break;
         case 1:                                                                 // normal mode;
            if((!high_t_stop)&&(!low_curr)&&(!low_acc_delay)) {
               output_high(PIN_B4);                                              // Green LED-ON;
               output_low(PIN_B5);                                               // Red LED-OFF;
            }
            sine_pwm_norm();
            if(index==31) {
               if((low_curr_l)&&(low_curr_h)) {                                  // check for low current;
                  low_curr=1;
                  stdby_go_delay++;
                  if((!low_acc_delay)&&(!high_t_stop)) {
                     if(stdby_go_blink>30) {
                        output_high(PIN_B4);                                     // Blink Green&Red LEDs;
                        output_high(PIN_B5);
                     }
                     else {
                        output_low(PIN_B4);
                        output_low(PIN_B5);
                     }
                     if(!stdby_go_blink) stdby_go_blink=60;
                     else stdby_go_blink--;
                  }
                  if((stdby_go_delay>600)&&(!sine_pol)) {
                     stdby=1;
                     stdby_go_delay=0;
                     stdby_go_blink=60;
                     low_curr_l=0;
                     low_curr_h=0;
                     low_curr=0;
                     inv_mode++;
                     output_low(PIN_B4);
                     output_low(PIN_B5);
                  }
               }
               else {
                  low_curr=0;
                  stdby_go_delay=0;
                  stdby_go_blink=60;
               }
            }
            break;
         case 2:                                                                 // stop mode;
            sine_pwm_stop();
            if(index==31) {
               high_ab=0;
               short_curr=0;
               inv_mode=4;
            }
            break;
         case 3:                                                                 // standby mode;
            sine_pwm_stdby();
            stdby_delay--;
            break;
         case 4:                                                                 // idle mode;
            set_pwm1_duty(0);                                                    // M=0;
            if((!high_t_stop)&&(!low_curr)&&(!low_acc_delay)) {
               if(stdby_delay>1023) output_high(PIN_B4);                         // Blink Green LED;
               else output_low(PIN_B4);
            }
            if(!stdby_delay) {
               stdby_delay=2047;
               if(stdby) inv_mode=3;
               else inv_mode=0;
            }
            else stdby_delay--;
            break;
      }
      if(index==15) {
         set_adc_channel(acc_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         acc_v=read_adc(ADC_READ_ONLY);
         acc_v_temp+=acc_v;
         acc_avg_counter++;
         if(acc_avg_counter==32) {
            acc_avg_counter=0;
            acc_v_avg=acc_v_temp>>5;
            if(acc_v_avg<=acc_min_l) {
               low_acc_delay++;
               if(!high_t_stop) {
                  output_low(PIN_B4);
                  output_high(PIN_B5);
               }
               if(low_acc_delay==16) {
                  low_acc=1;
                  low_acc_delay=0;
               }
            }
            else {
               if(acc_v_avg>=acc_max_h) high_acc=1;
               low_acc_delay=0;
            }
            acc_v_temp=0;
            acc_v_avg=0;
         }
         output_low(PIN_C3);                                                     // check vref value;
         set_adc_channel(stdby_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         volt_ref=read_adc(ADC_READ_ONLY);
         volt_ref_temp+=volt_ref;
         volt_ref_counter++;
         if(volt_ref_counter==32) {
            volt_ref_avg=volt_ref_temp>>8;
            volt_ref_delta=volt_ref_avg-30;
            volt_ref_counter=0;
            volt_ref_temp=0;
         }
      }
      if(index==31) {
         if(over_curr_delay>1600) over_curr=1;
         if(!input(PIN_C4)) {
            high_t_delay++;
            output_high(PIN_C5);
            if((high_t_delay>255)&&(high_t_delay<1024)) {
               high_t_stop=1;
               output_low(PIN_B4);
               if(high_t_blink>45) output_high(PIN_B5);                          // Blink Red LED;
               else output_low(PIN_B5);
               if(!high_t_blink) high_t_blink=90;
               else high_t_blink--;
            }
            else if(high_t_delay>1023) high_t_stop++;
         }
         else {
            high_t_delay=0;
            high_t_stop=0;
            high_t_blink=90;
            output_low(PIN_C5);
         }
         output_high(PIN_C3);                                                    // check stdby current value;
         set_adc_channel(stdby_chan);
         delay_us(10);
         read_adc(ADC_START_ONLY);
         delay_us(20);
         stdby_i=read_adc(ADC_READ_ONLY);
         stdby_i_temp+=stdby_i;
         stdby_i_avg_counter++;
         if(stdby_i_avg_counter==32) {
            stdby_i=stdby_i_temp>>5;
            if(stdby_i>=stdby_max) inv_on=1;
            else inv_on=0;
            if(stdby_i<=stdby_min) inv_off=1;
            stdby_i_h=(stdby_i>>1)+128;
            //if(stdby_i_h>stdby_i_h_max) stdby_i_h=stdby_i_h_max;
            //else if(stdby_i_h<stdby_i_h_min) stdby_i_h=stdby_i_h_min;
            stdby_i_l=255-stdby_i_h;
            stdby_i_avg_counter=0;
            stdby_i_temp=0;
         }
      }
   index++;
   if(index>31) index=0;
   }
   else {                                                                        // acc low mode;
      set_pwm1_duty(0);                                                          // M=0;
      output_high(PIN_C0);                                                       // Z=1;
      output_low(PIN_B4);                                                        // Green LED-OFF;
      if(!inv_off) output_high(PIN_B5);                                          // Red LED-ON;
      inv_mode=0;
      index=0;
      short_curr=0;
      over_curr=0;
      over_curr_delay=0;
      high_ab=0;
      high_t_delay=0;
      high_t_stop=0;
      stdby=0;
      pwm_pos=0;
      pwm_neg=0;
      delta_h_v=0;
      delta_l_v=0;
      //delta_h_ref_v=0;
      //delta_l_ref_v=0;
      //diff_h_v=0;
      //diff_l_v=0;
      delta_h_ref=0;
      delta_l_ref=0;
      //delta_h_ref_adj=0;
      //delta_l_ref_adj=0;
      low_curr_h=0;
      low_curr_l=0;
      curr_h_temp=0;
      curr_h_avg=0;
      curr_l_temp=0;
      curr_l_avg=0;
      low_curr=0;
      volt_h_temp=0;
      volt_h_avg=0;
      volt_l_temp=0;
      volt_l_avg=0;
      volt_ref_temp=0;
      volt_ref_avg=0;
      volt_ref_delta=0;
      volt_ref_counter=0;
      volt_h_avg_counter=0;
      volt_l_avg_counter=0;
      //volt_l_avg_counter=0;
      stdby_i_temp=0;
      //stdby_i_avg_counter=0;
      stdby_go_delay=0;
      stdby_delay=2047;
      high_t_blink=90;
      low_acc_delay=0;
      stdby_go_blink=60;
      //level=0;
      //level_corr=0;
      //level_l_corr=0;
      for(i=0; i<32; i++) {
         shape_corr[i]=0;
         //shape_l_corr[i]=0;
         level_corr[i]=0;
         //level_adj[i]=0;
         //shape_h_corr_temp[i]=0;
         //shape_l_corr_temp[i]=0;
      }
      output_high(PIN_C3);                                                       // check stdby current value;
      set_adc_channel(stdby_chan);
      delay_us(10);
      read_adc(ADC_START_ONLY);
      delay_us(20);
      stdby_i=read_adc(ADC_READ_ONLY);
      stdby_i_temp+=stdby_i;
      stdby_i_avg_counter++;
      if(stdby_i_avg_counter==32) {
         stdby_i=stdby_i_temp>>5;
         if(stdby_i>stdby_min) inv_off=0;
         //else inv_off=0;
         stdby_i_h=(stdby_i>>1)+128;
         //if(stdby_i_h>stdby_i_h_max) stdby_i_h=stdby_i_h_max;
         //else if(stdby_i_h<stdby_i_h_min) stdby_i_h=stdby_i_h_min;
         stdby_i_l=255-stdby_i_h;
         stdby_i_avg_counter=0;
         stdby_i_temp=0;
      }
      set_adc_channel(acc_chan);
      delay_us(10);
      read_adc(ADC_START_ONLY);
      delay_us(20);
      acc_v=read_adc(ADC_READ_ONLY);
      acc_v_temp+=acc_v;
      acc_avg_counter++;
      if(acc_avg_counter==32) {
         acc_avg_counter=0;
         acc_v_avg=acc_v_temp>>5;
         if(acc_v_avg<=acc_max_l) high_acc=0;
         if(acc_v_avg>=acc_min_h) low_acc=0;
         acc_v_temp=0;
         acc_v_avg=0;
      }
      if(input(PIN_C4)) output_low(PIN_C5);
   }
}


void main()
{
   set_tris_b(0xCD);
   set_tris_c(0x90);
   output_high(PIN_C0);                                                          // Z=1;
   //output_high(PIN_B4);                                                          // test LED's;
   //output_low(PIN_B5);
   //delay_ms(1000);
   output_low(PIN_B4);
   //output_high(PIN_B5);
   //delay_ms(1000);
   output_low(PIN_B5);
   index=0;
   inv_mode=0;                                                                   // init to normal start mode;
   inv_on=0;
   inv_off=0;
   stdby_mode=0;
   short_curr=0;
   over_curr=0;
   over_curr_delay=0;
   high_ab=0;
   high_t_delay=0;
   high_t_stop=0;
   low_acc=0;
   high_acc=0;
   acc_v_temp=0;
   acc_avg_counter=0;
   acc_v_avg=0;
   stdby=0;
   pwm_pos=0;
   pwm_neg=0;
   delta_h_v=0;
   delta_l_v=0;
   //delta_h_ref_v=0;
   //delta_l_ref_v=0;
   //diff_h_v=0;
   //diff_l_v=0;
   delta_h_ref=0;
   delta_l_ref=0;
   //delta_h_ref_corr=0;
   //delta_l_ref_corr=0;
   low_curr_h=0;
   low_curr_l=0;
   low_curr=0;
   curr_h_temp=0;
   curr_h_avg=0;
   curr_l_temp=0;
   curr_l_avg=0;
   low_curr=0;
   volt_h_temp=0;
   volt_h_avg=0;
   volt_l_temp=0;
   volt_l_avg=0;
   volt_ref_temp=0;
   volt_ref_avg=0;
   volt_ref_delta=0;
   volt_ref_counter=0;
   volt_h_avg_counter=0;
   volt_l_avg_counter=0;
   //volt_l_avg_counter=0;
   stdby_i_temp=0;
   stdby_i_avg_counter=0;
   stdby_go_delay=0;
   stdby_delay=2047;
   high_t_blink=90;
   low_acc_delay=0;
   stdby_go_blink=60;
   //level=0;
   //level_corr=0;
   //level_l_corr=0;
   for(i=0; i<32; i++) {
      shape_corr[i]=0;
      //shape_l_corr[i]=0;
      level_corr[i]=0;
      //shape_h_corr_temp[i]=0;
      //shape_l_corr_temp[i]=0;
      //level_adj[i]=0;
   }
   setup_adc_ports(ALL_ANALOG);                                                  // init the ADC;
   setup_adc(ADC_CLOCK_DIV_32);                                                  // Tad=1.6us;
   set_adc_channel(acc_chan);
   delay_us(10);
   for(i=0; i<32; i++) {     
      acc_v=read_adc();
      acc_v_temp+=acc_v;
      if(i==31) {
         acc_v_avg=acc_v_temp>>5;
         if(acc_v_avg<=acc_min_l) low_acc=1;
         if(acc_v_avg>=acc_max_h) high_acc=1;
         acc_v_temp=0;
         acc_v_avg=0;
      }
   }
   output_high(PIN_C3);                                                          // check stdby current value;
   set_adc_channel(stdby_chan);
   delay_us(10);
   for(i=0; i<32; i++) {     
      stdby_i=read_adc();
      stdby_i_temp+=stdby_i;
      if(i==31) {
         stdby_i=stdby_i_temp>>5;
         if(stdby_i<=stdby_min) inv_off=1;
         else if(stdby_i>=stdby_max) inv_on=1;
         stdby_i_h=(stdby_i>>1)+128;        
         stdby_i_l=255-stdby_i_h;
         stdby_i_temp=0;
      }
   }
   output_low(PIN_C3);
   set_adc_channel(stdby_chan);                                                  // check vref value;
   delay_us(10);
   for(i=0; i<32; i++) {     
      volt_ref=read_adc();
      volt_ref_temp+=volt_ref;
      if(i==31) {
         volt_ref_avg=volt_ref_temp>>8;
         volt_ref_delta=volt_ref_avg-29;
         volt_ref_temp=0;
      }
   }
   setup_timer_2(T2_DIV_BY_1, 255, 1);                                           // Init the PWM;
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(0);
   //setup_ccp2(CCP_PWM);
   //set_pwm2_duty(0);
   setup_wdt(WDT_18MS);
   set_timer0(60);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8);                                      // Init the TIMER0;
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
   while(TRUE) {
      restart_wdt();
      if((short_curr)||(high_ab)||(over_curr)||(high_t_stop>1)) {                // stop and wait for 60 sec;
         set_pwm1_duty(0);                                                       // M=0;
         output_high(PIN_C0);                                                    // Z=1;
         disable_interrupts(GLOBAL);
         output_low(PIN_B4);
         output_low(PIN_B5);
         short_curr=0;
         over_curr=0;
         over_curr_delay=0;
         high_ab=0;
         high_t_stop=0;
         high_t_delay=0;
         low_acc=0;
         high_acc=0;
         acc_avg_counter=0;
         acc_v_temp=0;
         acc_v_avg=0;
         low_curr_h=0;
         low_curr_l=0;
         index=0;
         inv_mode=0;
         inv_on=0;
         inv_off=0;
         stdby_mode=0;
         stdby=0;
         pwm_pos=0;
         pwm_neg=0;
         delta_h_v=0;
         delta_l_v=0;
         //delta_h_ref_v=0;
         //delta_l_ref_v=0;
         //diff_h_v=0;
         //diff_l_v=0;
         delta_h_ref=0;
         delta_l_ref=0;
         //delta_h_ref_corr=0;
         //delta_l_ref_corr=0;
         //level=0;
         //level_corr=0;
         //level_l_corr=0;
         for(i=0; i<32; i++) {
            shape_corr[i]=0;
            //shape_l_corr[i]=0;
            level_corr[i]=0;
            //level_adj[i]=0;
            //shape_h_corr_temp[i]=0;
            //shape_l_corr_temp[i]=0;
         }
         curr_h_temp=0;
         curr_h_avg=0;
         curr_l_temp=0;
         curr_l_avg=0;
         low_curr=0;
         volt_h_temp=0;
         volt_h_avg=0;
         volt_l_temp=0;
         volt_l_avg=0;
         volt_ref_temp=0;
         volt_ref_avg=0;
         volt_ref_delta=0;
         volt_ref_counter=0;
         volt_h_avg_counter=0;
         volt_l_avg_counter=0;
         //volt_l_avg_counter=0;
         stdby_i_temp=0;
         stdby_i_avg_counter=0;
         stdby_go_delay=0;
         stdby_delay=2047;
         high_t_blink=90;
         low_acc_delay=0;
         stdby_go_blink=60;
         delay_ms(30000);
         if(input(PIN_C4)) output_low(PIN_C5);
         clear_interrupt(int_timer0);
         set_timer0(60);
         enable_interrupts(GLOBAL);
      }
   }
}


INVERTER HEX FILE

:1000000008308A00802A0000FF00030E8301A1004F
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A6007B08A70083131E
:1000300083128B1E1D280B193028220884002308E8
:10004000F7002408F8002508F9002608FA00270818
:10005000FB0020088A00210E8300FF0E7F0E09009E
:100060008A150A1200280A108A100A1182075134D0
:100070000034A2340034F13400343E340134883486
:100080000134CE3401340F3402344C34023482341F
:100090000234B3340234DD340234003403341B340C
:1000A00003342F3403343B3403343F3403343B34C0
:1000B00003342F3403341B34033400340334DD346D
:1000C0000234B3340234823402344C3402340F34F8
:1000D0000234CE340134883401343E340134F134F6
:1000E0000034A234003451340034003400340A1097
:1000F0008A100A1182070334063409340C340F3491
:1001000012341434173419341B341C341E341F3485
:100110001F342034203420341F341F341E341C3448
:100120001B3419341734143412340F340C3409349A
:100130000634033400340310280D0317B200320ACA
:1001400003133320FA000317320803133320031775
:10015000B3007A08B40003100313280DA03E8400F6
:100160008313840A0008FA00840300080317330786
:10017000B5003408B6007A0803187A0FB6070310E2
:10018000360CB800350CB700B80CB70CB80CB70C6F
:10019000B80C3708031395000317B80C380C303926
:1001A000F70003131708CF39770497008714071057
:1001B00086100030F8001F08C73978049F006400DB
:1001C0001030F700F70BE2281F1564002030F7000D
:1001D000F70BE828EB281F19EB281E08C700470873
:1001E0005F3C0318F928B40A3408083C031CF828BB
:1001F000FA28B40187111030F8001F08C7397804B5
:100200009F0064001030F700F70B04291F156400ED
:100210002030F700F70B0A290D291F190D291E0898
:10022000CF004F08EE3C03181B29B30A3308083CE3
:10023000031C1A292629B3014F08DF3C031824297F
:10024000E40A0319E50A2629E501E4010034290836
:10025000003A03192F29013A03198D2AEC2B20307B
:10026000F8001F08C73978049F0064001030F700B9
:10027000F70B38291F1564002030F700F70B3E29D3
:1002800041291F1941291E08C1004108DE07031832
:10029000DF0A0310280D0317B200320A03133320BC
:1002A000FA0003173208031333200317B3007A0848
:1002B000B400103003132807840083170008FA01E4
:1002C000F700F71BFA0303173307B5003408B6002D
:1002D0007A0803187A0FB60703100313280DA03EFF
:1002E00084008313840A0008FA00840300080317BB
:1002F0003507F80036080318360FFA077808031395
:10030000DA007A08DB005B08033C03188B29033012
:10031000DB00FF30DA005B08F9005A08F800F90C3E
:10032000F80CF90CF80CF90C78089500F90C790C1C
:100330003039F7001708CF39770497008710071076
:1003400086140030F8001F08C73978049F00640045
:100350001030F700F70BAA291F1564002030F700B2
:10036000F70BB029B3291F19B3291E08C800480884
:100370005F3C0318C129B40A3408043C031CEC2B6D
:10038000C229B40187111030F8001F08C73978045A
:100390009F0064001030F700F70BCC291F15640094
:1003A0002030F700F70BD229D5291F19D5291E08AF
:1003B000D0005008103C031CE329B30A3308043C66
:1003C000031CEC2BEE29B30150081F3C031CEC2945
:1003D000E40A0319E50AEE29E501E4018715103066
:1003E000F8001F08C73978049F0064001030F70038
:1003F000F70BF8291F1564002030F700F70BFE29D2
:10040000012A1F19012A1E08CF004F08EC07031804
:10041000ED0A28081F3C031D8C2A6D0CFA006C0C99
:10042000F900FA0CF90CFA0CF90CFA0CF90CFA0CAC
:10043000F90C7908D1004A0851020318252AAE08A0
:10044000031D252A0130B100262AB1015F0CFA00F4
:100450005E0CF900FA0CF90CFA0CF90CFA0CF90C18
:10046000FA0CF90C7908C3005708573C4302D60030
:10047000D61B5E2A5608023C03185E2AAD012D08E1
:100480001F3C031C5D2A03102D0DA03E8400831326
:100490002D087720F7000310F70C77080007840A6F
:1004A000F8000008FA000318FA0A840378088000AC
:1004B000840A7A088000AD0A3F2A842A5608803AC6
:1004C0007D3C031C842AAD012D081F3C031C842A9B
:1004D00003102D0DA03E840083132D087720F70014
:1004E0000310F70C77080002F700840A0008FA00EE
:1004F0000030031C0130FA02770884038000840A6C
:100500007A088000AD0A642AED01EC01DF01DE010A
:10051000B401B3010130A900EC2B2030F8001F0812
:10052000C73978049F0064001030F700F70B962A53
:100530001F1564002030F700F70B9C2A9F2A1F1913
:100540009F2A1E08C0004008DC070318DD0A0310BC
:10055000280D0317B200320A03133320FA000317E1
:100560003208031333200317B3007A08B4001030A5
:1005700003132807840083170008FA01F700F71B0C
:10058000FA0303173307B5003408B6007A080318D6
:100590007A0FB60703100313280DA03E84008313BF
:1005A000840A0008FA008403000803173507F800DE
:1005B00036080318360FFA0778080313D8007A08AC
:1005C000D9005908033C0318E92A0330D900FF3049
:1005D000D8005908F9005808F800F90CF80CF90C83
:1005E000F80CF90C78089500F90C790C3039F70003
:1005F0001708CF397704970087140710861000304A
:10060000F8001F08C73978049F0064001030F70015
:10061000F70B082B1F1564002030F700F70B0E2B8B
:10062000112B1F19112B1E08C70047085F3C031828
:100630001F2BB40A3408043C031CEC2B202BB40100
:1006400087111030F8001F08C73978049F00640034
:100650001030F700F70B2A2B1F1564002030F7002D
:10066000F70B302B332B1F19332B1E08CF004F08ED
:10067000EE3C0318412BB30A3308043C031CEC2B5B
:100680004C2BB3014F08DF3C03184A2BE40A031933
:10069000E50A4C2BE501E40187151030F8001F082E
:1006A000C73978049F0064001030F700F70B562B11
:1006B0001F1564002030F700F70B5C2B5F2B1F1910
:1006C0005F2B1E08D0005008EE070318EF0A280819
:1006D0001F3C031DEB2B6F0CFA006E0CF900FA0C9B
:1006E000F90CFA0CF90CFA0CF90CFA0CF90C790863
:1006F000D20052084B020318832BAE08031D832B34
:100700000130B000842BB0015D0CFA005C0CF900E4
:10071000FA0CF90CFA0CF90CFA0CF90CFA0CF90CAD
:100720007908C200A8305707F80042087802D500BF
:10073000D51BBE2B5508023C0318BE2BAD012D085E
:100740001F3C031CBD2B03102D0DA03E8400831302
:100750002D087720F7000310F70C77080007840AAC
:10076000F8000008FA000318FA0A840378088000E9
:10077000840A7A088000AD0A9F2BE42B5508803A42
:100780007D3C031CE42BAD012D081F3C031CE42B16
:1007900003102D0DA03E840083132D087720F70051
:1007A0000310F70C77080002F700840A0008FA002B
:1007B0000030031C0130FA02770884038000840AA9
:1007C0007A088000AD0AC42BEF01EE01DD01DC01E7
:1007D000B401B301A901EC2B8A150A122C280310CD
:1007E000280D0317B200320A03133320FA0003174F
:1007F0003208031333200317B3007A08B400031040
:100800000313280DA03E84008313840A0008FA0015
:100810008403000803173307B5003408B6007A08CC
:1008200003187A0FB6070310360CB800350CB70062
:10083000B80CB70CB80CB70CB80C370803139500FC
:100840000317B80C380C3039F70003131708CF39E9
:10085000770497008710071086140030F8001F08EF
:10086000C73978049F0064001030F700F70B362C6E
:100870001F1564002030F700F70B3C2C3F2C1F198C
:100880003F2C1E08C80048085F3C03184D2CB40AD2
:100890003408043C031C4C2C4E2CB401871110303E
:1008A000F8001F08C73978049F0064001030F70073
:1008B000F70B582C1F1564002030F700F70B5E2C47
:1008C000612C1F19612C1E08D0005008103C031C1D
:1008D0006F2CB30A3308043C031C6E2C7A2CB30132
:1008E00050081F3C031C782CE40A0319E50A7A2CF3
:1008F000E501E40100342B08FC3E03181B2F043EE5
:100900001E2F9B2028081F3C031D892CB401B30116
:10091000AB0A1B2F0310280D0317B200320A031372
:100920003320FA0003173208031333200317B300F0
:100930007A08B40003100313280DA03E840083132B
:10094000840A0008FA008403000803173307F8003C
:1009500034080318340FFA0778080313DA007A080A
:10096000DB005B08033C0318B92C0330DB00FF30CD
:10097000DA005B08F9005A08F800F90CF80CF90CD9
:10098000F80CF90C78089500F90C790C3039F7005F
:100990001708CF3977049700871007108614203086
:1009A000F8001F08C73978049F0064001030F70072
:1009B000F70BD82C1F1564002030F700F70BDE2C46
:1009C000E12C1F19E12C1E08C1004108DE070318A5
:1009D000DF0A0030F8001F08C73978049F00640060
:1009E0001030F700F70BF22C1F1564002030F700D1
:1009F000F70BF82CFB2C1F19FB2C1E08C80048080D
:100A00005F3C0318092DB40A3408043C031C1B2F57
:100A10000A2DB40187111030F8001F08C739780477
:100A20009F0064001030F700F70B142D1F156400B1
:100A30002030F700F70B1A2D1D2D1F191D2D1E0834
:100A4000D00050083302031C2B2DB30A3308043C9A
:100A5000031C1B2F362DB30150081F3C031C342DE3
:100A6000E40A0319E50A362DE501E4018715103083
:100A7000F8001F08C73978049F0064001030F700A1
:100A8000F70B402D1F1564002030F700F70B462DA3
:100A9000492D1F19492D1E08CF004F08EC070318D8
:100AA000ED0A28081F3C031DCB2D6D0CFA006C0CC1
:100AB000F900FA0CF90CFA0CF90CFA0CF90CFA0C16
:100AC000F90C7908D1004A0851020318AC015F0CF7
:100AD000FA005E0CF900FA0CF90CFA0CF90CFA0C9D
:100AE000F90CFA0CF90C7908C3005708573C43027B
:100AF000D600D61B9E2D5608023C03189E2DAD0134
:100B00002D081F3C031C9E2D03102D0DA03E8400BC
:100B100083132D087720F7000310F70C77080007E0
:100B2000840AF8000008FA000318FA0A8403780817
:100B30008000840A7A088000AD0A802D5608803A29
:100B40007D3C031CC42DAD012D081F3C031CC42D8E
:100B500003102D0DA03E840083132D087720F7008D
:100B60000310F70C77080002F700840A0008FA0067
:100B70000030031C0130FA02770884038000840AE5
:100B80007A088000AD0AA42DED01EC01DF01DE0141
:100B9000B401B301AB0A1B2F0310280D0317B200D9
:100BA000320A03133320FA000317320803133320E9
:100BB0000317B3007A08B40003100313280DA03EF6
:100BC00084008313840A0008FA00840300080317D2
:100BD0003307F80034080318340FFA0778080313B2
:100BE000D8007A08D9005908033C0318FB2D0330BC
:100BF000D900FF30D8005908F9005808F800F90C5E
:100C0000F80CF90CF80CF90C78089500F90C790C33
:100C10003039F7001708CF39770497008714071089
:100C200086102030F8001F08C73978049F00640040
:100C30001030F700F70B1A2E1F1564002030F70054
:100C4000F70B202E232E1F19232E1E08C00040084C
:100C5000DC070318DD0A0030F8001F08C7397804E4
:100C60009F0064001030F700F70B342E1F1564004E
:100C70002030F700F70B3A2E3D2E1F193D2E1E088F
:100C8000C70047085F3C03184B2EB40A3408043CE5
:100C9000031C1B2F4C2EB40187111030F8001F08C5
:100CA000C73978049F0064001030F700F70B562E08
:100CB0001F1564002030F700F70B5C2E5F2E1F1904
:100CC0005F2E1E08CF004F08EE3C03186D2EB30AAE
:100CD0003308043C031C1B2F782EB3014F08DF3C64
:100CE0000318762EE40A0319E50A782EE501E401DB
:100CF00087151030F8001F08C73978049F0064007A
:100D00001030F700F70B822E1F1564002030F7001B
:100D1000F70B882E8B2E1F198B2E1E08D000500823
:100D2000EE070318EF0A28081F3C031D102F6F0C55
:100D3000FA006E0CF900FA0CF90CFA0CF90CFA0C2A
:100D4000F90CFA0CF90C7908D20052084B0203187E
:100D5000AC015D0CFA005C0CF900FA0CF90CFA0C11
:100D6000F90CFA0CF90CFA0CF90C7908C200A8304D
:100D70005707F80042087802D500D51BE32E550826
:100D8000023C0318E32EAD012D081F3C031CE22E8C
:100D900003102D0DA03E840083132D087720F7004B
:100DA0000310F70C77080007840AF8000008FA001F
:100DB0000318FA0A840378088000840A7A088000FD
:100DC000AD0AC42E092F5508803A7D3C031C092F1B
:100DD000AD012D081F3C031C092F03102D0DA03E53
:100DE000840083132D087720F7000310F70C770891
:100DF0000002F700840A0008FA000030031C0130EA
:100E0000FA02770884038000840A7A088000AD0A19
:100E1000E92EEF01EE01DD01DC01B401B301AB0A03
:100E20001B2FEF2328081F3C031D1A2FB401B30109
:100E3000AB01AA0A1B2F8A150A1281280A148A14E8
:100E40000A158207812C8A2CCC2D112F3130840079
:100E50008317000803193D2F0630F800BF30F70054
:100E60006400F70B302FF80B2E2F7A30F700F70BBA
:100E7000372F3A2F6400800B2C2F8A150A122D2C45
:1010000064000B113C308100B608031DAB29B70802
:10101000031DAB29AF08031DAB292A08FB3E0318AB
:10102000AD28053E772A8A119B208A1528081F3C87
:10103000031D1E28B401B301A901AA0AAD28B808EE
:10104000031D2A28BA08031D2A28BB08031D2A28C5
:10105000061686128A1127298A1528081F3C031DA7
:101060007228B10803196D28B00803196D280130E2
:10107000BA00E80A0319E90ABB08031D5228B80898
:10108000031D522835081E3C0318492806168616EB
:101090004B2806128612B508031D51283C30B500B6
:1010A0005228B5036908013C03186C28FF3A031D58
:1010B0005D286808583C03186C28A908031D6C2893
:1010C0000130AC00E901E8013C30B500B101B001EC
:1010D000BA01AA0A061286127228BA01E901E801C9
:1010E0003C30B500AD288A11EF238A1528081F3C33
:1010F000031D7E28B401B3010430AA00AD288A1173
:101100007B2C8A1566080319E703E603AD289501D1
:10111000B808031D9828BA08031D9828BB08031DAA
:1011200098286708033C0318972806169828061283
:1011300066086704031DA8280730E700FF30E600B3
:10114000AC080319A6280330AA00A728AA01AC28D6
:1011500066080319E703E603AD2828080F3C031DC2
:1011600023291830F8001F08C73978049F0064004D
:101170001030F700F70BBA281F1564002030F70075
:10118000F70BC028C3281F19C3281E08C50045082F
:10119000E2070318E30ABC0A3C08203C031DFB28B5
:1011A000BC01630CFA00620CF900FA0CF90CFA0CA1
:1011B000F90CFA0CF90CFA0CF90C7908C60046087F
:1011C0003C3C031CF128BB0AB808031DE9280612A1
:1011D00086163B08103C031DF0280130B600BB0109
:1011E000F8284608613C0318F7280130B700BB0116
:1011F000E301E201C60187110830F8001F08C73972
:1012000078049F0064001030F700F70B05291F15C4
:1012100064002030F700F70B0B290E291F190E2947
:101220001E08CD004D08E0070318E10ABD0A3D087D
:10123000203C031D23296108CE001E304E02D7003A
:10124000BD01E101E00128081F3C031DA529650837
:10125000053C03183429FF3A031D32296408403C39
:10126000031834290130B200071A5929EA0A031970
:10127000EB0A87166B08003C031854296B08033CE3
:10128000031C54290130B800061239082D3C0318FC
:101290004B2986164C298612B908031D52295A304B
:1012A000B9005329B90358296B08033C031CB80A39
:1012B0005F29EB01EA01B8015A30B900871287159E
:1012C0000830F8001F08C73978049F006400103008
:1012D000F700F70B69291F1564002030F700F70BA2
:1012E0006F2972291F1972291E08C9004908F007C1
:1012F0000318F10ACC0A4C08203C031DA529710CE7
:10130000FA00700CF900FA0CF90CFA0CF90CFA0C52
:10131000F90CFA0CF90C7908C9004908FC3C0318CF
:1013200094290130AE009529AE014908023C031C06
:101330009B290130AF000310490C803ECA004A08C7
:10134000FF3CCB00CC01F101F001A80A28081F3CAA
:10135000031CA801732A950107140612AF0803198C
:101360008616AA01A801B301B201E501E401B401A6
:10137000EB01EA01B801AC01D901D801DB01DA01C6
:10138000D301D401D501D601B001B101ED01EC01C9
:10139000D101EF01EE01D201BA01DD01DC01C20190
:1013A000DF01DE01C301E101E001CE01D701BD0192
:1013B000BF01BE01F101F001E901E8010730E700DA
:1013C000FF30E6005A30B900BB013C30B500AD013A
:1013D0002D081F3C031CFC2910302D0784008317A7
:1013E000800103102D0DA03E84008313840A800128
:1013F00084038001AD0AE82987150830F8001F082A
:10140000C73978049F0064001030F700F70B062AF4
:101410001F1564002030F700F70B0C2A0F2A1F1944
:101420000F2A1E08C9004908F0070318F10ACC0A60
:101430004C08203C031D382A710CFA00700CF9008E
:10144000FA0CF90CFA0CF90CFA0CF90CFA0CF90C70
:101450007908C9004908023C031CAF010310490C7C
:10146000803ECA004A08FF3CCB00CC01F101F001EC
:101470001830F8001F08C73978049F006400103046
:10148000F700F70B412A1F1564002030F700F70B17
:10149000472A4A2A1F194A2A1E08C5004508E2079A
:1014A0000318E30ABC0A3C08203C031D712ABC0156
:1014B000630CFA00620CF900FA0CF90CFA0CF90C46
:1014C000FA0CF90CFA0CF90C7908C60046085C3CD9
:1014D0000318B7014608413C031CB601E301E201D1
:1014E000C601071A87120B118A110A121D280A1049
:1014F0008A140A11820713281F2873287F28872837
:10150000840183131F30830583161F149F141F1536
:101510009F1107309C00CD308600903087008312E9
:10152000071406128612A801AA01AE01AF01AB0191
:10153000B301B201E501E401B401EB01EA01B80134
:10154000B601B701E301E201BC01C601AC01D9015A
:10155000D801DB01DA01D301D401D501D601B001F4
:10156000B101BA01ED01EC01D101EF01EE01D201AF
:10157000BA01DD01DC01C201DF01DE01C301E101CD
:10158000E001CE01D701BD01BF01BE01F101F001B3
:10159000CC01E901E8010730E700FF30E6005A30EE
:1015A000B900BB013C30B500AD012D081F3C031C48
:1015B000E92A10302D0784008317800103102D0DB8
:1015C000A03E84008313840A800184038001AD0A55
:1015D000D52A83161F109F101F119F111F138312EE
:1015E0001F139F1783169F1383121F141830F800C0
:1015F0001F08C73978049F0064001030F700F70B0C
:10160000FF2AAD012D081F3C031C322B1F151F198B
:10161000072B1E08C5004508E2070318E30A2D083A
:101620001F3C031D302B630CFA00620CF900FA0C0E
:10163000F90CFA0CF90CFA0CF90CFA0CF90C790803
:10164000C60046083C3C031C272B0130B600460868
:10165000613C03182D2B0130B700E301E201C60104
:10166000AD0A022B87150830F8001F08C739780427
:101670009F0064001030F700F70B3C2BAD012D08E4
:101680001F3C031C762B1F151F19442B1E08C90075
:101690004908F0070318F10A2D081F3C031D742B9D
:1016A000710CFA00700CF900FA0CF90CFA0CF90C38
:1016B000FA0CF90CFA0CF90C7908C9004908023C3B
:1016C000031C652B0130AF006B2B4908FC3C031851
:1016D0006B2B0130AE000310490C803ECA004A0853
:1016E000FF3CCB00F101F001AD0A3F2B8711083020
:1016F000F8001F08C73978049F0064001030F70015
:10170000F70B802BAD012D081F3C031C9D2B1F15D3
:101710001F19882B1E08CD004D08E0070318E10AA9
:101720002D081F3C031D9B2B6108CE001D304E026F
:10173000D700E101E001AD0A832B0030F800043846
:101740009200FF3083169200831207110C3097002D
:10175000950183160108F039810064003C30831242
:10176000810083160108C0390238810083128B166C
:10177000C0308B046400B308031DC82BB408031DDC
:10178000C82BB208031DC82B3808013C0318392C9C
:10179000950107140B138B138B1BCB2B0612861290
:1017A000B301B201E501E401B401B801EB01EA01C2
:1017B000B601B701BC01E301E201C601B001B1010C
:1017C000A801AA01AE01AF01AB01AC01D901D8015A
:1017D000DB01DA01D301D401D501D601AD012D0819
:1017E0001F3C031C032C10302D078400831780013D
:1017F00003102D0DA03E84008313840A800184030E
:101800008001AD0AEF2BED01EC01D101EF01EE01FA
:10181000D201BA01DD01DC01C201DF01DE01C30139
:10182000E101E001CE01D701BD01BF01BE01F1011F
:10183000F001CC01E901E8010730E700FF30E600E4
:101840005A30B900BB013C30B50078300317B00006
:10185000FA30B1008A110313262F8A150317B00B33
:10186000282C0313071A87120B113C308100C0305B
:061870008B04BA2B63009B
:02400E00763FFB
:00000001FF
;PIC16F876A

4 comments:

kolleyjay said...

nice work

Anthony said...

Good work Engr. Keep it up

Unknown said...

Gud work

Anonymous said...

Good work
A contribution to scientific innovation