Custom ArduPPM for alternative data inputs ?

Hi,

I'm interested in doing a custom version of the firmware for the ArduPPM to interface to SBUS (either directly or indirectly).

I'm currently converting my DJI Phantom 2 to use APM 2.5. But the Phantom 2's DJI receiver outputs SBUS.

So I've built a SBUS to PPM converter using an Arduino Mini and an inverter (as SBUS data is RS232 but inverted).

However, it seems a bit of a retrograde step to convert the SBUS to PPM, only for the ArduPPM to convert it back to digital values, and I've noticed that I get small errors in the PPM readings in MIssion Planner, i.e if I don't move the joysticks or switches, the values change slighly all the time.

I've debugged the SBUS data that my Arduino Mini is receiving and the data is stable, so the errors are in the PPM output encoding and the PPM decoding in the ArduPPM

Anyway, looking at the schematic, it looks like the PWM input CH2,CH3 and CH4 are connected to the SPI pins on the 32U2.

So the logical thing seems to be, to modify the ArduPPM to use SBUS to communicate with my converter.

However I don't quite know where to start.

Could some give me any clues. ;-)

Thanks

Roger

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Cool stuff going on here, but wanted to add that http://www.goodluckbuy.com/rmilec-signal-pwm-ppm-sbus-signal-dual-c... works like a champ - I was able to use it to get ezuhf working in PPM mode to the sbus port on the annoying as hell phantom 2 naza-m controller.

    • Interesting product.

      I've been looking at STM32 boards recently, as you can use them in place of Arduino Pro micro's and they are 72Mhz and have more flash and more ram.

      Shame this is a closed source product as the generic STM32 boards are around $5 !

  • I found this... Check it out:

    https://www.youtube.com/watch?v=7Nqr4-cbyvI

    If it works this easy, not confirmed yet, why hasnt the rest of the team actually picked it up and made sbus a part of the ArduPPM encoder yet?

  • Here are the files

    ArduPhantomSBUS.zip

    • Just found the code that controls the LEDS. This is just test code, that cycles all 4 arms through all 4 possible colour states i.e OFF, RED, GREEN, Yellow

      but it may be useful

      Note. I"m using Pins 3,5,6,9  If you use different pins you'd need to change the code, because the PWM values by default are not the same on all pins e.g. pins 5 and 6 operate by default at twice the PWM rate of the pins 3 and 9 (I'm not sure why this is).

      #define MIN_PULSE 12
      #define PULSE_INCREMENT 12
      #define OFF 0
      #define RED 1
      #define GREEN 2
      #define YELLOW 3

      void setLeds(byte led1,byte led2,byte led3,byte led4)
      {
        analogWrite(3,MIN_PULSE + led1 * PULSE_INCREMENT);
        analogWrite(5,(MIN_PULSE + led2 * PULSE_INCREMENT)*2);
        analogWrite(6,(MIN_PULSE + led3 * PULSE_INCREMENT)*2);
        analogWrite(9,MIN_PULSE + led4 * PULSE_INCREMENT);
      }

      byte counter=0;
      void setup() {
        // put your setup code here, to run once:

        setLeds(OFF,RED,GREEN,YELLOW);
        delay(5000);
      }

      void loop()
      {
        // put your main code here, to run repeatedly:
        setLeds(counter%4,(counter+1)%4,(counter+2)%4,(counter+3)%4);
        counter++;
        delay(500);
      }

      I'll post my mavlink code in a minute

      • OK. Here is my Mavlink code based on Mavlink-sniffer

        Note. You need to get the Mavlink library from inside this archive

        https://github.com/howroyd/mavlink_sniffer

        Then in the INO you must hard code the path to your mavlink library

        see in the code where it reads.

        IMPORTANT. YOU MUST PUT THE HARD CODED PATH TO THE MAVLINK LIBRARY HERE
        #include "C:/Documents and Settings/USERNAME/My Documents/Arduino/libraries/mavlink/include/include/mavlink/v1.0/ardupilotmega/mavlink.h"

        You must change this to be your arduino library directory etc

        mavlink_listner.ino

        OSD_Vars.h

        howroyd/mavlink_sniffer
        Simple arduino setch to receive mavlink. Contribute to howroyd/mavlink_sniffer development by creating an account on GitHub.
        • Thank you Roger for all these resources and for the quick answer. You've made a great work to make using the Phantom 2 radio possible.


          I will explore the code and let you know when I come to the desired result.

          Thank you again. :)

  • Hi Safwen,

    My Phantom 2 is definitely SBUS not PPM

    I'll attach the files in a minute to another post

    NOTE. This code needs an Arduino ATMega32U4 based board. I use a "Arduino Pro Micro" from eBay

    The reason it needs this board is because the software uses multiple Timers, and the ATMega32U4 has 1 extra timer. Also the 32U4 has Serial and Serial1 i.e 1 extra hardware serial.

    So if you want to use this code you need a 32U4 based board.



    I think you only need the SBUS and Streaming libraries, I can't remember why I have the other libraries in my backup folder, but perhaps they are needed somehow.

    Basically I only made a small change to the INO file to comment out things that were not used e.g. outputting individual servo values, as well as PPM.

    I also added some code to detect if SBUS SIGNAL was not OK, and set all channels to the minimum value.

    I have only done very basic testing with this. ie only some short flights very slow near the ground, as I have not attached the external compass yet.




    And it is now winter here and the weather is not so good for flying.

    I'm not using an external MPU but I now have an external compass module (http://www.ebay.com.au/itm/HMC5883L-3-Axis-Electronic-Compass-Magne...)
    . But I have not finished attaching it, as I could not get the correct connector etc.
    However I now have a connector that fits but is not perfect (its not quite the right one but its OK)
    I made a small plastic housing for the compass module (using 3D printing), and have glued the external compass near where the original DJI compass module was located.
    I now need to wire it up !

    The other thing I have done is to use another Arduino Mini (ATMega328) to operate the LED's under the arms of the Phantom.
    The signals are PWM, I think I posted the values of the PWM, but if you want it, I can find the program.

    I have also been working on code to read the MavLink data, so I can use this to control the LED flashing.

    However I have not finished this. But at least I can read the MavLink data and Print on Serial what is happening.

    The next step is to decide the LED flashing pattern and combine it with the Mavlink program.

    But at the moment my work is programming 10 hours per day (iPad and Android apps), so I don't have any time to program the Arduino for the Phantom.

  • Hi Roger,

    Your post comes with great help for me. I am actually working on the a similar project and I have some difficulties to interface the Phantom 2 receiver with the APM 2.5. I have read your comment here and looked for forum of the German website talking about the conversion SBUS-PPM using Arduino, but could not find it. I would really appreciate it if you could share it here.

    Actually, I thought that the Phantom 2 receiver type is PPM according to this DJi wiki, yet it seems to be  applicable only on the Phantom 1. That is I could not get any result with a PPM configuration.

    Through your posts about the SBUS-PPM, it seems that your project has advanced quite well . I would like to know if you succeeded to get signal with errors?

    I am also interested to know which kind of external MPU did you use; I have a MPU6050 and I am not pretty sure if I will only have to plug it to get it work, or I have to go through the code.

    Could you please share with us any information or resources about the project. It would be really helpful.



    Thank you,

    Safwen 

This reply was deleted.

Activity