单片机解密单片机PID循迹小车代码
extern int flag;
int RK=6;
int KP=4;
int out;
//int out0=40;
int Td=7;
int Ti=1;
int T =1;
int Sk;
int Dk;
int Ek[]={0,0,0,0,0};
void PID (int flag)
{
Ek[4]=Ek[3];
Ek[3]=Ek[2];
Ek[2]=Ek[1];
Ek[1]=Ek[0];
Ek[0]=RK-flag;
//Sk = (T/Ti)*(Ek[0]+Ek[1]+Ek[2]+Ek[3]+Ek[4]);
Dk = (Td/T)*(Ek[0]-Ek[1]);
out = KP*Ek[0]+Sk+Dk;
turn(25+out,25-out);
}
void xunji (void)
{
if(count ==200)//采样周期
{
if(input==0x77)//0111 0 111
flag=6;
else if(input==0x7b)//0111 0 01
flag=7;
else if(input==0x7b)//0111 1 011
flag=8;
else if(input==0x75)//0111 1 001
flag=9;
else if(input==0x7d)//0111 1 101
flag=10;
else if(input==0x7c)//0111 1 100
flag=11;
else if(input==0x7e)//0111 1 110
flag=12;
else if(input==0x6d)//0110 0 111
flag=5;
else if(input==0x6f)//0110 1 111
flag=4;
else if(input==0x4f)//0100 1 111
flag=3;
else if(input==0x5f)//0101 1 111
flag=2;
else if(input==0x1f)//0001 1 111
flag=1;
else if(input==0x10)//0011 1 111
flag=0;
count=0;
}

芯片解密