Pmic.lock() and pmic.disableCharging() for thermal regulation

Hi I am working on development of a new device after being absent from the Particle world for a few years. I have been reading about pmic and charge management for cold weather applications on the Boron (5.7.0). Right now I have a NTC thermistor which disables charging below 33 degrees F. Something like:

 batt_temp = thermistor->readTempF() * 10;
     int hy = 50;//hysteresis 
    if (chargeOn == true && (batt_temp < (charge_cutoff_f - hy)))
    {
        chargeOn = false;
         pmic.disableCharging();
    }
    else if (chargeOn == false &&  (batt_temp > (charge_cutoff_f + hy)))
    {
        chargeOn = true;
        pmic.enableCharging();
    }

My question is about making this 'sticky'. I don't sleep the device right now and evaluate the code above every minute or so. This post talks a little about how to do this but is a few years old. A few questions:

  1. Do I use pmic.lock() or PMIC pmic(true) or something else?
  2. How do I make this sticky for a long time?
  3. Right now I use pmic.lock() and plugging the Boron into a charger with battery eventually causes the LED to flash green and the device to be not connected anymore. - I have a feeling it has to do with calling lock(). Maybe the solution is to create a power config with .batteryChargeCurrent(0) instead?

I know there are lots of use cases out there but nobody wants to break their battery. I think it could really great to have the option to just tell the power configuration a pin for a simple NTC thermistor input or feed a temperature variable to the power configuration somewhere. I am actually surprised something like this isn't supported from a liability perspective.

The PMIC charging setting will be overwritten by the system unless you disable power management, but you can change it in the system power manager instead. This is from Tracker Edge, which manages charging itself based on its thermistor.

int Tracker::pmicEnableCharging() {
    auto powerConfig = System.getPowerConfiguration();
    if (powerConfig.isFeatureSet(SystemPowerFeature::DISABLE_CHARGING)) {
        powerConfig.clearFeature(SystemPowerFeature::DISABLE_CHARGING);
        return System.setPowerConfiguration(powerConfig);
    }

    return SYSTEM_ERROR_NONE;
}

int Tracker::pmicDisableCharging() {
    auto powerConfig = System.getPowerConfiguration();
    if (!powerConfig.isFeatureSet(SystemPowerFeature::DISABLE_CHARGING)) {
        powerConfig.feature(SystemPowerFeature::DISABLE_CHARGING);
        return System.setPowerConfiguration(powerConfig);
    }

    return SYSTEM_ERROR_NONE;
}

The reason you can't just connect a thermistor is that the bq24195 PMIC doesn't have the ability to turn off temperature charge control in software. When the Electron first came out (the first device with that PMIC), the LiPo packs with built-in thermistors weren't as common, and other vendors like Adafruit and Sparkfun used the non-sensor packs with 2-pin JST-PH connectors so we did the same.

Since the PMIC doesn't have the ability to turn temperature sensing on and off, the only way is to make sure the TS pin is of the correct voltage to allow charging. We put a fixed voltage divider to force charging to always stay on. Once you do this, there is no combination of resistors that could also make it work with or without a real thermistor, and it would require a switch or trace cut or something, which we did not do.

Some newer devices like the Monitor One use a 3-pin LiPo with a temperature sensor, and some future devices may both require a sensor battery and use the PMIC TS pin. Because the Monitor One uses the Tracker SoM, and the Tracker SoM TS pin has the force on voltage divider, it can't use the PMIC temperature sensor.

I just found this:

Maybe this is what I want but how would I re enable charging after calling conf.feature(SystemPowerFeature::DISABLE_CHARGING);?

Thanks for the background and code. I will try this out and see how it works.
Yes - I have one of those Electron's which has been running continuously in a remote location for many years. Still working great.

To test I defined:

 void enableCharging()
 {
       auto powerConfig = System.getPowerConfiguration();
    if (powerConfig.isFeatureSet(SystemPowerFeature::DISABLE_CHARGING)) {
        powerConfig.clearFeature(SystemPowerFeature::DISABLE_CHARGING);
        System.setPowerConfiguration(powerConfig);
    }


 }
void disableCharging()
{
     auto powerConfig = System.getPowerConfiguration();
    if (!powerConfig.isFeatureSet(SystemPowerFeature::DISABLE_CHARGING)) {
        powerConfig.feature(SystemPowerFeature::DISABLE_CHARGING);
        System.setPowerConfiguration(powerConfig);
    }
}

Then I check the temp with:

void check_batt_temp()
{
    batt_temp = thermistor->readTempF() * 10;
     int hy = 50;//hysteresis 
    if (chargeOn == true && (batt_temp < (charge_cutoff_f - hy)))
    {
        chargeOn = false;
         disableCharging();
        Particle.publish("chg","disabled");
    }
    else if (chargeOn == false &&  (batt_temp > (charge_cutoff_f + hy)))
    {
        chargeOn = true;
       enableCharging();
        Particle.publish("chg","enabled");
    }
}

Seems to be working well. Thanks again.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.