I have much better code for the PI loop for Id and Iq for the AC controller. There's even a secret extra step that I made up myself that automatically takes care of field weakening. It's not very secrety though. You can find the PI loop code here, starting on line 501:
https://github.com/MPaulHolmes/ACInd...onController.c
EDIT: Oops, you said field control, not field oriented control.