网友通过本文主要向大家介绍了高通qcom刷机工具下载,高通qcom刷机工具,高通qcom刷机,wcnss qcom cfg下载,qcom是什么意思等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
高通QCOM 8610平台电量计算
一: SOC(荷电状态)计算方法
公式:
SOC = RUC / (FCC-UUC)
名词:
</div>
术语 |
全称 |
注释 |
FCC |
Full-Charge Capacity |
满电荷电量 |
UC |
Remaining Capacity |
RC 剩余电量 |
CC |
Coulumb Counter |
电量计 |
UUC |
Unusable Capacity |
不可用电量 |
RUC |
Remaining Usable Capacity |
RUC=RC-CC-UUC,剩余可用电量 |
OCV |
Open Circuit Voltage |
开路电压,电池在开路状态下的端电压称为开路电压 |
SoC |
State of Charge |
电量百分比 |
PC |
Percentage Charge |
剩余电荷占FCC百分比 |
二:各参数计算方法:
1.FCC:根据电池温度temp通过查找表(lut)来计算
static int calculate_fcc(struct qpnp_bms_chip *chip, int batt_temp) { int fcc_uah; if (chip->adjusted_fcc_temp_lut == NULL) { // log显示,没有对温度lut进行修正; /* interpolate_fcc returns a mv value. */ fcc_uah = interpolate_fcc(chip->fcc_temp_lut, batt_temp) * 1000; // 不修正直接返回对应温度的FCC值 printk("fcc = %d uAh\n", fcc_uah); return fcc_uah; } else { return 1000 * interpolate_fcc(chip->adjusted_fcc_temp_lut, batt_temp); } }
2. RC: 依赖ocv,通过ocv计算;单位uAh
/* calculate remaining charge at the time of ocv */ static int calculate_ocv_charge(struct qpnp_bms_chip *chip, struct raw_soc_params *raw, int fcc_uah) { int ocv_uv, pc; // RAW - 存在pm?PM里读出来的未经修正的原始数据? // read_soc_params_raw -> qpnp_read_wrapper(chip, (u8 *)&raw->last_good_ocv_raw, // chip->base + BMS1_OCV_FOR_SOC_DATA0, 2); ocv_uv = raw->last_good_ocv_uv; // 1. 上次关机时存储的ocv;2. 电池新插入时会更新该值;3. 模拟电池新插入,手动更新:chip->insertion_ocv_uv;最终会更新raw->last_good_ocv_uv; pc = calculate_pc(chip, ocv_uv, chip->last_ocv_temp); // 上次ocv占FCC的百分比,受温度影响 printk("ocv_uv = %d pc = %d\n", ocv_uv, pc); return (fcc_uah * pc) / 100; } static int calculate_pc(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp) { int pc; pc = interpolate_pc(chip->pc_temp_ocv_lut, batt_temp / 10, ocv_uv / 1000); // 根据lut查找百分比 printk("pc = %u %% for ocv = %d uv batt_temp = %d\n", pc, ocv_uv, batt_temp); /* Multiply the initial FCC value by the scale factor. */ return pc; }
有时开机时的ocv和关机时的ocv(raw->last_good_ocv_raw?)差距太大就明显影响百分比计算了;
所以就需要做修正了;
3、CC:将bms电量计读值转换成uAh,coulomb counter有两种,shadow型不知道具体含义,不知是否和80x86里的影子寄存器是否为相同设计?:
/* Coulomb counter data */ #define BMS1_CC_DATA0 0x8A /* Shadow Coulomb counter data */ #define BMS1_SW_CC_DATA0 0xA8 /** * calculate_cc() - converts a hardware coulomb counter reading into uah * @chip: the bms chip pointer * @cc: the cc reading from bms h/w * @cc_type: calcualte cc from regular or shadow coulomb counter * @clear_cc: whether this function should clear the hardware counter * after reading * * Converts the 64 bit hardware coulomb counter into microamp-hour by taking * into account hardware resolution and adc errors. * * Return: the coulomb counter based charge in uAh (micro-amp hour) */ static int calculate_cc(struct qpnp_bms_chip *chip, int64_t cc, int cc_type, int clear_cc) { struct qpnp_iadc_calib calibration; struct qpnp_vadc_result result; int64_t cc_voltage_uv, cc_pvh, cc_uah, *software_counter; int rc; // chip->software_shdw_cc_uah == 0; chip->software_cc_uah == 0; software_counter = cc_type == SHDW_CC ? &chip->software_shdw_cc_uah : &chip->software_cc_uah; rc = qpnp_vadc_read(chip->vadc_dev, DIE_TEMP, &result); if (rc) { pr_err("could not read pmic die temperature: %d\n", rc); return *software_counter; } qpnp_iadc_get_gain_and_offset(chip->iadc_dev, &calibration); // 获得平台相关的增益修正参数,msm8610,msm8912; printk("%scc = %lld, die_temp = %lld\n", cc_type == SHDW_CC ? "shdw_" : "", cc, result.physical); cc_voltage_uv = cc_reading_to_uv(cc); cc_voltage_uv = cc_adjust_for_gain(cc_voltage_uv, calibration.gain_raw - calibration.offset_raw); cc_pvh = cc_uv_to_pvh(cc_voltage_uv); // 为减小cc的精度损失; cc_uah = div_s64(cc_pvh, chip->r_sense_uohm); // i = u / r;算出cc电流 rc = qpnp_iadc_comp_result(chip->iadc_dev, &cc_uah); // 根据QPNP不同版本ID,比如PM8110:QPNP_IADC_REV_ID_8110_1_0,做增益补偿 if (rc) printk("error compensation failed: %d\n", rc); if (clear_cc == RESET) { //1. calculate_state_of_charge -> calculate_soc_params中有RESET调用; // 2. load_shutdown_data(probe获取上次关机时的一些参数,比如ocv) -> recalculate_raw_soc -> recalculate_soc ->calculate_soc_params有调用(先cc、后shadow_cc