Power Management, Voltage Control and Grid Synchronization of Microgrids in Real Time