Showing posts with label ELECTRONICS. Show all posts
Showing posts with label ELECTRONICS. Show all posts

7/20/2018

How to charge phone using 12V battery

How to charge your phone using 12V battery or a  12V transformer.

The circuit below shows a simple android charger or simple mobile phone charger using 12V battery or 12V transformer and few components which are also cheap and easy to get.

   CHARGE YOUR PHONE

USING 12V BATTERY PHONE CHARGER CIRCUIT

 

12V BATTERY PHONE CHARGER CIRCUIT
Click to view


Circuit explanation

The circuit works by either using power from your house socket outlet or using any battery with voltage between 9V to 26V.
It is advisable not to use the two source of power together since it will be of no use.

When using a step down 12V transformer, the output voltage is rectified using D5,  D6, D7 and D8. The rectified voltage is then then filtered using C1. After rectification, voltage of 12V to 18V DC will be obtained.

When S1 is closed, power flow from either the battery or the rectified voltage into U1 which is a 5V voltage regulator.

The function the 5V regulator LM7805 is to provide a constant 5V 1A current to our phone. but 1A is too high for our phone so we use 100ohms 1 watt resistor to reduce the current from 1A to a good level that will not harm our phone.

When there is power from LM7805, LED 2 turns on to indicate power.

During charging, LED 1 turns bright. As the phone battery gets full, LED 1 glows dim.

The function of D1 is to prevent rectified Voltage from going to the battery.

Connect the output of the circuit to the positive (red) and the negative (black) cables of any changer cable to start charging your phone.

7/05/2018

DSPIC30f2010 PURE SINE INVERTER CIRCUIT WITH CHARGER

This is a highly reliable sine wave inverter circuit designed using digital signal processing IC (DSP30f2010) made by micro-chip.

DSP30f2010 PURE SINE INVERTER WITH CHARGER

Read dsp30f2010 mppt from HERE

THE DSP30f2010 INVERTER . 

The circuit am sharing today is an inverter circuit which can also charge every inverter/solar battery with a selected charge current.
As said earlier, the inverter / circuit runs on a digital signal processing micro-controller made by micro-chip. You can download the datasheet by clicking Here.

After testing the code and the hardware as designed by Mr. Sanjay, I decided to modify it so that it can be able to stand all tests of time. After the modification of hardware and code, the system has truly become 99% reliable and has the following functions and protections.


1. Ability to work as inverter or UPS.

2. Mosfet protection interrupt

3. Better battery charging algorithm

4. Low voltage protection

5. high voltage Protection

6. Works on 12V, 24V, 48V, 96V, 120V

7. Overload protection

8. Over charging protection

9. Over battery protection

10. Load display In KVA

11. Cooling fan failure detection and tripping with alarm

12. NTC sensor failure detection and tripping with alarm

13. Over Temperature protection

14. The circuit board can be used to repair all pure sine inverters.

15. Set your own maximum load, charging current and set almost everything by yourself if you don't   want the default values

16. Low battery alarm

17. Low Battery cut-off


18. The board can be used for control board replacement for all single phase low frequency pure sine wave inverters (MUST, POWER STAR, FELICITY, KAMA POWER, POWER JACK etc. )


19. The control board can be used to build high current 3 stages charger with current rating from 1A-100A

20.  will use either 16x2 or 16x4 LCD

21. Source code can be use for SMPS INVERTERS AS WELL





   12V-120V INVERTER PURE SINE WAVE CONTROL BOARD CIRCUIT



 VERSION 3.0

to make your own inverter transformer for this circuit click below



Read more on make inverter transformer


MOSFET BRIDGE CIRCUIT (POWER AMPLIFIER CIRCUIT)

The mosfet bridge circuit for pure sine inverters is also know as H-bridge or Power amplifying Stage. Click below to read more
about mosfet bridge circuit and how it works.



BUY MOSFET H BRIDGE BOARD



DSP30F2010 INVERTER CONTROL BOARD

Below are pictures of the professional inverter board.
it can be used for 12V systems, 24V systems, 48V system with no modification to the parts. 96V and 120V systems will need to change R11 to a higher value.

BUY CONTROL BOARD WITH OR WITHOUT COMPONENTS

If you are interested in buying the control boards together with a programmed DSPIC30f2010, kindly send me email 
opanin17@gmail.com



BUY PLAIN BOARD WITH PROGRAMMED IC





BUY ASSEMBLED PCB WITH PROGRAMMED IC


You can buy either PCB with the micro controller which is already programmed or buy only the programmed micro controller and use the circuit on this site to build your own PCB.

SIGNAL FROM MOSFET DRIVE WITH 20KHz. PWM

DSPINVERTER drive







BUY PROGRAM SOURCE CODE

If anyone is intrested in buying the source code for programing the PIC micro controller for this inverter, You can contact.
Mr. SANJAY by sending him mail on microsanju@gmail.com

You can also buy source code from me by sending me mail on opanin17@gmail.com.

People who are not into C programming can buy just the HEX file to program the ic without edditing. You should therefore state what you need in your mail.



CODE FOR DSPIC30F2010 PURE SINE INVERTER WITH CHARGER


//////////////////////////////////////////////////////////////////////
#include <p30f2010.h>
#include <libpic30.h>


_FOSC(CSW_ON_FSCM_OFF & XT_PLL16);
_FWDT(WDT_OFF);
_FBORPOR(MCLR_EN & PBOR_ON & BORV_42 & RST_PWMPIN & PWMxH_ACT_HI & PWMxL_ACT_HI);
_FGS (CODE_PROT_ON)
#define buzzer    LATEbits.LATE4
#define change    LATDbits.LATD1
#define stbyinv 1
#define upsmode 2
#define invmode 3
#define modekey 4
#define upkey   5
#define downkey 6
#define stbyups 7
#define fanheat 700


///////////////////////////////////////////////////////////////////////////////////////////
 const signed int sine_table[91]={0,174,348,523,697,871,1045,1218,1391,1564,1736,1908,2079,2249,2419,2588,2756,2923,3090,
                  3255,3420,3583,3746,3907,4067,4226,4383,4539,4694,4848,5000,5150,5299,5446,
                  5591,5735,5877,6018,6156,6293,6427,6560,6691,6819,6946,7071,7193,7313,7431,7547,7660,7771,
                  7880,7986,8090,8191,8290,8386,8480,8571,8660,8746,8829,8910,8987,9063,9135,9205,9271,9335,
                  9396,9455,9510,9563,9612,9659,9702,9743,9781,9616,9848,9876,9902,9925,9945,9961,9975,9986,
                  9993,10000,10000};

signed int factory[17]={3,12,0,350,220,250,400,180,400,180,141,104,102,117,50,10};
signed int setting[17];
char arr[4];

struct
{
unsigned int batt_full:1;
unsigned int frstdisp:1;
unsigned int setup:1;
unsigned int gravity:1;
unsigned int onflag:1;
unsigned int vcorrect:1;
unsigned int chrcorrect:1;
unsigned int chon:1;
unsigned int swon:1;
unsigned int nofeed:1;
unsigned int shorttrip:1;
unsigned int zincfail:1;
unsigned int mainsok:1;
unsigned int lbwarn:1;
unsigned int olwarn:1;
unsigned int olcut:1;
unsigned int lbcut:1;
unsigned int fault:1;
unsigned int hiload:1;
unsigned int msgrtn:1;
unsigned int chrmsgrtn:1;
unsigned int firston:1;
unsigned int fan_error:1;
unsigned int over_battery:1;
unsigned int ntc_fail:1;
}flags;

unsigned int chshoot;
unsigned int chshootdly=0;
unsigned int flicker=0;
int *adjust;
char *ptr;
int adj;
int *value;
unsigned int chadj;
unsigned int champs1;
signed int duty_cycle_1;
signed int p=0,flag=1,rising=1;

signed int pr=0,kflag=1,rising1=1;
unsigned int amplitude=0;

unsigned int pb,qb,cth,ctl;
////////////////////////////////
/*
///my settings to display load in wattage//

unsigned int overload_1;
unsigned int overload_2;
unsigned int max_load;
unsigned int total_load;
unsigned int load_decimal;
unsigned int ld_p;

 */

///////////////////////////////
unsigned int battery_full;
unsigned int setdly;
unsigned int menudelay;
unsigned int lcdtmr;
unsigned int lcdtmr1;
unsigned int counter;
unsigned int resumedelay;
unsigned int buzzcount;
unsigned int buzzdelay;
unsigned int buzzoftme;
unsigned int buzzontme;
unsigned int peakfail;
unsigned int oldelay;
unsigned int tripdly;
unsigned int rounds;
unsigned int chrdly;
unsigned int slowdly;
unsigned int fbdly;
unsigned int ctfaildly;
unsigned int deadshortdly;
unsigned int lbdly;
unsigned int acdly;
unsigned int keydly;
unsigned int msgrtndly;
unsigned int gravitydly;
unsigned int fltdly;
unsigned int blinkdly;
unsigned int startdly;
////////////////////////////////
unsigned long endtimer;
unsigned long controlavg;
unsigned long mainsavg;
unsigned long outavg;
unsigned long wattsavg;
unsigned long batavg;
unsigned long keyavg;
unsigned long heatavg;
unsigned int  modeavg;
/////////////////////////////////
unsigned int indummy;
unsigned int outdummy;
unsigned int ctdummy;
unsigned int keys;
unsigned int ntcvalue;
unsigned int batts;
unsigned int batrecharge;
//////////////////////////////////
unsigned int total_loaddisp;
unsigned int loaddisp;
unsigned int acoutdisp;
unsigned int mainsdisp;
unsigned int battdisp;
unsigned int battvolts;
unsigned int batrestart;
unsigned int loadpercent;
unsigned int champs;
unsigned int chdisp;
unsigned int mainsvolt;
unsigned int acout;
unsigned int keyvalue;
unsigned int key;
unsigned int heat;
unsigned int post;
unsigned int err;
unsigned int cherr;
unsigned int prect;
unsigned int initcount;
int yaxis;
///////////////////////////////////
signed int   upspeak;
signed int   acpeak;
signed int   ctpeak;
signed int   batclb;
signed int   mainsclb;
unsigned int chrclb;
unsigned int loadclb;
unsigned int pdctemp;
////////////////////////////////////

unsigned int deadshort;
unsigned int controlvolt;
unsigned int setvout;
unsigned int setchramp;
unsigned int setoverload;
unsigned int setupshi;
unsigned int setupslo;
unsigned int setinvhi;
unsigned int setinvlo;
unsigned int setbatful;
unsigned int setbatwrn;
unsigned int setbatlo;
unsigned int setbatres;
unsigned int defaults;
unsigned int setmaxwatts;

/////////////////////////////////////

unsigned int x,y,u;
unsigned long Ax,bx,Wt;
unsigned int aclo;
unsigned int achi;
unsigned int zinc;

/////////////////////////////////////
void InitADC1();
extern void Eeprom_WriteWord(unsigned short  pushAddressOffset, unsigned short value);
extern unsigned short Eeprom_ReadWord(unsigned short  pushAddressOffset);
void delay_ms(unsigned int gs);
void delay_us(unsigned int gs);

///////////////////////////////////////////////
const char str0[17]= "SYSTEM SETTINGS" ;
const char str20[17]=" BATTERY :    V" ;

//const char str24[17]="SWITCH IS ON ";
const char str25[17]="MAINS INPUT:   V";
const char str26[17]=" OUTPUT :   V   ";
const char str27[17]=" LOAD :    %    ";
//////////////////////////////////////////
const char str29[17]="SORRY BATT. LOW" ;
const char str30[17]="WAS OVERLOADED " ;
const char str31[17]="SHORT CCT FAULT" ;
const char str32[17]="  LOW BATTERY"   ;
const char str33[17]=" OVER LOADING"   ;
const char str34[17]="  NO OUTPUT "    ;
const char str35[17]="TRIP:SYNC FAULT ";
const char str36[17]="CHRGING.CUR:    ";
const char str38[17]="MANY CIRCUITS ";

//const char str40[17]="   FAULT";
const char str41[17]="  CHECK OUPUT   ";
const char str42[17]=" CHK FET/FORMER ";
const char str43[17]="  SYSTEM IS OFF ";
const char str44[17]="! REDUCE LOAD   ";
const char str45[17]="CONNECT CHARGER ";
const char str46[17]=" AUTO START ON  ";
const char str47[17]=" CHARGING MODE  ";
const char str48[17]="BATTERIES ERROR ";
const char str49[17]="REDUCE BATTERIES";
const char str50[17]="BATTERY IS FULL ";
const char str51[17]="CHGING COMPLETE ";
//const char str52[17]="LOAD:   WATT";
const char str53[17]="TEMPERATURE HIGH";
const char str54[17]="  CHECK FAN"     ;
const char str55[17]="HEAT SENSOR ERR" ;
const char str56[17]="   CHECK NTC    ";
const char str58[17]="  COMPLETE"      ;

#include "lcdsoft.h"
#include "functions.h"
void clear_flag();
void trip(int s);
int getvalue(int ch);
void chargeron();
void chroff();
void invon();
void invoff();
void stabilise();
void Modulate();
void find_key();
int findpeak(int ct);
void mains_stat_check();
void find_mainsvolt();
void find_batvolt();
void find_champs();
void find_upsvolt();
void find_load();
void  overload_check();
void lobat_check();
void chr_stabilize();
////////////////////////////////////
void feed_buzz(int a,int b,int c)
     {
     buzzdelay=0;
     buzzoftme=b;
     buzzontme=a;
     buzzcount=c;
     }
//////////////////////////////////////////////////////
void __attribute__((__interrupt__,no_auto_psv)) _FLTAInterrupt(void)
    {


_FLTAIF = 0;
    }
//////////////////////////////////////////////////////////
void __attribute__((__interrupt__, __auto_psv__)) _T1Interrupt(void)
   {
    _T1IF = 0;   // Clear interrupt flag
     if(PORTEbits.RE8==0)
     {
     fltdly++;
     if(fltdly>3000)
     {
      flags.olcut=1;
     __asm__ volatile ("reset");
     }
     }
    counter++;
    acpeak=getvalue(0);        //4.4 us
    indummy=acpeak;
    acpeak=indummy-508;
    if(acpeak<0)
    {
    acpeak=508-indummy;
    if(!flags.onflag)
    {
    rising=0;
    flag=0;
    }
    }
   
    mainsavg+=acpeak;

    if(flags.setup)
     {
OVDCON=   0X0000;
change=0;
buzzer=0;
     }

     if(!flags.setup)
    {
    if((indummy<600)&&(indummy>400)&&(flags.swon))
    {
    if(peakfail<150)
    {
    peakfail++;
    }
    if(peakfail==149)
    {
    if(flags.vcorrect)
    {
    invon(150);
    }
    }
    }
    else
    {
    peakfail=0;
    }

    if(flags.onflag)
    {
    Modulate();                         //4.4 us ///MODULATE SINE PWM OVER 50 HZ/////////////
    upspeak=getvalue(1);                //4.4 us
    outdummy=upspeak;              
    upspeak=outdummy-508;
    if(upspeak<0)
    upspeak=508-outdummy;
    outavg+=upspeak;
    if(upspeak<150)
     {
     fbdly++;
     if(fbdly>30000)                  // IF NO FEED BACK DETECTED///////////////
     {
     flags.fault=1;                  // TRIP: FB FAULT
     trip(5);
     }
     }
    else
    fbdly=0;
      }
    else
    {
    rising=1;
    flag=1;
    loadpercent=0;
    acout=0;
    }

    ctpeak=getvalue(2);

    if(flags.onflag)
    {
    if((ctpeak>750)||(ctpeak<250))
    {
    deadshortdly++;                  //OUTPUT DEAD SHORT TRIP//////////SHORT CKT FAULT
    if(deadshortdly>1500)
    {
    deadshort=1;
    OVDCON=   0X0000;
    trip(1);
    }
    }
    }

else
        {

        if(flags.chon==1)
        {
        if((ctpeak<508)||(ctpeak>512))
        ctfaildly=0;
        else
        {
        ctfaildly++;
        if(ctfaildly>10000)  // IF CT FEEDBACK FAIL, CHARGER OFF!
        {
        chroff();
        }
        }
        }
        }



    if(ctpeak>506)
    {
    pb=ctpeak-506;
    if(cth<pb)
    cth=pb;
    } 
    if(ctpeak<506)
    {
    qb=506-ctpeak;
    if(ctl<qb)
    ctl=qb;
    } 
    wattsavg+=cth+ctl;
    ctl=cth=0;
       heat=getvalue(3);    // GET NTC VALUE FOR FAN FUNCTION                      
     }       
   
                     
    batavg+=getvalue(5);   

lcdtmr1++;
    lcdtmr++;
if(counter==359)//////////////////////   20 milli sec checking sequence /////////////////
     {
     mainsvolt=__builtin_divud(mainsavg,288)+mainsclb;    //2.2 microseconds
  mainsavg=0;
   if(mainsvolt<90)
     {
     mainsvolt=0;
     mainsdisp=0;
     }
   else
     {
     if((indummy>180)&&(indummy<900))
     {
     if(mainsdisp==0)
     {
     mainsdisp=mainsvolt-80;
    
     }
     if(mainsdisp<mainsvolt-2)
     {
     mainsdisp++;
     }
     if(mainsdisp>mainsvolt+2)
     {
     mainsdisp--;
     }
     }
     }


     find_batvolt();  //get battery voltage


     keyavg+=getvalue(4);    // get switch status 
     keydly++;
     if(keydly==10)
     find_key();

     if(!flags.setup)
     {
     mains_stat_check(); // mains voltage status checking
     if(flags.onflag==1)
     {
     acout=__builtin_divud(outavg,285);
     outavg=0;  
     if(acoutdisp<acout-2)
     acoutdisp++;
     if(acoutdisp>acout+2)
     acoutdisp--;

     find_load();
     overload_check();
     lobat_check();
     }
     }
    
     wattsavg=0;

      if(buzzcount>0)
      {
      buzzdelay++;
      if(buzzdelay<=buzzontme)
      buzzer=1;
      else
      {
      buzzer=0;
      if(buzzdelay>=buzzoftme)
      {
      buzzdelay=0;
      buzzcount--;
      fltdly=0;
      }
      }
      }
      else
      {
      FLTACON=0x0001;
      IEC2bits.FLTAIE = 1;
      if(rounds>0)
      {
      if((!flags.onflag)&&(flags.swon)&&(rounds<4))
      {
      if(mainsvolt<110)
      {
      clear_flag();
      invon(0);
      }
      }
      }
      if(rounds==4)
      change=0;
      }
   
     if(!flags.setup)
    {
    if(flicker==0)
    {
    if((resumedelay==200)||(flags.mainsok==1))
    {
    LCD_DB6=1;
    if(flags.swon==1)
    {
    blinkdly++;
    if(blinkdly<30)
    LCD_DB7=1;
    else
    LCD_DB7=0;
    if(blinkdly>60)
    blinkdly=0;
    }
    else
    LCD_DB7=0;
    }
    else
   {
   LCD_DB6=0;
   if(flags.onflag==1)
   LCD_DB7=1;
   else
   LCD_DB7=0;
   }
   }


if((key==modekey)&&(flags.setup==0))
{
menudelay++;
if(menudelay>124)
flags.setup=1;
}
else
menudelay=0;
}

if(flags.setup==1)
{
setdly++;
if(setdly>3000)
__asm__ volatile ("reset");
}

  counter=0;

   }
   cherr=mainsvolt;
   }

//////////////////////////////////////
void init_PWM()
    {
    PTCON=    0XE003;
    PTMR =    0x0000;
    PTPER = PDC1=PDC2=  1230; //20 khz pwm
    SEVTCMP = 0x0000;
    PWMCON1 = 0x0033;
    PWMCON2 = 0x0000;
    DTCON1=   0X0059;      // 3.5 us dead band delay
    FLTACON = 0x0000;
    OVDCON=   0X0000;
    PTCONbits.PTEN = 1;
    IEC2bits.PWMIE = 0;        // disable PWM interrupts
   
    T1CON = 0XE000;        
    TMR1 = 0;           
    PR1 = 1355;         //20 khz timer
   _T1IF = 0;         
   _T1IE = 1;        //  enable timer interrupts
    }
/////////////////////////////////////////////////
void memread()
{
int x;
for(x=0;x<16;x++)
{
setting[x]=Eeprom_ReadWord(x);
}
}
//////////////////////////////////////////////////////////
void memwrite()
{

int x;
for(x=0;x<16;x++)
{
if(flags.setup==0)
Eeprom_WriteWord(x,factory[x]);
else
Eeprom_WriteWord(x,setting[x]);
}
}
//////////////////////////////////////////////
/*
void modedisp()
{
if(flags.msgrtn)
return;
if((key==upsmode)||(key==stbyups))
{
//printmes(str22,100,1);         //"\fU.P.S MODE ON";
if(key==upsmode)
{
aclo=setupslo;
achi=setupshi;
}
}
}
//if((key==invmode)||(key==stbyinv));      
                                        //"\fINVERTER MODE ON";
}*/
//////////////////////////////////////////////////////
/*void swdisp()
{
if(flags.msgrtn)
return;


if((key==stbyinv)||(key==stbyups))              //"\fSBY SWITCH OFF";
{

aclo=setinvlo;
achi=setinvhi;
}

}
*/


//                         MAIN ROUTINE                             
//*****************************************************************************/
int main()
{
TRISF=0X0000;
TRISE=0X010F;
TRISD=0X0000;
TRISC=0X0000;
TRISB=0XFFFF;
OVDCON=0X0000;
PWMCON1 = 0x0000;
PTCONbits.PTEN = 0;
buzzer=0;
lcd_init();
InitADC1();
init_PWM();
keyvalue=getvalue(4);
     if(((keyvalue>660)&&(keyvalue<680))||((keyvalue>560)&&(keyvalue<575)))
     {
     flags.swon=1;
     flags.firston=1;
     }

prect=getvalue(2);

flags.frstdisp=0;

defaults=Eeprom_ReadWord(14);
if(defaults!=50)
{
memwrite();
}

while(1)
{
while(PORTEbits.RE7==0)
{
 flags.msgrtn=0;
printmes(str31,100,1);     // SHORT CKT FAULT
printmes(str41,100,2);     // check output
if(flags.swon==0)
__asm__ volatile ("reset");
}

while(flags.nofeed==1)
{
 flags.msgrtn=0;
printmes(str34,100,1);     // NO FEED BACK
printmes(str42,100,2);     // CHK FET/FORMER
if(flags.swon==0)
__asm__ volatile ("reset");

while(flags.lbcut==1)
{
  flags.msgrtn=0;
printmes(str29,100,1);        //" TRIP:LOW-BATTERY ";
printmes(str43,100,2);        //SYSTEM IS OFF; 
if((flags.swon==0)||(resumedelay>175))
__asm__ volatile ("reset");
}


while((flags.olcut==1)||(flags.olwarn))
{
  flags.msgrtn=0;
printmes(str30,100,1);        //" TRIP:OVER-LOAD ";
printmes(str44,100,2);         // PLS REDUCE LOAD
if((flags.swon==0)||(resumedelay>175))
__asm__ volatile ("reset");
}

while(flags.olwarn)
{
  flags.msgrtn=0;
//printmes(str33,100,1);        //" WARN:OVER-LOAD ";
printmes(str44,100,2);        // PLS REDUCE LOAD
if(flags.swon==0)
__asm__ volatile ("reset");
}

while(flags.lbwarn==1)
{
  flags.msgrtn=0;
feed_buzz(2,50,25);
printmes(str32,100,1);        //"WARN:LOW-BATTERY";
printmes(str45,100,2);        //CONNECT CHARGER
printmes(str20,1,2);          //battery
if(flags.swon==0)
__asm__ volatile ("reset");

}
if(!flags.onflag==1)
{
//printmes(str59,100,1);       //"\fTITLE NAME
printmes(str38,100,1);       //"\fTITLE NAME
printmes(str43,100,2);     //   //"\system is off:";
printmes(str20,1,1);         // 0/0/"\fBATTERY V:";

}


if(mainsvolt>aclo+10)
{
    printmes(str25,2,2);     //   //"\fMAINS VOLT:";
}  

while(flags.chon==1)
{
if(champs==0)
goto outmes;
printmes(str36,3,1);          //"AC CHARGR:";
printmes(str20,1,2);         // 0/0/"\fBATTERY V:";
printmes(str25,2,2);        //"\fMAINS VOLT:"

if((change==0)&&(flags.swon==1))
{
printmes(str25,2,2);        //"\fMAINS VOLT:"
}
if((battvolts>=setbatful)&&(champs<=40))
{
 printmes(str50,100,1);      // battery is full
// printmes(str51,100,2);      //charging complete

}
}
outmes:


if((key==upsmode)||(key==invmode))
{
if(flags.onflag==1)
{
lcd_init();
printmes(str26,0,1);        //"\fINVERTER V:";
printmes(str27,4,2);        //"\fTOTAL LOAD:";;
printmes(str20,1,1);         // 0/0/"\fBATTERY V:"

//printmes(str25,2,2);     //   //"\fMAINS VOLT:";
//printmes(str52,4,2);        //"\fTOTAL WATT:";
}
}
/*else
{
//modedisp();
//swdisp();
printmes(str25,2,2);        //"\fMAINS VOLT:";
}
*/

if(heat<=fanheat-65)
{
feed_buzz(20,48,25);
printmes(str53,100,1);
printmes(str54,100,2);
if(flags.swon==1)
__asm__ volatile ("reset");
}

if(heat>=fanheat+320)
{
feed_buzz(2,48,25);
printmes(str55,100,1);
printmes(str56,100,2);
if(flags.swon==1)
__asm__ volatile ("reset");
}

if(battvolts>155)
{
printmes(str48,100,1);         ///over battery
printmes(str49,100,2);
}


if(menudelay>=125)
{
flags.setup=1;
menudelay=0;
printmes(str0,100,1);           //"\fCALIBRATION MENU";
while(key==modekey);
while(1)
{
if(key==modekey)
{
setchramp=setting[5]/10;
loadclb=setting[3];
functions();
memwrite();
flags.setup=0;
__asm__ volatile ("reset");
}
}

}

}


}

//main
///////////////////////////////////////////////////////////////////////////////////////
void InitADC1()
{
    ADPCFG = 0;       // Lowest 6 PORTB pins are analog inputs
    ADCON1 = 0;          // Manually clear SAMP to end sampling, start conversion
    ADCON2 = 0;          // Voltage reference from AVDD and AVSS
    ADCON3 = 0x0003;     // Manual Sample, ADCS=5 -> Tad = 3*Tcy
    ADCON1bits.ADON = 1; // Turn ADC ON
}

//////////////////////////////////////////
void delay_ms(unsigned int gs)
{
  while(gs--)
{
__delay32(55000);

}

}
///////////////////////////////////////////////////////////
void delay_us(unsigned int gs)
{
 while(gs--)
 __delay32(3000);
}
int getvalue(int ch)
{
ADCON1bits.DONE=0;
ADCHS = ch;        
ADCON1bits.SAMP = 1;     
__delay32(50);             
ADCON1bits.SAMP = 0;     
while (!ADCON1bits.DONE);
return ADCBUF0;

//////////////////////////////////
void clear_flag()
     {
     flags.olwarn=0;
     flags.lbwarn=0;
     flags.olcut=0;
     flags.lbcut=0;
     flags.nofeed=0;
     flags.zincfail=0;
     }
////////////////////////////////////
void trip(int s)
     {
     invoff();
     clear_flag();
     if(s==1)
     flags.olcut=1;
     if(s==2)
     flags.lbcut=1;
     if(s==4)
     flags.zincfail=1;
     if(s==5)
    flags.nofeed=1;
  if(s>2)
   {
    feed_buzz(8,48,25);
    flags.fault=1;
    rounds=0;
     }
     else
   {
     rounds++;
    feed_buzz(8,48,25);
    }
     flags.msgrtn=1;
     }
/////////////////////////////////////
void chargeron()
     {
     if(heat>=fanheat+300)
     return;
     if(heat<=fanheat-60)
     return;
     if(flags.onflag)
     return;
     chdisp=0;
     if(battvolts<90)
     return;
     if(battvolts>155)
     return;
     if(flags.chon==1)
     return;
     if(mainsvolt<150)
     return;
     if(chrdly<500)
     chrdly++;
     if(chrdly==499)
     {
     if(flags.gravity==1)
     {
     if(battvolts>batrestart)
     {
     chrdly=0;
     return;
     }
     gravitydly++;
     if(gravitydly<20)
     {
     chrdly=0;
     return;
     }
     gravitydly=0;
     }
     flags.gravity=0;
     PTCON=    0XE002;
     PTPER = 615;
     PWMCON1 = 0x0330;
     OVDCON=0X0A05;
     DTCON1=0X0000;
     PDC1=PDC2=0;
     flags.chon=1;
     chrdly=0;
   
     endtimer=0;
     }
     }
///////////////////////////////////////
void chroff()
    {
    OVDCON = 0x0000;
    PWMCON1 = 0x0033;
    DTCON1=0X0030;
    PTPER = 1230;
    PDC1=PDC2=0;
    flags.chon=0;
    champs=0;
    chrdly=0;
    }
/////////////////////////////////////////////////
void chr_stabilize()
     {
int kdly;

     if(flags.onflag)
     return;

     if(mainsvolt>cherr+5)
     {
     chroff();
     return;
     }

     if((battvolts>155)||(battvolts<90))
     {
     chroff();
     return;
     }

     if(mainsvolt<150)
     {
     chroff();
     return;
     }


//////////////////////////////////////////////////////////////
    if(battvolts>setbatful+1)
    {
    flags.chrcorrect=1;
     if(champs>35)
    {
    PDC1--;
    PDC2--;
    }
    }

 if(champs<30)
kdly=0;
else
kdly=4;




 if(battvolts<=setbatful)
     {
    if(flags.chrcorrect==0)
     {
     slowdly++;
     if(slowdly<kdly)
     return;
     slowdly=0;
     }

        if(champs<setchramp)
     {
     if(PDC1<900)
     {
     PDC1++;
     PDC2++;
     if(flags.chrcorrect==0)
     {
     if((champs<35)&&(champs>25))
     flags.frstdisp=1;
     }
     }
     }
    if(champs>setchramp)
       {
    flags.chrcorrect=1;
    if(PDC1>1)
    {
    PDC1--;
    PDC2--;
    }
    }

    }

    }
//void batt_full()
//{
  //  if((battvolts>=setbatful+1)&&(champs<=40))
    //  flags.batt_full=1; 
//}
////////////////////////////////////////////////
void find_champs()
     {
  
     x=__builtin_divud(wattsavg,359);             //1.03 microseconds
     Ax=__builtin_muluu(x,mainsdisp);
     bx=__builtin_divsd(Ax,battvolts);
     Ax=__builtin_muluu(bx,1000);
     bx=__builtin_divsd(Ax,450-chrclb);
     champs=bx;

   
if(flags.chrcorrect==1)
{
chshootdly++;
if(chshootdly==20)
{
 if(setchramp>chshoot)
setchramp--;
chshootdly=0;
}
}

     if(champs<10)

     {
     champs=0;
     chdisp=0;
     }
    
     if((battvolts<setbatful+2)&&(champs>35))
     {
     if(chdisp<champs-1)
     chdisp++;
     if(chdisp>champs+1)
     chdisp--;
     endtimer=0;
     }
     if((battvolts>=setbatful+2)&&(champs<35))
     {
     endtimer++;
     if(endtimer>100)
     {
     if(chdisp>12)
     chdisp--;
     else
     {
     flags.gravity=1;
     chroff();
     }
     endtimer=0;
     }
     }


    if(chdisp>chshoot)
    chdisp=chshoot;




     pb=qb=ctl=cth=0;
     }


//////////////////////////////////////
void invon(int k)
   {
   if(heat>=fanheat+300)
   return;
   if(heat<=fanheat-60)
   return;
   if(battvolts>155)
   return;    
   if(flags.olcut==1)
   return;
   if(flags.lbcut==1)
   return;
   if(flags.fault==1)
   return;
   if(flags.setup)
   return;
   if(flags.onflag)
   return;

   OVDCON = 0x0000;
   flags.onflag=1;
   flags.chon=0;  
   IEC2bits.FLTAIE = 0;
   FLTACON=0x0000;
   ctfaildly=0;
   fbdly=0;
   lbdly=0;
   oldelay=0;
   deadshortdly=0;
   chrdly=0;
   champs=0;
   ctfaildly=0;
   loadpercent=0;
   resumedelay=0;
   deadshort=0;
   flags.gravity=0;
   if(flag==0)
   p=90;
   else
   p=0;
   amplitude=k;
   buzzontme=51;
   buzzcount=1;
   buzzdelay=0;
   controlavg=u=0;
   change=1;
   PWMCON1 = 0x0033;
   DTCON1=0X0059;
   PTPER = 1230;
   OVDCON = 0x0F0f;
   }
////////////////////////////////////
  void invoff()
   {
  if(flags.onflag==0)
  return;
   flags.onflag=0;
   OVDCON = 0x0000;
   buzzer=0;
   flags.vcorrect=0;
   counter=0;
   }
//////////////////////////////////////////////////
void stabilise()
{
controlvolt=__builtin_divud(controlavg,90);
controlvolt+=43;
if(controlvolt<setvout)
{
err=setvout-controlvolt;
if(flags.vcorrect)
amplitude+=err;
else
amplitude++;
}
else
{
flags.vcorrect=1;
}

if(controlvolt>setvout)
{
err=controlvolt-setvout;
if(flags.vcorrect)
amplitude-=err;
}
controlavg=0;
}
///////////////////////////////////////

void Modulate()
{
if(flags.onflag==0)
return;

if(rising==1)
{
p++;
if((mainsvolt<50)&&(flags.mainsok==0))
{
if(p==45)
{
if(flag==1)
{
if(outdummy<200)
{
trip(4);// flags.zincfail=1;
}
}
}
}
u++;
controlavg+=upspeak;
}

if(p==91)
{
rising=0;
p=90;
u=0;
stabilise();



  if(resumedelay==200)
    {
    if((indummy<400))
    {
    IEC2bits.FLTAIE = 0;
    FLTACON=0x0000;
    flags.mainsok=1;
    change=0;
  __delay32(50000);
    flags.onflag=0;
    OVDCON = 0x0000;
    feed_buzz(10,50,3);
    peakfail=0;
    resumedelay=0;
    }
    }


    }
if(rising==0)
{
p--;
u++;
controlavg+=upspeak;
}
if(p<0)
{
rising=1;
p=0;
u=0;
stabilise();

if(flag==1)
{
flag=0;
}
else
{
flag=1;
}
}
duty_cycle_1=sine_table[p];
duty_cycle_1=((long)duty_cycle_1*amplitude)>>11;
if(duty_cycle_1>1230)
{
duty_cycle_1=1230;
}
if(duty_cycle_1<=0)
{
duty_cycle_1=0;
}
if(flag==1)
{
PDC1=1230+duty_cycle_1;
PDC2=1230-duty_cycle_1;
}
if(flag==0)
{
PDC1=1230-duty_cycle_1;
PDC2=1230+duty_cycle_1;
}
}
////////////////////////////////////////
void find_key()
     {
     keyvalue=__builtin_divsd(keyavg,10);
     keyavg=0;
     keydly=0;

     if(keyvalue>750)
     {
     key=7;//stbyups;

     if(keyvalue>850)
     {
     key=1;//stbymode;
     }
     if(flags.swon==1)
     {
     flags.swon=0;
    if((!flags.chon)&&(!flags.setup))
    __asm__ volatile ("reset");
     }
     flags.firston=1;
     peakfail=0;
     aclo=setinvlo;
     achi=setinvhi;
     return;
     }
 


     if((keyvalue>510)&&(keyvalue<530))
     {
     key=4;//modekey
     setdly=0;
     return;
     }


    if(flags.setup)
     {
     if((keyvalue>680)&&(keyvalue<705))
     {
     key=6;//downkey
     setdly=0;
     return;
     }

     if((keyvalue>590)&&(keyvalue<610))
     {
     key=5;//upkey
     setdly=0;
     return;
     }
     }

     if((keyvalue>660)&&(keyvalue<700))
     {
     if(flags.swon==0)
     {
     flags.swon=1;
     if(resumedelay==0)
     invon(0);
     }
     aclo=setinvlo;
     achi=setinvhi;
     key=3;//invmode
     return;
     }

     if((keyvalue>560)&&(keyvalue<575))
     {
     if(flags.swon==0)
     {
     flags.swon=1;
     if(resumedelay==0)
     invon(0);
     }
     aclo=setupslo;
     achi=setupshi;
     key=2;//upsmode;
     return;
     }
     }

//////////////////////////////////////////////////
void mains_stat_check()
    {
if(flags.fault==1)
   return;
    if((mainsvolt>aclo+10)&&(mainsvolt<achi-10))
    {
    if(resumedelay<200)
    resumedelay++;
    if(resumedelay==199)
    {
     clear_flag();
     rounds=0;
     setchramp=setting[5]+40;
    }

 if((key==3)||(key==2))
    {
    if(flags.firston==1)
    {
    flags.vcorrect=1;
    flags.firston=0;
    }
    }



      if(!flags.onflag)
      {
      if(resumedelay==200)
      {
      change=0;



      if(flags.chon==0)
      {
      slowdly=0;
      chargeron();
      flags.chrcorrect=0;
      }
      else
      {
      find_champs();
      chr_stabilize();
      }
    



      }
      }
      }
 
else
    {
 if((mainsvolt<aclo)||(mainsvolt>achi))
    {
    if(flags.chon)
    chroff();
    flags.mainsok=0;
    resumedelay=0;
    if(flags.firston==0)
    {
    if((key==3)||(key==2))
    {
    startdly++;
    if(startdly>10)
    {
    invon(150);
    startdly=0;
    }
    }
    else
   startdly=0;
    }
    }
    }
    }
/////////////////////////////////////////////////
void find_batvolt()
     {
     battvolts=__builtin_divsd(batavg,366);   ///1.307 microseconds
   __asm__ volatile ("mov   _battvolts, w3");
   __asm__ volatile ("mov     #0xffff, w1");
   __asm__ volatile ("mul.uu  w3,w1,w2");
   __asm__ volatile ("mov   w3,_battvolts");
     battvolts+=batclb+17;
     batavg=0;
     if(battdisp<battvolts)
     battdisp++;
     if(battdisp>battvolts)
     battdisp--;

 if(battvolts>=setbatful+1)
     battdisp=setbatful+1;

     }

////////////////////////////////////////////////

////////////////////////////////////////////////
void find_load()
     {
     x=__builtin_divud(wattsavg,loadclb);             //1.03 microseconds
     Ax=__builtin_muluu(x,125);
     bx=__builtin_divud(Ax,100);  //2.25 microseconds
     x=bx ;                    
     loadpercent=x;               // 1.2 microseconds
     if(loadpercent<10)
     {
     loadpercent=0;
     loaddisp=0;
     }
     if(loaddisp<loadpercent)
     loaddisp++;
     if(loaddisp>loadpercent)
     loaddisp--;
     }
/////////////////////////////////////////////////
void  overload_check()
     {
     if(flags.fault==1)
     return;
     if(loadpercent>=100)
     {
     oldelay++;

     if(loadpercent>110)
     tripdly=20;
     else if(loadpercent>105)
     tripdly=40;
     else
     tripdly=60;


if(tripdly==60)
{
if(oldelay>tripdly)
   {
 if(!flags.lbwarn)
     {
     if(!flags.olwarn)
     {
     flags.olwarn=1;
     if(!flags.lbwarn)
     flags.msgrtn=1;
     feed_buzz(10,50,7800);
     }
 }
}
}
     else
     {
     if(oldelay>tripdly)
     {
     if(!flags.olcut)
     {
     trip(1);
     }
     }
     }
     }
     else
     {
     if(flags.olwarn)
     {
     buzzer=0;
     buzzcount=0;
     flags.olwarn=0;
   flags.msgrtn=0;
     }
     oldelay=0;
     }



     }

/////////////////////////////////////////////////
void lobat_check()
     {
    if(flags.fault==1)
     return;
    if(flags.onflag==0)
     return;
   if(battvolts<setbatwrn)
     {
     lbdly++;
    if(lbdly>150)
     {
     if(!flags.lbwarn)
     {
     flags.olwarn=0;
     flags.lbwarn=1;
     flags.msgrtn=1;
     }
   if(battvolts<setbatlo)
     {
     trip(2);
     }
     }
     }
else
     lbdly=0;
     if(battvolts>setbatwrn)
     {
     if(flags.lbwarn)
     {
     flags.lbwarn=0;
     }
     }
     }

//////////////////////////////////////////////////////////////////////////////

9/25/2017

EGS002 SINE WAVE INVERTER CIRCUIT

This is a simple sine wave inverter circuit without programming.
Pure sine wave inverter circuit with no center tap design has become simple by using EGS002 Sinusoidal Inverter Driver Card. This post will give explain how to make a pure sine inverter at home without any programming. Let me start this tutorial by first introducing you to EGS002 DRIVER BOARD.



EGS002 DRIVER BOARD/CARD

Build your own MPPT read here
EGS002 is an already made 17pins plug and play driver board specific for single phase sinusoidal inverter. It uses ASIC EG8010 as control chip and IR2110S as driver chip. The driver board integrates functions of voltage, current and temperature protection, LED warning indication and fan control. Jumper configures 50/60Hz AC output, soft start mode and dead time.

The driver board has an LCD monitor port. A connected LCD monitor will display Output voltage, current, system temperature and Output frequency. The board will still work even when no display is connected.

The board can be used for two stage AC converter (DC-DC-AC) or DC-AC single stage low power frequency transformer systems. In this tutorial, we are going to limit ourselves to Low frequency transformer systems. That is no center tap transformer inverter.

Lets now take a look at our EGS002 card and its pins. You can download the pdf. datasheet of the card by clicking here




EGS002 DISPLAY CONNECTION




The board has several functions which the user can activate or select by using
jumper or soldering the points together. The image below provides the jumper setting if the default is not wanted.




SINE WAVE INVERTER MOSFET BRIDGE BOARD

Now that you have fair idea of the sine inverter card, plug the card into the circuit below. the below circuit will work without any modification when using 12V or 24V battery system. To use 48V or higher Dc voltage designs, you have to step down the higher DC voltage to 12V using a buck converter or an appropriate Step down IC and later use 7805 to get your 5V.

Please note that LM7805 and LM7812 will burn when the input is more than 30V DC.


SINE WAVE INVERTER CIRCUIT


to make your own transformer for this circuit click below

Read more on make inverter transformer


With this circuit, you only fix your card pins to the corresponding circuit pins. Output regulation is achieved by adjusting the 10K variable resistor. U6 is 10K NTC for temperature sensing and fan regulation. The 220V ac output of this power inverter is protected from power surge using Power NTC 10ohms.

The egs002 card can be used for all voltage systems.

But 24 and 48V systems will need a voltage conveter.
YOU CAN READ ON HOW TO MAKE SMPS VOLTAGE CONVERTER BY CLICKING THIS TEXT

The feedback can also be achieved by using a separate 12V transformer instead of one transformer with a separate winding.

 

     WATTAGE


The wattage of the inverter depends on the number of mosfets you will connect in parallel. Add more mosfets in parallel for high output power. Every 4 Mosfets will switch 250W in 12V system, 500W in 24V system and 1000w in 48V system. I hope you can make your calculation from it as to how many Fets to connect in parallel to get a certain wattage.


WHERE TO BUY THE SINE WAVE INVERTER DRIVER CARD

You can buy it on ebay or Ali express at 6 to 18 dollars with delivery time up to 40 working days.

You can also buy the BRIDGE BOARD from me by stating the wattage

Contact me on +233273315313 or opanin17@gmail.com


BATTERY PROTECTION AND LOW BATTERY ALARM


The inverter battery is very expensive and must be protected to prolong its life. when the battery is drained too low, the battery expected life will be shortened. connect the positive lines of my battery protection circuit to J1 and negative to the ground. Battery protection circuit can be seen by clicking this link



OVERLOAD PROTECTION FOR THE SINE WAVE INVERTER CARD


Overload protection protects the inverter from failing when the output is shorted or load exceeds maximum load. The sine wave driver board has an inbuilt current sense which shuts down the inverter when max current is exceeded. Pin 1 of the card is dedicated to this function. The current sense uses a shunt resistor. Shunt value is selected such that at maximum current, The voltage drop will be 0.5V. This prompts the system that there is an overload so that the system turns off until overload cause is removed.

The formulae for calculating the shunt resistance are:

1. R= 0.6 ( V/ I max) where V=0.5, I=Max DC switching current. and R = Shunt value.

read how to calculate max drive stage current from 


Inverter repairs 

http://manycircuits.blogspot.com/2017/05/inverter-circuit-with-charger.html

5/24/2017

How to repair inverters part 3

The image below was taken from a two weeks old china inverter which failed when 600W of load was plugged on it. The power rating of the inverter was 3000W with 6000W surge capacity.





Two stages switching inverter board

Facts about china switching inverters.

All these inverters are two stages high frequency-low frequency inverters.

All these inverters power their second stage using an auxiliary winding on one of the ferrite transformers in the first stage.

They all use mosfets connected in either H-Bridge or Half Bridge for their output.

Only few (about 10 percent) of these inverters uses micro controllers.

The most common PWM IC used is SG3525, SG3524 OR TL494.

Now that we know these about the inverters that we are going to repair, please follow the tutorial below carefully. Please read it until you get the whole concept since its the basis of all two stage inverters seen on our markets.




HOW TWO STAGES HIGH FREQUENCY INVERTER WORKS

Every high frequency inverter consists of:

DC to DC boost stage

low frequency AC stage.

Let's start by talking about the first stage of a high frequency inverter which is the DC to DC boost stage.

At this stage, the input DC battery is switched across a ferrite transformer at frequency between 25kHz. to 60khz. using a pulse width modulation driver IC such as 3524,3525, Tl491 etc. The switching topology used for this stage is mostly push pull using N channel mosfets.

The output high frequency square wave its rectified using fast switching diodes connected to form a bridge rectifier and a filter capacitor of 400V. The resulting output voltage ranges from 270V DC to 330V DC with best value of 310V which is 220V multiplied by the square root of 2 (RMS value).

Feedback is applied to the driver stage using either a separate winding from one of the switching ferrite transformers or using an optocoupler. The feedback ensures that the output voltage of this first stage is always stable.

low frequency AC stage.

This is the final stage of a high frequency inverter and this stage brings the difference between two inverters from different manufacturers. The kind of switching topology employed here will determine the quality, efficiency and durability of the inverter.

At this stage, the boost DC voltage obtained from the first stage is converted to 50Hz or 60Hz. AC which is either:

Pure sine wave
modified sine wave
square wave

using either H bridge topology or Half bridge topology.The switching mosfets used here are high voltage N mosfets or IGBT with minimum voltage of 400V.

The type of wave obtained at this stage which is the inverter output depends on the driving circuit and technique employed.

Note that at each section, there will be op amps or decision making ICs which monitors max current and high or low voltage.

I think i have given a fair idea about the subject. Your comments are welcome.


READ ABOUT MPPT

Featured Post

MAKE INVERTER TRANSFORMER

Inverter transformers are just like any other power transformers except that inverter transformers works in the reversed form of the standa...

Contributors