找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

合泰單片機(jī)的步進(jìn)電機(jī)驅(qū)動(dòng)控制源碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
使用合泰芯片制作的步進(jìn)電機(jī)控制,沒做仿真,使用模塊的直接上實(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)



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

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

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

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