標(biāo)題:
關(guān)于步進電機的工作原理 帶程序和仿真圖
[打印本頁]
作者:
永遠(yuǎn)的學(xué)者
時間:
2016-12-21 21:42
標(biāo)題:
關(guān)于步進電機的工作原理 帶程序和仿真圖
用四路I/O口的輸出實現(xiàn)環(huán)形脈沖的分配,控制步進電機按固定方向連續(xù)轉(zhuǎn)動。同時按鍵控制電機的正反轉(zhuǎn)和停止。
帶程序和仿真圖。
#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[]={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;
out=turn[i];
delayms(50);
}
else if(!neg)
{
i=i>0?i-1:7;
out=turn[i];
delayms(50);
}
}
}
void delayms(uint j)
{
uchar i;
for(;j>0;j--)
{
i=250;
while(--i);
i=249;
while(--i);
}
}
復(fù)制代碼
0.png
(78.79 KB, 下載次數(shù): 63)
下載附件
2017-1-2 02:30 上傳
資料下載:
步進電機.rar
(58.05 KB, 下載次數(shù): 20)
2016-12-21 21:41 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1