Composite Energy Storage System with Photovoltaic Power Generation and UPS Function



CIRCUIT

WAVEFORMS


GATE SIGNALS OF INVERTER MOSFET
Step-up transformer
 The transformer rating is 12-0-12V,8A. AC (centre tapped) at primary and 230V,0.9A across the secondary winding. The 230V appearing across the secondary is the RMS value of the waveform and the peak value would be 230*1.414=325.22V.
PROGRAM ( COMPILER MIKRO C)
//used crystal of 4 MHz

// duty_50% = (clock frequency/ (output_frequency*4* 2*1)) -1 =19999

#define modeswitch  PORTE.F8  //modeswitch
#define relay LATC.F14  //relay
#define charge_switch LATC.F13  //relay
int boostvoltage,solarvoltage;
int maximum_duty=5;
int maximum_duty_solar=5;
unsigned long int pwm_period, current_duty ;
unsigned int current_duty2,current_duty3;
unsigned int pwm_period2, pwm_period3;
int f=0;
void pins_init(void);
void inverter_init(void);
void solarboost_init(void);
void charger_boost_init(void);
void boostcontrol(void);
void solar_boost_control(void);
void off_inverter_and_boost(void);
void on_inverter_and_boost(void);
void mode_control(void);
void main()
{
pins_init() ;
inverter_init();
charger_boost_init();
solarboost_init();
 ADC1_Init();
relay=0;

while (1)
{
 if(f==0)  //boost mode duty
{
 boostcontrol();
}

 solar_boost_control();
 mode_control();
}
}
void mode_control(void)
{
if(modeswitch==0)
{
if(f==0)   //change to rectifier mode
{
f=1; off_inverter_and_boost();Delay_ms(1000);
relay=1;charge_switch=1;
}
else     //change to inverter mode
{
relay=0;charge_switch=0;Delay_ms(1000);
f=0;on_inverter_and_boost();


}

}
}

void off_inverter_and_boost(void)
{
PWM1_Mc_Stop(); PWM_Stop(2);
}
void on_inverter_and_boost(void)
{
PWM1_MC_Start();  PWM_Start(2);
}
void solar_boost_control(void)
{
solarvoltage = ADC1_Read(1)*0.054; Delay_ms(1);
if(solarvoltage>12)
{
current_duty2=current_duty2-1;
  if(current_duty2<1)current_duty2=0;
PWM_Set_Duty(current_duty2,  1);
}
else if (solarvoltage<14 )
{
current_duty2=current_duty2+1;
  if(current_duty2>maximum_duty_solar)current_duty2=maximum_duty_solar;
PWM_Set_Duty(current_duty2,  1);
}
}


void boostcontrol(void)
{
boostvoltage = ADC1_Read(0)*0.054; Delay_ms(100);
if(boostvoltage>13)
{
current_duty3=current_duty3-1;
  if(current_duty3<1)current_duty3=0;
  PWM_Set_Duty(current_duty3, 2);
}
else if (boostvoltage<11 )
{
current_duty3=current_duty3+1;
  if(current_duty3>maximum_duty)current_duty3=maximum_duty;
  PWM_Set_Duty(current_duty3, 2);
}
}
void inverter_init(void)
{
current_duty=20000;                   //duty ratio 50% =99
pwm_period = PWM1_MC_Init(50, 0, 0x11, 0);      //enable 1L AND 1H pwm pins
PWM1_MC_Set_Duty (current_duty, 1) ;
PWM1_MC_Start();
DTCON1=511;     //DEAD TIME CONTROL   maximum 79
////Delay_ms(2000); PWM1_Mc_Stop();
}
void solarboost_init(void)  //pwm 2
{
current_duty2  =1;      //80% IS 24,MAXIMUM  33 
pwm_period2 = PWM_Init(30000 , 1, 1, 2);//FREQ,CHANNEL,PRESCALE,TIMER NAME
PWM_Start(1);
PWM_Set_Duty(current_duty2,  1);            // Set current duty for PWM1                         // initial value for current_duty1
}
void charger_boost_init(void) //pwm 3
{
current_duty3 = 1;                        // initial value for current_duty1
pwm_period3 = PWM_Init(30000, 2, 1, 3);
PWM_Start(2);
PWM_Set_Duty(current_duty3, 2);
}
void pins_init(void) //pwm 3
{
TRISB.F0 = 1; TRISB.F1 = 1; //feed back
TRISE.F8 = 1;   //mode switch
TRISD.F0 = 0; TRISD.F1 = 0;  //pwm boost
TRISE.F0 = 0; TRISE.F1 = 0;  //inverter
TRISC.F14 = 0;   //RELAY
TRISC.F13 = 0;   //charger mosfet
}