I'm working on a device that would restore voltage on my collection of used 18650 cells. The theory is that they need to be charged extremely slowly with constant current of max 100mA until they are around 3V. This can take above 24 hours. To make the device cheaper I decided to create 40mA-50mA constant current source using just NE5532 opAmp it should not have any problems delivering that amount as it can provide up to 60mA.
I used Tinkercad for simulation and divided the device into two parts. On the left there is a simple DAC design using 4.7kOhm resistor, 10uF capacitor and opAmp in buffer configuration. This part works without a problem and is easily controlled by analogWrite command.
Second part is the charging circuit. There is a 1 Ohm resistor to detect voltage drop, opAmp in 100x amplifier configuration (with 2 x 10kOhm and 2 x 1MOhm resistors) with a 10uF capacitor to smooth out the error. There is a diode to prevent discharge of the battery before voltage in the device is high enough to charge it (broken cell voltage can be between 0.5V and 2.5V so a slow ramping up is required)
Everything is OK in simulation when I try to keep amperage at 10mA level. (The 18650 cell is represented as 1.5V battery) As you can see 12mA of voltage to flow into device and the amplifier turns that into 1.2V that is read by Arduino, and it stops ramping up the voltage.
But as soon as I try to set amperage to 20mA or higher this happens.
The system stabilizes at 31mA and 2V from the opAmp. At 31mA opAmp should return 3.1V. the 2V should correspond with 20mA of charge current.
The question is. Can I somehow decrease the error in 100x amplifier circuit? Is it just a behavior of the simulator, or real NE5532 will have the same issue? Should I simply fix the non linearity in the Arduino code?
Code I used:
float INITIAL_VOLTAGE_V = 1.90;
float CHARGE_AMPERAGE_A = 0.02;
int v = 0;
int a = 0;
void setup()
{
pinMode(A0, OUTPUT);
pinMode(11, OUTPUT);
v = map(INITIAL_VOLTAGE_V * 100, 0,500,0,255);
a = map(CHARGE_AMPERAGE_A * 100, 0,5,0,1024);
Serial.begin(9600);
analogWrite(11, v);
delay(1000);
}
void loop()
{
int x = analogRead(A0);
if (x < a)
v += 1;
if (v > 255)
v = 255;
analogWrite(11, v);
Serial.print(x);
Serial.print("->");
Serial.println(v);
delay(500);
}
EDIT I prepared the device schema.
After some simulation I found out that the issue is in the voltages I put into the opAmp. Tinkercad uses LM741 in it's opAmp, and I wanted to use NE5532. they both are extremely nonlinear close (around 1V) to the Vcc- and Vcc and their values are completely unreliable.
It was suggested to me to use LM358 for the feedback loop.





