OPTIMIZING MICROGRID CONTROL WITH BATTERY MANAGEMENT SYSTEMS