新聞中心

        單片機解碼PPM信號

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


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

        本文引用地址:http://www.104case.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)閉
        主站蜘蛛池模板: 玉龙| 益阳市| 九江县| 巢湖市| 富裕县| 当雄县| 颍上县| 临夏市| 海原县| 原阳县| 乌鲁木齐市| 桃江县| 从江县| 吴忠市| 彩票| 廊坊市| 建湖县| 浮梁县| 盐边县| 嵩明县| 金秀| 温泉县| 渝北区| 乳源| 嘉义市| 永安市| 青河县| 南召县| 枞阳县| 历史| 南充市| 准格尔旗| 和林格尔县| 蒙城县| 巴中市| 彩票| 东台市| 邵东县| 屏边| 化德县| 成安县|