Working principle of microgrid battery