This is my first post here so hopefully no mistakes. I’ve been having a lot of trouble implementing a charge code successfully. The code that I’m using prints the values of Analogue inputs to the serial monitor. The circuit I’m using is for charging a LiFePO4 pack with a nominal voltage of 13.2V and 50AH. The Arduino uses PWM to control the charge, I have a voltage divider at the source and another at the battery which are used for comparison in the charge conditions. The code itself I reverse engineered from a Solar Charge Controller, coding is not my strong point.
I can’t seem to find why, but as soon as I switch on the source, the values at the voltage sensors are reasonably accurate but a little unstable. However they start to decrement and continue to do so. It’s very frustrating and I’m kind of stumped. I’m putting a Voltage of 14-20V at the source. The dividers provide a save voltage of between 2-3V to the analogue pins. I’m pretty sure my ADC calculations are accurate. I can’t move forward to connecting the actual batteries if I can’t get stable readings.
The code and a circuit diagram are attached. Anyone with any suggestions or with past experience of such problems please leave me some feedback.
Using a Multimeter the voltage dividers have constant and expected values.
I,m using an Arduino Uno with the Atmega328.
Charge_Control.ino (8.2 KB)