Single phase grid connected conroller not working

I cannot get the closed loop control to work in grid connected mode for single phase inverter. Same controller works in the matlab. The controller is as follows


Following is the calculated a,B and D, Q values of the Voltage


The current is all messed up as the control loop is not working. But the voltage conversion is working and so current must be as well. The current conversion is good in off grid mode so it should be working in grid connected mode as well. But i can not get the control loop to work in grid connected mode.
It seems to me that the response of the Controller is somehow damped or not fast enough. Can someone help me with this. Does anyone have A controller that works in grid connected mode. The controller should be for single phase and AB–aB–dq–aB type.