Battery Only being used sometimes in grid connected system
I've created a system that uses PV, wind, SonnenBatterie 16 kW Li-ion batteries, a converted, and is grid tied. I would to create a system where as much renewable energy or battery storage is being used to meet the load as possible, before energy is sold to the grid. To restate, I'd only rather the system sell energy to the grid when the storage is full and the load is being entirely met. And likewise, I only want the system to buy energy from the grid when the batteries are empty and renewables aren't producing enough to meet the load. The problem I am having is overnight sometimes when renewable generation is lower than the load, the model will buy energy from the grid rather than using the nearly full batteries to meet the load. Does anyone know how to make the batteries discharge fully before electricity is purchased from the grid? I am using the load following control strategy, because generation order is not an option with a grid connection system. Also, I don't know where to start writing a matlab script to get better control over the system. Any suggestions would be most appreciated.
Under demand rates, try selecting discharge battery as much as possible option and see if it helps.