/***************************************************************************************** 函数名称 : stepping_move 描述 : 步进电机驱动 入口参数 : 0顺时针 1逆时针 度数 返回值 : 无 *****************************************************************************************/ void stepping_move(unsigned char direction,unsigned int degree) { du = degree*1.42; bujindianji_on=1; if(direction==0)bujindianji_fx=0; if(direction==1)bujindianji_fx=1; } void __attribute((interrupt(0x0C))) TB0(void) //8ms定时中断一次 { _tb0f=0; //清除中断标志位 if(bujindianji_on==1&&bujindianji_fx==1&&zhuanquan_ed<=du) { iii++; if(iii==1) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=1; Motor_B=0; Motor_C=0; Motor_D=0; } if(iii==2) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=1; Motor_B=1; Motor_C=0; Motor_D=0; } if(iii==3) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=1; Motor_C=0; Motor_D=0; } if(iii==4) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=1; Motor_C=1; Motor_D=0; } if(iii==5) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=0; Motor_C=1; Motor_D=0; } if(iii==6) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=0; Motor_C=1; Motor_D=1; } if(iii==7) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=0; Motor_C=0; Motor_D=1; } if(iii==8) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=1; Motor_B=0; Motor_C=0; Motor_D=1; } if(iii==8) {iii=0;zhuanquan_ed++;} if(zhuanquan_ed==( unsigned int )du){ bujindianji_on=0; zhuanquan_ed=0; Motor_A=0; Motor_B=0; Motor_C=0; Motor_D=0; iii=0; } } if(bujindianji_on==1&&bujindianji_fx==0&&zhuanquan_ed<=du) { iii++; if(iii==1) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=1; Motor_B=0; Motor_C=0; Motor_D=1; } if(iii==2) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=0; Motor_C=0; Motor_D=1; } if(iii==3) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=0; Motor_C=1; Motor_D=1; } if(iii==4) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=0; Motor_C=1; Motor_D=0; } if(iii==5) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=1; Motor_C=1; Motor_D=0; } if(iii==6) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=0; Motor_B=1; Motor_C=0; Motor_D=0; } if(iii==7) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=1; Motor_B=1; Motor_C=0; Motor_D=0; } if(iii==7) { Motor_A=0;Motor_B=0;Motor_C=0;Motor_D=0; Motor_A=1; Motor_B=0; Motor_C=0; Motor_D=0; } if(iii==8) {iii=0;zhuanquan_ed++;} if(zhuanquan_ed==( unsigned int )du){ bujindianji_on=0; zhuanquan_ed=0; Motor_A=0; Motor_B=0; Motor_C=0; Motor_D=0; iii=0; } } }