您的位置 首页 开关

51单片机驱动步进电机protues仿真

电路图:protues仿真文件和完整代码下载地址:http:www51heicombbsdpj-20399-1html下面是部分程序代码:includereg51hinclude

电路图:

protues仿真文件和完好代码下载地址:http://www.51hei.com/bbs/dpj-20399-1.html
下面是部分程序代码:
#include”reg51.h”
#include”intrins.h”
#include”math.h”
#include”absacc.h”
#define PORTA XBYTE[0x8500]
#define PORTB XBYTE[0x8502]
#define PORTC XBYTE[0x8504]
#define PORTC0 XBYTE[0x8506]
#definenop_nop_()
#define Right_RUN 1
#define Left_RUN 0
unsignedlongRunSpeed=76;
unsigned char RUNState=1;
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
sbit P17=P1^7;
bitflag=0;
unsigned char xx[]=”speed(n/min):”;
unsigned char SD[]=”76″;
char state[2][14]={“direction:cw”,”direction:ccw”};
unsigned char FLG,INMA=0;
unsigned char t,s=0x01;
unsigned int a;
main()
{
void OPJIAN();
unsigned char JIAN();
unsigned char JIANZHI();
void speed();
void SHOW_LCD();
void show_state();
void write1();
void writ2(unsigned char i);
void delay();
void time();
void busy();
unsigned char i;
i=0x90;
PORTC0=i;
i=0x01;
TMOD=i;
t=0x10;
a=0x0f;
TH0=0x10;
TL0=0x0f;
FLG=INMA;
SHOW_LCD();
show_state();
EA=1;
ET0=1;
TR0=1;
while(1)
{
i=JIAN();
if(i!=0)
{
time();
time();
}
i=JIAN();
if(i!=0)
{
INMA=JIANZHI();
OPJIAN();
time();
}
if(FLG!=INMA||flag==1)
{ FLG=INMA;
SHOW_LCD();
show_state();
flag=0;
}
}
}
void SHOW_LCD()/*lcd设置程序*/
{
P1=0x38;
write1();
delay();
P1=0x38;
write1();
delay();
P1=0x38;
write1();
delay();
P1=0x01;
write1();
delay();
P1=0x0f;
write1();
delay();
P1=0x06;
write1();
delay();
P1=0x0c;
write1();

}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/dianyuan/kaiguan/318178.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部