How to Add 2 more inflight Modes

I found a discussion for getting 5 switch positions out of channel 5 on a DX6i and it also works on my JR XP6102.  What I want to do is add 2 more switchable modes to Ardupilot 2.7.1 which currently uses these 3 position outputs from channel 5.  I looked in Ardupilot and see it uses a Case statement to switch between 3 modes, but I cant find anywhere where the low level stuff for channel 5 is even described.

It'd be nice if all I had to do was add 2 more #defines and 2 more case statements, but I get the feeling that the PWM values of the additional switch positions need to be stated somewhere. 

Any clues where I need to make some changes.?

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

Join diydrones

Replies are closed for this discussion.

Replies

  • AP uses 6 positions on the channel to set the modes.  You need to set up mixing to mix another switch into channel 5.  It is the combination of these two switches that gives the 6 modes.

    This is something you need to set on your transmitter, no need to mess with the code.

  • Here's the function that reads the switch and its found in the control modes tab.

    void read_control_switch()
    {
     byte switchPosition = readSwitch();
     if (oldSwitchPosition != switchPosition){
      
      switch(switchPosition)
      {
       case 1: // First position
       set_mode(POSITION_1);
       break;
     
       case 2: // middle position
       /*
        if (GPS_fix != FAILED_GPS){
         set_mode(RTL);
        }else{
         set_mode(CIRCLE);
        }
       */
       set_mode(POSITION_2);
       break;
     
       case 3: // last position
       set_mode(POSITION_3);
       break;
      }

    Somewhere the PWM of POSITION_# is setup and that's what I'm looking for.  I'm thinking that mystery location is where I could tell it there are 5 different PWM values and then I could go in to the control modes tab and add 2 more cases.

This reply was deleted.

Activity