For a university Lab course i have to realize a UPS unit with a internal LiPo battery . The unit is composed by:uses as battery charger a buck converter
- AC/DC converter: its output is simulated by a 4-AA battery pack for safety reason
- Battery Charger: which is realized with a Buck Converter
- LiPo battery 3.7V 50mAh
- Inverter: which is realized with a H-bridge that operates ad DC/AC converter by modulating the PWM signal that drive the component
I do all the code and it works pretty well. I have only a problem with the battery charger (buck converter). Few weeks before i verify the code and it works without problem. Now i can notice that the analog value that i read are floating too much and this represents a problem for the Constant Current (CC) and Constant Voltage (CV) phases of the battery charge process.
I found that this problem happens when plug arduino into the USB port of the computer after after i have started the PC, while it doesn't happen when i plug the USB cable of arduino and then start the PC. It seems to be a problem with the ground of arduino.
I'm using one arduino, on which i have uploaded the code of the UPS, and a second arduino to verify the output of the UPS unit (output of the internal inverter). I verify that the problemcircuit scheme is not connected to the Inverter or other component of the UPS since i try the battery charger alonefollowing one:

and what i can still have the voltage floating.obtain is that:
I make the circuit on tinkercad, with the same topology thatas you can see i have realized on the breadboard. The valuea strange increase of all the components are:
- 10Ohm Resistor: connected between the inductance and the Lipo Battery. It's placed here only to measure the charging current (I calculate the charging current as: resistor_voltage - battery_voltage/10.00) and regulate it with the modulation of the dutycycle of the PWM signal that drive the Pmos of the buck converter during the CC phase.
- Two 4.7kOhm Resistor uses to read the voltage of the network (output of the 4AA battery pack). I read the voltage at the central node of the voltage divider and then i multiply the read value for a factor 2
- The capacitor of the buck converter that is in parallel with the Lipo Battery is 2200uF
- The inductance of the buck converter is 18mH
- The output capacitance are 470uF
- The output resistor is 50Ohm
noticevoltage that the 9V battery representsi read with the LiPo batteryanalog pin of 3arduino.7V (on tinkercad there's no a rechargeable battery model) The code is correct since before this week it works well, but if necessary i will upload it.
I also read the value on one side of the output10Ohm resistor with the same arduino on which i have uploaded the total code ofis placed in the UPSbuck converter only to apply a reaction and give the correct value ofmeasure the output chargin current that i calculate as:
charging_current=(3V peakanalogRead(A1)-peakanalogRead(A2) while the battery goes down)*5.00/1023.00
If necessary i will upload allThe battery must be charged at constant current equal to 50mA until the codebattery voltage became equal to 4.10V, but i'm sureafter that it is correct... The two arduinos are connected trought USB cable onvalue the same laptop..battery must be charged at constant voltage equal to 4. i can't understand where is20V until the problem..charging current became smaller than 10/5mA. it seems to be connected
Notice that i try also to make more acquisition for each voltage: i made 8 measurement and then i calculate the ground...average value, but the result doesn't change.

