標(biāo)題: 步進(jìn)電機(jī)正反轉(zhuǎn)程序 [打印本頁]

作者: chf    時(shí)間: 2017-4-25 16:56
標(biāo)題: 步進(jìn)電機(jī)正反轉(zhuǎn)程序
  1. #include <reg52.h>


  2. unsigned char code F_Rotation[4]={0x02,0x04,0x08,0x10};//正轉(zhuǎn)表格
  3. unsigned char code B_Rotation[4]={0x10,0x08,0x040,0x02};//反轉(zhuǎn)表格

  4. void Delay(unsigned int i)//延時(shí)
  5. {
  6. while(--i);
  7. }

  8. main()
  9. {

  10. unsigned char i;

  11. while(1)
  12. {
  13.   for(i=0;i<4;i++)      //4相
  14.      {
  15.      P1=F_Rotation[i];  //輸出對(duì)應(yīng)的相 可以自行換成反轉(zhuǎn)表格
  16.      Delay(500);        //改變這個(gè)參數(shù)可以調(diào)整電機(jī)轉(zhuǎn)速
  17.          }
  18.   }
  19. }

復(fù)制代碼

作者: 啊哈哈000    時(shí)間: 2017-5-4 08:08
有沒有原理圖啊
作者: 10507018217    時(shí)間: 2017-6-5 19:50
啊哈哈000 發(fā)表于 2017-5-4 08:08
有沒有原理圖啊

我有





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1