正反转可控的步进电机Proteus仿真

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

仿真图:仿真程序:#includereg52.h#defineuintunsignedint#defineucharunsignedchar//------8拍-----ucharcodezz[]={0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09};//正转ucharcodefz[]={0x09,0x08,0x0c,0x04,0x06,0x02,0x03,0x01};//反转voiddelay(uintms){uintt;while(ms--)for(t=0;t120;t++);}voidmotor_zz(uintn){uinti,j;for(i=0;i5*n;i++){for(j=0;j8;j++){if(P3==0xfb)break;P1=zz[j];delay(20);}}}voidmotor_fz(uintn){uinti,j;for(i=0;i5*n;i++){for(j=0;j8;j++){if(P3==0xfb)break;P1=fz[j];delay(20);}}}voidmain(){uintN=3;while(1){P3=0xff;if(P3==0xfe){while(P3==0xfe);P0=0xfe;motor_zz(N);if(P3==0xfb)break;}elseif(P3==0xfd){while(P3==0xfd);P0=0xfd;motor_fz(N);if(P3==0xfb)break;}else{P0=0xfb;P1=0x03;}}}

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功