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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 正交解碼及在旋轉(zhuǎn)編碼器中的應(yīng)用

          正交解碼及在旋轉(zhuǎn)編碼器中的應(yīng)用

          作者: 時(shí)間:2024-01-25 來源:電子森林 收藏

          module quad(clk, quadA, quadB, count);
          input clk, quadA, quadB;
          output [7:0] count; 
          reg quadA_delayed, quadB_delayed;
          always @(posedge clk) quadA_delayed <= quadA;
          always @(posedge clk) quadB_delayed <= quadB; 
          wire count_enable = quadA ^ quadA_delayed ^ quadB ^ quadB_delayed;
          wire count_direction = quadA ^ quadB_delayed; 
          reg [7:0] count;
          always @(posedge clk)begin
            if(count_enable)
            begin
              if(count_direction) count<=count+1; 
              else count<=count-1;
            end
           end 
           endmodule

          實(shí)際的電路

          module quad(clk, quadA, quadB, count);
          input clk, quadA, quadB;output [7:0] count; 
          reg [2:0] quadA_delayed, quadB_delayed;
          always @(posedge clk) quadA_delayed <= {quadA_delayed[1:0], quadA};
          always @(posedge clk) quadB_delayed <= {quadB_delayed[1:0], quadB}; 
          wire count_enable = quadA_delayed[1] ^ quadA_delayed[2] ^ quadB_delayed[1] ^ quadB_delayed[2];
          wire count_direction = quadA_delayed[1] ^ quadB_delayed[2]; 
          reg [7:0] count;
          always @(posedge clk)begin
            if(count_enable)
            begin
              if(count_direction) count<=count+1; else count<=count-1;
            end
           end 
            endmodule


          評(píng)論


          相關(guān)推薦

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