我们目前的项目在使用Bq27441EVM-G1B进行电量测量。
我们用的电池的相关信息: Lithium-ion battery(锂离子电池),3.7V,5000 mAh , 18.5 wh 。
我们使用的驱动程序是:bq27x00_battery.c 。 驱动程序链接如下
https://github.com/aneeshv/linux-bq27xxx/blob/master/drivers/power/bq27x00_battery.c
我们将驱动程序移植到我们的linux内核,
内核驱动中关于电池参数的配置代码如下:
static struct dm_reg bq274xx_dm_regs[] = {
{82, 0, 2, 5000}, /* Qmax */
{82, 5, 1, 0x81}, /* Load Select */
{82, 10, 2, 5000}, /* Design Capacity */
{82, 12, 2, 19000}, /* Design Energy */
{82, 16, 2, 3000}, /* Terminate Voltage */
{82, 27, 2, 437}, /* Taper rate */
};
通过cat 命令读取电量状态:
查看电源状态:
root@and:/sys/class/power_supply/bq274xx-0 # ls
capacity
capacity_level
charge_full
charge_full_design
charge_now
current_now
device
power
present
status
subsystem
technology
temp
type
uevent
voltage_now
root@and:/sys/class/power_supply/bq274xx-0 # cat capacity
82
root@and:/sys/class/power_supply/bq274xx-0 # cat voltage_now
4037000
root@and:/sys/class/power_supply/bq274xx-0 # cat current_now
231000
1|root@and:/sys/class/power_supply/bq274xx-0 #
其中,电压值(voltage_now)是正确的,和万用表测试结果的一致;
电流值(current_now)是正确的,和万用表测试结果的一致;
电量百分比(capacity)不正确,当电量百分比从100降到1时,电池电量只消耗了一半(因为电池放电结束时输出电压是3.0V ,充满时的电压是4.2V ,而电池百分比为1时电池输出电压是3.6V)
基于我上面的描述,请各位大侠帮忙分析,请给出宝贵建议:
1.电量百分比不正确的原因是什么?
2.Taper rate 这个参数是如何计算的?