ARDUINO AS GRID TIE INVERTER

I PLANED TO MAKE AN SOLAR GRID TIE INVERTER
BUT THE PROBLEM IS THAT I DONT KNOW HOW TO SYNC IN PHASE THE SINE WAVE TO THE GRID.
THIS CODE PRODUCES SINE WAVE.
ANYONE CAN HELP ME?

#include <avr/io.h>
#include <avr/interrupt.h>

#define SinDivisions (200)// Sub divisions of sisusoidal wave.

static int microMHz = 16; // Micro clock frequency
static int freq = 60;     // Sinusoidal frequency
static long int period;   // Period of PWM in clock cycles.
static unsigned int lookUp[SinDivisions];
static char theTCCR1A = 0b10000010; //varible for TCCR1A

void setup(){
  double temp; //Double varible for <math.h> functions.
  
  period = microMHz*1e6/freq/SinDivisions;// Period of PWM in clock cycles
  
  for(int i = 0; i < SinDivisions/2; i++){ // Generating the look up table.
    temp = sin(i*2*M_PI/SinDivisions)*period;
    lookUp[i] = (int)(temp+2);       // Round to integer.    
  }
  // Register initilisation, see datasheet for more detail.
  TCCR1A = theTCCR1A; // 0b10000010;
        /*10 clear on match, set at BOTTOM for compA.
          00 compB disconected initially, toggled later to clear on match, set at BOTTOM.
          00
          10 WGM1 1:0 for waveform 15.
        */
  TCCR1B = 0b01112001;
        /*000
          11 WGM1 3:2 for waveform 15.
          001 no prescale on the counter.
        */
  TIMSK1 = 0b10101001;
        /*0000000
          1 TOV1 Flag interrupt enable.
        */  
  ICR1   = period;   /* Period for 16MHz crystal, for a switching frequency of 100KHz for 200 subdivisions per 50Hz sin wave cycle. */
  sei();             // Enable global interrupts.
  // Set outputs pins.
  DDRB = 0b00010110; // Set PB1 and PB2 as outputs.
  pinMode(13, OUTPUT);
}

void loop(){;/*Do nothing . . . forever*/}

ISR(TIMER1_OVF_vect){
    static int num;
    static int delay1;
    static char trig;
    
    if(delay1 == 1){/*delay by one period because the high time loaded into OCR1A:B values are buffered but can be disconnected immediately by TCCR1A. */
      theTCCR1A ^= 0b10100000;// Toggle connect and disconnect of compare output A and B.
      delay1 = 0;             // Reset delay1
    } else if(num >= SinDivisions/2){
      num = 0;                // Reset num
      delay1++;
      digitalWrite(13,trig);
    }
    // change duty-cycle every period.
    OCR1A = OCR1B = lookUp[num];
    num++;
}

I think you should ask your electricity utility. I suspect they will say NO WAY

Connecting a solar system to the grid risks electrocuting the utility staff.

IMHO if you have to ask on this Forum then you do not have the required level of competence to build a grid-tie system

...R

Not to worry. The OP is likely to electrocute him or herself before this project could get as far as endangering power line workers.

And I presume it is seriously illegal to connect generating equipment to the grid without the prior approval of the utility.

...R

This is a complete no-go area for amateur construction, the risks are to life and limb.

However as a thought exercise its OK - for instance how do you ensure a electricity supply worker can't be
electrocuted by the inverter when they are fixing the circuit on your road? How does one detect this situation?

Commercial units have to pass rigorous safety analysis and testing as back-feeding onto a tripped distribution
line is potentially a killer to the employee fixing the fault, and brown-outs can start fires in motors.

i have already a way to detect the main grid absence.,
the only problem i only have is syncing to the grid in phase

Whats your method of detecting main grid absence?
I suspect that you really arnt thinking this through.
How are you implementing anti islanding?
Wheres the rest of your circuit?

You don't state which country you intend blacking out but if you want to see what's required in the UK you might care to spend a couple of minutes browsing this

sorry to bother you guys., since theres a problem implementing anti islanding..

i had seen tim nolans grid tie inver., but i want you to help me to modify the circuit to high wattage instead making my own.,,

i want you to modify the circuit to high wattage instead making my own.

Surely you are joking.

HI,
What is the advantage of your own grid-tie inverter if the power utility is not going to pay you for power put into the grid?
As previously indicated, there are regulations and build standards and approvals needed to connect anything to the grid.

Can you tell us your electronics, programming, arduino, hardware experience?

Tom... :slight_smile:

hi tom
i am not planning to build it my own since there many things to consider., and my knowledge is not that good either

i have personally sent you a message.,
can you take a look.?

kikiloaw:
hi tom
i am not planning to build it my own since there many things to consider., and my knowledge is not that good either

i have personally sent you a message.,
can you take a look.?

curious what the message said!

Paul

i am not planning to build it my own since there many things to consider., and my knowledge is not that good either

Why are you bothering us, then?