新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)驅(qū)動(dòng)步進(jìn)電機(jī)protues仿真

51單片機(jī)驅(qū)動(dòng)步進(jìn)電機(jī)protues仿真

作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
電路圖:

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設(shè)置程序*/
{
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();

}


上一頁(yè) 1 2 下一頁(yè)

評(píng)論


技術(shù)專區(qū)

關(guān)閉