How to detect the internal resistance of a battery pack