《步进电机驱动电路图与程序.doc》由会员分享,可在线阅读,更多相关《步进电机驱动电路图与程序.doc(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流步进电机驱动电路图与程序.精品文档.#includeunsigned char codetable=0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9,0x00,0xf1,0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0x00;unsigned char temp,temp_old;unsigned char key;unsigned char i,j,k,m,s;#define uchar unsigned charuchar code tab3=0x02,0x07,0x03,0x08,0
2、x08,0x01,0x08,0x02,0x01;void d10ms()int p,q;for(p=2;p0;p-)for(q=40;q0;q-);void delay(int i)int a;a=i-1;for(m=i;m0;m-)P0=taba0;P3=0x01;d10ms();P3=0x00;P0=taba1;P3=0x02;d10ms();P3=0x00;P0=taba2;P3=0x04;d10ms();P3=0x04;d10ms();P3=0x00;void saomiao()P1=0xff;if(P1_4=0)temp=P1;temp=temp&0x0f;if(temp!=0x0f
3、)for(i=3;i0;i-)for(j=80;i0;i-);temp=P1;temp=temp&0x0f;if(temp!=0x0f)temp=P1;temp=temp&0x0f;switch(temp)case 0x0e:key=1;break;case 0x0d:key=2;break;case 0x0b:key=3;break;case 0x07:key=4;break;temp=P1;temp=temp&0x0f;while(temp!=0x0f)temp=P1;temp=temp&0x0f;P1=0xff;if(P1_5=0)temp=P1;temp=temp&0x0f;if(te
4、mp!=0x0f)for(i=3;i0;i-)for(j=80;j0;j-);temp=P1;temp=temp&0x0f;switch(temp)case 0x0e:key=8;break;case 0x0d:key=5;break;case 0x0b:key=6;break;case 0x07:key=7;break;temp=P1;temp=temp&0x0f;while(temp!=0x0f)temp=P1;temp=temp&0x0f;void main(void)while(1)saomiao();if(key=1)P1=0;P2=0;saomiao();if(key=2)temp
5、_old=key;for(s=0;s8;s+)P2=tables;delay(3);saomiao();if(key=3)temp_old=key;for(s=0;s8;s+)P2=tables;delay(2);saomiao();if(key=4)temp_old=key;for(s=0;s8;s+)P2=tables;delay(1);saomiao();if(key=5)temp_old=key;for(s=9;s17;s+)P2=tables;delay(3);saomiao();if(key=6)temp_old=key;for(s=9;s17;s+)P2=tables;delay(2);saomiao();if(key=7)temp_old=key;for(s=9;s17;s+)P2=tables;delay(1);saomiao();if(key=8)P1=0;P2=0;saomiao();