diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index 46874df116..24367eb9d3 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -266,6 +266,18 @@ then then pwm failsafe -c ${PWM_AUX_OUT} -p ${FAILSAFE} -d ${OUTPUT_AUX_DEV} fi + + # + # Per channel failsafe settings. + # + pwm failsafe -c 1 -p p:PWM_AUX_FAIL1 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 2 -p p:PWM_AUX_FAIL2 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 3 -p p:PWM_AUX_FAIL3 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 4 -p p:PWM_AUX_FAIL4 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 5 -p p:PWM_AUX_FAIL5 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 6 -p p:PWM_AUX_FAIL6 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 7 -p p:PWM_AUX_FAIL7 -d ${OUTPUT_AUX_DEV} + pwm failsafe -c 8 -p p:PWM_AUX_FAIL8 -d ${OUTPUT_AUX_DEV} fi fi @@ -310,6 +322,18 @@ then then pwm failsafe -c ${PWM_OUT} -p ${FAILSAFE} -d ${OUTPUT_DEV} fi + + # + # Per channel failsafe settings. + # + pwm failsafe -c 1 -p p:PWM_MAIN_FAIL1 + pwm failsafe -c 2 -p p:PWM_MAIN_FAIL2 + pwm failsafe -c 3 -p p:PWM_MAIN_FAIL3 + pwm failsafe -c 4 -p p:PWM_MAIN_FAIL4 + pwm failsafe -c 5 -p p:PWM_MAIN_FAIL5 + pwm failsafe -c 6 -p p:PWM_MAIN_FAIL6 + pwm failsafe -c 7 -p p:PWM_MAIN_FAIL7 + pwm failsafe -c 8 -p p:PWM_MAIN_FAIL8 fi unset MIXER_AUX_FILE diff --git a/src/modules/sensors/pwm_params_aux.c b/src/modules/sensors/pwm_params_aux.c index fee49c90ee..63b087e9c4 100644 --- a/src/modules/sensors/pwm_params_aux.c +++ b/src/modules/sensors/pwm_params_aux.c @@ -101,6 +101,136 @@ PARAM_DEFINE_INT32(PWM_AUX_MAX, 2000); */ PARAM_DEFINE_INT32(PWM_AUX_DISARMED, 1500); +/****************************************************************************** +* PWM_AUX_FAIL * +******************************************************************************/ +/** + * Set the failsafe PWM for the auxiliary 1 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL1, -1); + +/** + * Set the failsafe PWM for the auxiliary 2 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL2, -1); + +/** + * Set the failsafe PWM for the auxiliary 3 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL3, -1); + +/** + * Set the failsafe PWM for the auxiliary 4 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL4, -1); + +/** + * Set the failsafe PWM for the auxiliary 5 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL5, -1); + +/** + * Set the failsafe PWM for the auxiliary 6 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL6, -1); + +/** + * Set the failsafe PWM for the auxiliary 7 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL7, -1); + +/** + * Set the failsafe PWM for the auxiliary 8 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_AUX_FAIL8, -1); /****************************************************************************** * PWM_AUX_DIS * diff --git a/src/modules/sensors/pwm_params_main.c b/src/modules/sensors/pwm_params_main.c index 4db274f24c..d7e9a70df2 100644 --- a/src/modules/sensors/pwm_params_main.c +++ b/src/modules/sensors/pwm_params_main.c @@ -101,6 +101,138 @@ PARAM_DEFINE_INT32(PWM_MAX, 2000); */ PARAM_DEFINE_INT32(PWM_DISARMED, 900); +/****************************************************************************** +* PWM_MAIN_FAIL * +******************************************************************************/ + +/** + * Set the failsafe PWM for the main 1 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL1, -1); + +/** + * Set the failsafe PWM for the main 2 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL2, -1); + +/** + * Set the failsafe PWM for the main 3 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL3, -1); + +/** + * Set the failsafe PWM for the main 4 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL4, -1); + +/** + * Set the failsafe PWM for the main 5 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL5, -1); + +/** + * Set the failsafe PWM for the main 6 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL6, -1); + +/** + * Set the failsafe PWM for the main 7 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL7, -1); + +/** + * Set the failsafe PWM for the main 8 output + * + * This is the PWM pulse the autopilot is outputting if in failsafe mode. + * When set to -1 the value is set automatically depending if the actuator + * is a motor (900us) or a servo (1500us) + * + * @reboot_required true + * + * @min -1 + * @max 2200 + * @unit us + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_MAIN_FAIL8, -1); + /****************************************************************************** * PWM_MAIN_DIS * ******************************************************************************/ diff --git a/src/systemcmds/pwm/pwm.cpp b/src/systemcmds/pwm/pwm.cpp index f42c0e1a47..4978333742 100644 --- a/src/systemcmds/pwm/pwm.cpp +++ b/src/systemcmds/pwm/pwm.cpp @@ -597,6 +597,10 @@ pwm_main(int argc, char *argv[]) return 1; } + if (pwm_value < 0) { + return 0; + } + if (pwm_value == 0) { usage("failsafe: no PWM provided"); return 1;