注册会员
- 积分
- 81
- 威望
- 45
- 贡献
- 22
- 兑换币
- 19
- 注册时间
- 2017-2-21
- 在线时间
- 7 小时
- 毕业学校
- 青岛理工大学
|
void main()
{
//unsigned short int ADC_Sample[5][5]={0,0,0,0,0};//ADC采样值,5个传感器各采5次
uint16 a,b,c,d=0,e=0,f=0,g,h,i,l;
float Kp,Kd;
float ek,ek1;
PID_Init();
LQLCD_Init();
adc_init(ADC1_SE15); //ADC初始化
adc_init(ADC1_SE11);
ftm_pwm_init(FTM0, FTM_CH3,10*1000,0);
ftm_pwm_init(FTM1, FTM_CH0,100,1750);
//LCD_CLS();
while(1)
{
for(g=0;g<10;g++)
{
a = adc_once (ADC1_SE15, ADC_8bit);
//b = adc_once (ADC1_SE14, ADC_8bit);
b = adc_once (ADC1_SE13, ADC_8bit);
i = adc_once (ADC1_SE12, ADC_8bit);
c = adc_once (ADC1_SE11, ADC_8bit);
//printf("\nADC采样结果为:%d %d %d %d %d",a,b,c,d,e);
//printf(" 相应电压值为%dmV %dmV %dmV %dmV %dmV",(3300*a)/((1<<8)-1),(3300*b)/((1<<8)-1),(3300*c)/((1<<8)-1),(3300*d)/((1<<8)-1),(3300*e)/((1<<8)-1));
d=a+d;
e=b+e;
f=c+f;
l=i+l;
}
d=d/10;
e=e/10;
f=f/10;
l=l/10;
LED_PrintShort(42,3,d);
LED_PrintShort(42,1,e);
LED_PrintShort(42,5,f);
LED_PrintShort(42,7,l);
//DELAY_MS(500);
ek=(d-f)/(d+f);
ek1=ek;
h=Kp*ek+Kd(ek-ek1)+1550;
//***********************
if (h>1950) h=1950;
if (h<1150) h=1150;
ftm_pwm_duty(FTM0,FTM_CH3,140);
if(a>100&&c>100)
{Kp=0.12;
Kd=1.6;
ftm_pwm_duty(FTM1,FTM_CH0,h);
}
if (h>1200|h<1800)
{ Kp=0.18;
Kd=2.2;
ftm_pwm_duty(FTM1,FTM_CH0,h);
//*******丢线
if (a<60)
{ftm_pwm_duty(FTM1,FTM_CH0,2000);
ftm_pwm_duty(FTM0,FTM_CH3,100);
}
if(c<60)
{ftm_pwm_duty(FTM1,FTM_CH0,1100);
ftm_pwm_duty(FTM0,FTM_CH3,100);
}
}
if (h>=1800) ftm_pwm_duty(FTM1,FTM_CH0,2000);
if (h<=1200) ftm_pwm_duty(FTM1,FTM_CH0,1100);
// h=(d-f)*900/80+1550;
//g=pow(b/1600,1.0/3);
// if (h>1200|h<1800)
// { ftm_pwm_duty(FTM1,FTM_CH0,h);
// if (a<60) ftm_pwm_duty(FTM1,FTM_CH0,2000);
// if(c<60) ftm_pwm_duty(FTM1,FTM_CH0,1100);
// }
// if (h>=1800) ftm_pwm_duty(FTM1,FTM_CH0,2000);
//
// if (h<=1200) ftm_pwm_duty(FTM1,FTM_CH0,1100);
}
}
他说Error[Pe109]: expression preceding parentheses of apparent call must have (pointer-to-) function type C:\Users\lenovo\Desktop\ADC - 副本\App\main.c 74
前括号表达式的调用必须有(指针)函数类型
请问这是为什么怎么改
求大神指教
|
|