The main aim of this paper is to design a local controller for DC/DC converter in a battery energy storage system (BESS) and a controller based on a virtual synchronous generator (VSG) for photovoltaic (PV) converter connected to AC grid. In the DC/DC converter design, the state feedback method is used so that the voltage and current control loops are combined, leading to higher flexibility and improved damping. This flexibility, which maintains the state of charge (SOC) of BESS, is supported by the design of virtual resistance and virtual capacitor statically and dynamically. In this design method, the BESS can be independently connected to each DC bus node and detect disturbances through local measurements. In addition, the improved Pre-Parallelism (PREP) method has been used to improve the transient performance caused by the disconnection and connection of additional loads, the existence of faults, and the inherent inertia difference in parallel operation between VSG and synchronous generator (SG). In this method, the problem of phase jump caused by transient disturbances is solved by considering a cosine function in VSG design. Also, to solve the problem of inertia difference between the units, a small signal model has been presented, in which, by considering the capacity ratio of the units on the AC side, the necessary inertia for VSG can be included in the design. The proposed method is simulated by considering different scenarios in MATLAB software, so the results demonstrate the superiority of the proposed controller compared to other existing methods.