Measure current in a simulation

I want to simulate a capacitor discharge ciruit (CDU)

This is the original circuit. It’s goal is to briefly supply a large amount of current without affecting the PSU. During charging the transistor is supposed to decrease the charge time significantly.

I have used a 4A transistor because… well internet said so. But I don’t know how much current it is going to draw when the capacitors are charging. There are also CDU’s out there which which draw no more than 400mA and can supply up to 9A for < 100ms.

I want to know how much faster the capacitors charge with the transistor.
I also want to know how much current is actually drawn during loading with and without transistor.

Therfore I made this simulation circuit. The load is not yet in use. I used 2 separate transistors to simulate a darlington.

I want to know the current flowing throuh I1

The result is not satisfactory. So I am doing something wrong but I don’t know what.

Can somebody help me out here?

Kind regards :wine_glass:

Bas

I1 is a stub.
What do you mean?
Current in D1 perhaps?

From what I can see, you can throw away all the 2k resistors (why are they there instead of a 500 ohm resistor???) and the transistor as well. I don’t see the point of them.

I assume you want to build a constant current source, but with that circuit, the transistors do not work that way.

No comment on your circuit.

I use the circuit below to determine Cap and Resistor values. And, use the Tuning feature…

I think I get what you want to do.
This is for points on a model railway, and you want a constant current draw from the PSU, but large current pulses for the point solenoids. Is that right?
That’s pretty simple, but lacking, because your circuit does not limit the pulse time to the points.

Not really a KiCAD question, more for EEVBlog IMO.

What that means? Specially ‘without affecting the PSU’.
This circuit is supposed to be in paralel to PSU to fast pre-load its output capacitors to let PSU not worry about it at the first moment?
What is electrical task of this circuit.
To charge capacitors as fast as possible - than what for the transistor - just short it.
To charge them with limited current - than transistor should be used in a kind of current limiting configuration and not in just being switched on.

Why not?
Because it takes 10s to reach voltage you expect?

It behaves as I would expect from schematic.

I am guessing he intended to build something like:

First of all, I have not designed the circuit neither I asked questions about this proven-to-work-really-well circuit. This is only the 3rd time that I use KiCad’s simulation tool, and I am asking if I am doing something wrong in the simulation tool because I suspect so. This is where this topic is about.

I do will answer some questions.

They are intended for extra heat dissipation. Switching may happen via a decoder device which switches the load with a transistor or a manually operated physical switch.

Some of the loads (point motors) have limit switches. They disconnect the driving coil physcially. But not all of them.

If you don’t have a limit switch and you hold down the button too long and you supply with 18V. There can be power dissipation of roughly 0.65W in those resistors. I tend to use 1206 SMD resistors, so I put 4 in parallel. This costs next to nothing and it does not hurt.

That’s pretty simple, but lacking, because your circuit does not limit the pulse time to the points.
It is not lacking because the capacitor will start charging again as soon as you let go of of the switch.

The original design used THT resistor. The transistor is also rated to 4A. Whether this is actually needed I cannot yet tell, that is where is simulation is for.

Current in D1 perhaps?

For now yes. In the future I want to add more measure points ofcourse. But I do want to know the charge current flowing through D1

What that means? Specially ‘without affecting the PSU’.

CDU does 2 things.

It prevents voltage dips on the power output lines during switching actions. In the old days when you would set a switch, you would see your lighting dim. At this time we still used old transformers. CDU solves this issue.

CDU can supply like 7A or more. While it only draws a small current of around 0.5A or less from the PSU. If I would switch one of those coil drive abomination which consume 7A (these exist), my 1A meanwell PSU will go into short circuit mode or so. With the CDU in between my 1A PSU can supply a 7A point motor just fine.

I am guessing he intended to build something like:

I assume you want to build a constant current source,

I am sorry but your assumptions and guesses don’t come close.

Back to the topic.

In the simulation I am looking at the pink dotted line I(V1) I am seeing a negative current of a few mA in the very beginning and than the current seems to be 0 mA. This cannot be correct. The voltage line does look real to me.

So what do I have to do in the simulation schematic in order to measure the current flowing through D1.

I’ll go try out some things. See if it is any other plot in the right side menu. I see references to D1.
And I go examine the post of @BlackCoffee

Kind regards :coffee:

Bas

No luck so far. I reduced the circuit, but I am not seeing a typical capacitor charge
The diode does not seem to make a change

Am I using the right voltage symbol?
Do I have to fill in something for the capacitor other than capacity? Does kicad understand that the capacitor is empty at the beginning?

:tumbler_glass:
Bas

Now I understand. This is device inserted between supply and load needing short high current pulses from time to time.

In my opinion paulvdh guesses are right.

The circuit you try to analyse is simply voltage follower. Using Darlington it certainly not limits the current drawn from power source to a small value.
Let us imagine that you have at Darlington collector 18V and at capacitors 10V. You have 1.4V (2x0.7V) drop at Darlington b-e so you have 18-10-1.4 = 6.6V at 0.5k resistor. So the current in resistor is 13.2mA. If both transistors in Darlington will have hfe of 100 your 13.2mA will be multiplied by 10000 giving you 132A. There will be other factors limiting that current.
Limit your simulation to first 100us to see what happens in the circuit.

The circuit you have can be useful under some circumstances but discussing it certainly is not KiCad related.

In my opinion paulvdh guesses are right

In my opinion they are 100% offtopic.

No offense to you guys, but I am not the one who is discussing the circuit. In the opening post I asked one whole question with a ? I litterly asked what I am doing wrong inside the Kicad simulation tool.

And I merely added some extra background information. Unfortunately it triggered a discussion leading to:

but discussing it certainly is not KiCad related.

I concur completely, can you please all stop discussing the circuit? This topic isn’t about that.

If it helps, this entire threat may go into the digital dumpster. Than I can start a new one with just this:

Why I am not seeing a typical capacitor charge plot

Why is this plot no beuno?

Bas

And the question was:

I’m sorry to be pedantic, but that was not your question. Before your actual question you wrote a whole story about intentions and expectations that can be interpreted in several different ways, and it’s not clear to me what your actual topic is. With such questions my mind starts wandering too, so I’ll go being off topic somewhere else.

1 Like

I’m not Spice expert. I was using PSPICE from time to time. Last time may be 10 years ago.
I have also spend day or two with KiCad Spice several months ago.

Spice calculates the stable DC polarization point, and when you start to simulate what happens next than nothing happens until you don’t have any made by you changes.
But in your first plots there were some changes so I supposed you have a voltage source changing its value at time = 0.
To see how capacitors are loaded you should use Pulse voltage source to define that it starts from 0V and then it steps (in some very short time) to 18V and stays there for whole time of your simulation.

1 Like

I’ve read all the replies, and in my mind is why not simply add a “resistor” to the original schematic with R=0 ohms, for production (a short), and for the simulation change that value to 0.001 ohms, then measure the current through that resistor (or voltage across it). A value of 0.001 isn’t likely to change the operation of the circuit - and the final version delete it - before doing the board. Or if you want it left in, place a jumper foot print in place of the resistor.

The title of the thread is misleading. The OPs problem is not with current measurement capability, but with some unexpected results of this current measurement.

As Piotr has suggested, the thread is about simulating a start-up condition.

When you do a transient simulation, typically an operating point is determined firstly, and then transient sim starts. During operating point simulation ngspice opens all capacitors and shorts all inductors, sets all voltage and current sources to ‘on’ and then calculates the DC operating point of the circuit, taking all device non-linearities into account.

You may look at the results per node, as they are indicated in the Eeschema circuit diagram after a simple OP sim. Capacitors are charged to their node voltages for example. So no charging current is measured, when you then run the transient sim, they start being already charged.

If you are interested in simulating the start-up, you have to do so explicitely. There are at least two methods:

Define an intial condition for a node voltage, e.g. by setting the capacitor node to 0 V by putting
.ic V(nodename) = 0
into a text box on the Eeschema canvas (‘nodename’ has to be replaced by the actual name of the node).

Another method (which I prefer and Piotr already has pointed to) is to replace the constant voltage source V1 by something which starts at 0 V (which then is also used for determining OP) and switches on only during transient simulation. This may be a pulsed source VPULSE with the appropriate parameters or a PWL source VPWL with for example parameters like
pwl="0 0 5m 0 6m 18 10 18"
So for the first 5 millisecond the voltage is 0 V, only then it rises with rise duration 1ms to 18 V where it stays. With this method you are determining the startup conditions, not letting the simulator do it for you.

Not sure if I I should start a separate threat or not. But I have some succeses. And one thing which just doesn’t want to work. That is a voltage controlled switch.

Charging the capacitor takes now roughly 1.5s and that looks okay. The voltage will reach around 16.7V

I added a 4R load and I want the switch to close when the capacitor voltage reaches 16.1V. I want to open the switch again when voltage drops below 0.1R.

afbeelding

Voltage exceeds the threshold value but I don’t see any switching.

Why is this switch not switching?

EDIT.
nvm. I found out why. It seems that the switching points are at threshold ± hysteresis. My values were all wrong. Now I put a threshold voltage at 8V with a hysteresis at 7.9V.

Kind regards :coffee:

Bas

I would expect threshold ± 1/2 of hysteresis but I have never used switch in simulation.

4 posts were split to a new topic: Simulation not working

This topic was automatically closed after 90 days. New replies are no longer allowed.