Custom Field Oriented Control servo driver for the Kuka arm

After several weeks of board design and firmware development, the first revision of servo driver is up and running! There will be six of these in the final controller, most likely communicating over high speed RS422 with a computer. The servo driver is based on the FSBB30CH60C IGBT module and a dsPIC33EP512MC806. The communications interfaces are isolated from the uC to allow the drivers to operate on floating supply that is rectified directly from single phase 240V AC. The RJ-45 connector on the left is for the quadrature encoder on the motor. The data input and 5v supply is through the DB15 connector on the right. The DIP switch is for setting the motor type (brush, PMAC, BLDC, induction) and the bus address for the driver. On this prototype, I am using a standard desktop processor heatsink, which has been sufficient for driving a few amps. On the full robot, the drives will be heatsinked to an enclosure with external fins.
The display is not used yet, I included it in the hardware as an option in case there was a need to display some simple status info when the driver is running.
The firmware is implementing Field Oriented Control using fixed point math. To prevent the typical squealing noise PMAC motors make, I have the PWM frequency set to 20kHz, which is above the typical audible range. The challenge is to make the control loop run fast enough that it can be executed on every PWM period, which is only 50uS (1/20kHz). Operations like sin(), cos() and sqrt() become a challenge to implement at that speed so a few tricks were used to speed things up, more on this in a future post.
Next step, Replacing Kuka Resolvers with Quadrature Encoders