Improve this constant current circuit to become LOGARITHMIC?  - Page 1
Forum section: electronics / beginners

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 10, 2024, 12:43:48 am
content: Circuit in FalstadLikely going to get this circuit made by a PCB manufactuer to be used for various things. It's just a basic constant-current control, from 0-2A. My only problem is that I can't figure out how toLOGARITHMICALLYcontrol the potentiometer, to have fine-control at 0-100mA, and less control at 100mA-2A. I know that I could simply use a logarithmic pot, but is there any other way to have the circuit act in a logarithmic manner?Design-rationale (before people ask):- The first op-amp is to simply decrease the input resistant into the second op-amp.- The 70k resistor to ground at the input of the second op-amp exists so thatif the pot breaks, only ~5mA will be allowed to flow through the FET.- I know that I'll need a compensation capacitor at the FET to reduce ringing- I'm using a 0.1ohm resistor to reduce voltage drop at the 2A load- The op-amp I'll be using to measure the ~0.5mv voltages at the 0.1ohm current sense resistor is the Microchip MCP6V97 (+/- 25μV at 25C).

author: macboy
author_rank: Super Contributor
timestamp: July 10, 2024, 01:49:52 am
content: Change the 70k resistor to 1 or 2k and you'll get a response curve close to what you are looking for.

author: JoeyG
author_rank: Regular Contributor
timestamp: July 10, 2024, 04:32:52 am
content: use a logarithmic POT?https://eepower.com/resistor-guide/resistor-types/potentiometer-taper/

author: Ian.M
author_rank: Super Contributor
timestamp: July 10, 2024, 07:51:40 am
content: The left OPAMP in the Falstad sim is absolutely pointless. +in tied low and -in tied high so its output is railed at its negative supply (ground). You then pull that up a bit with the left 70K resistor and because a LM324 is not a RRIO OPAMP, that gives you *some* voltage across the pot, but in no way a stable voltage.Get rid of it, and if you need better stability than your 5V supply, use a reference IC to feed the pot via a dropper resistor.

author: srb1954
author_rank: Super Contributor
timestamp: July 10, 2024, 09:42:06 am
content: You can get an approximately logarithmic response out of a linear taper pot by having a low value (compared to the pot resistance) resistor connected from the pot wiper to ground. This extra loading on the pot wiper alters the division ratio from that expected from the pot alone, except at the bottom end of the pot travel where it reverts to a more linear characteristic.You can tune the shape and range of the division curve by adjusting the ratio between the pot total resistance and the extra load resistor. I suggest you set-up a spreadsheet calculation and try various values until you get the curve you like. Try starting with a load resistor of 1/10 the pot resistance.A consequence of the extra load resistor is that the input resistance to the pot varies considerably as the pot is turned so you will need a much better voltage reference, which can tolerate additional load current draw, than your circuit.

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 10, 2024, 12:51:39 pm
content: Quote from: Ian.M on July 10, 2024, 07:51:40 amDoes RRIO simply stand for rail-to-rail input out? I assume using a 1.25v voltage reference should be fine, something like a TL431?Quote from: macboy on July 10, 2024, 01:49:52 amDone; Falstad Circuit. Now the only problem seems to be that the minimum current is around 30mA instead of close to 0mA as before. I guess at this point I'll just need to mess around a bit with the IRL circuit to get it working perfectly?

author: MarkF
author_rank: Super Contributor
timestamp: July 10, 2024, 01:52:27 pm
content: You're missing some components in your MOSFET feedback loop.Here's my load:https://www.eevblog.com/forum/projects/constant-current-dummy-load-ran-a-gutter/msg3180226/#msg3180226

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 10, 2024, 02:16:49 pm
content: Quote from: MarkF on July 10, 2024, 01:52:27 pmWhy are you putting 12v at 0R2? What's the purpose of the unity gain buffer OP-amp? Why is the potentiometer also at the input of the unity gain buffer and not after it?

author: MarkF
author_rank: Super Contributor
timestamp: July 10, 2024, 03:05:24 pm
content: The 12V through 1K resistor is a bodge partial solution.If the DUT is powered off, the op-amp can't develop any voltage across the sense resistor. This causes the op-amp to drive the MOSFET gate very high (i.e. fully turning 'on' the MOSFET). If you than turn 'on' the DUT, it will see a momentary dead short. As a partial fix, I always feed a small current through the sense resistor which will allow you to turn down the pot to minimum. Hence, turning 'off' the MOSFET. Any position of the pot other then minimum and again the MOSFET gate will be driven to max. The real solution is to add a bunch of circuitry to sense the DUT voltage and disable the MOSFET. My solution has minimal effect on the current. Since, I already had the PCB made, I can live this limitation.You can look atJay_Diddy_B's Dynamic Electronic Load Project. He doesn't have my problem. But, it requires a -/+V power supply.The unity gain op-amp is to buffer the set voltage of the pot from the 10:1 resistor divider into the op-amp driving the MOSFET. A 0-5V output from the pot or the external control results in a 0-0.5V across the sense resistor. This gives me a 0-2.5A current load. The 10-turn pot gives me a controllable current down below 5mA.

author: macboy
author_rank: Super Contributor
timestamp: July 10, 2024, 03:54:56 pm
content: QuoteYou could try 100k pot with ~10k to ground, instead of 10k and ~1k.I also agree about the opamp selection. Like the dual LM358, the quad LM324 will do input to negative rail (ground) but needs plenty of room to the positive rail. It can output close-ish to negative rail IF the load impedance is very high (very little current). You can help it get closer to -ve rail with a pull down resistor, keeping in mind the current wasted in it when the output is higher voltage. As always, only you can test if it can do what you need.

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 14, 2024, 05:52:41 pm
content: What aboutthis circuit?It's more logarithmic near the center of the POT but less around the 0ohms and 10k ohms points. I also decided to adjust it to 0mA-1A instead of 0mA-2A for more control. I think I may still need to use the Microchip MCP6V97 OP-AMP because I don't think an LM324/LM358 will be able to accurately control the FET at 0-25mA ranges due to the current-resistor measurement voltages being between 0.5mv-5mv.Anyone see any problems with it? I'm using all standard resistors and the 1nf cap can be modified to reduce oscillations if needed in the actual circuit, as well as the 220ohm resistor at the current sense resistor can be changed to adjust the lowest-current flowing through the FET.The 2.5v voltage reference I'll likely generate via a TL431, which should be able to easily handle the ~15mA.

author: MarkF
author_rank: Super Contributor
timestamp: July 14, 2024, 08:51:23 pm
content: It seems overly complex to me.If you don't intend on having an external control source, you don't need thefirst op-amp buffer and the middle voltage divider resistors (4.7K and 680).Just drive the second op-amp directly with the output from the pot.Remember, the voltage applied to the (+) input of the op-amp will appearacross the sense resistor. This will determine the load's current.You might want to put a small capacitor from the pot wiper to GND. It willfilter small instabilities and noise in the control.The only reason I had the buffering op-amp was because I have two control sourcesand I needed to isolate the resistor division of the pot from the 10:1 division.Also, it would be better if the 1K resistor on the MOSFET gate was lower.A 100 ohm resistor would be better and give a better response from the MOSFET.The 220 ohm resistor is not adjusted for lowest load current. You make it justbig enough so the MOSFET gate voltage goes to zero when no SUT is connected and thecontrol is set to minimum. A little of the adjust will be determined by how muchplay you have at the low side of the pot. You want the pot to come off its end stopa little before the op-amp reacts. You'll see want I mean when you start testing.(I would leave it out until everything else is working.)

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 14, 2024, 10:14:14 pm
content: Quote from: MarkF on July 14, 2024, 08:51:23 pmWhat about now?I've included the 2.5v TL431 voltage reference in the circuit, removed the unity-gain buffer, added a small cap to the wiper of the POT, and I decreased the resistor to the FET-gate to 220-ohm. I'll need to adjust the 220-ohm resistor beside the current-sense resistor IRL I guess?From your earlier comment:Quote from: MarkF on July 10, 2024, 03:05:24 pmDo you have a source-post on the circuitry to sense the DUT voltage and disable the FET?I was also thinking of making a digital version of this circuit, replacing the POT with a digital PWM + varying duty cycle to control the output current. I ONLY want to work on this AFTER I finalize the analog circuit.

author: MarkF
author_rank: Super Contributor
timestamp: July 14, 2024, 10:50:31 pm
content: I can offer this from my stash of thing I've saved over the years:Caution: There is NO over-voltage protection on the feedback voltage from the DUT.

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 15, 2024, 12:05:22 am
content: Well that circuit schematic is incredibly useful and saves me a lot of time to support digital control of my circuit, thanks! That's an incredibly simple way to read the voltage, read the current, and set the current. Do you have the source code for this circuit as well?Further I guess going back to my circuit in Falstad, do you have any additional feedback for it or do you think it's "good enough" at this time?

author: MarkF
author_rank: Super Contributor
timestamp: July 15, 2024, 12:45:56 am
content: I don't have the software for that electronic load. It's not mine.Really, it's just setting the DAC output for the current and reading two ADC inputs for the Arduino. Plus what's required to control it (i.e. display, rotary encoder, a PC connection, etc.) You might try to search for his web page. It would be years old though.One last thing you seem to have dismissed. In the load I built, I had the ability to control the load externally with the simple addition of a switch and BNC connector. Being able to control the load from an arbitrary waveform generator is just as nice to have as computer controlled. Your choice.

author: MarkF
author_rank: Super Contributor
timestamp: July 15, 2024, 01:08:34 am
content: It looks like there is still a GitHub page for the Jasper Sikken Electronic Load:https://github.com/bertrik/ElectronicLoad?tab=readme-ov-fileAnd a description:https://www.tindie.com/products/jaspersikken/arduino-electronic-load-r3/

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 18, 2024, 11:21:12 pm
content: How does my attached PCB + schematic lookin terms of functionality? I know it's ugly and there's two odd empty spaces (bottom-left corner, top right corner) but I couldn't figure out what to fit there, as well as that I've already spent more than 8 hours working on this simple PCB. It's my first completed one.Some things to note about the schematic/PCB:- For all of the resistors, diode, and fuse, they are "duplicated"; this is so that I can decide whether I want to use an SMD or through-hole component in the future- The Op-AMP is also duplicated, with both a regular SOIC8 package (on the front) and a TDFN8 package (on the back)- There is some solder mask that has been removed; this is so that I can add solder in the future, if I decide to go above 1A and want to decrease voltage drop- STP* = "Small through point", BTP* = "Big through point", in case I need to make bodges or decide to make circuit changes- The 4 yellow arrows in the board view show my 4x mounting spots- Most traces are 0.4mm or greater (excluding the TDFN8 traces, which are 0.25mm)Copper fill:- Corner smoothing of fillet, 0.5mm radius- Electrical properties of 0.5mm clearance + 0.025mm minimum width- Thermal relief gap of 0.3mm and spoke width of 0.8mmFurther, most components + through-hole points on the PCB are spaced 1.5mm (or greater) apart.Two problem I know of:- The silkscreen of D1 covers the solder pad. I have 0 idea how to fix this and tried to google it but couldn't find an answer- I seemingly arbitrarily alternated between 45-degree traces & free-angle traces (this can be fixed but I'm tired). I don't think this will create any functional problems?

author: MarkF
author_rank: Super Contributor
timestamp: July 19, 2024, 12:16:41 am
content: There are several things I don't understand:The FDD8896 MOSFET in a D-PAK will never handle the power dissipation for a 50W, 2.5A load. I suggest a MOSFET in a TO-247 package mounted on a large heatsink with a small fan. I used a IRFP250 directly mounted on anOhmite RA-T2X-64E heatsinkwith a40x40x10mm 12V fan. The heatsink was mounted on the PCB with isolated pads for mechanical support and no mica isolator for best heat transfer.(Amazon links for reference only.)The sense resistor (R6) will need to be 2 watts or bigger.The power supply for it (Vin) can be a small wall-wart and doesn't need large traces.The DUT will connect between (Vout-) and (GND). I used 4mm wide traces. I don't know what the purpose of (Vout+) is?I would also allow for an amp meter some place. I used a repurposed a volt meter with a custom face and tweeked burden resistance for the proper range. It monitored the voltage across the sense resistor.

author: LooseJunkHater
author_rank: Frequent Contributor
timestamp: July 19, 2024, 12:43:32 am
content: Quote from: MarkF on July 19, 2024, 12:16:41 amWOOPS. Okay I guess I didn't explain the need for this "constant current circuit". It'll be used to limit the current flowing to various USB devices to whatever my desired current is (ex. 1ma-1A).I essentially want to slow-charge my cellphone and other devices. I know that I can do this in the form of a switching regulator for improved efficiency (and that such modules already exist) but I do not want to do that. The amount of power that will be dissipated by the FET at 5v will be quite low, hence using the small TO-247 package.If I want to use this circuit to control the brightness of high-power LED's, I can do that as well but using the "BTP" as connection points for a higher-power FET.Hopefully this clears things up? Ido notintent to use this circuit to dissipate like 20w+, such as for testing USB power bricks or whatever.