**Abstract**

In this chapter, a photovoltaic system integrated into the building is investigated. The studied structure includes also a battery energy storage system. The overall system is connected to a four-wire AC bus, with the possibility to supply single-phase and three-phase loads. Each equipment is interfaced with a dedicated power converter. This chapter examines the technical operation of all structure components and gives a detailed mathematical study of the DC/AC power converter control in case of two modes, namely, grid connected mode and standalone mode. The investigated control is based on resonant controller. The resonant controller parameters tuning, which is based on the generalized stability margin criterion, is detailed in this chapter. To prove the performance of the proposed control algorithm, several simulation tests developed under PSIM software were performed and then validated by experimental results.

**Keywords:** photovoltaic systems, battery energy storage system, building microgrid, DC/AC power converter control, standalone mode, grid connected mode
