calculations for battery charger