基于单片机的步进电机系统设计 联系客服

发布时间 : 星期六 文章基于单片机的步进电机系统设计更新完毕开始阅读

河南科技大学毕业设计(论文)

while (key_fan ==0); data_ref(); }

else if(key_jiasu==0) {

delay(20); if(key_jiasu==0) {

if(speed!=0) speed--;

while (key_jiasu ==0); data_ref(); } }

else if(key_jiansu==0) {

delay(20);

if(key_jiansu==0) {

if(speed<14) speed++; while (key_jiansu ==0); data_ref(); } }

void moto_control(void) {

static uchar i;

if(state==1) P0=rotate[i]; if(state==2) P0=rotate[3-i]; if((++i)>3) i=0;

if(state==0) P0=rotate[4]; }

41

河南科技大学毕业设计(论文)

void timer_0 (void) interrupt 1 {

static uchar j;

TH0=timer_set[speed]>>8;

//2ms

TL0= timer_set[speed]&0x0ff; //设置定时器的参数 if((++j)> moto_delay) {

moto_control(); j=0; } }

void timing1() interrupt 3 {

TH1=0xEC; TL1=0xF8; display(); }

void main() {

delay(1000); data_ref();

TMOD=0x11; //定时器初始化 TH0=0xd6; //设置初值 TL0= 0xf1; TR0=1; ET0=1; ET1=1; TR1=1; EA=1; while(1) {

42

//定时器启动

//中断使能

//定时器1中断使能 //定时器1启用

//全局中断使能

河南科技大学毕业设计(论文)

delay(5); key_scan() ; }

43