Switched to control with the controller (Atmega8). PID is now customizable. My algorithm (from the Internet, creatively reworked):
----
static int PrevValue;
float cc;
Error = Target - mpc3201;
// Compensation surges
cc=0.18*adc_mega;
cc=(cc/2.5*cc)/255; //power/1tik
/////////
P_Term = Kp/cc * Error;
if (Integral > MaxIntegral) {Integral = MaxIntegral;}
else if (Integral < - MaxIntegral) {Integral = - MaxIntegral;}
else Integral += Error;
I_Term = f_Ki * Integral;
D_Term = Kd * (PrevValue - mpc3201);
PrevValue = mpc3201;
Out = (P_Term + I_Term + D_Term);
if(Out > 0xFF) { OCR2 = 0xFF; }
else if(Out < 0) { OCR2 = 0;}
else OCR2 = Out;
// SMA for komp.
Error=0;
sma_OCR2[9]=Out;
while (Error < 8){
sma_OCR2[Error]=sma_OCR2[Error+1];
Error++;
}
Error=0;
P_Term=0;
//sma
while (Error < 10){
P_Term+=sma_OCR2[Error];
Error++;
}
sma_OCR2_out=P_Term/10; // SMA,10.
}
----
At the moment, I pick up rates.
Maybe someone can help.
GlowFish, thank you.