diff --git a/src/modules/systemlib/pwm_limit/pwm_limit.c b/src/modules/systemlib/pwm_limit/pwm_limit.c index adcfb703c0..2f72d347c6 100644 --- a/src/modules/systemlib/pwm_limit/pwm_limit.c +++ b/src/modules/systemlib/pwm_limit/pwm_limit.c @@ -1,7 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. - * Author: Julian Oes + * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,9 +34,9 @@ /** * @file pwm_limit.c * - * Lib to limit PWM output + * Library for PWM output limiting * - * @author Julian Oes + * @author Julian Oes */ #include "pwm_limit.h" @@ -46,6 +45,8 @@ #include #include +#define PROGRESS_INT_SCALING 10000 + void pwm_limit_init(pwm_limit_t *limit) { limit->state = PWM_LIMIT_STATE_INIT; @@ -112,7 +113,11 @@ void pwm_limit_calc(const bool armed, const unsigned num_channels, const uint16_ { hrt_abstime diff = hrt_elapsed_time(&limit->time_armed); - progress = diff * 10000 / RAMP_TIME_US; + progress = diff * PROGRESS_INT_SCALING / RAMP_TIME_US; + + if (progress > PROGRESS_INT_SCALING) { + progress = PROGRESS_INT_SCALING; + } for (unsigned i=0; i + * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,11 +32,11 @@ ****************************************************************************/ /** - * @file pwm_limit.h + * @file pwm_limit.c * - * Lib to limit PWM output + * Library for PWM output limiting * - * @author Julian Oes + * @author Julian Oes */ #ifndef PWM_LIMIT_H_