DC sweep circuit LTspice simulation.

Thread Starter

k1ng 1337

Joined Sep 11, 2020
531
Howdy,

How do I simulate this LTspice circuit? I would like to plot current vs time at the drains of U2 and U3 as VBAT sweeps from 4.2-3.0V.

Circuit Description: Low battery monitoring that cuts off its own power supply a short time after turning off U3

The theory:
1) Fresh battery is connected and switch is closed (if necessary) to turn ON U2
2) As VBAT drops below 3.1V, U3 is turned OFF and load is disconnected
3) U2's gate remains charged for some time via C1 to ensure the SR latch has completed its operation
4) U2 turns OFF and quiescent current of the entire monitoring circuit is minimized, ideally 0A

bc5.png

I have included the models for the logic gates as I had to find ones with power pins. Any help is appreciated.

Regards,
Mark
 

Attachments

Papabravo

Joined Feb 24, 2006
18,408
The simulation you have is a DC sweep. that is, you are sweeping the source VBAT from 4 to 3.2 in steps of 0.5V which does not make a whole lot of sense. A step of 0.05V would make more sense.

To get a plot of some quantity with respect to time you want to do a transient analysis. The simulation command is a .TRAN with some arguments. In the transient analysis you can use a step command to change the value of VBAT, or you can make VBAT have a fast turn on at the start of the simulation and a slow fall time to simulate a battery that is losing its charge. Like this:

1652440047705.png

A real battery would never behave like this, but in a simulator you can do unreal things just to see what would happen.
 
Last edited:

crutschow

Joined Mar 14, 2008
29,779
One of your problems is not reading the data sheets.
The input of the LM393 will only operate to within 1.5V of its supply voltage (below), so with a 3.7V supply, that's 2.2V, which you are exceeding.
You need to add resistive dividers to the input to get your comparison voltages below 2.2V.

1652450931959.png
 

eetech00

Joined Jun 8, 2013
3,149
Howdy,

How do I simulate this LTspice circuit? I would like to plot current vs time at the drains of U2 and U3 as VBAT sweeps from 4.2-3.0V.

Circuit Description: Low battery monitoring that cuts off its own power supply a short time after turning off U3

The theory:
1) Fresh battery is connected and switch is closed (if necessary) to turn ON U2
The battery could be simulated as a PWL voltage source ramp that decreases (or increases) over time.
But....what is "Vin".

2) As VBAT drops below 3.1V, U3 is turned OFF and load is disconnected
Why is the whole circuit shutoff and not just the load?

I have included the models for the logic gates as I had to find ones with power pins. Any help is appreciated.
Bordodynov has a library of pre-defined component models you can download. The library include digital devices like the CD4000 series.

You circuit still has a few issues.

For example, the voltage source ground connections need to be thought through...
 
Last edited:

Papabravo

Joined Feb 24, 2006
18,408
The battery could be simulated as a PWL voltage source ramp that decreases (or increases) over time.
...
I like this suggestion, since in theory, you could approximate an actual discharge curve. If I was going to do this, I would compute the pairs of points in a spreadsheet and output them to a file which I would call with the appropriate PWL method.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
531
The simulation you have is a DC sweep. that is, you are sweeping the source VBAT from 4 to 3.2 in steps of 0.5V which does not make a whole lot of sense. A step of 0.05V would make more sense.

To get a plot of some quantity with respect to time you want to do a transient analysis. The simulation command is a .TRAN with some arguments. In the transient analysis you can use a step command to change the value of VBAT, or you can make VBAT have a fast turn on at the start of the simulation and a slow fall time to simulate a battery that is losing its charge. Like this:

View attachment 267103

A real battery would never behave like this, but in a simulator you can do unreal things just to see what would happen.
Thanks, I'll look into the syntax. I have been using the "Edit Simulation Command" menu to enter parameters and it looks like you have added additional arguments that are outside that menu.

One of your problems is not reading the data sheets.
The input of the LM393 will only operate to within 1.5V of its supply voltage (below), so with a 3.7V supply, that's 2.2V, which you are exceeding.
You need to add resistive dividers to the input to get your comparison voltages below 2.2V.

View attachment 267109
So for a starting voltage of 4.2V as VBAT is the supply voltage, a resistive divider of 2:1 would be sufficient as 2.1V < 2.7V. VREF does not require a divider. Also, I like the use of "one of"...

The battery could be simulated as a PWL voltage source ramp that decreases (or increases) over time.
But....what is "Vin".


Vin and VBAT both represent the battery which in retrospect should probably be the same entity.


Why is the whole circuit shutoff and not just the load?

As a safety feature to ensure my Li-ion cells do not over discharge. I have several LM317 I have put to use as voltage references with a load current of 5mA + 0.4mA of the LM393. If I could work out how much energy "headroom" I need between an arbitrary cut off voltage and the voltage at which damage would occur I would not be so concerned. I'm trying to use up the components I already have and its a fun challenge "making it work".

You circuit still has a few issues.

Feel free to lecture at your leisure..

For example, the voltage source ground connections need to be thought through...

Are you suggesting a group loop or low impedance path is formed after shutdown?
 

Papabravo

Joined Feb 24, 2006
18,408
Thanks, I'll look into the syntax. I have been using the "Edit Simulation Command" menu to enter parameters and it looks like you have added additional arguments that are outside that menu.
...
No you are mistaken. I use the following dialog box when I invoke the Edit Simulation Command.

1652571731119.png
As you can see there are six different tabs, labeled "Transient", "AC Analysis", "DC sweep", "Noise", "DC Transfer". and "DC op pnt". I never try to enter the simulation command as text -- my memory is not that good, the one for Transient just happens to be the default. Here is the one for DC sweep
1652571955717.png
As you fill in the boxes in the dialog box the string is constructed in the bottom entry box.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
531
No you are mistaken. I use the following dialog box when I invoke the Edit Simulation Command.

View attachment 267234
As you can see there are six different tabs, labeled "Transient", "AC Analysis", "DC sweep", "Noise", "DC Transfer". and "DC op pnt". I never try to enter the simulation command as text -- my memory is not that good, the one for Transient just happens to be the default. Here is the one for DC sweep
View attachment 267235
As you fill in the boxes in the dialog box the string is constructed in the bottom entry box.
Yes I understand. You are using new arguments is all. Perhaps there is a LTspice manual you can recommend? The ones I found are more of examples and intro tutorials
 

Papabravo

Joined Feb 24, 2006
18,408
Yes I understand. You are using new arguments is all. Perhaps there is a LTspice manual you can recommend? The ones I found are more of examples and intro tutorials
The LTspice Help file and the LTwiki:
https://ltwiki.org/index.php?title=Main_Page
are the only two things that I rely on. There is no book or manual that I have found that is even worth the powder to blow it away.
@Bordodynov did reveal to me that he finds the Pspice documentation "helpful" when exploring the dark corners of "spice" simulators.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
531
It it's 3.3V as you show, it does.
As I stated, neither input should go above 2.2V for proper operation.
Well, that was the first problem I noticed. ;)
VREF would normally be 1.25V. I made it 3.1V in the schematic to simplify things instead of including the reference circuit of VREF and the divider circuit of VBAT to set the trip point relative to a VREF of 1.25V so VBAT would have got a divider anyway. However, I have been ignoring the Input Common Mode Voltage Range tolerance so I'm glad you pointed that out.

I have changed the schematic several times and the answer to why I choose some details is partly an artifact of my previous reasonings that no longer belong. It's easy to become snow blind staring at a schematic eh? Then I wonder why the heck I did that!?
 

crutschow

Joined Mar 14, 2008
29,779
VREF would normally be 1.25V. I made it 3.1V in the schematic to simplify things instead of including the reference circuit of VREF
Then why not initially show a reference voltage of 1.25V on the schematic, to avoid misunderstandings?
It's not good practice to deliberately show incorrect info on a schematic.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
531
Then why not initially show a reference voltage of 1.25V on the schematic, to avoid misunderstandings?
It's not good practice to deliberately show incorrect info on a schematic.
Well the thinking was adding the LM317 model to the simulation might cause problems because I know using it as a reference is not an intended use. Another artifact because I could have just made the value 1.25V which more accurately represents the operation. Some laziness been factored into the why response as well haha. In any case, I'll present complete schematics from now own.
 
Top