在电动车辆充电和放电过程中保护电池
R2026a本示例说明了如何高效地为电动汽车 (EV) 的电池进行充电和放电,并处理电池故障。便携式电子设备和电动汽车广泛采用锂离子电池作为电源,因其具有高能量密度。但锂离子电池也存在安全问题,主要是由于极端条件,如过放电、过充电、高温和低温。这些极端条件可能损坏电池,并长期影响其性能。在某些情况下,它们可能导致系统稳定性丧失,进而引发热失控。
在此示例中,两个断路器将电池的正极和负极连接到负载电路。另外两个断路器用于连接或断开充电或放电电路。基本控制策略操作这些断路器,将电池置于充电或放电模式,并在故障情况下断开电池。
模型概览
打开模型 batt_BatteryManagementSystem.slx。
clearvars
disp('Start battery plant model simulations workflow');Start battery plant model simulations workflow
% Open the model open_system('batt_BatteryManagementSystem.slx');

加载参数文件。
batt_BatteryManagementSystem_param; % Load model parameters batt_packBTMSExampleLib_param; % Load battery pack parameters
加载 LoadResistance 和 LoadCurrent 的数据以用于驱动运行。
load('batt_BatteryManagementSystem_Drive.mat');电池模组
该电池由一个 400V 的电池包组成,通常用于电动汽车。由于单个电芯无法提供这样的电压或功率水平,因此将多个电芯串联和并联,以形成所需的电池包。此例中的电池包由 10 个模组组成,每个模组有 11 个串联并联组(p 组)。每个 p 组由三个串联的电芯组成。所有模组串联在一起,形成一个由 330 个电芯组成的电池组。
要创建此示例中电池包中使用的模组,请参阅 构建带热效应的电池模组模型 示例。

打开 pack 子系统。
% Show battery Pack open_system('batt_BatteryManagementSystem/Pack','force')

模式控制仪表板
在电动汽车中,您可以控制电池的充电和放电操作。
要启动汽车,需转动钥匙,从而接通电池断路器,并将电池与汽车系统连接。
在驾驶过程中,电池处于放电模式。
当您将车辆连接到充电器时,电池处于充电模式。
在汽车中,放电模式与充电模式是相互排斥的。此示例通过在模型中实现一个名为“电池命令”的充电控制仪表板来模拟此场景。该仪表盘包含一个用于手动操作的旋转开关、一个用于自动操作的开/关开关以及指示灯。

使用旋转开关手动选择充电模式或放电模式。旋转开关的位置影响电池模式:
Off - 电池已断开连接。
Bat - 电池已连接。
Chg - 电池正在充电。
Dchg - 电池正在放电。
使用开/关开关通过将开关设置为“开”并指定 BatCmd 变量来自动在模式之间切换。当 BatCmd 变量等于:
0 - 电池已断开连接。
1 - 电池已连接。
2 - 电池正在充电。
3 - 电池正在放电。
指示灯显示电池当前的工作模式。当指示灯为红色时,特定模式处于关闭状态。当指示灯为绿色时,特定模式处于激活状态。该模型还包含用于跟踪故障出现的指示灯和用于将所有故障重置为零以进行测试的“重置”按钮。红色指示灯亮起表示存在故障。
电池管理系统
电池管理系统 (BMS) 负责管理所有电池操作,并确保其在安全运行范围内。电池管理系统 (BMS) 在充电和放电过程中,将电池组的电流、电压和温度维持在安全范围内。在此例中,BMS 根据电池包传感器数据和估计参数(如荷电状态 (SOC) 以及放电和充电电流限制)控制断路器,以保护电池包。为了控制温度,BMS 使用“开/关”流量控制模块来控制冷却液的流量。
要打开 BMS 子系统,请在 MATLAB® 命令行窗口中输入:
% Show battery BMS open_system('batt_BatteryManagementSystem/BMS','force')

此例中的 BMS 包括四个不同的组件:系统级芯片 (SOC) 功耗估计、最小最大电流限制器、热管理及电池保护逻辑。
SoC 估计
电池电量状态 (SOC) 显示电池内部剩余的电量。该值是根据许多不同参数估计得出的。估计电池的剩余电量 (SOC) 有不同的方法。此示例使用扩展卡尔曼滤波器估计策略。
要打开 SoC 估计子系统,在 MATLAB 命令行窗口中,输入:
% Show SoC estimator open_system('batt_BatteryManagementSystem/BMS/SoC Estimation','force')

电流限制器
电池的当前状态(如电池电压和温度)决定了电池的过放电和过充电电流限制,以保护电池组。例如,在放电过程中,如果温度过高,必须降低电动汽车从电池中提取的电流。如果电池电压较低,而车辆从电池中提取的电流过大,可能会损坏电池电芯,因此必须限制电流。
要打开“电流限制器”子系统,在 MATLAB 命令行窗口中,输入:
% Show Current limit calculation open_system('batt_BatteryManagementSystem/BMS/MinMax Current Limiter','force')

热控制
为了确保电池的安全运行,电池温度必须保持在规定范围内。为了控制温度,必须使用冷却液回路去除多余的热量。冷却液的流动控制着您可以从电池包中散发的热量。在此示例中,一个开/关控制模块管理冷却液回路。
如果温度高于阈值,泵将启动。当温度低于最低阈值时,泵关闭。
要打开“热管理”子系统,在 MATLAB 命令行窗口中,输入:
% Show Thermal management control open_system('batt_BatteryManagementSystem/BMS/Thermal Management','force')

电池保护逻辑
电池保护逻辑是一个状态流逻辑,它从充电控制仪表板获取电池参数、传感器数据和用户输入,以生成继电器操作信号、电池状态和电池故障分析。
要打开电池保护逻辑子系统,在 MATLAB 命令行窗口中,输入:
% Show protection stateflow open_system('batt_BatteryManagementSystem/BMS/Battery Protection Logic/State Flow' ... ,'force')

为了故障保护,一个计数器记录电流和电压故障的触发。当故障数量超过五个时,电池保护逻辑会断开电池与负载的连接,直至您重置故障计数。计数器不记录热故障。电池在首次出现热故障时断开连接。在放电过程中,如果电池的状态电量 (SOC) 低于特定阈值,保护逻辑将断开电池连接。充电过程中,若电池电量状态 (SOC) 超过上阈值,保护逻辑将电池与充电电路断开。
该流程图展示了“故障保护”状态流模块内部的逻辑。该逻辑遵循以下步骤:
电池请求 - 根据接收到的输入,将电池设置为理想模式、充电模式或放电模式。
保护 - 检查电池参数(电流、电压和温度)是否超过阈值并触发故障。
继电器操作 - 根据请求和故障状态,控制电池、充电和放电继电器。

故障仿真
电池故障通常发生在电池处于极端环境条件下时。
打开模型 batt_BatteryManagementSystem.slx。
open_system('batt_BatteryManagementSystem/','force')
电池充电过程中出现的故障
在充电模式下,电池可能出现以下故障:
过压故障 - 设备与电池不兼容,导致电池充电电压超过其额定电压。
过电流故障 - 电流超过允许的限值,导致电池充电。
充电过程中,随着电池电压和温度的升高,充电电流限制值会降低。如果电流限制值低于充电电流,充电故障触发,充电电路为保护目的与电池断开连接。在出现五次故障后,电池断路器将在仿真的其余时间内断开。
batt_BatteryManagementSystem_param; % Load Simulation parameters ChargerCC_A = 125; % charger max charging current (Ah) initialPackSOC = 0.5; % Initial SoC of the pack set to low BatCmdData=timeseries([0;0;1;1;2;2],[0;1.99;2;2.99;3;130],'Name','BatCmdData'); % Battery input for vehicle in charge at three sec batt_packBTMSExampleLib_param; % Load battery parameters with the new data sim('batt_BatteryManagementSystem.slx'); % Simulate the model %% Plot for comparison % Plot for current figure plot(logsout_batt_BatteryManagementSystem.get("CurDisp").Values,'r-'); hold on plot(logsout_batt_BatteryManagementSystem.get("<CurChgLmt>").Values ,'b-'); plot(logsout_batt_BatteryManagementSystem.get("<CurDchgLmt>").Values ,'g-'); hold off;legend("Battery pack current","Chg Cur Lmt","Dchg Cur Lmt"); xlabel("Time (s)");ylabel("Current [A]");title("Battery Pack Current");
![Figure contains an axes object. The axes object with title Battery Pack Current, xlabel Time (s), ylabel Current [A] contains 3 objects of type line. These objects represent Battery pack current, Chg Cur Lmt, Dchg Cur Lmt.](protectbatterychargeanddischargeforelectricvehicleexample_11_zh_CN.png)
%% Plot Voltage figure simlog_handles(2) = subplot(3, 1, 2); plot(logsout_batt_BatteryManagementSystem.get("<BatVolt>").Values,'b-'); legend("Battery pack voltage"); xlabel("Time (s)");ylabel("Volt [V]");title("Battery Voltage");
![Figure contains an axes object. The axes object with title Battery Voltage, xlabel Time (s), ylabel Volt [V] contains an object of type line. This object represents Battery pack voltage.](protectbatterychargeanddischargeforelectricvehicleexample_12_zh_CN.png)
对于较高的 SOC 值,电芯电压更接近满电电压。高充电电流可能导致电池过充或电池电压过高,从而触发过压故障。在发生五次故障后,电池断路器断开,仿真结束。
batt_BatteryManagementSystem_param; % Load Simulation parameters MaxVoltLmt = 4.2; % cell max voltage limit ChargerCC_A = 70; % charger max charging current initialPackSOC = 0.95; % Initial SoC of the pack set to high BatCmdData=timeseries([0;0;1;1;2;2],[0;1.99;2;2.99;3;130],'Name','BatCmdData'); % Battery input for vehicle in charge at three sec batt_packBTMSExampleLib_param; % Load battery parameters with the new data sim('batt_BatteryManagementSystem.slx'); % Simulate model %% Plot for comparison % Plot for current figure plot(logsout_batt_BatteryManagementSystem.get("CurDisp").Values,'r-'); hold on plot(logsout_batt_BatteryManagementSystem.get("<CurChgLmt>").Values ,'b-'); plot(logsout_batt_BatteryManagementSystem.get("<CurDchgLmt>").Values ,'g-'); hold off;legend("Battery pack current","Chg Cur Lmt","Dchg Cur Lmt"); xlabel("Time (s)");ylabel("Current [A]");title("Battery Pack Current");
![Figure contains an axes object. The axes object with title Battery Pack Current, xlabel Time (s), ylabel Current [A] contains 3 objects of type line. These objects represent Battery pack current, Chg Cur Lmt, Dchg Cur Lmt.](protectbatterychargeanddischargeforelectricvehicleexample_13_zh_CN.png)
%% Plot Voltage figure simlog_handles(2) = subplot(3, 1, 2); plot(logsout_batt_BatteryManagementSystem.get("<BatVolt>").Values,'b-'); legend("Battery pack voltage"); xlabel("Time (s)");ylabel("Volt [V]");title("Battery Voltage");
![Figure contains an axes object. The axes object with title Battery Voltage, xlabel Time (s), ylabel Volt [V] contains an object of type line. This object represents Battery pack voltage.](protectbatterychargeanddischargeforelectricvehicleexample_14_zh_CN.png)
电池放电过程中发生的故障
在放电模式下,电池可能出现以下故障:
欠压故障 - 电池放电电压低于其额定最欠压。
过电流故障 - 电流超过允许的限值,导致电池放电。
在放电过程中,随着电池电压的降低和电池温度的升高,放电电流限制值会逐渐减小。如果电流限制值低于放电电流,则触发放电故障。如果电芯电压低于最欠压限制,则会触发电压故障。对于上述任何故障,放电电路将与电池断开以确保安全。在出现五次故障后,电池断路器将在仿真的其余时间内断开。
batt_BatteryManagementSystem_param; % Load Simulation parameters load('batt_BatteryManagementSystem_Drive.mat') % load drive data MinVoltLmt=3.2; % battery minimum voltage limit initialPackSOC = 0.25; % Initial SoC of the pack set to low BatCmdData=timeseries([0;0;1;1;3;3],[0;1.99;2;2.99;3;130],'Name','BatCmdData'); % Battery input for vehicle in discharge at three sec batt_packBTMSExampleLib_param; % Load battery parameters with the new data sim('batt_BatteryManagementSystem.slx'); % Simulate model %% Plot for comparison % Plot for current figure plot(logsout_batt_BatteryManagementSystem.get("CurDisp").Values,'r-'); hold on plot(logsout_batt_BatteryManagementSystem.get("<CurChgLmt>").Values ,'b-'); plot(logsout_batt_BatteryManagementSystem.get("<CurDchgLmt>").Values ,'g-'); hold off;legend("Battery pack current","Chg Cur Lmt","Dchg Cur Lmt"); xlabel("Time (s)");ylabel("Current [A]");title("Battery Pack Current");
![Figure contains an axes object. The axes object with title Battery Pack Current, xlabel Time (s), ylabel Current [A] contains 3 objects of type line. These objects represent Battery pack current, Chg Cur Lmt, Dchg Cur Lmt.](protectbatterychargeanddischargeforelectricvehicleexample_15_zh_CN.png)
%% Plot Voltage figure simlog_handles(2) = subplot(3, 1, 2); plot(logsout_batt_BatteryManagementSystem.get("<BatVolt>").Values,'b-'); legend("Battery pack voltage"); xlabel("Time (s)");ylabel("Volt [V]");title("Battery Voltage");
![Figure contains an axes object. The axes object with title Battery Voltage, xlabel Time (s), ylabel Volt [V] contains an object of type line. This object represents Battery pack voltage.](protectbatterychargeanddischargeforelectricvehicleexample_16_zh_CN.png)
电池热故障
当电池温度超过安全工作范围时,热故障会触发。简单的开/关策略控制热循环中的冷却液流量,以管理电池温度。
为了仿真热故障,此示例首先关闭冷却液控制,使电池温度处于无调节状态。电池的初始温度较高。高电流会给电池充电,使其温度超过安全工作范围的值。这会触发热故障,电池断路器在剩余的仿真过程中断开。
batt_BatteryManagementSystem_param; % Load Simulation parameters % Temperature parameter to "switch on" flow for thermal control CoolantSwitchOnTp = MaxThLmt+5; % switch on temp set to 338.15 K (65 deg C) % "Switch on" temperature for coolant flow set five degrees more than the max allowed temperature for battery initialBattTemp=328.15; % Initial temperature set to high(K) - 55 deg Celsius ChargerCC_A = 75; % charger max charging current initialPackSOC = 0.5; % Initial SoC of the pack set to low BatCmdData=timeseries([0;0;1;1;2;2],[0;1.99;2;2.99;3;130],'Name','BatCmdData'); % Battery input for vehicle in charge at three sec batt_packBTMSExampleLib_param; % Load battery parameters with the new data sim('batt_BatteryManagementSystem.slx'); % Simulate the model %% Plot for comparison % Plot for current figure plot(logsout_batt_BatteryManagementSystem.get("CurDisp").Values,'r-'); hold on plot(logsout_batt_BatteryManagementSystem.get("<CurChgLmt>").Values ,'b-'); plot(logsout_batt_BatteryManagementSystem.get("<CurDchgLmt>").Values ,'g-'); hold off;legend("Battery pack current","Chg Cur Lmt","Dchg Cur Lmt"); xlabel("Time (s)");ylabel("Current [A]");title("Battery Pack Current");
![Figure contains an axes object. The axes object with title Battery Pack Current, xlabel Time (s), ylabel Current [A] contains 3 objects of type line. These objects represent Battery pack current, Chg Cur Lmt, Dchg Cur Lmt.](protectbatterychargeanddischargeforelectricvehicleexample_17_zh_CN.png)
%% Plot Voltage figure simlog_handles(2) = subplot(3, 1, 2); plot(logsout_batt_BatteryManagementSystem.get("<BatVolt>").Values,'b-'); legend("Battery pack voltage"); xlabel("Time (s)");ylabel("Volt [V]");title("Battery Voltage");
![Figure contains an axes object. The axes object with title Battery Voltage, xlabel Time (s), ylabel Volt [V] contains an object of type line. This object represents Battery pack voltage.](protectbatterychargeanddischargeforelectricvehicleexample_18_zh_CN.png)
%% Plot for Temp figure plot(logsout_batt_BatteryManagementSystem.get("<TpMax>").Values,'r-') legend("Battery pack Temp");xlabel("Time (s)");ylabel("Temp [K]"); title("Battery Temperature")
![Figure contains an axes object. The axes object with title Battery Temperature, xlabel Time (s), ylabel Temp [K] contains an object of type line. This object represents Battery pack Temp.](protectbatterychargeanddischargeforelectricvehicleexample_19_zh_CN.png)
实时仿真结果
此示例已在以下平台上进行了测试:
配备 Intel® 3.5 GHz i7 多核 CPU 和 4 GB RAM 的 Speedgoat™ Performance 实时目标计算机。
配备 Intel® Core XEON E3-1275v3 3.5 GHz 处理器和 4 GB RAM 的 dSPACE® SCALEXIO LabBox。
您可以使用 Simscape 局部求解器,以 400 微秒的步长实时运行此模型。采样率较低时,由于缓存未预热,在初始任务执行期间可能会发生任务超限。为避免此类超限,如果所选平台支持相关选项,请通过指定有限次数的任务超限或增加实时应用程序启动阶段的周期性任务采样时间来放宽启动行为。