光电编码器软件四倍频和辨向程序
时间:10-02
整理:3721RD
点击:
光电编码器软件四倍频和辨向程//A接P1.0,B接P1.1
if((P1|0xfc)==0xfc)
{ if(P1_temp==0xfd) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xfe) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xfd)
{ if(P1_temp==0xff) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xfc) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xff)
{ if(P1_temp==0xfe) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xfd) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xfe)
{ if(P1_temp==0xfc) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xff) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xfc)
{ if(P1_temp==0xfd) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xfe) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xfd)
{ if(P1_temp==0xff) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xfc) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xff)
{ if(P1_temp==0xfe) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xfd) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
if((P1|0xfc)==0xfe)
{ if(P1_temp==0xfc) {a-=0.0100*jzcs;sign=0;plus++;}
if(P1_temp==0xff) {a+=0.0100*jzcs;sign=1;plus++;}
P1_temp=P1;
}
谢谢分享,学习