diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-03-07 11:45:23 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-03-07 11:45:23 +0100 |
commit | ff5ca82c7546d5e6db69144b57fb2878c4585ddf (patch) | |
tree | affd59b6ea3ccf4b8d2a8023fea10ec64d84fdd6 /apps/px4io/controls.c | |
parent | c993ba5bbc9e9a2781d26a5837b5711298de45ab (diff) | |
download | px4-firmware-ff5ca82c7546d5e6db69144b57fb2878c4585ddf.tar.gz px4-firmware-ff5ca82c7546d5e6db69144b57fb2878c4585ddf.tar.bz2 px4-firmware-ff5ca82c7546d5e6db69144b57fb2878c4585ddf.zip |
Fixed throttle scaling issue, harmonized FMU and IO RC scaling code
Diffstat (limited to 'apps/px4io/controls.c')
-rw-r--r-- | apps/px4io/controls.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/apps/px4io/controls.c b/apps/px4io/controls.c index b3b639857..d678fd351 100644 --- a/apps/px4io/controls.c +++ b/apps/px4io/controls.c @@ -164,7 +164,8 @@ controls_tick() { * * First normalize to 0..1 range with correct sign (below or above center), * then scale to 20000 range (if center is an actual center, -10000..10000, - * if center is min 0..20000, if center is max -20000..0). + * if parameters only support half range, scale to 10000 range, e.g. if + * center == min 0..10000, if center == max -10000..0). * * As the min and max bounds were enforced in step 1), division by zero * cannot occur, as for the case of center == min or center == max the if @@ -173,10 +174,10 @@ controls_tick() { * DO NOT REMOVE OR ALTER STEP 1! */ if (raw > (conf[PX4IO_P_RC_CONFIG_CENTER] + conf[PX4IO_P_RC_CONFIG_DEADZONE])) { - scaled = 20000.0f * ((raw - conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE]) / (float)(conf[PX4IO_P_RC_CONFIG_MAX] - conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE])); + scaled = 10000.0f * ((raw - conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE]) / (float)(conf[PX4IO_P_RC_CONFIG_MAX] - conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE])); } else if (raw < (conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE])) { - scaled = 20000.0f * ((raw - conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE]) / (float)(conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE] - conf[PX4IO_P_RC_CONFIG_MIN])); + scaled = 10000.0f * ((raw - conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE]) / (float)(conf[PX4IO_P_RC_CONFIG_CENTER] - conf[PX4IO_P_RC_CONFIG_DEADZONE] - conf[PX4IO_P_RC_CONFIG_MIN])); } else { /* in the configured dead zone, output zero */ |