使用合泰芯片制作的步进电机控制,没做仿真,使用模块的直接上实物图,电机是上面那个红圈标的,黄圈标的是驱动也有51单片机的代码
单片机源码:
- #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--);
- }
复制代码
全部资料51hei下载地址:
步进电机.rar
(438.31 KB, 下载次数: 33)
|