Battery management system for micro_grid application with correction algorithms