You are controlling the PWM power via PI loop. But are you controlling the acceleration from one value to the next? In a pump controller I wrote, I wanted to control the acceleration smoothly. Why not add code that slews the current limited by some acceleration value.
Code:
#define RAMP_SPEED 20 // how much to increase the OCR0A value from one step to the next.
...
// This function runs every ms to ramp the actual PWM value from one speed to the next smoothly
{
// Read the current PWM value
TC0_READ_16_BIT_OCR0AB(temp16); // safe inside an interrupt
if(requested_speed < temp16) // is the requested spped less than the current speed?
{
// Our requested speed is either higher or lower than what we need
temp16 -= RAMP_SPEED;
TC0_WRITE_16_BIT_OCR0AB( SERVO_CLIP(temp16) );
}
else if(requested_speed > temp16)
{
temp16 += RAMP_SPEED;
TC0_WRITE_16_BIT_OCR0AB( SERVO_CLIP(temp16) );
}
}
// ------------------------------------------------End Ramp