欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
步進(jìn)電機(jī)的反轉(zhuǎn)控制設(shè)計代碼
[打印本頁]
作者:
大飛啊啊
時間:
2018-12-11 15:14
標(biāo)題:
步進(jìn)電機(jī)的反轉(zhuǎn)控制設(shè)計代碼
#include <reg51.h> //51芯片管腳定義頭文件
#include <intrins.h>//內(nèi)部包含延時函數(shù) _nop_();
#define uchar unsigned char
#define uint unsignedint
uchar code FFW[8]={0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9};
uchar code REV[8]={0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1};
/**************************************************/
/* 延時t毫秒
/* 11.0592MHz時鐘,延時約1ms
/*************************************************/
void delay(uint t)
{
uint k;
while(t--)
{
for(k=0; k<125; k++)
{ }
}
}
/******************步進(jìn)電機(jī)正轉(zhuǎn)********************/
void motor_ffw(uint n)
{
uchari;
uint j;
for (j=0; j<12*n; j++) //轉(zhuǎn)1×n圈
{
for (i=0; i<8; i++) //一個周期轉(zhuǎn)30度
{
P1 = FFW[i]; //取數(shù)據(jù)
delay(15); //調(diào)節(jié)轉(zhuǎn)速
}
}
}
/****************步進(jìn)電機(jī)反轉(zhuǎn)************************/
void motor_rev(uint n)
{
uchari;
uint j;
for (j=0; j<12*n; j++) //轉(zhuǎn)1×n圈
{
for (i=0; i<8; i++) //一個周期轉(zhuǎn)30度
{
P1 = REV[i]; //取數(shù)據(jù)
delay(15); //調(diào)節(jié)轉(zhuǎn)速
}
}
}
/*********************主程序**************************/
main()
{
while(1)
{
motor_ffw(5); //電機(jī)正轉(zhuǎn)
delay(1000); //換向延時
motor_rev(5); //電機(jī)反轉(zhuǎn)
delay(1000); //換向延時
}
}
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1