Main Content

Battery CC-CV

Constant current constant voltage charging algorithm

Since R2022b

Simscape / Battery / BMS / Current Management


This block implements a constant-current (CC), constant-voltage (CV) charging algorithm for a battery. For a discharging battery, the block uses the value of the CurrentWhenDischarging input port.

This block supports single-precision and double-precision floating-point simulation.


To enable single-precision floating-point simulation, the data type of all inputs and parameters, except for the Sample time (-1 for inherited) parameter, must be single.

You can switch between continuous and discrete implementations of the block by using the Sample time (-1 for inherited) parameter. To configure the block for continuous time, set the Sample time (-1 for inherited) parameter to 0. To configure the block for discrete time, set the Sample time (-1 for inherited) parameter to a positive, nonzero value, or to -1 to inherit the sample time from an upstream block.


Continuous-time implementation of this block works only in a double-precision floating-point simulation. If you provide single-precision floating-point parameters and inputs, this block casts them to double-precision floating-point values to prevent errors.

This diagram illustrates the overall structure of the block:


This block implements the CC-CV algorithm in constant-current and constant-voltage modes. This figure shows the operation of these modes:

This equation defines the battery reference current that the block outputs:



  • vmax is the value of the Maximum cell voltage (V) parameter.

  • vmeas is the voltage of the highest cell.

  • Kp and Ki are the values of the Controller proportional gain and Controller integral gain parameters.




expand all

Whether to enable battery charging, specified as 1 (enabled) or 0 (disabled).

Voltage of the cells, specified as a scalar for a single cell or a vector for multiple cells.

Value of the current that the battery uses for charging, specified as a scalar.

Value of the current that the battery uses for discharging, specified as a scalar.


expand all

Reference current for the battery pack, returned as a scalar.


expand all

Maximum allowable cell voltage, in volt.

Proportional gain, Kp, of the PI controller.

Integral gain, Ki, of the PI controller.

Anti-windup gain of the PI controller.

Tracking coefficient, Kt, of the PI controller.

The block feeds the difference between the tracking signal and the controller output back to the integrator input with a gain value Kt. Use this parameter to specify the gain in that feedback loop.

Signal tracking has several applications, including bumpless control transfer and avoiding windup in multiloop control structures.

Time between consecutive block executions. During execution, the block produces outputs and, if appropriate, updates its internal state. For more information, see What Is Sample Time? and Specify Sample Time.

For inherited discrete-time operation, specify this parameter as -1. For discrete-time operation, specify this parameter as a positive integer. For continuous-time operation, specify this parameter as 0.

If this block is in a masked subsystem or a variant subsystem that allows you to switch between continuous operation and discrete operation, promote the sample time parameter. Promoting the sample time parameter ensures correct switching between the continuous and discrete implementations of the block. For more information, see Promote Block Parameters on a Mask.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2022b