Skip to content

Commit

Permalink
FLVSS_FAKE_SENSOR bug
Browse files Browse the repository at this point in the history
Fix for FLVSS_FAKE_SENSOR_DATA bug where voltage spike was causing code
to think higher number of cells, so then cell voltage divided by higher
number of cells giving low Cmin value. Code now determines cell count
once and uses that value.
  • Loading branch information
athertop committed Jun 12, 2017
1 parent d1d4bc5 commit 0fedcd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Teensy/MavLink_FrSkySPort/MavLink_FrSkySPort.ino
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ float ap_climb_rate = 0; // 100 = 1m/s
* *** Message #181 BATTERY2 ***
* *******************************************************
*/
#ifdef USE_BATT2
#ifdef USE_BATT2
uint16_t ap_voltage_battery2 = 0; // 1000 = 1V | Battery voltage, in millivolts (1 = 1 millivolt)
int16_t ap_current_battery2 = 0; // 10 = 1A | Battery current, in 10*milliamperes (1 = 10 milliampere),
#endif // -1: autopilot does not measure the current.
Expand Down
27 changes: 14 additions & 13 deletions Teensy/MavLink_FrSkySPort/Mavlink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -267,28 +267,29 @@ void _MavLink_receive() {
debugSerial.print(mavlink_msg_sys_status_get_current_battery(&msg));
debugSerial.println();
#endif
uint8_t temp_cell_count;
#ifdef USE_SINGLE_CELL_MONITOR
uint8_t temp_cell_count;
ap_cell_count = lscm.getCellsInUse();
if (lscm.getCellsInUse() == 0){
if (ap_cell_count == 0) {
if (ap_voltage_battery > 21000) temp_cell_count = 6;
else if (ap_voltage_battery > 17500) temp_cell_count = 5;
else if (ap_voltage_battery > 12750) temp_cell_count = 4;
else if (ap_voltage_battery > 8500) temp_cell_count = 3;
else if (ap_voltage_battery > 4250) temp_cell_count = 2;
else temp_cell_count = 0;
if (temp_cell_count > ap_cell_count)
ap_cell_count = temp_cell_count;
if (temp_cell_count > ap_cell_count) ap_cell_count = temp_cell_count;
}
#elif defined USE_FLVSS_FAKE_SENSOR_DATA
uint8_t temp_cell_count;
if (ap_cell_count == 0) {
if(ap_voltage_battery > 21000) temp_cell_count = 6;
else if (ap_voltage_battery > 17500) temp_cell_count = 5;
else if (ap_voltage_battery > 12750) temp_cell_count = 4;
else if (ap_voltage_battery > 8500) temp_cell_count = 3;
else if (ap_voltage_battery > 4250) temp_cell_count = 2;
else temp_cell_count = 0;
if(temp_cell_count > ap_cell_count) ap_cell_count = temp_cell_count;
}
#else
if(ap_voltage_battery > 21000) temp_cell_count = 6;
else if (ap_voltage_battery > 17500) temp_cell_count = 5;
else if (ap_voltage_battery > 12750) temp_cell_count = 4;
else if (ap_voltage_battery > 8500) temp_cell_count = 3;
else if (ap_voltage_battery > 4250) temp_cell_count = 2;
else temp_cell_count = 0;
if(temp_cell_count > ap_cell_count)
ap_cell_count = temp_cell_count;
#endif
break;
/*
Expand Down

0 comments on commit 0fedcd3

Please sign in to comment.