Relay Control on AUX ports

Hi,
I’m evaluating 3.3.1 on a Pixhawk and was excited to see options for multiple relays using the AUX ports. After playing around with various param settings I have still been unable to get the relay outputs to function as I expect. I seem to be only able to get a single relay to work. Is anybody able to offer some advice as to how I can configure multiple relay outputs on the AUX ports please. Ultimately I have a desire to use 4 or more relay output outputs, but I’d be really happy to begin with Relay1 (Aux5) and Relay2(Aux6) and get them functional.

I have previously asked the question, but I suspect I have put the question in the wrong place :slight_smile:

thanks
Mogy …

I’ve been playing with the Mission Planner setting of params a bit more and here is what I see -

I’ve configured my MC20 controller to use a variety of toggle switches on 4xSBUS channels, (ie) SBUS Channels 7, 8, 9 and 10. I have then set following params -
BRD_PWM_COUNT=0
CH7_OPT = 28 (Relay ON/OFF)
CH8_OPT = 28
CH9_OPT = 28
CH10_OPT = 28
RELAY_PIN=52
RELAY_PIN2=53
RELAY_PIN3=54
RELAY_PIN4=55
This setup seems to allow all 4 switches to control the single AUX3/RC11 (or RELAY_PIN configured) output. I cannot see how to assign an SBUS channel to drive any of RELAY_PIN2/3 or 4 outputs.
I’m sure I’m missing something fundamental here, but not really sure what. :slight_smile:

Hi,
I’ve been looking in the code base for answers regarding the behaviour I saw above, and it appears what I see, is the expected behaviour.

Anyway - I’ve added some code to get 4 relays working on AUX3-AUX6 (using the standard SBUS7-10),
and wanted to know if an experienced developer could make comment on the changes please.
I’m new to the code base and unsure if I’m going to break something else.

defines.h - Added some extra enumerations to
“aux_sw_func” enumeration

    AUXSW_RELAY2 =              34, // Relay2 pin on/off (in Mission planner set CH8_OPT  = 34)
    AUXSW_RELAY3 =              35, // Relay3 pin on/off (in Mission planner set CH9_OPT  = 35)
    AUXSW_RELAY4 =              36  // Relay4 pin on/off (in Mission planner set CH10_OPT = 36)

switches.cpp - Added extra case statement elements in the method
void Copter::init_aux_switch_function(int8_t ch_option, uint8_t ch_flag) after case AUXSW_RELAY:

        case AUXSW_RELAY2:
        case AUXSW_RELAY3:
        case AUXSW_RELAY4:

and
switches.cpp - Added extra case statement elements in the method
“void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)”

	case AUXSW_RELAY2:
        ServoRelayEvents.do_set_relay(1, ch_flag == AUX_SWITCH_HIGH);
        break;

    case AUXSW_RELAY3:
        ServoRelayEvents.do_set_relay(2, ch_flag == AUX_SWITCH_HIGH);
        break;
    
	case AUXSW_RELAY4:
        ServoRelayEvents.do_set_relay(3, ch_flag == AUX_SWITCH_HIGH);
        break;

I’d appreciate any advice, thanks
Mogy …

I’ve just noticed that I couldn’t get the default relay level working (Parameter RELAY_DEFAULT) until I commented out several case statements

switches.cpp - Removed case statements in the method
void Copter::init_aux_switch_function(int8_t ch_option, uint8_t ch_flag)

       case AUXSW_RELAY:
        case AUXSW_RELAY2:
        case AUXSW_RELAY3:
        case AUXSW_RELAY4:

cheers
Mogy …

@oldmogy,
Ah, you’re working hard but making progress!
sorry for not helping out sooner. What you’ve done is a-ok. If you want to submit a PR we can likely include your changes in Copter-3.4.
dev.ardupilot.com/wiki/submittin … to-master/

That’s great - thanks for the feedback.
I’m keen to see this change in the main release so I will get to the PR as soon as I figure out the procedure etc :slight_smile:
thanks again, Mogy …