Hi Sergey-What you're describing is called a grid tie inverter. Generally speaking, the frequency of the power grid is very stable, so the inverter can easily synchronize with it. As for voltage- the voltage of the grid usually doesn't change much either, but by making a subtle changes in output voltage the inverter can either feed power back to the grid, or at least reduce the amount of power drawn from the grid. It is very important that this type of inverter detects that grid power has failed an must either shut down gracefully or at least isolate itself from the grid to avoid feeding power out during a time when linemen my be working to restore service.Searching the Internet will turn up lots of information about these inverters, but you might want to start with Wikipedia.-Rick