Voltage sag on old batteries resetting the LH deck

Topics related to the Lighthouse positioning system, configuration and use
Post Reply
cafeciaojoe
Member
Posts: 83
Joined: Mon Jun 18, 2018 2:37 am

Voltage sag on old batteries resetting the LH deck

Post by cafeciaojoe »

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.

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
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...?

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;
    }
  }
}
Attachments
X axis = number of (launches, 1 sec hover, landings) before the error occured
X axis = number of (launches, 1 sec hover, landings) before the error occured
X axis = number of (launches, 1 sec hover, landings) before the error occured
X axis = number of (launches, 1 sec hover, landings) before the error occured
PhD Student
RMIT University
School of Design
http://www.cafeciaojoe.com
Image
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Voltage sag on old batteries resetting the LH deck

Post by tobias »

This is a problem that we have been looking at a bit as well. We would like to detect bad batteries, connector or cables but we are not quite there yet. As with the propeller test there is also a battery test implemented in stabilizer.c (which should be moved somewhere else). It needs more work though and I don't think the current version works at all. If I get some time over I will try to finish that implementation. Until then you could check if connecting and disconnecting the battery several times helps. I think that over time a oxide layer can build up on the connector pins which is causing even bigger voltage drops.

So to summarize I think a battery test is what you need, hopefully I have some time to look into this on Friday.
cafeciaojoe
Member
Posts: 83
Joined: Mon Jun 18, 2018 2:37 am

Re: Voltage sag on old batteries resetting the LH deck

Post by cafeciaojoe »

Ok great to hear! I would like to also add my two fixes to reduce the chances of this bug happening.

1) add the cut out voltage in the firmware. the critical sag voltage added in a previous post has been working well. somewhere between 2.65 and 2.7 catches most of the faults.

2) gradual take off of the cf. I was sending setpoints from the commander of (0,0,1) to the cf which I assume made it take off with full throtttle. gradually feeding it z position in smaller and slower increments had reduced the voltage sag and in turn the LH deck brownig out.

Cheers
PhD Student
RMIT University
School of Design
http://www.cafeciaojoe.com
Image
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Voltage sag on old batteries resetting the LH deck

Post by tobias »

Glad to here you improved the situation. I will add a github ticket to implement this but as there are other platforms, such as the bolt, the implementation needs a bit more thinking so it works for all platforms. That is why there is currently a compile flag to activate the auto shutdown functionality.

Maybe you also have seen that I pushed the battery test last week. Could you give this a try? Check this blog post. It would be great for us if that catches you bad batteries as well.

As for the solution, it might also be possible to reduce the max output power if e.g. voltage goes below say 2.7v to prevent brown out resets. Maybe this is a better solution? It would effect stability though.
cafeciaojoe
Member
Posts: 83
Joined: Mon Jun 18, 2018 2:37 am

Re: Voltage sag on old batteries resetting the LH deck

Post by cafeciaojoe »

Great, yes I did see that just had not had time to test it out! will do it next week some time and let you know.

Thank you !! :)
PhD Student
RMIT University
School of Design
http://www.cafeciaojoe.com
Image
Post Reply