The growing trend of distributed generation, such as solar photovoltaic (PV) systems and small scale wind turbines have promoted the development of microgrids which are highly dependent on renewable energy. Due to the intermittent nature of renewable energy, these microgrids are generally equipped with energy storage, such as batteries. Batteries are generally operated using fixed control methods, often deviating from the optimal operation. This aspect has created an opportunity to gain improved outcomes for microgrid owners and operators. This research study describes a pathway for designing an optimisation framework which can be used to optimise the charge and discharge operation of battery storage within a microgrid containing a solar PV system. Optimisation is implemented in terms of gaining maximum cost benefit for microgrid owners. The advantages of using model predictive control optimisation compared to fixed control methods for this particular problem, solvers and verification procedures are highlighted. A case study is provided with results including analysis of battery operation, energy usage, and impact on overall tariff. The study describes each step of the control and optimisation platform development ensuring readers to be able to replicate the process utilised.