I took speedybee, and made a custom firmware: changing RSSI pad to CURR2. So I wanted to be able to see 2 current values on OSD.
When I have BATT2_MONITOR disabled, OSD1_CURRENT shows the correct value (like 0.1A), when I activate BATT2_MONITOR = 4 I get crazy and weird results:
OSD1_CURRENT becomes like 100A, and OSD2_CURRENT also something like 124A.
I made these changes:
PC2 BATT2_CURRENT_SENS ADC1 SCALE(1)
define HAL_BATT2_CURR_PIN 12
It’s strange, but when I check BATTERY_STATUS data in QGroundControl, I see the correct values for bat1 and bat2. So the issue is only when it display on OSD.
I use Plane-4.5.6 branch.
I also defined AP_BATT_MONITOR_MAX_INSTANCES to 2, but it didn’t help.
why did you edit the code? you should have been able to set the RSSI pin for voltage in the battery 2 parameters. by changing BATT2_VOLT_PIN to the RSSI pin.
Initially, I thought these configurations were used during compilation. However, I just check and found that RSSI_ADC_PIN is not actually used anywhere in the code.
This doesn’t resolve my issue, though. I still need to figure out why activating the second battery monitoring causes the OSD readings to become erratic, even though the mavlinkBATTERY_STATUS shows correct values.
P.S.
I need to edit the config file anyway to remap the BIDIR for my purposes.
I found the issue in the AP_OSD_Screen.c, it’s really a bug with OSD functionality.
In the function AP_OSD_Screen::draw_current, there is a filter that uses same average for both batteries. If they have ± the same current, it’s okay, but in my case, the current is different and the values are incorrect.
I removed the filter and get the correct values, for me it’s a temporary solution, but in case somebody will find the topic:
void AP_OSD_Screen::draw_current(uint8_t instance, uint8_t x, uint8_t y)
{
float amps;
if (!AP::battery().current_amps(amps, instance)) {
amps = 0;
}
if (amps < 10.0) {
backend->write(x, y, false, "%2.2f%c", amps, SYMBOL(SYM_AMP));
}
else {
backend->write(x, y, false, "%2.1f%c", amps, SYMBOL(SYM_AMP));
}
}