This paper deals with the control of pulsewidth modulation inverters connected to the grid through resonant LCL filters. It proposes two alternative (piecewise affine) models that account for the switched behavior of the converter. Based on these improved models, an explicit model-predictive control scheme is derived in order to provide a fast response, making it very suitable for applications, such as active filtering, where a large bandwidth is required. A state observer and a grid voltage estimator are used in order to reduce the number of required sensors and to eliminate noise. The control scheme relies only on filtered current measurements and on the DC voltage.