使用合泰芯片制作的步進電機控制,沒做仿真,使用模塊的直接上實物圖,電機是上面那個紅圈標的,黃圈標的是驅動也有51單片機的代碼
TIM圖片20180525165402.jpg (58.12 KB, 下載次數: 62)
下載附件
2018-5-25 16:57 上傳
單片機源碼:
- #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- void delay();
- void main()
- {/* //CCW[8]={0x08,0x18,0x10,0x30,0x20,0x60,0x40,0x48};
- //CW[8]={0x48,0x40,0x60,0x20,0x30,0x10,0x18,0x08};
- unsigned char code FFW[8]={0x08,0x18,0x10,0x30,0x20,0x60,0x40,0x48};
- //{0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9}; //反轉
- unsigned char code FFZ[8]={0x48,0x40,0x60,0x20,0x30,0x10,0x18,0x08};
- //{0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1}; //正轉 */
- uchar code BeatCode[8]={0x0E,0X0C,0X0D,0X09,0X0B,0X03,0X07,0X06};
- uchar tem;
- uchar index=0;
- uint i=0; //旋轉圈數
- while(1)
- {
- while(i<20000) //20000大約5圈
- {
- tem=0x00|BeatCode[index]; //屏蔽高四位
- // tem=0x0f&BeatCode[index]; //屏蔽高四位
- delay();
- P2=tem;
- delay();
- index++;
- index=index&0x07;
- delay();
- i++;
- }
- }
- }
- void delay()
- {
- unsigned int i=200;
- while(i--);
- }
復制代碼
0.png (44.44 KB, 下載次數: 49)
下載附件
2018-5-26 00:29 上傳
全部資料51hei下載地址:
步進電機.rar
(438.31 KB, 下載次數: 33)
2018-5-25 17:00 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|