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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)電機(jī)測速程序

          單片機(jī)電機(jī)測速程序

          作者: 時(shí)間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
          這個(gè)51單片機(jī)+電機(jī)霍爾測速程序是從一個(gè)制作成功的智能小車里面提取出來的

          本文引用地址:http://www.ex-cimer.com/article/201612/325017.htm

          原理圖及其源代碼壓縮包的下載地址:http://www.51hei.com/bbs/dpj-19526-1.html

          下面是主要的程序文件預(yù)覽:
          #include
          unsigned int i=0;
          sbit P36=P3^6;
          unsigned char j;
          unsigned int kop;
          unsigned char a[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
          unsigned char b[8]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
          void delaym(unsigned int t)
          { unsigned char p;
          while(t--)
          {
          for(p=0; p<125; p++);
          }
          }

          void main()
          {
          EA = 1;
          TH0=0x00;
          TL0=0x00;
          ET0=1;
          ET1=1;
          TMOD = 0x15;// 打開定時(shí)器和計(jì)數(shù)器T0,因此矩形脈沖輸入端接P3.4
          TH1=0x3C; //50ms
          TL1=0xB0;
          TR0 = 1;
          TR1 = 1;
          while(1)
          {
          for(j=0;j<3;j++) //顯示個(gè)數(shù)
          {
          P0=b[j];
          P2=j;
          delaym(2);
          }
          }
          }
          timer3() interrupt 3 //定時(shí)器中斷時(shí)間到,就讀取計(jì)數(shù)器值
          { TH1=0X3C;
          TL1=0XB0;
          i++;
          if(i==20) //1s才進(jìn)行技術(shù)脈沖值顯示,即每秒更新一次速度
          {
          kop=TH0;//計(jì)數(shù)器計(jì)入脈沖,每來一個(gè)矩形脈沖計(jì)數(shù)值加1
          kop=kop<<8;
          kop=kop+TL0;

          b[2]=a[kop/100]; //顯示計(jì)數(shù)器的值即實(shí)際測得速度
          b[1]=a[kop%100/10];
          b[0]=a[kop%100%10];
          i=0;
          TH0=0;//計(jì)數(shù)器速度獲取后清零,進(jìn)行下次獲取
          TL0=0;
          }
          }



          關(guān)鍵詞: 單片機(jī)電機(jī)測

          評論


          技術(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); })();