# CC and CV mode implementation

#### Ravenghost

Joined Mar 17, 2016
2
I'm working on a project where i need to charge multiple li-ion cells. I'm thinking of buck converter circuit powered by ac-dc 24V 1A wall adapter and controlled by Atmega328P MC PWM. I've covered theory behind li-ion battery charging, buck converters, PWM. I believe constant voltage mode implementation is quite straight forward. A simple voltage divider to get feedback voltage to ADC and Rsense resistor with current sense amp to ADC adjusting PWM duty cycle to keep stable voltage while checking current drop to 10% to cut off power(correct me if i'm wrong about this). But i'm unsure how to approach constant current mode.

#### ronv

Joined Nov 12, 2008
3,770
I'm working on a project where i need to charge multiple li-ion cells. I'm thinking of buck converter circuit powered by ac-dc 24V 1A wall adapter and controlled by Atmega328P MC PWM. I've covered theory behind li-ion battery charging, buck converters, PWM. I believe constant voltage mode implementation is quite straight forward. A simple voltage divider to get feedback voltage to ADC and Rsense resistor with current sense amp to ADC adjusting PWM duty cycle to keep stable voltage while checking current drop to 10% to cut off power(correct me if i'm wrong about this). But i'm unsure how to approach constant current mode.
You can use the same Rsense resistor to limit the current during the initial charge

#### Ravenghost

Joined Mar 17, 2016
2
You can use the same Rsense resistor to limit the current during the initial charge
How can i limit current with Rsense resistor?

#### ronv

Joined Nov 12, 2008
3,770

#### GopherT

Joined Nov 23, 2012
8,009
How can i limit current with Rsense resistor?
You know the resistance, then if you measure the voltage drop across the resistor with your ADC, you can calculate the current = V/R. Then use PWM to control current.

#### SLK001

Joined Nov 29, 2011
1,549
You limit the current the same way you limit the voltage, only you get your sense from a resistor. "OR" the current control to the voltage control.