请教关于51调速直流电机程序
时间:10-02
整理:3721RD
点击:
- <span style="line-height: 1.7; background-color: rgb(255, 255, 255);">这个程序一直抖,端口改不了,定死了</span>
- while(1)
- {
- P36=1;P37=1;
- ADC_CONTR = 0x88; //打开ADC电源 以及启动模数转换
- while(ADC_CONTR!=0x90); //开着ADC电源,判断是否转换完成
- Adc = ADC_RES;
- i=Adc;
- ADC_CONTR = 0x80;
- Delay30us(1);
- if(i<=0x0f){op=0;oy=d;}
- else if(i<=0x1f){op=d-550;oy=d-1;}
- else if(i<=0x2f){op=d-500;oy=d-2;}
- else if(i<=0x3f){op=d-450;oy=d-3;}
- else if(i<=0x4f){op=d-400;oy=d-4;}
- else if(i<=0x5f){op=d-350;oy=d-5;}
- else if(i<=0x6f){op=d-300;oy=d-7;}
- else if(i<=0x7f){op=d-250;oy=d-9;}
- else if(i<=0x9f){op=d-200;oy=d-12;}
- else if(i<=0xaf){op=d-150;oy=d-20;}
- else if(i<=0xbf){op=d-100;oy=d-27;}
- else if(i<=0xcf){op=d-50;oy=d-31;}
- else if(i<=0xdf){op=d-0;oy=d-38;}
- else {op=d;oy=1;}
- Delay30us(1);
- P36=0;P37=1;
- Delay30us(op);
- }
啊哦,前前后后,延时调了N多遍了~~忽略楼上程序,实际程序如下: while(1)
{
P36=1;P37=1;
ADC_CONTR = 0x88; //打开ADC电源 以及启动模数转换
while(ADC_CONTR!=0x90); //开着ADC电源,判断是否转换完成
i = ADC_RES;
ADC_CONTR = 0x80;
Delay30us(5);
op=i*30;
P36=1;P37=0;
Delay30us(op);
}