From 32a6de6b79e7d34c14351a30fecfb13c2b265ab1 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 1 May 2016 02:04:01 +0200 Subject: [PATCH 1/5] LP-233 Support OneShot42 --- flight/modules/Actuator/actuator.c | 10 ++++++++++ .../targets/boards/coptercontrol/firmware/pios_board.c | 6 ++++-- flight/targets/boards/revonano/firmware/pios_board.c | 3 ++- shared/uavobjectdefinition/actuatorsettings.xml | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/flight/modules/Actuator/actuator.c b/flight/modules/Actuator/actuator.c index f3f77ca41..7276e27ef 100644 --- a/flight/modules/Actuator/actuator.c +++ b/flight/modules/Actuator/actuator.c @@ -77,6 +77,8 @@ static int8_t counter; #define ACTUATOR_ONESHOT125_CLOCK 2000000 #define ACTUATOR_ONESHOT125_PULSE_SCALE 4 +#define ACTUATOR_ONESHOT42_CLOCK 6000000 +#define ACTUATOR_ONESHOT42_PULSE_SCALE 4 #define ACTUATOR_PWM_CLOCK 1000000 // Private types @@ -941,6 +943,10 @@ static bool set_channel(uint8_t mixer_channel, uint16_t value) // Remap 1000-2000 range to 125-250 PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value / ACTUATOR_ONESHOT125_PULSE_SCALE); break; + case ACTUATORSETTINGS_BANKMODE_ONESHOT42: + // Remap 1000-2000 range to 41,666-83,333µs + PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value / ACTUATOR_ONESHOT42_PULSE_SCALE); + break; default: PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value); break; @@ -994,6 +1000,10 @@ static void actuator_update_rate_if_changed(bool force_update) freq[i] = 100; // Value must be small enough so CCr isn't update until the PIOS_Servo_Update is triggered clock[i] = ACTUATOR_ONESHOT125_CLOCK; // Setup an 2MHz timer clock break; + case ACTUATORSETTINGS_BANKMODE_ONESHOT42: + freq[i] = 100; + clock[i] = ACTUATOR_ONESHOT42_CLOCK; + break; case ACTUATORSETTINGS_BANKMODE_PWMSYNC: freq[i] = 100; clock[i] = ACTUATOR_PWM_CLOCK; diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index 90cbfa8b9..5145ca3da 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -954,7 +954,8 @@ SystemAlarmsExtendedAlarmStatusOptions CopterControlConfigHook() if ((recmode == HWSETTINGS_CC_RCVRPORT_PPM_PIN8ONESHOT || flexiMode == HWSETTINGS_CC_FLEXIPORT_PPM) && (modes[3] == ACTUATORSETTINGS_BANKMODE_PWMSYNC || - modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT125)) { + modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 || + modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT42)) { return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT; } else { return SYSTEMALARMS_EXTENDEDALARMSTATUS_NONE; @@ -967,7 +968,8 @@ SystemAlarmsExtendedAlarmStatusOptions CopterControlConfigHook() case HWSETTINGS_CC_RCVRPORT_PWMNOONESHOT: for (uint8_t i = 0; i < ACTUATORSETTINGS_BANKMODE_NUMELEM; i++) { if (modes[i] == ACTUATORSETTINGS_BANKMODE_PWMSYNC || - modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125) { + modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 || + modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42) { return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;; } diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index 4cc6f58d9..c3f42ad0e 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -893,7 +893,8 @@ SystemAlarmsExtendedAlarmStatusOptions RevoNanoConfigHook() case HWSETTINGS_RM_RCVRPORT_PWM: for (uint8_t i = 0; i < ACTUATORSETTINGS_BANKMODE_NUMELEM; i++) { if (modes[i] == ACTUATORSETTINGS_BANKMODE_PWMSYNC || - modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125) { + modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 || + modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42) { return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;; } } diff --git a/shared/uavobjectdefinition/actuatorsettings.xml b/shared/uavobjectdefinition/actuatorsettings.xml index 4890a0c60..e57633f67 100644 --- a/shared/uavobjectdefinition/actuatorsettings.xml +++ b/shared/uavobjectdefinition/actuatorsettings.xml @@ -2,7 +2,7 @@ Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType - + From 49107e40079a9e6eac1ba6a09f4ab8ab130d9136 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 1 May 2016 14:10:49 +0200 Subject: [PATCH 2/5] LP-233 Increase Oneshot output resolution --- flight/modules/Actuator/actuator.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/flight/modules/Actuator/actuator.c b/flight/modules/Actuator/actuator.c index 7276e27ef..b661d5d30 100644 --- a/flight/modules/Actuator/actuator.c +++ b/flight/modules/Actuator/actuator.c @@ -61,25 +61,25 @@ static int8_t counter; #endif // Private constants -#define MAX_QUEUE_SIZE 2 +#define MAX_QUEUE_SIZE 2 #if defined(PIOS_ACTUATOR_STACK_SIZE) -#define STACK_SIZE_BYTES PIOS_ACTUATOR_STACK_SIZE +#define STACK_SIZE_BYTES PIOS_ACTUATOR_STACK_SIZE #else -#define STACK_SIZE_BYTES 1312 +#define STACK_SIZE_BYTES 1312 #endif -#define TASK_PRIORITY (tskIDLE_PRIORITY + 4) // device driver -#define FAILSAFE_TIMEOUT_MS 100 -#define MAX_MIX_ACTUATORS ACTUATORCOMMAND_CHANNEL_NUMELEM +#define TASK_PRIORITY (tskIDLE_PRIORITY + 4) // device driver +#define FAILSAFE_TIMEOUT_MS 100 +#define MAX_MIX_ACTUATORS ACTUATORCOMMAND_CHANNEL_NUMELEM -#define CAMERA_BOOT_DELAY_MS 7000 +#define CAMERA_BOOT_DELAY_MS 7000 -#define ACTUATOR_ONESHOT125_CLOCK 2000000 -#define ACTUATOR_ONESHOT125_PULSE_SCALE 4 -#define ACTUATOR_ONESHOT42_CLOCK 6000000 -#define ACTUATOR_ONESHOT42_PULSE_SCALE 4 -#define ACTUATOR_PWM_CLOCK 1000000 +#define ACTUATOR_ONESHOT125_CLOCK 12000000 +#define ACTUATOR_ONESHOT125_PULSE_FACTOR 1.5f +#define ACTUATOR_ONESHOT42_CLOCK 12000000 +#define ACTUATOR_ONESHOT42_PULSE_SCALE 2 +#define ACTUATOR_PWM_CLOCK 1000000 // Private types @@ -941,7 +941,7 @@ static bool set_channel(uint8_t mixer_channel, uint16_t value) switch (mode) { case ACTUATORSETTINGS_BANKMODE_ONESHOT125: // Remap 1000-2000 range to 125-250 - PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value / ACTUATOR_ONESHOT125_PULSE_SCALE); + PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value * ACTUATOR_ONESHOT125_PULSE_FACTOR); break; case ACTUATORSETTINGS_BANKMODE_ONESHOT42: // Remap 1000-2000 range to 41,666-83,333µs @@ -998,11 +998,11 @@ static void actuator_update_rate_if_changed(bool force_update) switch (actuatorSettings.BankMode[i]) { case ACTUATORSETTINGS_BANKMODE_ONESHOT125: freq[i] = 100; // Value must be small enough so CCr isn't update until the PIOS_Servo_Update is triggered - clock[i] = ACTUATOR_ONESHOT125_CLOCK; // Setup an 2MHz timer clock + clock[i] = ACTUATOR_ONESHOT125_CLOCK; // Setup an 12MHz timer clock break; case ACTUATORSETTINGS_BANKMODE_ONESHOT42: freq[i] = 100; - clock[i] = ACTUATOR_ONESHOT42_CLOCK; + clock[i] = ACTUATOR_ONESHOT42_CLOCK; // Setup an 12MHz timer clock break; case ACTUATORSETTINGS_BANKMODE_PWMSYNC: freq[i] = 100; From 78be10ff28485a12a4bad14675c667f826802266 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 1 May 2016 18:28:37 +0200 Subject: [PATCH 3/5] LP-233 Multiply / factor instead of scale --- flight/modules/Actuator/actuator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flight/modules/Actuator/actuator.c b/flight/modules/Actuator/actuator.c index b661d5d30..df89a8ed4 100644 --- a/flight/modules/Actuator/actuator.c +++ b/flight/modules/Actuator/actuator.c @@ -78,7 +78,7 @@ static int8_t counter; #define ACTUATOR_ONESHOT125_CLOCK 12000000 #define ACTUATOR_ONESHOT125_PULSE_FACTOR 1.5f #define ACTUATOR_ONESHOT42_CLOCK 12000000 -#define ACTUATOR_ONESHOT42_PULSE_SCALE 2 +#define ACTUATOR_ONESHOT42_PULSE_FACTOR 0.5f #define ACTUATOR_PWM_CLOCK 1000000 // Private types @@ -940,12 +940,12 @@ static bool set_channel(uint8_t mixer_channel, uint16_t value) uint8_t mode = pinsMode[actuatorSettings.ChannelAddr[mixer_channel]]; switch (mode) { case ACTUATORSETTINGS_BANKMODE_ONESHOT125: - // Remap 1000-2000 range to 125-250 + // Remap 1000-2000 range to 125-250µs PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value * ACTUATOR_ONESHOT125_PULSE_FACTOR); break; case ACTUATORSETTINGS_BANKMODE_ONESHOT42: // Remap 1000-2000 range to 41,666-83,333µs - PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value / ACTUATOR_ONESHOT42_PULSE_SCALE); + PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value * ACTUATOR_ONESHOT42_PULSE_FACTOR); break; default: PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value); From 2bda2e2901506191cf06ea95058baa698eb15955 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 1 May 2016 19:24:41 +0200 Subject: [PATCH 4/5] LP-233 Simplify, same clock used for all OneShot modes --- flight/modules/Actuator/actuator.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/flight/modules/Actuator/actuator.c b/flight/modules/Actuator/actuator.c index df89a8ed4..d9cc780eb 100644 --- a/flight/modules/Actuator/actuator.c +++ b/flight/modules/Actuator/actuator.c @@ -75,9 +75,8 @@ static int8_t counter; #define CAMERA_BOOT_DELAY_MS 7000 -#define ACTUATOR_ONESHOT125_CLOCK 12000000 +#define ACTUATOR_ONESHOT_CLOCK 12000000 #define ACTUATOR_ONESHOT125_PULSE_FACTOR 1.5f -#define ACTUATOR_ONESHOT42_CLOCK 12000000 #define ACTUATOR_ONESHOT42_PULSE_FACTOR 0.5f #define ACTUATOR_PWM_CLOCK 1000000 // Private types @@ -997,12 +996,9 @@ static void actuator_update_rate_if_changed(bool force_update) } switch (actuatorSettings.BankMode[i]) { case ACTUATORSETTINGS_BANKMODE_ONESHOT125: - freq[i] = 100; // Value must be small enough so CCr isn't update until the PIOS_Servo_Update is triggered - clock[i] = ACTUATOR_ONESHOT125_CLOCK; // Setup an 12MHz timer clock - break; case ACTUATORSETTINGS_BANKMODE_ONESHOT42: - freq[i] = 100; - clock[i] = ACTUATOR_ONESHOT42_CLOCK; // Setup an 12MHz timer clock + freq[i] = 100; // Value must be small enough so CCr isn't update until the PIOS_Servo_Update is triggered + clock[i] = ACTUATOR_ONESHOT_CLOCK; // Setup an 12MHz timer clock break; case ACTUATORSETTINGS_BANKMODE_PWMSYNC: freq[i] = 100; From 214ae849a2ec8c5a729e6e001aeb9b094f5999d7 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Mon, 2 May 2016 20:22:05 +0200 Subject: [PATCH 5/5] =?UTF-8?q?LP-233=20Add=20MultiShot=205=20-=2025=C2=B5?= =?UTF-8?q?s=20pulses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flight/modules/Actuator/actuator.c | 6 ++++++ flight/targets/boards/coptercontrol/firmware/pios_board.c | 6 ++++-- flight/targets/boards/revonano/firmware/pios_board.c | 3 ++- shared/uavobjectdefinition/actuatorsettings.xml | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/flight/modules/Actuator/actuator.c b/flight/modules/Actuator/actuator.c index d9cc780eb..a2a66838f 100644 --- a/flight/modules/Actuator/actuator.c +++ b/flight/modules/Actuator/actuator.c @@ -78,6 +78,7 @@ static int8_t counter; #define ACTUATOR_ONESHOT_CLOCK 12000000 #define ACTUATOR_ONESHOT125_PULSE_FACTOR 1.5f #define ACTUATOR_ONESHOT42_PULSE_FACTOR 0.5f +#define ACTUATOR_MULTISHOT_PULSE_FACTOR 0.24f #define ACTUATOR_PWM_CLOCK 1000000 // Private types @@ -946,6 +947,10 @@ static bool set_channel(uint8_t mixer_channel, uint16_t value) // Remap 1000-2000 range to 41,666-83,333µs PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value * ACTUATOR_ONESHOT42_PULSE_FACTOR); break; + case ACTUATORSETTINGS_BANKMODE_MULTISHOT: + // Remap 1000-2000 range to 5-25µs + PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], (value * ACTUATOR_MULTISHOT_PULSE_FACTOR) - 180); + break; default: PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value); break; @@ -997,6 +1002,7 @@ static void actuator_update_rate_if_changed(bool force_update) switch (actuatorSettings.BankMode[i]) { case ACTUATORSETTINGS_BANKMODE_ONESHOT125: case ACTUATORSETTINGS_BANKMODE_ONESHOT42: + case ACTUATORSETTINGS_BANKMODE_MULTISHOT: freq[i] = 100; // Value must be small enough so CCr isn't update until the PIOS_Servo_Update is triggered clock[i] = ACTUATOR_ONESHOT_CLOCK; // Setup an 12MHz timer clock break; diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index 5145ca3da..8ba03f975 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -955,7 +955,8 @@ SystemAlarmsExtendedAlarmStatusOptions CopterControlConfigHook() flexiMode == HWSETTINGS_CC_FLEXIPORT_PPM) && (modes[3] == ACTUATORSETTINGS_BANKMODE_PWMSYNC || modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 || - modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT42)) { + modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT42 || + modes[3] == ACTUATORSETTINGS_BANKMODE_MULTISHOT)) { return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT; } else { return SYSTEMALARMS_EXTENDEDALARMSTATUS_NONE; @@ -969,7 +970,8 @@ SystemAlarmsExtendedAlarmStatusOptions CopterControlConfigHook() for (uint8_t i = 0; i < ACTUATORSETTINGS_BANKMODE_NUMELEM; i++) { if (modes[i] == ACTUATORSETTINGS_BANKMODE_PWMSYNC || modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 || - modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42) { + modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42 || + modes[i] == ACTUATORSETTINGS_BANKMODE_MULTISHOT) { return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;; } diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index c3f42ad0e..f02a2fdbf 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -894,7 +894,8 @@ SystemAlarmsExtendedAlarmStatusOptions RevoNanoConfigHook() for (uint8_t i = 0; i < ACTUATORSETTINGS_BANKMODE_NUMELEM; i++) { if (modes[i] == ACTUATORSETTINGS_BANKMODE_PWMSYNC || modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 || - modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42) { + modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42 || + modes[i] == ACTUATORSETTINGS_BANKMODE_MULTISHOT) { return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;; } } diff --git a/shared/uavobjectdefinition/actuatorsettings.xml b/shared/uavobjectdefinition/actuatorsettings.xml index e57633f67..6aaed72f7 100644 --- a/shared/uavobjectdefinition/actuatorsettings.xml +++ b/shared/uavobjectdefinition/actuatorsettings.xml @@ -2,7 +2,7 @@ Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType - +