Current scaling: Employ per-board defaults

This commit is contained in:
Lorenz Meier 2016-01-24 16:02:21 +01:00
parent 4b55c5276e
commit b2237ce525
2 changed files with 17 additions and 1 deletions

View File

@ -1842,7 +1842,7 @@ PARAM_DEFINE_FLOAT(BAT_V_SCALING, -1.0f);
*
* @group Battery Calibration
*/
PARAM_DEFINE_FLOAT(BAT_C_SCALING, 0.0124); /* scaling for 3DR power brick */
PARAM_DEFINE_FLOAT(BAT_C_SCALING, -1.0);
/**

View File

@ -883,6 +883,22 @@ Sensors::parameters_update()
/* scaling of ADC ticks to battery current */
if (param_get(_parameter_handles.battery_current_scaling, &(_parameters.battery_current_scaling)) != OK) {
warnx("%s", paramerr);
} else if (_parameters.battery_current_scaling < 0.0f) {
/* apply scaling according to defaults if set to default */
#if defined (CONFIG_ARCH_BOARD_PX4FMU_V4)
/* current scaling for ACSP4 */
_parameters.battery_current_scaling = 0.029296875f;
#elif defined (CONFIG_ARCH_BOARD_PX4FMU_V2)
/* current scaling for 3DR power brick */
_parameters.battery_current_scaling = 0.0124f;
#elif defined (CONFIG_ARCH_BOARD_AEROCORE)
_parameters.battery_current_scaling = 0.0124f;
#elif defined (CONFIG_ARCH_BOARD_PX4FMU_V1)
_parameters.battery_current_scaling = 0.0124f;
#else
/* ensure a missing default leads to an unrealistic current value */
_parameters.battery_voltage_scaling = 0.00001f;
#endif
}
param_get(_parameter_handles.board_rotation, &(_parameters.board_rotation));