怎么让步进电机高速旋转,同时消抖,我写的程序来回抖,哪位懂得讲一下啊
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
char count=0;
char time,i=0;
unsigned char code table_UP []= {0x11,0x33,0x22,0x66,0x44,0xcc,0x88,0x99}; //前进
unsigned char code table_Down []= {0x99,0x88,0xcc,0x44,0x66,0x22,0x33,0x11}; //后退
uint X=50;
/*******************************************/
//八拍驱动正转(N*360/400)度
/*******************************************/
void main()
{
TMOD=0x01;
//TH0=0x33;
//TL0=0xf5;
TH0=(65536-X)/256; // 2ms
TL0=(65536-X)%256;
EA=1;
ET0=1;
EX0=1;
TR0=1;
while(1)
{
}
}
void time0() interrupt 1 using 1
{
//TH0=0x33;
//TL0=0xf5;
TH0=(65536-X)/256;
TL0=(65536-X)%256;
count++;
if(count==10)//count==X
{
count=0;
if(i<8)
{
P0=table_UP[i];i++;
}
if(i==8)
{i=0;}
}
}
|