Battery CC-CV
Libraries:
      Simscape / 
      Battery / 
      BMS / 
      Current Management
   
Description
The Battery CC-CV 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. To implement a simpler version of the CC-CV charging algorithm with proportional control, see the CC-CV Charging (Proportional Control) block.
This block supports single-precision and double-precision floating-point simulation.
Note
To enable inherited 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.
Note
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:

Equations
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:
where
- vmax is the value of the Cell voltage threshold (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. 





