For a microgrid consisting of photovoltaic generators and hybrid energy storage systems (HESS) with the battery and supercapacitor (SC) banks, this paper presents a real time energy coordinated control method for both grid-connected and stand alone operation modes. In the proposed method, the low-frequency and high-frequency power of fluctuant loads are decomposed by the algorithm of Fast Fourier Transfer (FFT), and are sent to battery and supercapacitor banks, respectively, thus extending the service life of battery. To achieve the control objectives and realize the smooth transfer of different operation modes for the microgrid, a unified control strategy is designed for the inverter of battery, which enables it to operate at both islanding and grid-connected mode without detecting the operation mode of microgrid in advance. Simulation results show that the power of loads absorbed by battery is smooth, and the supercapacitor can respond to rapid fluctuation of the power of loads. With the unified control strategy, the power flows to grid can be controlled when the microgrid operates at grid-connected mode while the voltage and frequency on AC bus can be stabilized by the inverter of battery at the islanding mode.