2019-03-25 18:51发布
dingzy_2002 发表于 2017-7-21 10:07 2.PWM函数问题,主要是按键过程中,PWM数据传递出现异常了. 3.干扰问题:相关函数操作出现互相影响.
最多设置5个标签!
您好,我重新一段一段的调试,发现按键影响到了我的速度反馈值,我是用捕获模块来测速的,但就是不明白为什么会影响到它
//*****************测速程序***********************//
void calculate()
{
if(speednum1<799)
{
cp_flag=0;
if(z==1)
{
timelen1=w2-w1;
speednum1=60000/timelen1;
if(speednum1>800)
{
speednum1=800;
}
CCP1IE=1;
z=0;
}
}
else if(speednum1>=800)
{
cp_flag=1;
if(f==1) //每圈计算一次转速
{
if(!(time2>=time1&&TMR1IF))
{
if(time_flag1==1)
{
time_flag1=0;
timelen=time2-time1;
speednum1=60000*500/timelen;
}
if(time_flag2==1)
{
time_flag2=0;
timelen=60000+5536-time1+time2;
speednum1=60000*500/timelen;
}
}
TMR1IF=0;
f=0;
CCP1IE=1;
}
}
//return (speednum1);
}
一周热门 更多>