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

          新聞中心

          單片機解碼PPM信號

          作者: 時間:2016-11-27 來源:網(wǎng)絡(luò) 收藏


          上述代碼每個通道都要占用一個中斷口。但是一般的Arduino只有數(shù)字口2、3具有中斷功能,也就是說只能接兩個通道。如果想使用更多的通道,就需要用mega了,mega有5個外部中斷源。其實,還有一種簡單辦法可以用一個中斷接收所有通道。這就是繞過接收機的解碼電路,使用arduino直接對PPM信號解碼。這種方式麻煩的地方是需要拆開接收機,把解碼前的PPM信號引出來。

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


          參考:http://diydrones.com/profiles/blogs/705844:BlogPost:38393
          打開接收機后,尋找PPM信號接口有幾種辦法:

          1.查芯片資料,如Futaba接收機使用BU4015BF移位寄存器芯片,管腳1或9焊一根線引出即可。
          2.使用示波器
          3.使用arduino,寫入測量脈寬的程序,在電路板上找吧,直到出現(xiàn)一些隨機數(shù)估計就是了。
          找到以后使用下面代碼進行解碼。此段代碼使用查詢方式,效率較低。更有效率的辦法是使用兩個中斷。一個中斷檢測同步信號,另一個中斷處理PPM信號。




          ARDUINO 代碼復(fù)制打印
          1. //http://diydrones.com/profiles/blogs/705844:BlogPost:38393
          2. #define channumber4//How many channels have your radio?
          3. intvalue[channumber];
          4. voidsetup()
          5. {
          6. Serial.begin(57600);//Serial Begin
          7. pinMode(3,INPUT);//Pin 3 as input
          8. }
          9. voidloop()
          10. {
          11. while(pulseIn(3,LOW)<5000){}//Wait for the beginning of the frame
          12. for(intx=0; x<=channumber-1; x++)//Loop to store all the channel position
          13. {
          14. value[x]=pulseIn(3,LOW);
          15. }
          16. for(intx=0; x<=channumber-1; x++)//Loop to print and clear all the channel readings
          17. {
          18. Serial.print(value[x]);//Print the value
          19. Serial.print(" ");
          20. value[x]=0;//Clear the value afeter is printed
          21. }
          22. Serial.println("");//Start a new line
          23. }


          上一頁 1 2 下一頁

          關(guān)鍵詞: 單片機解碼PPM信

          評論


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