In this paper, we present a model-based frequency controller for microgrids with nonzero line resistances based on a port-Hamiltonian formulation of the microgrid model and real-time dynamic pricing. The controller is applicable for
conventional generation with synchronous machines as well as for power electronics interfaced sources and it is robust against power fluctuations from uncontrollable loads or volatile regenerative sources. The price-based formulation allows additional requirements such as active power sharing to be met. The capability and effectiveness of our procedure is demonstrated by means of an 18-node exemplary grid.