欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 1489|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

步進(jìn)電機(jī)的反轉(zhuǎn)控制設(shè)計(jì)代碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:444119 發(fā)表于 2018-12-11 15:14 來(lái)自觸屏版 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include <reg51.h>      //51芯片管腳定義頭文件
#include <intrins.h>//內(nèi)部包含延時(shí)函數(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};
/**************************************************/
/* 延時(shí)t毫秒
/* 11.0592MHz時(shí)鐘,延時(shí)約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++)    //一個(gè)周期轉(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++)    //一個(gè)周期轉(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);          //換向延時(shí)
motor_rev(5);          //電機(jī)反轉(zhuǎn)
delay(1000);          //換向延時(shí)
}
}
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表