请教关于51调速直流电机程序

2019-07-15 10:50发布

  1. <span style="line-height: 1.7; background-color: rgb(255, 255, 255);">这个程序一直抖,端口改不了,定死了</span>
复制代码
  1. while(1)
  2. {

  3. P36=1;P37=1;

  4. ADC_CONTR = 0x88;        //打开ADC电源 以及启动模数转换       
  5. while(ADC_CONTR!=0x90);        //开着ADC电源,判断是否转换完成
  6. Adc = ADC_RES;
  7. i=Adc;
  8. ADC_CONTR = 0x80;
  9. Delay30us(1);
  10. if(i<=0x0f){op=0;oy=d;}
  11. else if(i<=0x1f){op=d-550;oy=d-1;}
  12. else if(i<=0x2f){op=d-500;oy=d-2;}
  13. else if(i<=0x3f){op=d-450;oy=d-3;}
  14. else if(i<=0x4f){op=d-400;oy=d-4;}
  15. else if(i<=0x5f){op=d-350;oy=d-5;}
  16. else if(i<=0x6f){op=d-300;oy=d-7;}
  17. else if(i<=0x7f){op=d-250;oy=d-9;}
  18. else if(i<=0x9f){op=d-200;oy=d-12;}
  19. else if(i<=0xaf){op=d-150;oy=d-20;}
  20. else if(i<=0xbf){op=d-100;oy=d-27;}
  21. else if(i<=0xcf){op=d-50;oy=d-31;}
  22. else if(i<=0xdf){op=d-0;oy=d-38;}
  23. else {op=d;oy=1;}
  24. Delay30us(1);

  25. P36=0;P37=1;       
  26. Delay30us(op);
  27. }
复制代码

0条回答

一周热门 更多>