In this paper, a fuel cell and battery-based distributed generation system is demonstrated. A proton exchange membrane fuel cell is the primary power generator in this decentralized system, with a lead-acid battery providing backup power. A boost converter regulates the fuel cell's output power to ensure its optimal performance. A bidirectional buck-boost converter has been employed to integrate battery using slope compensated current control. 5-level cascaded H-Bridge inverter is used to convert available DC power into AC power while integrating DG systems with the grid and improving power quality. The artificial neural network has been trained and used to generate the estimated reference current for sinusoidal pulse width modulation techniques. The artificial neural network has been fine-tuned with the help of the scaled conjugate gradient with the performance value 0.094056. The THD of grid current has been reduced by 12.5% and 8.14% approximately for 30 Ω resistive, 30mH inductive load and 20 Ω resistive, 15mH inductive load respectively. The system has been simulated in Matlab/Simulink, and the findings have been validated. The results demonstrate the effectiveness of the methodology.