Friday, September 6, 2013

high frequencysine wave inverter



// just follow the code for H- bridge inverter with pic in bult PWM controllers  for genrating sine wave  inverters

#ifndef _XTAL_FREQ
#define _XTAL_FREQ 16000000 
#define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
#endif

#include
__CONFIG(PROTECT&
        HS& //INTIO&             //internal
        OSC_8MHZ&
        WDTDIS&
        MCLRDIS&
        PWRTEN &
        BOREN &
        0x3FFF);

unsigned char sin_table[32] = {0, 25, 49, 73, 96, 118, 137,
    159, 177, 193, 208, 220, 231, 239, 245, 249, 250, 249, 245,
    239, 231, 220, 208, 193, 177, 159, 137, 118, 96, 73, 49, 25};



unsigned char index;
unsigned char soft_start_sh; //soft start shift count.
unsigned char soft_start_td; //soft start time delay.
unsigned int DUTY_CYCLE; //delay.
bit soft_start, wave_flag = 0;

void interrupt siva() {
    if (TMR2IF == 1) {
        TMR2IF = 0;
        CCPR1L = 200; //sin_table[index];

      //  ++index;
        if(index == 32)
        {  index = 0;
           wave_flag = ~wave_flag;
           if( wave_flag)  CCP1CON = 0x8D; //half bridge control
           else  CCP1CON = 0x8C; //half bridge control
        }
    }
}

void main() {

    ANSEL = 0; //Disable ADC
    CM1CON0 = 0; //Disable Comparator
    CM2CON0 = 0; //Disable Comparator
    VRCON = 0;
    PR2 = 249; //16 khz@16MHZ
    TRISC = 0x3F;
    CCP1CON = 0x00;
    ECCPAS = 0x40;
    PWM1CON = 0x94; //5ussec
    PRSEN = 1;
    CCP1CON = 0x8D; //half bridge control
     wave_flag = 0;
    __delay_ms(500);
    TMR2IF = 0;
    T2CON = 0x24; //TMR2 on, prescaler and postscaler 1:5
    while (TMR2IF == 0);
    TMR2IF = 0;
    TRISC = 0x03; //set pwm pins as o/p
    TMR2IE = 1;
    GIE = 1;
    PEIE = 1;
    RC2 = 0; 
    RC3 = 0;
    while (1) {
        if (ECCPASE) index = 0;
   }
}

PWM1A,1B,1C,1D pins form the H bridge circuit. IR2110 and IRF 740 MOS FETS are Used  for circuit. 

2 comments:

  1. Hello, Tahmid. I'm Vladimir from Uzbekistan. Currently I'm working on a 5kW pure sine wave inverter. I've made the circuit based on pic16f684 and two IR2110. It works correctly, but ... But there's one little problem: I have pure sine wave only when the load on the output of my inverter is greater than 300W. If the load is less than 300W, the sine distorts, it reminds of square wave. If I don't connect the load at all, the output is clear square wave. I know, what the problem is: the capacitor of output LC filter under light load charges quickly even if we have low duty cycle. It remains charged during the whole half sine wave. That's how square wave instead of sine wave is generated. I've tried to lower duty cycle under no load, it doesn't help. 50Hz square wave remains. May be you have some suggestions about this? And by the way, there is not problem in LC filter. I'm using factory made LC-filter from broken 5kW inverter. This factory made 5kW inverter also has driving PCB for full-bridge. Only it contains pic16f716 instead pic16f684. I think my problem is in software. And... I've examined the factory made PCB. It has strange connections. It uses pic16f716 in half-bridge mode, not in full - bridge mode. Only P1A and P1B are used and additional, not P1C and P1D. And all four pin connected in a tricky way to IR2110 through 8 1n4148 diodes and pullup and pulldown resistors. Your ISIS simulation picture also have such connection. It has interesting output signals. Why do you connect diodes in a such way? Any suggestions on this point? Thank you a lot in advance for possible help.

    ReplyDelete
  2. Hello, Siva, I'm Vladimir. It's a nice article. But I think there's some shortcomings in source code. You use only two half-bridge outputs, but in proteus you use four output pins. These two additional output pins are not present in source code...

    ReplyDelete

Popular Posts