A system for charging a capacitor used to power measurement-while-drilling equipment includes a power bus, which is electrically connected to the capacitor; a first pair of battery terminals; switching circuitry for electrically connecting the power bus to and disconnecting the power bus from the first pair of battery terminals; and a controller, for controlling the switching circuitry, which is configured to charge the capacitor by applying a first pulse width modulated control signal to control the switching circuitry. The first pulse width modulated control signal has a duty cycle selected such that the voltage of the first battery remains above a first minimum operating voltage while the capacitor is being charged.