Motor Control Programming

 

Hardware: PIC32 microcontroller on NU32 board,  MAX9918 current-sense amplifier, DRV8835 H-bridge, Brushed DC motor with encoder, Decoder, nScope, 16x2 character LCD.

Programmed in C and Matlab.

Used 2 controllers: PI controller for current control and PID controller for motion control.

Used 3 timers:  Timer 2 for 20KHz PWM signal, Timer 3 for 5KHz ISR and Timer 4 for 200Hz ISR. Timer 2 has e prescaler of 1 and PR2 = 3999; Timer 3 has prescaler of 1, PR3 = 15999 and priority 6; and Timer 4 has prescaler of 8, PR3 = 49999 and priority 5.