Microcontroller emulating DW01 (Battery Protection IC) - Page 1
Forum section: electronics / general

author: Leo86
author_rank: Contributor
timestamp: June 25, 2020, 07:14:29 pm
content: Hello everyone!I'm not sure if I should post this question here. Ou se deveria postar no topico (Power & Renewable Energy).I am working with a system that uses a high discharge lithium battery, this battery is being monitored by my microcontroller. The microcontroller controls the OVERCHARGE and OVER_DISCHARGE mosfets, according to the attached figure.Basically the microcotroller emulates the DW01.https://cdn.sparkfun.com/assets/learn_tutorials/2/5/1/DW01-P_DataSheet_V10.pdfHowever, when the microcontroller reads the battery voltage and detects that the battery is above 4.1V. The Mosfet Charge should shut down and stay at level "0". However, it is at level "1" and level "0" without stability.I read in the DW01 datasheet that it has a tD delay of 1s when entering the OVERCHARGE condition and 100ms in the OVERDISCHARGE condition. Should I put a delay without any criteria in my algorithm?.My code:if(vBat > 410){ // OVER-CHARGEFET_CHARGE (0);FET_DISCHARGE(1);}else if( (vBat <= 410)&&(vBat > 270) ) // NORMAL{FET_CHARGE (1);FET_DISCHARGE(1);}else if(vBat <= 270) // OVER-DISCHARGE{if(flag.statusRede){FET_CHARGE (1);FET_DISCHARGE(0);}else{FET_CHARGE (0);FET_DISCHARGE(0);stateModo = ECONOMICO;powerOff();}}*410 = 4.10VCan anybody help me?thanks!

author: jpanhalt
author_rank: Super Contributor
timestamp: June 25, 2020, 08:10:20 pm
content: You schematic is too simplified to be meaningful.What are Discharge and Charge connected to? I am assuming MCU pins.What is "Return" connected to? If not to ground, your design will not work. Please show the entire schematic that you plan. Details, like component values, are not necessary at this stage.

author: Leo86
author_rank: Contributor
timestamp: June 26, 2020, 07:15:44 pm
content: Hi jpanhalt.Follow the complete scheme.My job is basically a DC-DC converter from a lithium battery to 12V / 1A.I put two transistors to make the DW01 functionality on my microcontroller.There is a delay to be placed before triggering the MOSFET. Both in the condition of OVERCHARGER and OVERDISCHARGER, which I did not understand how to do.

author: jpanhalt
author_rank: Super Contributor
timestamp: June 26, 2020, 07:42:56 pm
content: This part doesn't make sense:A short to ground does nothing.

author: Leo86
author_rank: Contributor
timestamp: June 27, 2020, 04:43:33 am
content: Hi jpanhalt!The transistors that connect the GNDs are used to isolate or ground the 12V 18650 lithium battery that the user will use.Another use of these two transistors is to protect the battery in OVERDISCHARGE (In this condition or to allow the battery to enter the battery).And in the condition of OVERCHARGER (The transistors would only let current from the battery).As I said earlier, I want to do what the attached circuit of the DW01 does on my microcontroller.

author: sleemanj
author_rank: Super Contributor
timestamp: June 27, 2020, 05:09:54 am
content: Your code includes no hysteresisOnce overcharge is detected you should not enable charge again until some point less than the overcharge limit is reached indicating a sufficient discharge has occurred.If(charge_enabled && voltage > 4.1){charge_enabled = false;}if(! charge_enabled && voltage < 3.9){charge_enabled = true;}(potentially incomplete of course because you also want to be able to charge undercharged cells initially, additional logic left as exercise for reader)

author: Leo86
author_rank: Contributor
timestamp: July 09, 2020, 06:38:32 pm
content: My code doesn't really have a hysteresis region. This makes perfect sense when monitoring a 18650 lithium battery voltage.sleemanj, i made my own operating logic, based on your explanation. Basically I created a region where I maintain the condition of the previous situation. This region of 10mV.if(vBat > 410){ // OVER-CHARGEFET_CHARGE (0);FET_DISCHARGE(1);}else if( (vBat <= 410)&&(vBat > 400) ){// Região de Histerese de 10mV.}else if( (vBat <= 400)&&(vBat > 270) ) // NORMAL{FET_CHARGE (1);FET_DISCHARGE(1);}else if( (vBat <= 270)&&(vBat > 260) ){// Região de Histerese de 10mV.}else if(vBat <= 260) // OVER-DISCHARGE{FET_CHARGE (0);FET_DISCHARGE(0);}