<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PIC單片機(jī)驅(qū)動(dòng)步進(jìn)電機(jī)先正轉(zhuǎn)后反轉(zhuǎn)

          PIC單片機(jī)驅(qū)動(dòng)步進(jìn)電機(jī)先正轉(zhuǎn)后反轉(zhuǎn)

          作者: 時(shí)間:2018-08-01 來源:網(wǎng)絡(luò) 收藏

          本文介紹了利用驅(qū)動(dòng)先正轉(zhuǎn)后反轉(zhuǎn)。

          本文引用地址:http://www.ex-cimer.com/article/201808/384807.htm

          //**************************************************

          //實(shí)驗(yàn)?zāi)康模?/p>

          //熟悉驅(qū)動(dòng),先正轉(zhuǎn)后反轉(zhuǎn)

          //**************************************************

          //**************************************************

          //硬件設(shè)置:

          //1、把接在J10位置上

          //2、5腳是5V電源腳,1-4接步進(jìn)電機(jī)線圈

          //**************************************************

          //**************************************************

          //*****************定義頭文件**********************

          //**************************************************

          #include

          //**************************************************

          //******************定義配置位*********************

          //**************************************************

          __CONFIG(0x3541);

          //FLASH代碼不保護(hù),RB6和RB7為調(diào)試模式,F(xiàn)LASH不寫保護(hù),數(shù)據(jù)代碼不保護(hù)

          //RB3為數(shù)字IO口,低電壓復(fù)位使能,上電延時(shí)開,看門狗關(guān),4M晶體XT振蕩器

          //**************************************************

          //******************定義常量***********************

          //**************************************************

          #define uchar unsigned char

          #define uint unsigned int

          //***********************************************

          //函 數(shù) 名:delay();

          //入口參數(shù):無

          //出口參數(shù):無

          //函數(shù)作用:延時(shí)

          //說 明:

          //***********************************************

          void delay(void)

          {

          uint i;

          for(i=400;i>0;i--){;}

          }

          //***********************************************

          //函 數(shù) 名:main(void);

          //入口參數(shù):無

          //出口參數(shù):無

          //函數(shù)作用:MAIN函數(shù)

          //說 明:

          //***********************************************

          void main(void)

          {

          uint i;

          OPTION=0X8F; //分頻給WDT,分頻比為128

          ADCON1=0X07; //設(shè)置RA口,RE口為普通IO口

          TRISA=0X00; //設(shè)置RD口為輸出口

          PORTA=0XDF; //RD口首先輸出高電平

          while(1)

          {

          for(i=400;i>0;i--) //步進(jìn)電機(jī)正轉(zhuǎn)

          {

          PORTA=0XDD;

          delay();

          PORTA=0XDB;

          delay();

          PORTA=0XD7;

          delay();

          PORTA=0XCF;

          delay();

          }

          for(i=400;i>0;i--) //步進(jìn)電機(jī)反轉(zhuǎn)

          {

          PORTA=0XCF;

          delay();

          PORTA=0XD7;

          delay();

          PORTA=0XDB;

          delay();

          PORTA=0XDD;

          delay();

          }

          }

          }



          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();