Use of batteries in microgrid systems