### Author Topic: Constant Current Load - Problems with simulation in LTSpice  (Read 7721 times)

0 Members and 1 Guest are viewing this topic.

#### mnaevis

• Contributor
• Posts: 6
• Country:
##### Constant Current Load - Problems with simulation in LTSpice
« on: October 12, 2016, 09:19:00 pm »
I'm completely new to electronics and started watching Dave some weeks ago. I'm interested in building a CC load to test batteries with (end goal might be PC data logging).

I've read lots of those CC dummy load threads here and adjusted my circuit accordingly.
Because I want to know and learn what happens when I change some parts I started learning how to use LTSpice and simulate the circuits.
Now the problem arises:
Picture 1&2: You can see V2 varying from 1-5V and the current through R1 going up until V2 is ~4.2V. The potentiometer to the left is at 10% (so voltage at the + of first opamp is ~8V).
So the current depends on V2 and is not constant. Why?
I also attached the project file but you need the LM324 and potentiometer part http://ltwiki.org/?title=Components_Library_and_Circuits#A_Large_LTspice_Folder_from_Bordodynov.

Thank you

#### 2N3055

• Super Contributor
• Posts: 2085
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #1 on: October 12, 2016, 09:45:46 pm »
On R1 you will have a voltage drop of 1V/1A on output...
On the noninverting input  you have 4V (8V divided by two).. That would be 4V over R1, plus a bit over mosfet....  Constant current sinks of this kind have a minimum compliance voltage.. This one has about 4-5V .. Try increasing V2 to go from 6 to 10 V and it should be ok...

R1 is usually much smaller, 0.001 to 0.1 Ohm per A, and drop is amplified before going to comparator amp... also ref voltage up to few volts..

All that would give much better minimum compliance voltage ( it can never be zero in this architecture), but you would need to use better opamps than LM324....

#### mnaevis

• Contributor
• Posts: 6
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #2 on: October 12, 2016, 10:13:08 pm »
On R1 you will have a voltage drop of 1V/1A on output...
On the noninverting input  you have 4V (8V divided by two).. That would be 4V over R1, plus a bit over mosfet....  Constant current sinks of this kind have a minimum compliance voltage.. This one has about 4-5V .. Try increasing V2 to go from 6 to 10 V and it should be ok...

R1 is usually much smaller, 0.001 to 0.1 Ohm per A, and drop is amplified before going to comparator amp... also ref voltage up to few volts..

Well I use 1 Ohm because everyone does and it seems to work and Dave's circuit was meant for batteries so it should work in the 1-4V range I suppose.
Yes V2 above the 5V it works fine, but that's not what I need.
The second opamp does have 4V at the noninverting input but the voltage over R1 is never 4V, as can be seen on the second pic.

#### 2N3055

• Super Contributor
• Posts: 2085
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #3 on: October 12, 2016, 11:13:45 pm »
As you say you are beginner let me just start with this.. You shouldn't decide value of components on "everybody does" .. You must understand how circuit works and than you decide (calculate) values for your purpose..

R1 here serves as a so called sensing resistor, or a current shunt.. It's purpose is to "sense" (measure) current on the output..  Ohm's law says that U=I*R, so 1A, 1 Ohm, gives 1 V over resistor..
Opamp compares that voltage to the input (reference voltage), and regulates mosfet so it pases just enough current so the voltage on R1 is exactly the same as input voltage..
That is theory, in real world it's not exactly that accurate, that but with good components it gets real close...

In order to control mosfet, opamp regulates voltage on it's output that is connected to gate.. If voltage between gate and source is large enough, mosfet will start passing current between drain and source..
For this particular mosfet it will start opening with Vgs of 4-5V.. But it will not open completely until maybe 10V..

And you are supplying opamp with 9V,this opamp cannot go all the way to V+ it is v+ -1.5V  , minus drop on a resistor (4V at 4A)... So your mosfet sees only  9V-1.5V-4V=3.5V.... That's not enough to fully open it.. In this regime, mosfet behaves like resistor, so you see changes  in output current...

So, you should try to increase opamp V+ to 15-20V and than see how it goes..

Hope this helps..

#### mnaevis

• Contributor
• Posts: 6
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #4 on: October 13, 2016, 01:59:32 pm »
I can change R1, but that does nothing for the circuit, just the current will be higher. It has no effect on how the circuit behaves in the simulation.
Giving the opamp a higher voltage also does not change much, see attached pic.
The noninverting input of the opamp always has 4V, but the opamp cannot output enough voltage to also level the inverting input to the same level, up to where "V2" is ~4.5V. After that point is reached, the opamp can keep both inputs at the same level and its output (the input to the mosfet gate) will go down from maximum voltage.

What kinda works, is lowering R3 to 500 Ohm, so the opamp noninverting input has a much lower voltage, making it easier for the opamp to reach this voltage at the inverting input.
Then I also have to change R1 from 1 to 0.1 Ohm to make the current somewhat relevant. But to get currents low as ~60mA the potentiometer has to be at 99%.

The internet is full of those circuits and they all claim to work for batteries, but my simulation still does not reflect that - this is what wonders me.
« Last Edit: October 13, 2016, 02:01:38 pm by mnaevis »

#### Kalvin

• Super Contributor
• Posts: 1786
• Country:
• Embedded SW/HW.
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #5 on: October 13, 2016, 02:56:00 pm »
What happens if you increase the V1 from 9V to, say 12V. Then you should check the op amp's and the mosfet's datasheets. Check the op amp's input voltage range. Try changing the op amp to LT1677 and see what happens.
« Last Edit: October 13, 2016, 03:15:08 pm by Kalvin »

#### 2N3055

• Super Contributor
• Posts: 2085
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #6 on: October 13, 2016, 03:12:42 pm »
I guess i went into details too much too soon..

You need to increase voltage that supply opamp.. opamp doesn't have voltage high enough going to it  to be able to make it's output high enough.
Try making V1  15-20 V and try..

Also you have to make resistor smaller and use smaller input voltage as control.. If you have 4V on 4A on a 1 Ohm resistor it is 16W.. that's a lot...
For smaller currents let's say 1A it is ok at only 1W..

Also, please try some other opamp model.. I downloaded one you use and it seems to be behaving funny..

#### Audioguru

• Super Contributor
• Posts: 1508
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #7 on: October 13, 2016, 03:35:34 pm »
The datasheet of the LM324 shows that the inputs do not work if their voltages are above (the supply voltage minus 1.5V) which is 7.5V in your circuit. But your input is 8V so of course the opamp does not work.
If you increase the supply voltage V1 of the opamp then the inputs will work properly.

The datasheet for the Mosfet shows that it completely turns on when its gate to source voltage is 10V. But since the value of R1 is so high at 1 ohm then for 4A though it its power is 16W (!) and its voltage is 4V and the input to the Mosfet must be 14V. then the supply voltage V1 for the opamp must be 15.5V or more.

Hee, hee. Don't make the resistor smaller as was said, instead reduce its value to 0.15 ohms or so. Also the voltage from the pot must be reduced with a series resistor making a voltage divider.

#### Cliff Matthews

• Supporter
• Posts: 1766
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #8 on: October 13, 2016, 04:43:18 pm »
Nice CC load 3-part video series here:

enjoy!

#### mnaevis

• Contributor
• Posts: 6
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #9 on: October 13, 2016, 06:02:52 pm »
You need to increase voltage that supply opamp.. opamp doesn't have voltage high enough going to it  to be able to make it's output high enough.
Try making V1  15-20 V and try..
Yes I did that - see the post you answered to: "Giving the opamp a higher voltage also does not change much, see attached pic."
I should have worded it better, sorry.
I gave them their own voltage supply of 15 or 20 Volt (V3), and let V1 at 9V. In the picture CCL_3c.png above, both opamps had 20V supply.

Also you have to make resistor smaller and use smaller input voltage as control.. If you have 4V on 4A on a 1 Ohm resistor it is 16W.. that's a lot...
For smaller currents let's say 1A it is ok at only 1W..

You mean making R1 smaller? And making the input voltage for the second opamp on the noninverting input (+ on the left side) smaller? I did that, see the above post: I changed the dividers R2 & R3, so that the opamp input voltage on the noninverting input (+) is lower, then it somewhat works.

Also, please try some other opamp model.. I downloaded one you use and it seems to be behaving funny..
I just tried like 20 different opamps (also LT1677) and they all show the same characteristics.

The datasheet of the LM324 shows that the inputs do not work if their voltages are above (the supply voltage minus 1.5V) which is 7.5V in your circuit. But your input is 8V so of course the opamp does not work.
If you increase the supply voltage V1 of the opamp then the inputs will work properly.
Only the first opamp might have input voltages >7.5V if the potentiometer is <~20%, its output at 10% potentiometer value is ~8V. The second opamp that is the relevant one never has input voltages anywhere near 7.5V - see CCL_3c.png above: This is what happens when both opamps have 20V supply. The input voltages at the second opamp are maximum 4V (U+ and U- in the picture).

The datasheet for the Mosfet shows that it completely turns on when its gate to source voltage is 10V. But since the value of R1 is so high at 1 ohm then for 4A though it its power is 16W (!) and its voltage is 4V and the input to the Mosfet must be 14V. then the supply voltage V1 for the opamp must be 15.5V or more.
Back to the setup from my original post and both opamps having 9V supply (which I've shown does not make a difference to them having 20V supply when looking at the current through R1). The mosfet's maximum gate-source voltage is 7V.

Hee, hee. Don't make the resistor smaller as was said, instead reduce its value to 0.15 ohms or so. Also the voltage from the pot must be reduced with a series resistor making a voltage divider.
I don't quite understand this sentence. The resistor R1 was 1 ohm, you tell me not to make it smaller but instead to reduce its value to 0.15 ohm - for me that is smaller than 1 ohm.
But the overall characeristics of the current/voltage at R1 does not change no matter what value R1 has.

« Last Edit: October 13, 2016, 06:05:16 pm by mnaevis »

#### Kevin.D

• Frequent Contributor
• Posts: 277
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #10 on: October 13, 2016, 06:23:01 pm »
The current sink can only sink as much current as it's minimum resistance and the Voltage at v2 allows . I.e the minimum resistance the CC load can achieve (that is FET is full on) is R1 + M1 rds(on) = ~ 1.1R . so for e.g if V2 is only 2V then the max current possible is  ~ 1.8A ( your 4A setting can't be achieved until V2=> ~ 4.4V.).
Aside from that (but not related to your earlier observations) there is another current limit :- with a
9V supply the highest output the lm324 can achieve is Vcc - 1.5 = 7.5V this sets an upper limit on
current even when sufficient V2 since you have a max Vgs available of  7.5 - Vrsense . If you look at Vgs versus Id in irf530 data sheet we find ~ 4.2Vgs = 3A Ids this means a practical limit of around 2.5-3.5A (depending on temp) when using a 1R sense resistor . To Increase this use a lower value Rsense (bearing in mind with higher current of that upper limit of FET power dissipation ).

Regards

#### 2N3055

• Super Contributor
• Posts: 2085
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #11 on: October 13, 2016, 06:28:04 pm »
Try this one and then ask away...

#### mnaevis

• Contributor
• Posts: 6
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #12 on: October 13, 2016, 07:33:57 pm »
Try this one and then ask away...

This has exactly the same problem in my simulation.
I set V2 to go from 1-5V, and got the attached results.

#### 2N3055

• Super Contributor
• Posts: 2085
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #13 on: October 13, 2016, 07:49:35 pm »
Try this one and then ask away...

This has exactly the same problem in my simulation.
I set V2 to go from 1-5V, and got the attached results.

I told you, this type of schematic CANNOT go down to zero on the output.. Compliance voltage on the good ones with a very small shunt  are 1-2V ..

The diagram shows that load starts working nicely at around 2 Volts, which is great with a 0.1 Ohm shunt that drops a 1V on that current.. Together with 0.1 Ohm of the mosfet that is just right...
By using mosfet with very small RdsOn and very small shunt you could get down to 1 Volt maybe...

If you want to test something with this architecture down to 0 V, you have to connect a voltage source in series with a load to create few volts bias to compensate for dropout voltage of the load...

#### mnaevis

• Contributor
• Posts: 6
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #14 on: October 13, 2016, 09:04:27 pm »
Try this one and then ask away...

This has exactly the same problem in my simulation.
I set V2 to go from 1-5V, and got the attached results.

I told you, this type of schematic CANNOT go down to zero on the output.. Compliance voltage on the good ones with a very small shunt  are 1-2V ..

The diagram shows that load starts working nicely at around 2 Volts, which is great with a 0.1 Ohm shunt that drops a 1V on that current.. Together with 0.1 Ohm of the mosfet that is just right...
By using mosfet with very small RdsOn and very small shunt you could get down to 1 Volt maybe...

If you want to test something with this architecture down to 0 V, you have to connect a voltage source in series with a load to create few volts bias to compensate for dropout voltage of the load...

Why 0? I'm talking about 1+ volt.
This thing is designed as a battery tester. There are dozens of schematics that show this circuit as a load for battery testing. For example MJLorton (used code because otherwise it would embed the video, don't know how to prevent this)
Code: [Select]
https://www.youtube.com/watch?v=xLI3yqZvHbs&t=10m40s @ 10:40, you can see it being stable down to 0.5V. His circuit is pretty much a copy of Dave and can be seen in this video @ ~1:35. So it works in real live in his video.
So the circuit works down to that voltage just fine. So either the simulation is wrong, or the mosfet is too different. Dave used an MTP3055, MJLorton used an BUZ31LH - cannot find a ltspice model for either. I've also seen an IRLZ44N being used, simulation this one yields the same results.

So how can I find a similar mosfet to the two above and can they be so different?
IRF530: http://www.vishay.com/docs/91019/91019.pdf
MTP3055: http://pdf1.alldatasheet.com/datasheet-pdf/view/23382/STMICROELECTRONICS/MTP3055/+Q3_84UORlHDyRHOIpa/1XXyxeobifKHxO+/datasheet.pdf
BUZ31LH : http://pdf1.alldatasheet.com/datasheet-pdf/view/397044/INFINEON/BUZ31LH/+2J7Q57VGL.pOhSSeHbFwzUy+/datasheet.pdf

When I modify the design to the one shown in the attachment (both files are the same circuit), I get it mostly stable in all voltage ranges.
« Last Edit: October 13, 2016, 09:08:04 pm by mnaevis »

#### 2N3055

• Super Contributor
• Posts: 2085
• Country:
##### Re: Constant Current Load - Problems with simulation in LTSpice
« Reply #15 on: October 13, 2016, 09:15:49 pm »
A friendly advice: you should really start with a bit of electronic theory... You seem not understand voltage drop on resistor carrying current..

Let me go backwards: what currents you want to test?

What I uploaded was a load that has 1V input and 10A output...  If you change input voltage for 1V to cca 0.526V ( which you did changing that resistor on the input ) you are pulling 5,26A on the output, drop on the R1 is cca 0.526V , a bit more on the mosfet gives lowest voltage of a cca 1.1 V...

So with this config you can go down to 1.2V at 5 A current.. If that is ok for you this is it.. For a mosfet try IRF 540 (it has Rds(on) of 0.044 Ohm)..

EDIT:

I'm sorry I didn't see 50k resistor you added to top of pot.. That further divided input voltage  to half of what I said, so cca 2.6 A,  0.26V drop on R1,  and no wonder it worked down to 1V ..
But that is if current is 2.5 A or less, if that is enough of current for you then this is it..

« Last Edit: October 13, 2016, 09:37:06 pm by 2N3055 »

Smf