Control of a battery packs