Fig. 5 shows the PWM interrupt routine. The sensing current is firstly calculated and fed to the current controller. Since the PWM frequency is 20 kHz, the current controller is updated for every 50 us. After the calculation of current controller, the speed calculation is then performed by
speed controller. The speed is constrained by the limiter for the operating speed range.