Voltage sag on old batteries resetting the LH deck
Posted: Mon Feb 01, 2021 12:03 am
Hey all,
This is not as much as a problem as it is a PSA for anyone experiencing the same kind of phantom bug that I thought I had. After take off with an LH deck, the CF would drift away and crash. All logged raw angles would just repeat themselves even though the lighthouseses were in plain sign of the deck. The LH was working just fine before takeoff.
Problem was (I think!) that I was using really old (standard) batteries, the voltage sag was so great that even though the voltage was being read in the 3.8's before take off, It would drop down to below 2.55 - 2.6v, which seems to be the magic range at which there is some sort partial brown out reset on the LH deck(?)
This is not that big of a problem with new batteries because by the time the voltage sag at launch is getting close to 2.56v the low batterylight is on the CF anyway, so you would replace the battery.
But I want to avoid this problem because I am leaving the drones with non technical users for a while for a user experience study. So with the help of this post viewtopic.php?p=21340#p21340 I modified the pm.h file in the firmware to include a CRITICAL_SAG_VOLTAGE.
Then in pm_stm32f4.c I tried to make the CF shut down when the voltage dips under 2.65v But this is not 'catching it' and it still takes off. I think this is because according to the documentation "The SYSLINK_PM_BATTERY_STATE packet is sent 100 times per seconds to the STM32." Which is probably not enough time to catch this happening right? Even though the min and max voltages from my datasets were taken from log configurations with a period of 10ms...?
This is not as much as a problem as it is a PSA for anyone experiencing the same kind of phantom bug that I thought I had. After take off with an LH deck, the CF would drift away and crash. All logged raw angles would just repeat themselves even though the lighthouseses were in plain sign of the deck. The LH was working just fine before takeoff.
Problem was (I think!) that I was using really old (standard) batteries, the voltage sag was so great that even though the voltage was being read in the 3.8's before take off, It would drop down to below 2.55 - 2.6v, which seems to be the magic range at which there is some sort partial brown out reset on the LH deck(?)
This is not that big of a problem with new batteries because by the time the voltage sag at launch is getting close to 2.56v the low batterylight is on the CF anyway, so you would replace the battery.
But I want to avoid this problem because I am leaving the drones with non technical users for a while for a user experience study. So with the help of this post viewtopic.php?p=21340#p21340 I modified the pm.h file in the firmware to include a CRITICAL_SAG_VOLTAGE.
Code: Select all
#ifndef CRITICAL_SAG_VOLTAGE
#define PM_BAT_CRITICAL_SAG_VOLTAGE 2.65f
#else
#define PM_BAT_CRITICAL_SAG_VOLTAGE CRITICAL_SAG_VOLTAGE
#endif
Code: Select all
// Actions during state
switch (pmState)
{
case charged:
break;
case charging:
{
// Charge level between 0.0 and 1.0
float chargeLevel = pmBatteryChargeFromVoltage(pmGetBatteryVoltage()) / 10.0f;
ledseqSetChargeLevel(chargeLevel);
}
break;
case lowPower:
{
if (pmGetBatteryVoltage() < PM_BAT_CRITICAL_SAG_VOLTAGE)
{
pmSystemShutdown();
}
}
break;
case battery:
{
if ((commanderGetInactivityTime() > PM_SYSTEM_SHUTDOWN_TIMEOUT))
{
pmSystemShutdown();
}
if (pmGetBatteryVoltage() < PM_BAT_CRITICAL_SAG_VOLTAGE)
{
pmSystemShutdown();
}
}
break;
default:
break;
}
}
}