Update ADC voltage calculation instances to avoid divide by integer.

This commit is contained in:
mcsauder
2018-07-09 07:51:15 +02:00
committed by Beat Küng
parent 850b1ad6a7
commit cf7dd383b1
3 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -376,7 +376,7 @@ ADC::update_system_power(hrt_abstime now)
if (_samples[i].am_channel == ADC_5V_RAIL_SENSE) {
// it is 2:1 scaled
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096);
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096.0f);
}
}
+1 -1
View File
@@ -324,7 +324,7 @@ ADC::update_system_power(void)
for (unsigned i = 0; i < _channel_count; i++) {
if (_samples[i].am_channel == 4) {
// it is 2:1 scaled
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096);
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096.0f);
}
}
+2 -1
View File
@@ -281,6 +281,7 @@ int board_adc_init()
return OK;
}
int
ADC::init()
{
@@ -401,7 +402,7 @@ ADC::update_system_power(hrt_abstime now)
if (_samples[i].am_channel == ADC_SCALED_V5_SENSE) {
// it is 2:1 scaled
system_power.voltage5V_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096);
system_power.voltage5V_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096.0f);
cnt--;
} else