標(biāo)題:
單片機uln2003按鍵控制步進(jìn)電機正反轉(zhuǎn)Proteus仿真程序
[打印本頁]
作者:
Mfb971016
時間:
2020-12-9 18:20
標(biāo)題:
單片機uln2003按鍵控制步進(jìn)電機正反轉(zhuǎn)Proteus仿真程序
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png
(17.83 KB, 下載次數(shù): 55)
下載附件
2020-12-9 22:52 上傳
單片機源程序如下:
#include "reg51.h"
#define uchar unsigned char
#define uint unsigned int
#define out P2
sbit pos=P0^0;
sbit neg=P0^1;
void delayms(uint);
uchar code turn[]={0x07,0x06,0x0e,0x0c,0x0d,0x09,0x0b,0x03};
uchar code turn1[]={0x02,0x06,0x04,0x0c,0x08,0x09,0x01,0x03};
void main(void)
{
uchar i;
out=0x03;
while(1)
{
if(!pos)
{
//i = i < 8 ? i+1 : 0;
if(i<8)
i=i+1;
else
i=0;
out=turn[i];
delayms(1000);
}
else if(!neg)
{
i = i > 0 ? i-1 : 7;
out=turn[i];
delayms(1000);
}
}
}
void delayms(uint j)
{
uchar i;
for(;j>0;j--)
{
i=250;
while(--i);
i=249;
while(--i);
}
}
復(fù)制代碼
所有資料51hei提供下載:
JINBU.zip
(52.94 KB, 下載次數(shù): 53)
2020-12-9 18:19 上傳
點擊文件名下載附件
步進(jìn)電機仿真
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1