这是一个群里朋友发给我的步进电机实现正转反转和加速减速的单片机c语言源程序,这里给大家共享下,有需要的朋友直接复制到keil里编译就可以了,程序已测试成功。
/*****************************************
单4拍正转 zheng[]={0x01,0x08,0x04,0x02}
单4拍反转 fang[]={0x01,0x02,0x04,0x08}
双4拍正转 zheng[]={0x09,0x0c,0x06,0x03}
双4拍反转 fang[]={0x03,0x06,0x0c,0x09}
单双8拍正转 zheng[]={0x01,0x09,0x08,0x0c,0x04,0x06,0x02,0x03}
单双8拍反转 fang[]={0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09}
*****************************************/
#include"reg51.h"
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
bit front_move,back_move;
uchar jzaj(void); //单4拍正转 zheng[]={0x01,0x08,0x04,0x02}; 单4拍反转 fang[]={0x01,0x02,0x04,0x08};
void ajcl(uchar jz);
void delay(uchar del);
uchar code zheng[]={0x01,0x09,0x08,0x0c,0x04,0x06,0x02,0x03};