Microgrid battery balancing principles