Skip to content

Commit

Permalink
Change current sensor offset voltage unit to 0.1mV
Browse files Browse the repository at this point in the history
  • Loading branch information
shellixyz committed Mar 19, 2018
1 parent cea7ef0 commit b75a604
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ groups:
max: 10000
- name: current_meter_offset
field: current.offset
min: -3300
max: 3300
min: -32768
max: 32767
- name: current_meter_type
field: current.type
table: current_sensor
Expand Down
4 changes: 2 additions & 2 deletions src/main/sensors/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ uint16_t batteryAdcToVoltage(uint16_t src)

int32_t currentSensorToCentiamps(uint16_t src)
{
int32_t millivolts = ((uint32_t)src * ADCVREF) / 0xFFF - batteryConfig()->current.offset;
return millivolts * 1000 / batteryConfig()->current.scale; // current in 0.01A steps
int32_t microvolts = ((uint32_t)src * ADCVREF * 1000) / 0xFFF - (int32_t)batteryConfig()->current.offset * 100;
return microvolts / batteryConfig()->current.scale; // current in 0.01A steps
}

void batteryInit(void)
Expand Down

0 comments on commit b75a604

Please sign in to comment.