Battery charging and discharging AC power supply principle