Calculation of lithium battery charging voltage and current