找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3239|回復: 0
打印 上一主題 下一主題
收起左側

合泰單片機的步進電機驅動控制源碼

[復制鏈接]
跳轉到指定樓層
樓主
ID:338198 發(fā)表于 2018-5-25 17:02 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
使用合泰芯片制作的步進電機控制,沒做仿真,使用模塊的直接上實物圖,電機是上面那個紅圈標的,黃圈標的是驅動也有51單片機的代碼


單片機源碼:
  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}; //反轉
  10. unsigned char code FFZ[8]={0x48,0x40,0x60,0x20,0x30,0x10,0x18,0x08};
  11. //{0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1}; //正轉          */
  12.         uchar code BeatCode[8]={0x0E,0X0C,0X0D,0X09,0X0B,0X03,0X07,0X06};
  13.         uchar tem;
  14.         uchar index=0;
  15.         uint i=0;  //旋轉圈數
  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. }
復制代碼



全部資料51hei下載地址:

步進電機.rar (438.31 KB, 下載次數: 33)



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

使用道具 舉報

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

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表