-
-
Notifications
You must be signed in to change notification settings - Fork 725
Refactor and improve PMIC configuration #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Add PMIC.h and PMIC.cpp for general PMIC support in variants. * Add BQ24195.h with register addresses and definitions for BQ24195/BQ24195L devices. * Add setupPMIC function to provide consistent initialization, including: * Disable I2C watchdog timer to keep device in 'host' mode. * Disable charging when no battery present. * Disable charging system safety timer when no battery present. * Disable battery FET when no battery present. * Enable USB D+/D- on boards where they are connected to PMIC. * Enable 2A input current limit and 3.88V input voltage limit, to enable high-speed battery charging. * Update all variants with BQ24195 devices to use setupPMIC function. Results: * STAT LED no longer blinks on devices without batteries (was caused by charging system safety timer expiration). * Charging is actually disabled on boards without batteries (previously it was left as the default, which is 'enabled' in these PMICs). * Charging speed is dramatically increased (assumes 2A USB power supply is used to power board; MKR GSM 1400 previously assumed 3A power supply).
This has now been tested through multiple cycles on a MKR WiFi 1010 with a 2000mAh battery; from full charge through full discharge and back to full charge again. |
I am interested in seeing this, as I'd like to take advantage of battery stuff. What does it take to get this merged in? |
Hi @kpfleming, I was planning to use your code for increasing the charging current of an MKR WiFi 1010 to 2A as you propose. I have one concern. If I look at the schematic of the MKR WiFi 1010 provided by Arduino I see that in series with the battery connector there is a fuse (MF-FSMF050) which from datasheet can hold a max of 0.5A. As you say that you tested this code without issues, can you please help me understand what am I missing? can the current go above the 0.5A? wouldn't the fuse burn out? Thanks in advance |
It's been a while since I worked on this, but I believe that the '2A Input Current Limit" referred to is the input power from the USB connector; it's not the charging current sent to the battery. The PMIC handles battery-charging current itself, based on the battery's response, and I suspect that the battery will not accept more than 0.5A of charging current so the fuse is properly sized. |
Hi kpfleming, thank you I appreciate your feedback. I now understand. I looked at the BQ24195L datasheet and indeed you are right, there are two settings. One is for the current drawn from USB (which you modify), the other is for the max current sent to the battery. This last value is 2A by default but the Arduino changes this register to 0.5A, thus the battery, even if you draw 2A from USB, is recharged at max 0.5A. This means that maybe the statement "enable high-speed battery charging" is a bit misleading, because it only solves the issue of the reduced input current from USB (0.1 A due to D+/D- not connected to BQ24195L). You could set up a 0.5A current from USB instead of 2A and you would get the same charge time. Otherwise, you could change the register for the charging current, but then the fuse would burn... In my case this is important because I'm planning to use a large capacity battery (7800 mA/h), which would require about 15h recharge time at 0.5A, compared to about 4h at 2A. I guess I will need to replace the fuse... Thanks again! |
That's almost accurate I believe: if you set the input current limit to 0.5A, then the battery could be charged at a maximum of 0.5A minus the current being drawn by the Arduino and any devices attached to it. That's not typically a large amount of current, but it's non-zero, so should be factored into the equation. |
Good point, with Wifi it can reach even 100mA, so it must be taken into account. |
Add PMIC.h and PMIC.cpp for general PMIC support in variants.
Add BQ24195.h with register addresses and definitions for
BQ24195/BQ24195L devices.
Add setupPMIC function to provide consistent initialization,
including:
to enable high-speed battery charging.
Update all variants with BQ24195 devices to use setupPMIC function.
Results:
STAT LED no longer blinks on devices without batteries (was caused
by charging system safety timer expiration).
Charging is actually disabled on boards without batteries (previously
it was left as the default, which is 'enabled' in these PMICs).
Charging speed is dramatically increased (assumes 2A USB power supply
is used to power board; MKR GSM 1400 previously assumed 3A power supply).
Testing: