驱动器我选择的共阳接法,也就是ENA+,DIR+,PUL+接+5V;然后PUL-,DIR-,ENA-分别直接接的单片机P1^2,P1^1,P1^0程序是这样的:
#include "reg52.h"
unsigned char timer1;
sbit DIR=P1^0;
sbit ENA=P1^1;
sbit PWM=P1^2;
void system_Ini()
{
TMOD|=0X11;
TH1=0XFE;
TL1=0X33;
TR1=1;
IE=0X8A;
}
void Tlzd() interrupt 3
{
TH1=0XFE;
TL1=0X33;
timer1++;
}
void main()
{
system_Ini();
while(1)
{
if(timer1>10)
{
timer1=0;
}
if(timer1<3)
{
PWM=0;
}
else
{
PWM=1;
}
// PWM=~PWM;
}
}
为什么电机不能转呢?而且,当我关闭单片机电源时,驱动器指示灯正常,打开单片机电源驱动器就开始闪烁。求问各位大神问题出在哪了?
|