mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 20:28:37 +08:00
Sensors app: Stop the bad habit of params per board
This commit is contained in:
@@ -1807,36 +1807,13 @@ PARAM_DEFINE_INT32(RC_DSM_BIND, -1);
|
|||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(BAT_V_SCALE_IO, 10000);
|
PARAM_DEFINE_INT32(BAT_V_SCALE_IO, 10000);
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
|
|
||||||
/**
|
/**
|
||||||
* Scaling factor for battery voltage sensor on FMU v2.
|
* Scaling factor for battery voltage sensor on FMU v2.
|
||||||
*
|
*
|
||||||
* @board CONFIG_ARCH_BOARD_PX4FMU_V2
|
* @board CONFIG_ARCH_BOARD_PX4FMU_V2
|
||||||
* @group Battery Calibration
|
* @group Battery Calibration
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.0082f);
|
PARAM_DEFINE_FLOAT(BAT_V_SCALING, -1.0f);
|
||||||
#elif CONFIG_ARCH_BOARD_AEROCORE
|
|
||||||
/**
|
|
||||||
* Scaling factor for battery voltage sensor on AeroCore.
|
|
||||||
*
|
|
||||||
* For R70 = 133K, R71 = 10K --> scale = 1.8 * 143 / (4096*10) = 0.0063
|
|
||||||
*
|
|
||||||
* @board CONFIG_ARCH_BOARD_AEROCORE
|
|
||||||
* @group Battery Calibration
|
|
||||||
*/
|
|
||||||
PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.0063f);
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Scaling factor for battery voltage sensor on FMU v1.
|
|
||||||
*
|
|
||||||
* FMUv1 standalone: 1/(10 / (47+10)) * (3.3 / 4095) = 0.00459340659
|
|
||||||
* FMUv1 with PX4IO: 0.00459340659
|
|
||||||
* FMUv1 with PX4IOAR: (3.3f * 52.0f / 5.0f / 4095.0f) = 0.00838095238
|
|
||||||
*
|
|
||||||
* @group Battery Calibration
|
|
||||||
*/
|
|
||||||
PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.00459340659f);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scaling factor for battery current sensor.
|
* Scaling factor for battery current sensor.
|
||||||
|
|||||||
@@ -825,6 +825,16 @@ Sensors::parameters_update()
|
|||||||
/* scaling of ADC ticks to battery voltage */
|
/* scaling of ADC ticks to battery voltage */
|
||||||
if (param_get(_parameter_handles.battery_voltage_scaling, &(_parameters.battery_voltage_scaling)) != OK) {
|
if (param_get(_parameter_handles.battery_voltage_scaling, &(_parameters.battery_voltage_scaling)) != OK) {
|
||||||
warnx("%s", paramerr);
|
warnx("%s", paramerr);
|
||||||
|
} else if (_parameters.battery_voltage_scaling < 0.0f) {
|
||||||
|
/* apply scaling according to defaults if set to default */
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
|
||||||
|
_parameters.battery_voltage_scaling = 0.0082f;
|
||||||
|
#elif CONFIG_ARCH_BOARD_AEROCORE
|
||||||
|
_parameters.battery_voltage_scaling = 0.0063f;
|
||||||
|
#else
|
||||||
|
_parameters.battery_voltage_scaling = 0.00459340659f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scaling of ADC ticks to battery current */
|
/* scaling of ADC ticks to battery current */
|
||||||
|
|||||||
Reference in New Issue
Block a user