#ifndef __MoveStepMotor_H__
#define __MoveStepMotor_H__
//#define StepmotorPort P3OUT //P3口为步进电机的接口
#define uchar unsigned char
#define uint unsigned int
//sbit FlagNoEdge = P3^4;//步进电机运动标志,0为到边缘,1为可运
uchar stepkey_x[8]={0x0E,0x0A,0x0B,0x09,0x0D,0x05,0x07,0x06};//motro1正传(A-AB-B-BC-C-CD-D-DA-A)
uchar stepkey_y[8]={0xE0,0XA0,0XB0,0X90,0Xd0,0X50,0X70,0X60};//motro2
uchar stepkeynum_x ;
uchar stepkeynum_y ;
//P1~3 x
//P4~7 Y
void motordelay(uchar a)//5ms
{uint i,j;
for(j=0;j<a;j++)
for(i=0;i<3571;i++);
}
//void MoveStepmotor(uchar FlagLR_x,uchar num_x,uchar FlagUD_y,uchar num_y)
//x电机转向,x转数,y电机转向,y转数//哪个电机,转向,转数
void MoveStepmotor(uchar num_x ,uchar num_y)
{ //sent_byte(0x11);
//sent_byte(stepkey_x[num_x]);
//sent_byte(stepkey_x[num_y]);
P2OUT=stepkey_x[num_x]+stepkey_y[num_y];
motordelay(2);
}
/* if(FlagLR_y==0)//X_motro1正转
{
if(stepkeynum_y == 0 )
stepkeynum_x = 7;
else
stepkeynum_x--;
}
else //X_motor反转
stepkeynum_x = (stepkeynum_x+1)%8;
*/
#endif
这个驱动器好高级啊,做过430驱动进步电机的飘过。。。。 |