Control Of Microgrids With Renewable Energy Sources And Battery Energy Storage Systems