第一次做电机驱动,出了很多状况,请大家帮忙啊!!! 我在P2.0~P2.7上接了发光二极管!在没接步进电机的时候,发光管正常点亮,熄灭!在接上步进电机后,发光管就停在一个状态了~~~(P2.2,P2.3,P2.6,P2.7亮,其他灭),当用电表去测OUTA,OUTB的电压的时候,二级管会闪,但停停闪闪的.... 电机也是停停,动动~~~~正转反转....郁闷 下面是程序: /*************************************************
步进电机驱动
*************************************************/
#include <REG54.H> #include <intrins.h> #define uchar unsigned char
#define uint unsigned int
code unsigned char seg7code[32]={0xcc,0xbd,0xae,0x9f,0x8f,0x1f,0x2e,0x3d, 0x4c,0x5b,0x6a,0x79,0x78,0x71,0x62,0x53, 0x44,0x35,0x26,0x17,0x87,0x97,0xa6,0xb5, 0xc4,0xd3,0xe2,0xf1,0xf8,0xf9,0xea,0xdb}; /*延时程序
由Delay参数确定延迟时间
*/
void mDelay(unsigned int Delay)
{ unsigned int i;
for(;Delay>0;Delay--)
{ for(i=0;i<124;i++)
{;}
}
}
void main()
{ unsigned char j; for(;;)
{ for(j=0;j<31;j++) { mDelay(200); P2=seg7code[j]; }
}
}
|