步进电机正反转控制C语言程序,只为初学者.docxVIP

  • 17
  • 0
  • 约小于1千字
  • 约 5页
  • 2019-10-30 发布于江苏
  • 举报

步进电机正反转控制C语言程序,只为初学者.docx

-- -- 只为初学者的步进电机正反控制程序 #includereg51.h #define uchar unsigned char #define uint unsigned int #define MotorData P2 // 步进电机控制接口定义 sbit zheng=P3^0; sbit fan=P3^1; sbit stop=P3^2; uchar phasecw[8] ={0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09};// 正转 uchar phaseccw[8]={0x09,0x08,0x0c,0x04,0x06,0x02,0x03,0x01};// 反转 //ms 延时函数 void delay(uint t) { uint k; while(t--) { for(k=0; k125; k++); } } void Delay_xms(uint x) { uint i,j; for(i=0;ix;i++) for(j=0;j112;j++); } //顺时针转动 void Motor_work(uint t) { uchar i,j; switch(t) { case 0: while(1) {if(stop==0) break; for(i=0;i8;i++) {MotorData=phasecw[i]; delay(50);

文档评论(0)

1亿VIP精品文档

相关文档