单相交流电机PID控制问题
现在在做一个50HZ,1500转的单相交流电机的调速器(闭环,测速通过测速发电机),遇到一些问题:1、空载时,有轻微的震荡。
2、假负载后,电机时快,时慢,稳定不下来;
采用的是模糊算法,仅有积分和微分相。
这里面是模糊算法程序,请高人指点
void ChangePwm(uint n)
{
uint i;
static uchar accint=0,t=0;
if(++accint>10) //100ms
{
accint =0;
if((setSpeed+2)>conSpeed)
{
i= conSpeed + myReg;
if(i>setSpeed)i=setSpeed;
conSpeed = i;
}
else if(setSpeed<(conSpeed-2))
{
i= conSpeed - myReg;
if((i< setSpeed)||(i>0x8000))i=setSpeed; //ÆúíûËù¶èμÄÖμ
conSpeed = i;
}
}
//é趨Ëù¶è óë êμ¼êËù¶è±è½Ï
pwm_cal = conSpeed/5;
diff = conSpeed-n;
if(diff>200)
{
pwm_cal = pwm_cal + 80;
}
else if(diff<(-200))
{
pwm_cal = pwm_cal - 80;
}
else
{
if(conSpeed> n) //PIDμ÷½ú ′Ë′|ê1óÃμÄêÇÄ£ÄaPID 2Îêyí¨1yê±¼äμ÷½ú
{
if(diff> 100){pwm_cal = pwm_cal + diff/2;}
else if(diff> 50){pwm_cal = pwm_cal + diff/4;}
elseif(diff >20) { pwm_cal =pwm_cal + 4; }
else if(diff> 4)
pwm_cal = pwm_cal +1;
}
else if(conSpeed<n)
{
if(diff< -100){pwm_cal = pwm_cal+diff/2 ;}
else if(diff< -50){pwm_cal = pwm_cal +diff/4;}
else if(diff< -20) { pwm_cal =pwm_cal - 4; }
else if(diff< -4)
pwm_cal = pwm_cal -1;
}
//±¾′Îêμ¼êËù¶è óë éÏ′Îêμ¼êËù¶è±è½Ï diff
if(t>2)
{
t = 0;
if((diff<50)&&(diff>-50))
pwm_cal = pwm_cal;
else if((diff<100)&&(diff>-100))
pwm_cal = pwm_cal + (diff-last_diff)*3;
else
pwm_cal = pwm_cal + (diff-last_diff)*8;
}
else
t++;
}
last_diff =diff;
if(pwm_cal< 0)pwm_cal= 0;
if(pwm_cal> 5000) pwm_cal= 5000;
out_pwm = (pwm_cal+last_pwm+last_pwm+last_pwm)/4; //′æÖü֮ǰμļ¸′ÎPWMÕ¼¿Õ±èÖμ
last_pwm = last_pwm;
last_pwm = last_pwm;
last_pwm= pwm_cal;
}
页:
[1]