current sink with opamp not working properly - any suggestions - Page 1
Forum section: electronics / projects

author: jmibk
author_rank: Regular Contributor
timestamp: January 12, 2022, 06:44:31 am
content: I want to build a current sink for discharging batteries to measure its capacity.Now I built up the basic current sink with a shunt, a mosfet and an opamp like Dave was talking about some years ago.Basically this circuit works fine and I extended it with an arduino to set the current with a pot and measuring the capacity in Ah and Wh - also that works fine in combination with an 16bit ADC.After playing around, at some time the cell voltage was too high for the adc and blows some parts in the circuit up.I rebuilt it and came up with this:U3.1 is the general opamp that is controlling the mosfet Q1, below that you can see the shunt R6.All Z-Diodes are protection against high voltages on all inputs to prevent damage. They shouldn't influence the circuit in normal operation.Current reading via ADC:U2.4 is a differential amplifier to amplify the shunt dropout voltage and U4.3 is a times 2 gain amplifier to get 40x amplification of the shunt voltage to maximize the range of the ADC.Why two amps in series - because a diffential amplifier with a gain of 40 didn't work in my test, a times 20 was perfectly working.ADC is a ADS1115.Voltage setpoint via 16Bit PWM on an Arduino output (using timer2):R10, R13, C3 and C6 works as a double stage low pass filter to convert the PWM signal into a DC voltage.U4.4 acts as an buffer amplifier that the voltage divider R8, R22 doesn't influences the lowpass filter.The voltage divider R8 and R22 divides the DC voltage from the PWM control signal into a smaller voltage to maximize the PWM range.This DC "PWM" control signal goes into the "+" input of opamp U3.1 and acts as a setpoint value for the current sink.On the "-" input of U3.1 is the shunt voltage attached to built up the regulation loop.U4 is an AD8608 i had laying around - it is a 5V opamp.U3 is an LM358 i had also laying around. Here i tried also the AD8608, LM324 and the LT4191 - all worked nearly the same. VCC is 12V.Now the problem:The voltage divider was initially designed to get around 150mV at 100% PWM on the "+" pin of U3.1. That should do the trick if we have 100mV at 10Amps through the shunt resistor.The circuit was sinking only 4 amps instead of 10 amps. The duty of the PWM was 100%, the voltage on the "+" pin of U3.1 137mV and on the "-" pin 47mV. The opamp output was around 3,4V.So I changed the value of R8 to 2k, so the maximum PWM results into a voltage of 416mV on the "+" pin of U3.1. Now it worked up to 15Amps (the maximum of my power supply).So I measured the differential voltage between + and - inputs of U3.1 (they should be ideally zero, the datasheet says 2mV max).at 10A sinking current the differential voltage is 16mV, at 5A it is 13mV.Why is this voltage so high? What I'm not thinking about? Maybe a tapped into the trap of youngplayers?

author: strawberry
author_rank: Super Contributor
timestamp: January 12, 2022, 08:26:08 am
content: could be that U3.1 oscillatehttps://cdn-shop.adafruit.com/datasheets/mcp4725.pdf

author: magic
author_rank: Super Contributor
timestamp: January 12, 2022, 08:27:44 am
content: Either that or you run it from 5V and its output is right at the edge of its limits.

author: Kleinstein
author_rank: Super Contributor
timestamp: January 12, 2022, 08:59:41 am
content: Chances are high that U3.1 is oscillating. The extra zener diode adds capacitance to make it even more prone to oscillation, close to a reliable oscillator.The current source circuit should have an addition cap in direct feedback and a resistor in series to the gate.Not directly related: The extra zener diode D2 and D3 are not really needed and they can cause trouble with leakage current and the added capacitance. With the series resistors the OP is suficciently protected. Especially the ground would hardly exceed 5 V and like in the current sink the capacitance of D2 hurts the stability of the amplifier.This is a strange mix of OPs too. The LT1491 is likely the best and the buffer at the input is the least critical OP.

author: jmibk
author_rank: Regular Contributor
timestamp: January 12, 2022, 11:39:18 am
content: Thanks a lot for your replys.QuoteHere you can see the voltage on the output of U3.1. There is a weird ringing on the output, it is not in sync with the PWM signal.Maybe it comes from the powersupply. I use the Riden RD6018 switching PSU (these chinese ones). I searched for a linear psu jobby but I have nothing here at the moment - only switching types.QuoteI have these parts here, ordered a few days ago. After ordering theses DACs I found out, that I can output a 16bit PWM on an Arduino with the AVR commands.QuoteU3.1 is powered via a 12V supply and its output rises up to 10V when disconnecting the cell voltage. So both should be good.QuoteSeems not to be oscillating at all (see oscilloscope screens above of U3.1 output). I removed Zener diodes D2, D3, D5 and resistor R23 and added a 20R series resistor to the gate.Where do I have add the additional cap? Between U3.1 pin "-" and GND?Here the edited circuit. The measurements above are taken on that schematic here. Sorry for the different destignators (Rx and so on). Lets refer them to the following schematic from now on.

author: Kleinstein
author_rank: Super Contributor
timestamp: January 12, 2022, 11:52:09 am
content: the capacitor (e.g. 1-10 nF range) at the OP U3.1 would be between pins 6 and 7 and with R23 back in place.Getting some 4 V at the OPs output = gate would be about right for normal operation. It is not very likely to get such an intermediate level with the circuit not working.What is the actual current, and the voltage at U1.4 output (e.g. the set point) ?

author: Vovk_Z
author_rank: Super Contributor
timestamp: January 12, 2022, 12:58:57 pm
content: 1. For U2.1:Put 1-10 nF cap between pin 6 an pin 7.And add a series 1k resistor between shunt and pin 6 of opamp.2. Aren't R12 and R13 must be the same value?3. IRFP7430 is not a best choice to work in a linear mode. I suggest to use something with three numbers in a part number (and with a lower input capacitance).

author: Kleinstein
author_rank: Super Contributor
timestamp: January 12, 2022, 01:05:57 pm
content: Same value for R12 and R13 improves common mode suppression. With one side to ground R13 is not needed at all. It still makes no sense to have R13 smaller than R12. Either use the same or leave out R13 all together.

author: jmibk
author_rank: Regular Contributor
timestamp: January 12, 2022, 01:26:56 pm
content: QuoteQuoteParts are replaced - R23 with 1k and the cap as negative feedback path with 10nF.QuoteCircuit and values based on this calculator website:https://www.changpuak.ch/electronics/DifferentialAmplifier.phpQuoteIsink = 2.00AUShunt = 20.32mV (measured)U1.2 output voltage = 358.34mVU1.3 output voltage = 773mVADC16Bit Value = 4128 [0...65535]PWM16bit duty cycle for feedback: 9%, 6449 [0...65535]voltage U1.4 + input: 497mVvoltage U1.4 output: 499mVvoltage U2.1 + input: 41.47mVvoltage U2.1 - input: 41.6mVvoltage U2.1 output: 3.876VIsink = 5.00AUShunt = 50.9mV (measured)U1.2 output voltage = 964mVU1.3 output voltage = 1.937VADC16Bit Value = 10336[0...65535]PWM16bit duty cycle for feedback: 25%, 16421[0...65535]voltage U1.4 + input: 1.257mVvoltage U1.4 output: 1.256mVvoltage U2.1 + input: 104.62mVvoltage U2.1 - input: 104.20mVvoltage U2.1 output: 4.02Vvalues seems OK to me, the removal of zener diode D6 was the biggest difference.

author: Kleinstein
author_rank: Super Contributor
timestamp: January 12, 2022, 01:53:38 pm
content: Quote from: jmibk on January 12, 2022, 01:26:56 pmLooks that website has a problem - it even says that the resistor should be equal forther down.

author: jmibk
author_rank: Regular Contributor
timestamp: January 12, 2022, 02:53:14 pm
content: QuoteNow I used the formulas an the website, both input resistors 3k3 (R8, R10) and the others (R12, R13) 120k. That makes an amplification of around 36, so I can delete the times 2 amp U1.2 - great!

author: jmibk
author_rank: Regular Contributor
timestamp: January 22, 2022, 02:39:35 pm
content: Yesterday I used the circuit to discharge a liion battery pack with 100A without any problems. Thanks for the help.