BMT(battery management task)

2023-10-24 19:10
文章标签 management task battery bmt

本文主要是介绍BMT(battery management task),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

BMT(battery management task)模块主要包含 ADC management,charging control和 BMT customization等相关内容。 

BMT模块软件架构

 脉冲充电硬件原理图如下:

charging control 主要阶段的电池电压和充电电流情况如下:

BMT状态转换图如下:

BMT模块客制化

const bmt_customized_struct bmt_charging_para =
{
#if !defined(BMT_CHARGING_DISABLE)		
#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
(kal_int32)CHR_VCHARGER_HV_HIGH, /* kal_int32 VCHARGER_HIGH */
#else(kal_int32)CHR_VCHARGER_HW_HIGH, /* HW HV*/
#endif(kal_int32)CHR_VCHARGER_HIGH, /* SW HV */(kal_int32)CHR_VCHARGER_LOW, /* kal_int32 VCHARGER_LOW */(kal_int32)CHR_ICHARGE_ON_HIGH, /* kal_int32 ICHARGE_ON_HIGH */(kal_int32)CHR_ICHARGE_ON_LOW, /* kal_int32 ICHARGE_ON_LOW */(kal_int32)CHR_ICHARGE_OFF_HIGH, /* kal_int32 ICHARGE_OFF_HIGH */(kal_int32)CHR_V_PRE2FAST_THRES, /* kal_int32 V_PRE2FAST_THRES */ (kal_int32)CHR_V_PRE2FULL_THRES, /*kal_int32 CHR_V_PRE2FULL_THRES */(kal_int32)CHR_FAST_ICHARGE_HIGHLEVEL, /* kal_int32 FAST_ICHARGE_HIGHLEVEL */(kal_int32)CHR_FAST_ICHARGE_LOWLEVEL, /* kal_int32 FAST_ICHARGE_LOWLEVEL */(kal_int32)CHR_I_TOPOFF2FAST_THRES, /* kal_int32 I_TOPOFF2FAST_THRES */(kal_int32)CHR_I_TOPOFF2FULL_THRES, /* kal_int32 I_TOPOFF2FULL_THRES */#if defined(LINEAR_LI_CHARGING) || defined(PULSE_LI_CHARGING)  (kal_int32)CHR_V_FAST2TOPOFF_THRES_LI, /* kal_int32 V_FAST2TOPOFF_THRES */(kal_int32)CHR_V_FULL2FAST_THRES_LI, /* kal_int32 V_FULL2FAST_THRES */(kal_int32)CHR_MAX_VBAT_LI, /* kal_int32 MAX_VBAT_LI */(kal_int32)CHR_V_PROTECT_HIGH_LI, /* kal_int32 V_PROTECT_HIGH_LI */(kal_int32)CHR_V_PROTECT_LOW_LI, /* kal_int32 V_PROTECT_LOW_LI */
#endif
#if defined(LINEAR_NIMH_CHARGING) || defined(PULSE_NIMH_CHARGING)  (kal_int32)CHR_V_TEMP_FAST2FULL_THRES_NI, /* kal_int32 V_TEMP_FAST2FULL_THRES_NI */(kal_int32)CHR_V_FULL2FAST_THRES_NI, /* kal_int32 V_FULL2FAST_THRES_NI */(kal_int32)CHR_MAX_VBAT_NI, /* kal_int32 MAX_VBAT_NI */
#endif /* PRE CHARGE ,search table */(kal_uint32)PRE_TON_TIME, /* kal_uint32 PRE_TON */ (kal_uint32)PRE_TOFF_TIME, /*  kal_uint32 PRE_TOFF *//* FAST CHARGE, search table */(kal_uint32)TOPOFF_TON_TIME, /* kal_uint32 TOPOFF_TON */(kal_uint32)TOPOFF_TOFF_TIME, /* kal_uint32 TOPOFF_TOFF */#if defined(PULSE_LI_CHARGING) || defined(PULSE_NIMH_CHARGING)   (kal_uint32)PULSE_POSTFULL_TWAIT_TIME, /* kal_uint32 BATPOSTFULL_TWAIT_LI */(kal_uint32)PULSE_POSTFULL_TON_TIME, /* kal_uint32 BATPOSTFULL_TON_LI */(kal_uint32)PULSE_POSTFULL_TOFF_TIME, /* kal_uint32 BATPOSTFULL_TOFF_LI */
#endif 
#if defined(LINEAR_LI_CHARGING) || defined(PULSE_LI_CHARGING)  (kal_uint32)BATFULL_TON_TIME_LI, /* kal_uint32 BATFULL_TON_LI */(kal_uint32)BATFULL_TOFF_TIME_LI, /* kal_uint32 BATFULL_TOFF_LI */
#else(kal_uint32)BATFULL_TON_TIME_NI;  /* unit : second */(kal_uint32)BATFULL_TOFF_TIME_NI;
#endif    (kal_uint32)CHR_STOP_TOFF_TIME, /* kal_uint32 BATFULL_TOFF */(kal_uint32)BATHOLD_TOFF_TIME, /* kal_uint32 BATHOLD_OFF *///  kal_int32 CurrOffset[3];//{CURRENT_OFFSET_IDLE_MODE, // 100maCURRENT_OFFSET_TALK_MODE,CURRENT_OFFSET_SWOFF_MODE,//},   (kal_uint32)TOTAL_CHARGE_TIME,//  kal_uint8 TONOFFTABLE[6][2];   //{(kal_uint8)FAST_ICHARGE_HI_NORMAL_ON,     (kal_uint8)FAST_ICHARGE_HI_NORMAL_OFF,(kal_uint8)FAST_ICHARGE_MID_NORMAL_ON,    (kal_uint8)FAST_ICHARGE_MID_NORMAL_OFF,(kal_uint8)FAST_ICHARGE_LO_NORMAL_ON,     (kal_uint8)FAST_ICHARGE_LO_NORMAL_OFF,(kal_uint8)FAST_ICHARGE_HI_TALK_ON,       (kal_uint8)FAST_ICHARGE_HI_TALK_OFF,(kal_uint8)FAST_ICHARGE_MID_TALK_ON,      (kal_uint8)FAST_ICHARGE_MID_TALK_OFF,(kal_uint8)FAST_ICHARGE_LO_TALK_ON,       (kal_uint8)FAST_ICHARGE_LO_TALK_OFF,//},#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)//kal_int32 HIGH_VCHG_TABLE[VCHG_VOL_LEVEL][VCHG_PARAMTER_COUNT];//{HIGH_V_VCHG_THRESHHOLD_LEVEL_0, HIGH_V_CHARGING_CURRENT_LEVEL_0, HIGH_V_SAFETY_TIME_LEVEL_0,HIGH_V_VCHG_THRESHHOLD_LEVEL_1, HIGH_V_CHARGING_CURRENT_LEVEL_1, HIGH_V_SAFETY_TIME_LEVEL_1,HIGH_V_VCHG_THRESHHOLD_LEVEL_2, HIGH_V_CHARGING_CURRENT_LEVEL_2, HIGH_V_SAFETY_TIME_LEVEL_2,HIGH_V_VCHG_THRESHHOLD_LEVEL_3, HIGH_V_CHARGING_CURRENT_LEVEL_3, HIGH_V_SAFETY_TIME_LEVEL_3,HIGH_V_VCHG_THRESHHOLD_LEVEL_4, HIGH_V_CHARGING_CURRENT_LEVEL_4, HIGH_V_SAFETY_TIME_LEVEL_4,		  HIGH_V_VCHG_THRESHHOLD_LEVEL_5, HIGH_V_CHARGING_CURRENT_LEVEL_5, HIGH_V_SAFETY_TIME_LEVEL_5,HIGH_V_VCHG_THRESHHOLD_LEVEL_6, HIGH_V_CHARGING_CURRENT_LEVEL_6, HIGH_V_SAFETY_TIME_LEVEL_6,//},
#endif(kal_bool)CHR_BATTERY_TYPE,(kal_bool)CHR_CHECK_CHARGER_VOLTAGE,(kal_bool)CHR_CHECK_BATT_TEMP,#endif //#if !defined(BMT_CHARGING_DISABLE)    (kal_bool)CHR_CHECK_BATTERY,(kal_uint32)CHR_BATT_EXIST_ADC_THRESHOLD /* kal_uint32 BATT_EXIST_ADC_THRESHOLD */
};

常用客制化参量如下:

 充电电流如何设置

充电过程中只有Fast charge(CC)阶段的充电电流是可以通过软件设定的,Pre-charge阶段充电电流是由硬件决定的,一般USB充电时预充电流为70mA,AC充电时预充电流为200mA。TOP-OFF(CV)阶段的充电电流是不断下降的,默认在ICHG<120mA时进入Charger Complete阶段。

CC阶段充电电流的设置可通过修改chr_parameter.h文件中的宏:

// Configuration of AC/USB Charge Current
#define CHR_AC_CHARGE_CURRENT           PMU_CHARGE_CURRENT_450_00_MA
#define CHR_USB_CHARGE_CURRENT          PMU_CHARGE_CURRENT_450_00_MA
#define CHR_NON_AC_CHARGE_CURRENT        PMU_CHARGE_CURRENT_450_00_MA
#define CHR_USB_CHARGING_HOST_CHARGE_CURRENT PMU_CHARGE_CURRENT_450_00_MA

或直接在hal\peripheral\src\bmt_utility.c文件的void bmt_set_chr_current(void)函数中设置:

void bmt_set_chr_current(void)
{ kal_uint32 chr_current = PMU_CHARGE_CURRENT_0_00_MA;CHR_DET_TYPE_ENUM chr_type;chr_type = bmt_get_chr_type();switch (chr_type){case PW_AC_CHR:chr_current = CHR_AC_CHARGE_CURRENT;//修改CC电流drv_trace0(TRACE_GROUP_10, BMT_SET_AC_CHARGE_CURRENT_TRC);  break;case PW_USB_CHR:chr_current = bmt_usb_chr_current;//修改成USB电流drv_trace0(TRACE_GROUP_10, BMT_SET_USB_CHARGE_CURRENT_TRC);               break;case PW_AC_NON_STD_CHR:chr_current = CHR_NON_AC_CHARGE_CURRENT;break;	case PW_USB_CHARGING_HOST_CHR:chr_current = CHR_USB_CHARGING_HOST_CHARGE_CURRENT;break;default:ASSERT(0);break;}

通过宏设置的充电电流与实际设置下去的充电电流关系是:

实际设置下去的充电电流是通过hal\peripheral\src\bmt_internal_chr_setting.c中的bmt_find_and_set_the_nearest_current(void *data)函数从hal\peripheral\src\bmt_hw.c中chr_CS_VTH[CS_VTH_SIZE] 表里搜索的与通过宏设置的最接近的那一档。

static DCL_STATUS bmt_find_and_set_the_nearest_current(void *data)
{DCL_STATUS status = STATUS_OK;DCL_UINT32 set_chr_current;DCL_UINT32 array_size;DCL_UINT16 register_value;array_size = GETARRAYNUM(chr_CS_VTH);set_chr_current = bmt_find_closest_level(chr_CS_VTH, array_size, *(DCL_UINT32 *)data);register_value = bmt_parameter_to_value(chr_CS_VTH, array_size ,set_chr_current);status = bmt_set_register_value(RG_CS_VTH_OFFSET,RG_CS_VTH_MASK,register_value<<RG_CS_VTH_SHIFT);return status;
}
const DCL_UINT32 chr_CS_VTH[CS_VTH_SIZE]=
{PMU_CHARGE_CURRENT_1600_00_MA,  PMU_CHARGE_CURRENT_1500_00_MA,PMU_CHARGE_CURRENT_1400_00_MA,  PMU_CHARGE_CURRENT_1300_00_MA,PMU_CHARGE_CURRENT_1200_00_MA,  PMU_CHARGE_CURRENT_1100_00_MA,PMU_CHARGE_CURRENT_1000_00_MA,  PMU_CHARGE_CURRENT_900_00_MA,PMU_CHARGE_CURRENT_800_00_MA,   PMU_CHARGE_CURRENT_700_00_MA,PMU_CHARGE_CURRENT_600_00_MA,   PMU_CHARGE_CURRENT_500_00_MA,PMU_CHARGE_CURRENT_400_00_MA,   PMU_CHARGE_CURRENT_300_00_MA,PMU_CHARGE_CURRENT_200_00_MA,   PMU_CHARGE_CURRENT_70_00_MA
};

停充电流是在chr_parameter.h文件中通过如下宏设置的:

#define  CHR_I_TOPOFF2FULL_THRES         120000

 此值最小只能设置为60mA,否则充电电流会波动比较大。

电池检测

如果引脚BAT_ON>2.5V,充电器将立即关闭。 这个功能是用来阻止充电器的输入,以防止电线意外被取下。 在充电过程中,电池断开可能导致VBAT电压浪涌,在启动过压保护之前损坏芯片。

电池是否存在的检测接口函数是:

kal_bool bmt_is_bat_on()
{if(bmt_charging_para->bmt_check_battery){return bmt_is_bat_on_pw();}else{return bmt_check_if_bat_on();}
}

首先要将chr_parameter.h文件中的宏CHR_CHECK_BATTERY设置为KAL_TRUE。 

电池温度测量与过热保护 

 温度检测并不是实际去检测温度,而是实时检测BAT_ON引脚的电压而感知温度 BAT_ON Voltage = 2.8V*RNTC/(R1+RNTC) 当温度变化,RNTC变化,BAT_ON引脚电压变化,BB通过电压变化感知温度变化。

注意: 1.在不使用电池充电检测功能时,BAT_ON pin需下拉10K电阻到GND。 2.电路图中R2是为了防止不当的电池设置(BATID pin 直接接电池 GND,中间未加电阻,即没有RNTC)造成在插电池瞬间,可能产生的VRTC电压不稳定,需保留。 3.若电池温度检测功能未使用,请不要把BATID pin接到Base Band。

弹出充电完成提示后为什么ISENSE还有电流

充电完成的判断条件是在CV状态下检测到充电电流小于chr_parameter.h中的设定值:

#define  CHR_I_TOPOFF2FULL_THRES         120000

 从BMT转换图中可见当VBAT>4.05V时会跳转到CV状态,在CV状态下充电电流不断下降,当充电电流小于120mA时,充电状态跳转到CHR_BATFULL,Show Charger Complete,然后向上层发送充电完成消息BMT_CHARGE_COMPLETE,并启动30分钟定时器BMT_STOP_CHARGE_TIMER,接着会在CHR_BATFULL状态下继续涓流充电30分钟才完全切断充电流程。

static void BMT_CHRTOPOFF_OFF(BATPHYStruct *BATPHYS)
{drv_trace0(TRACE_STATE, BMT_CHRTOPOFF_OFF_STATE_TRC);if(bmt_get_chr_cv_det() || (BATPHYS->VBAT >= 4200000)){BATFULL_index++;}if(BATFULL_index == 6 ){// change state to post fullBMT.bat_state = CHR_POSTFULL;drv_trace0(TRACE_GROUP_10, BMT_CHR_POSTFULL_CHANGE_TRC);/*30min*/bmt_set_timer(BMT_STOP_CHARGE_TIMER,STOPTIMER_TIMEOUT_TICK);bmt_sendMes2UEM(BMT_CHARGE_COMPLETE);bmt_timer_config(bmt_charging_para.BATPOSTFULL_TWAIT_LI*KAL_TICKS_1_SEC); //wait 90 seconds, then check the vbat at BMT_CHRBATFULL_OFFBATFULL_index = 0; //reset the index, recount the percentage again.return;}bmt_CtrlCharge((kal_uint8)KAL_TRUE);bmt_timer_config(bmt_charging_para.TOPOFF_TON*CHARGING_TIME_UNIT);
}

 定时器的设置是在:

#define STOPTIMER_TIMEOUT_TICK	 (KAL_TICKS_1_MIN*30)

有关Vcharger 能够识别的高压和低压值

// For V Charge check, turn on by CHR_CHECK_CHARGER_VOLTAGE = KAL_TRUE
#define CHR_VCHARGER_HW_HIGH            PMU_VOLT_07_000000_V
#define CHR_VCHARGER_HIGH               6500000
#define CHR_VCHARGER_LOW                0

chr_parameter.h中的CHR_VCHARGER_HW_HIGH设置的是硬件检测的充电高压,CHR_VCHARGER_HIGH是软件检测的充电高压,CHR_VCHARGER_LOW 目前代码中没有实际用到,是在寄存器CHR_COO[11:8]RG_VCDT_LV_VTH中设置的(具体参考datasheet)。

这篇关于BMT(battery management task)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/277192

相关文章

安装SQL2005后SQL Server Management Studio 没有出来的解决方案

一种情况,在安装 sqlServer2005 时 居然出现两个警告: 1 Com+ 目录要求 2 Edition change check 郁闷!网上说出现两个警告,是肯定装不成功的!我抱着侥幸的态度试了下,成功了。 安装成功后,正准备 “ 仅工具、联机丛书和示例(T)” 但是安装不了,他提示我“工作站组件”安装过了对现有组件无法更新或升级。 解决办法: 1 打开“控

SIGMOD-24概览Part7: Industry Session (Graph Data Management)

👇BG3: A Cost Effective and I/O Efficient Graph Database in ByteDance 🏛机构:字节 ➡️领域: Information systems → Data management systemsStorage management 📚摘要:介绍了字节新提出的ByteGraph 3.0(BG3)模型,用来处理大规模图结构数据 背景

兔子--Android Studio出现错误:Error:Execution failed for task ':myapp:dexDebug'. com.android.ide.common.pro

重点在:finished with non-zero exit value 2. 这里表明了有重复的内容存在。 由于:Android Studio中引入包的方式有如下2种:    compile 'com.android.support:support-v4:22.0.0'    compile files('libs/support-v

Android 接收系统广播,开机启动Service,SMS,Battery

本文内容摘自《疯狂Android讲义 第3版》李刚 著 自动开启的Service: package shortcut.song.com.myapplication;import android.app.Service;import android.content.Intent;import android.os.Binder;import android.os.IBinder;im

【SqlServer】SQL Server Management Studio (SSMS) 下载、安装、配置使用及卸载——保姆级教程

超详细的 SQL Server Management Studio (SSMS) 下载、安装、连接数据库配置及卸载教程 SQL Server Management Studio (SSMS) 是微软提供的图形化管理工具,主要用于连接、管理和开发 SQL Server 数据库。以下是详细的 SSMS 下载、安装、连接数据库以及卸载的完整教程。 一、SSMS 下载与安装 1.1 下载 SSM

深入理解.NET 中的 Task 和 Task.WhenAll

一、Task 的原理         Task 代表一个异步操作。它允许你在不阻塞主线程的情况下执行耗时的操作,如文件读取、网络请求等。 异步执行 当你调用一个异步方法时,它会立即返回一个 Task 对象。这个 Task 对象表示正在进行的异步操作。异步方法会在后台线程上执行,而不会阻塞调用它的线程。例如,使用 Task.Run(() => { /* 耗时操作 */ }); 可以在一个新的线

Linux的进程,线程以及调度(fork与僵尸,内存泄漏,task结构体,停止状态与作业控制)

1.Linux进程生命周期(就绪、运行、睡眠、停止、僵死) 2.僵尸是个什么鬼? 3.停止状态与作业控制,cpulimit 4.内存泄漏的真实含义 5.task_struct以及task_

swoole http服务器task投递异步任务

官网的task案例代码是在tcp服务器中写的,本人在想,http服务器也是server服务器中的一种,应该也可以投递task任务。 一个简单的http服务器代码:    $server = new Swoole\Http\Server('127.0.0.1',8888);$server->on('request',function($request, $response) use($serv

Linux操作系统学习笔记(五)进程的核心——task_truct

一. 前言   在前文中,我们分析了内核启动的整个过程以及系统调用的过程,从本文开始我们会介绍Linux系统各个重要的组成部分。这一切就从进程和线程开始,在 Linux 里面,无论是进程,还是线程,到了内核里面,我们统一都叫任务(Task),由一个统一的结构 task_struct 进行管理。这个结构非常复杂,本文将细细分析task_struct结构。主要分析顺序会按照该架构体中的成员变量和函数

transformer之预训练task小析(五)

上接transformer预训练task之小析(四)      首先思考一个问题,怎么表示掌握了一门语言?      最好的方式可能体现在遣词造句上吧,比如饱受诟病的八股文上有很多的旷世奇作[1],比如很多读起来朗朗上口的👇 天对地,雨对风。大陆对长空。山花对海树,赤日对苍穹。雷隐隐,雾蒙蒙。日下对天中。风高秋月白,雨霁晚霞红。牛女二星河左右,参商两曜斗西东。十月塞边,飒飒寒霜惊