<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 直流電機(jī)調(diào)速程序

          直流電機(jī)調(diào)速程序

          作者: 時間:2012-09-04 來源:網(wǎng)絡(luò) 收藏
          #includereg52.h>



          sbit KEY1 = P3^1; //定義調(diào)速按鍵
          sbit = P1^5; //定義調(diào)速端口
          unsigned char CYCLE; //定義周期T=x*0.1ms
          unsigned char _ON ; //定義高電平時間

          void delay(unsigned int cnt)
          {
          while(--cnt);
          }

          main()
          {
          unsigned char _Num;
          TMOD |=0x01;
          TH0=(65536-1000)/256;
          TL0=(65536-1000)%256;
          IE= 0x82;
          TR0=1;

          CYCLE = 10;
          while(1)
          {
          if(!KEY1)
          {
          delay(10000);
          if(!KEY1)
          {
          PWM_Num++;
          if(PWM_Num==4)

          PWM_Num=0;
          switch(PWM_Num)

          {
          case 0:P0=0x06;PWM_ON=0;break;
          case 1:P0=0x5B;PWM_ON=4;break;
          case 2:P0=0x4F;PWM_ON=6;break;
          case 3:P0=0x66;PWM_ON=8;break;
          default:break;
          }
          }
          }
          }

          }

          void tim(void) interrupt 1 using 1
          {
          static unsigned char count;
          TH0=(65536-1000)/256;
          TL0=(65536-1000)%256;

          if (count==PWM_ON)
          {
          PWM = 1;
          }
          count++;
          if(count == CYCLE)
          {
          count=0;
          if(PWM_ON!=0)
          PWM = 0;

          }

          }


          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();