So I have built a small battery capacity tester for button batteries with an Arduino nano a Nextion display and some N-Channel MOSFETs and opamps, but I am having some problems.
To build the project I followed this other project: https://www.instructables.com/Battery-Capacity-Tester-Using-Arduino-Lithium-NiMH/.
So I designed the following PCB:
For the moment I have just checked that nothing is burning up and that the Arduino is reading voltages correctly. So, what is acting weird in the circuit, is that if I place the batteries on the holders, the voltage lectures are correct, same as with the tester. But, when I remove the batteries the voltage on battery 2 and battery 3 remains as if the battery was still there, and the tester shows the same reading. What is the reason for this happening? How could I solve this?
As always, if you build something from destructables, you must know more than the author.
Couple of things I would have done differently.
R1,R2 could have been omitted if the code had used internal pull up.
pinMode (A2, INPUT_PULLUP);
R4 shouldn't have a ground connection.
pin A0 could burn out if a battery is connected before board power is connected.
Must use a (4k7) resistor between battery(+) and C6 to keep fault current below 1mA.
Battery connector must have a (1Megohm) resistor across to drain leakage currents.
(a better way would have been a high resistor value voltage divider and 1.1volt Aref)
The LM358 is not a rail2rail opamp, and won't output >3.75volt on a 5volt supply.
That's borderline for the non-logic level fet used (maybe de author got lucky).
That's the hardware part. Didn't even look at the code yet.
Leo..
Wondering how you figured all this out. Did you actually go to the original project cited because it sure ain't in any way evident from this posting here?
please note the two capacitors from A0 to ground!
Also if the battery is removed and the FET is off the inputs are floating and as @DVDdoug says you need a resistor to ground; and as @Wawa says you also need protection for the analog inputs.
It's poor. The hardware is actually the better part of the project, and not too bad honestly. I've seen much worse. Your remark #3 is important though.
As to #4: I see what you mean, but it'll work with these component parts as long as discharge currents below 750mA are targeted, which the original project does. However, the authors mention reducing R7 in value if higher currents are desired, and that likely won't work very well due to the limitation you mentioned.
Yeah, which made me wonder if the 1000uF one is really needed. But it doesn't hurt either - provided the safety error @Wawa mentioned is dealt with.
The project in itself should work OK but has room for several improvements. In the code I really don't like the fact that there is no provision for stopping the discharge process; i.e. it's effectively being deep-cycled which permanently affects the performance of a Li-Ion cell in a negative way. I'd call this circuit an 'artificial Lio-Ion battery ager/destroyer'.
Forgot to add that.
Not needed, and not wanted.
If you remove project supply then the cap will discharge through the A/D pin, and that can also fry that pin. 100n is more than enough, and ok if you also have that resistor between battery and A0.
Leo..