標(biāo)題: 合泰單片機(jī)的步進(jìn)電機(jī)驅(qū)動(dòng)控制源碼 [打印本頁(yè)]

作者: darkLee    時(shí)間: 2018-5-25 17:02
標(biāo)題: 合泰單片機(jī)的步進(jìn)電機(jī)驅(qū)動(dòng)控制源碼
使用合泰芯片制作的步進(jìn)電機(jī)控制,沒(méi)做仿真,使用模塊的直接上實(shí)物圖,電機(jī)是上面那個(gè)紅圈標(biāo)的,黃圈標(biāo)的是驅(qū)動(dòng)也有51單片機(jī)的代碼


單片機(jī)源碼:
  1. #include <reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int
  4. void delay();
  5. void main()
  6. {/*        //CCW[8]={0x08,0x18,0x10,0x30,0x20,0x60,0x40,0x48};
  7. //CW[8]={0x48,0x40,0x60,0x20,0x30,0x10,0x18,0x08};
  8. unsigned char code FFW[8]={0x08,0x18,0x10,0x30,0x20,0x60,0x40,0x48};
  9. //{0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9}; //反轉(zhuǎn)
  10. unsigned char code FFZ[8]={0x48,0x40,0x60,0x20,0x30,0x10,0x18,0x08};
  11. //{0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1}; //正轉(zhuǎn)          */
  12.         uchar code BeatCode[8]={0x0E,0X0C,0X0D,0X09,0X0B,0X03,0X07,0X06};
  13.         uchar tem;
  14.         uchar index=0;
  15.         uint i=0;  //旋轉(zhuǎn)圈數(shù)
  16.         while(1)
  17.         {
  18.         while(i<20000) //20000大約5圈
  19.             {
  20.                 tem=0x00|BeatCode[index];    //屏蔽高四位
  21. //                tem=0x0f&BeatCode[index];    //屏蔽高四位
  22.                 delay();
  23.                 P2=tem;
  24.                 delay();
  25.                 index++;
  26.                 index=index&0x07;
  27.                 delay();
  28.                 i++;
  29.                 }
  30.         }
  31. }
  32. void delay()
  33. {                  
  34.         unsigned int i=200;
  35.         while(i--);
  36. }
復(fù)制代碼



全部資料51hei下載地址:

步進(jìn)電機(jī).rar (438.31 KB, 下載次數(shù): 33)








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