I noticed some weird behavior when trying to use PMIC functions get/setInputCurrentLimit. Whenever I tried to set anything over 900, it actually reported a lower value. I am using this code to test:
#include "Particle.h"
SYSTEM_MODE(MANUAL);
PMIC pmic;
int currentValues[] = { 100, 150, 500, 900, 1200, 1500, 2000, 3000 };
void setup() {
Serial.begin();
pmic.begin();
delay(2000);
Serial.print("Starting value of inputCurrentLimit: ");
Serial.println(pmic.getInputCurrentLimit());
Serial.println("");
for (int i = 0; i < sizeof(currentValues) / sizeof(int); i++) {
Serial.print("Calling setInputCurrentLimit with value: ");
Serial.println(currentValues[i]);
pmic.setInputCurrentLimit(currentValues[i]);
delay(500);
Serial.print("Calling getInputCurrentLimit.... Result: ");
Serial.println(pmic.getInputCurrentLimit());
delay(500);
Serial.println("");
}
Serial.println("Finished.");
}
void loop() { }
The results on the default 0.8.0-rc.25 and 0.9.0 are the same:
Serial monitor opened successfully:
Starting value of inputCurrentLimit: 500
Calling setInputCurrentLimit with value: 100
Calling getInputCurrentLimit.... Result: 100
Calling setInputCurrentLimit with value: 150
Calling getInputCurrentLimit.... Result: 150
Calling setInputCurrentLimit with value: 500
Calling getInputCurrentLimit.... Result: 500
Calling setInputCurrentLimit with value: 900
Calling getInputCurrentLimit.... Result: 900
Calling setInputCurrentLimit with value: 1200
Calling getInputCurrentLimit.... Result: 100
Calling setInputCurrentLimit with value: 1500
Calling getInputCurrentLimit.... Result: 150
Calling setInputCurrentLimit with value: 2000
Calling getInputCurrentLimit.... Result: 500
Calling setInputCurrentLimit with value: 3000
Calling getInputCurrentLimit.... Result: 900
Finished.
Iām not sure if this is a bug in the getter or the setterā¦ Or if we are just not āallowedā to set anything over 900 on that device and this is expected behavior? Doesnāt BQ24195 allow up to 2.5A or 3A input current? Any response would be appreciated.
I have noticed the charge current not going much over .9 - 1 Amp of charging current even when charging from a bench power supply that can supply up to 5 amps of power.
Iām sure this has to do with battery voltage drop in the battery JST Connector, thin wires, and feeding the battery through the the battery protection circuit, which all causes the PMIC charging circuit to see the battery voltage higher than it actually is which causes the charging current to drop lower as it should and does typically as the battery voltage rises as it reaches a full charge.
I reported this and experienced this same issue with the original Electron devices years back.
Really you donāt want to charge the stock 2 AH lipo at more than 1 Amp anyways but I can see why you would want to with a bigger sized battery connected.
Wiggling the JST connector during charging to get a better connection should allow you to see more or less charging current as the resistance in the circuit changes due to pressure you apply to then JST connector contacts.
Yeah, Iām currently testing with a 4000mAH battery as a trialā¦ and yes, having difficulties getting it charged at times. I have a separate board for a different project (using raspi) that has a custom LiPo charging circuit that can charge these quickly with no problem. And we arenāt using anything as nice as the BQ24195.
As I understand it from the datasheet, (maybe I mis-read) but you should be able to set the input charge current limit higher, and if the BQ24195 will enable dynamic power management (DPM) and reduce that if needed:
When input source is over-loaded, either the current exceeds the input current limit (REG00[2:0]) or the voltage
falls below the input voltage limit (REG00[6:3]). The device then reduces the charge current until the input current
falls below the input current limit and the input voltage rises above the input voltage limit.
So I feel like I should be able to set this to at least 1500 or something and the PMIC will drop the charge current down if needed due to problems with input voltage, etc.
Iām currently trying to charge with a 6v/6w voltaic solar panel at the moment so 900mA should be āOKā I suppose (have tested with a 5V/2.5A power supply which seems to charge it ok)ā¦ but it has trouble getting above around 3.95-4V. Iāve read through that LTE solar trials thread many times (on which your responses were really helpful as well), and have tried changing the input voltage as well. Always seems stuck at 3.95-4V max. So I wasnāt sure if bumping this up a bit would help, but seems to not be able to go over 900mA.
Thanks @Rftop ā yes I am referring to setInputCurrentLimit, but I have also tested increasing the setChargeCurrent value to some high option like 4096mA in conjunction with this test just to see if that mattered at all (in case the two were related), but it doesnāt seem to change anything.
Setting anything higher than 900mA seems like it actually results in a lower value being set by the PMIC.
@abatardi I also am using a similar BQ24250 charging chip for both LiPo + LiFePO4 Battery types and it works just fine and can charge at 2.2 Amps with zero problems.
@abatardi,
The PMIC will over-ride the setInputCurrentLimit if the input voltage drops out.
Thatās likely whatās happening to you. Might not be a bug after all.
Digressing from the Thread Title a bit:
Are you having issues with Solar Recharging when Sleeping?
In my Boron Solar Trial w/ EN Pin, I had to run the following during every Startup. If not, when the Solar Panel Dropped out, it wouldnāt re-start the charging:
// Li-Po Power Management:
pmic.begin();
pmic.setInputVoltageLimit(5080); // for 6V Solar Panels
pmic.setChargeVoltage(4208); // Set Li-Po charge termination voltage to 4.21V,
pmic.enableDPDM();
pmic.enableBuck(); // enableBuck required when using EN Pin Shutdown ??.
pmic.enableCharging();
[copy/paste] Once pmic.enableBuck(); was added, the daily Battery Profile became pretty boring, with no major unexpected results. The 0.5-watt Solar Panel can easily recharge the Li-Po when running a 5 minute Wake/Publish schedule. The Boron doesnāt terminate the Li-Po charge at 4.2V (SoC 100%) anymore, as with my previous tests using pmic.setChargeVoltage(4208). This isnāt necessarily a negative result, and Iām sure there is a explanation.
As you know, your panel wont produce itās max rated 930mA @ the highest InputVoltageLimit we have access to (5.080V).
So using pmic.setChargeCurrent(0,0,1,0,0,0);// 1024mA (512 + 512 offset) should do the trick.
From the serial output it looks like he is just setting new current input limits and then reading back the setting. In that case the setting should stick but itās not doing that so it does look like a bug to me.
The above tests were done just plugged into USB on a computer with a full battery connected (not charging), so I donāt think itās because itās getting overridden by the PMIC, and itās consistently reporting back invalid values immediately after calling the set function (well, 500ms delay in this example). If it were being overridden, Iād think the values it dropped to would be consistently ānearā the set max, like dropping from 1200 -> 900, not from 1200->100, and 1500->150 (every single time).
Iām not putting the boron to sleep at all during these tests, just letting it sit idle between cellular publishes. I can try to 1024mA setting, and increasing again to the 5080 max input voltageā¦ So you suggest using enableBuck as well? I will give all those a shot now. I have it in full sun at the moment so itās a good time to test.
The pmic.setInputVoltageLimit(5080) is the Minimum Voltage the PMIC will allow the source to drop to and will adjust the battery charging current so that the source Voltage does not drop below 5.080V. This is similar to a watered down MPPT. You definitely want to use this with a 6V panel.
Note: When bench testing with USB connected, this could cause you problems if your USB port can't maintain 5.x Volts. It wont be an issue when operating normally on battery + solar.
I never did fully understand enableBuck, that was old-fashioned "try-it-all" that worked for that project.
As @RWB said, If you do intend on Sleeping, you'll need to perform the PMIC adjustments every cycle.
When not sleeping, you can set this group to be performed on a schedule (say 5 minutes) if you are still having problems with Solar Re-Charging after a cloud passes over.
Iāve done some more testing. I have an INA226 voltage/current monitor measuring the input voltage/amperage on this. I wanted to stay consistent so Iām powering it with a 5V/2.5A power supply. My power supply doesnāt have quite enough voltage to hit the 5080 limit after a schottky diode drop, so I have to test this with 4840 setting onlyā¦
Iāve tested a bunch of input current settings, charge rate settings, enablebuck, enabledpdm, etcā¦ bottom line is I canāt get the current input rate above right around 245mA no matter what I do. I verified this with a meter and am getting very close to what the INA226 is reading.
4840 input voltage, no other settings = 244mA
set charge rate explicitly to 2A (just to test default), = 245mA
bump charge rate to 4A = 246mA (no change)
back to 2A charge rate, current limit increased to 900mA = 246mA
enable buck = 244mA
enable DPDM = 245mA (I noticed with this on, it sometimes changes the max input current back to 500)
disable DPDM & buck, set current limit to 100mA = 94mA
set current limit to 150mA = 139mA
So when dropping the input current max to 100 or 150, I do see the input current drop to below those levels. But curiously when set to 500 or 900, I still canāt get higher than 250mA. So Iām at a bit of a loss. Unless the INA226 is somehow restricting to 250mA, or there is something else wrong that is causing thisā¦ I canāt seem to break through that ceilingā¦
Not sure if anyone has tested, but Iād be curious to see if anyone else has been able to get a higher input current than this on a boronā¦
Now that you mention it, I looked back at some previous notes/results during Solar Testing :
310 mA was the highest I recorded, and that was using a lower InputVoltageLimit
Using pmic.setInputVoltageLimit(4840)
Actual Charging started at 5.05V, Li-Po resting at 3.83V, Current Measured w/ a ĀµCurrent GOLD
23mA @ 5.10V
42mA @ 5.15V
80mA @ 5.20V
105mA @ 5.25V
150mA @ 5.30V
200mA @ 5.40V
310mA @ 5.50V
Iāll repeat w/ pmic.setInputVoltageLimit(5080)
"Charging" LED lights at 4.25V, 2.6mA,
22mA @ 5.30V
50mA @ 5.40V
170mA @ 5.50V
240mA @ 5.60V
I was testing much smaller panels than your 6 watt at the time, so I was concentrating on the Termination Voltage of the Li-Po, not the charging current.
Maybe I should repeat a similar voltage swing for charging current with all the settings:
pmic.setInputVoltageLimit(5080); // Highest available right now, Use for 6V Solar Panels
pmic.setInputCurrentLimit(900) ; // 900 mA
pmic.setChargeVoltage(4208); // Set Li-Po charge termination voltage to 4.21V, CAUTION! not for everyone
pmic.setChargeCurrent(0,0,1,0,0,0); // 1024mA (512 + 512 offset)
pmic.enableDPDM();
pmic.enableBuck();
pmic.enableCharging();
Do you see anything that youād want me to change ?
Interesting. Iām back to a solar panel now with 5.08v input voltage and itās gone down to around 200mA, but Iām also not getting great sun right now.
The only thing is maybe not enableDPDM, as in my testing that seemed to make changes to the max input current when enabled, and sometimes drops it back to 500.
And thank you, I appreciate you looking into this alsoā¦ Iām at the point where Iām starting to feel crazy, itās either something dead simple that Iām missing, or possibly the bq24195 current registers really arenāt getting set properly by the firmware.
The input source register seems to be getting set correctly, so maybe this is just an error in the getter. When I call pmic.readInputSourceRegister, it seems to correlate to the expected values (last 3 bits):
// setting 900ma max (expect 011)
01111011
// 1200ma (expect 100)
01111100
// 3000ma (expect 111)
01111111
All these are with 5080 input voltage which is the first part (0bx1111xxx)ā¦
Reading through the BQ24195 datasheet, it shows the pre-charge/term-charge current is 256mA. So I have a suspicion I am getting dropped into one of these somehow, and not getting into āfast chargeā mode, but the āsetPreChargeCurrentā method is currently not implemented so I have no way to test this. :-/
So keep in mind, Iām supplying a Constant Voltage (5.45 V) to the USB connector with this test. The power supply has the capability to meet any current demands of the Boron LTE.
A solar panel works the opposite. It produces current.
The Boron LTE was in Manual Mode on 0.9.0. The Cell Modem was Off. The Boron was using 7 mA prior to connecting a 10,000 mAh Li-Po @ a resting voltage of 3.83V for each test.
All tests used the following:
pmic.setInputCurrentLimit(900) ; // 900 mA
pmic.setChargeVoltage(4208); // Set Li-Po charge termination voltage to 4.21V, CAUTION! not for everyone
pmic.setChargeCurrent(0,0,1,0,0,0); // 1024mA (512 + 512 offset)
I only changed the pmic.setInputVoltageLimit(x);
#1 pmic.setInputVoltageLimit(5080); // = 500 mA
#2 pmic.setInputVoltageLimit(4840); // = 460 mA
#3 pmic.setInputVoltageLimit(4200); // = 810 mA
On the last test, I checked the Voltage at the Vusb Pin, just to make sure my wiring wasnāt the limiting factor.
The Supply voltage is dropping from 5.45V at the PSU to 4.58V at Vusb during the 810 mA Charging.
Iām going to rebuild my test rig with larger & shorter wiring to eliminate that being a possibility. Iāll look for the best USB that I can find in my office.
@Rftop, Inspired by your last post, I decreased the setInputVoltageLimit to 4520, and all of a sudden I am now seeing a full amp of charging from my 5v/2.5a adapter. Switch back to 4840, it drops back down to about 250mA again. 4680 gives me around 645mA. So do you think this points to some physical problem? At 4680 voltage limit, my INA226 is reporting 4.73V, and Iām measuring 4.65V @ VUSB pin with my meter.