標(biāo)題:
單片機(jī)基礎(chǔ)學(xué)習(xí)2.2—步進(jìn)電機(jī)的簡單使用
[打印本頁]
作者:
hhh365
時間:
2020-6-21 17:34
標(biāo)題:
單片機(jī)基礎(chǔ)學(xué)習(xí)2.2—步進(jìn)電機(jī)的簡單使用
學(xué)習(xí)了步進(jìn)電機(jī)的簡單編程和仿真,分享給大家
功能:實現(xiàn)步進(jìn)電機(jī)轉(zhuǎn)動(每次90°)
51hei.png
(89.63 KB, 下載次數(shù): 32)
下載附件
2020-6-21 22:17 上傳
#include <reg51.h>
#define uint unsigned int
unsigned char code f_rotation[4]={0xCF,0x9F,0x3F,0x6F }; //雙4拍正轉(zhuǎn)相序字
unsigned char code b_rotation[4]={0x6F,0x3F,0x9F,0xCF }; //雙4拍反轉(zhuǎn)相序字
void delay_ms(uint x) //以毫秒為單位的步間延時函數(shù)
{
uint i,j;
for (i=x; i>0; i--)
for (j=700; j>0;j--);
}
void main()
{ unsigned char i;
while(1)
{
for(i=0;i<4;i++)
{
P2=f_rotation[ i]; //查表并輸出相序字,可自行換成反轉(zhuǎn)表格[ i]
delay_ms(200); //改變延時可調(diào)整步進(jìn)電機(jī)的轉(zhuǎn)速
}
}
}
復(fù)制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1