How to set either simulation duration or number of pulses (np)

I’ve been getting some unexpected simulation results for a simple circuit driven by a VPULSE.

I just want to sim a fixed number of pulses. Isn’t the ‘np’ parameter of the vpulse source supposed to do just that? It seems to be ignored. The sim duration is always 10msec no matter what I change. The only way I’ve found to change the number of pulses is by changing the tw and per parameters, but I still can’t change the sim duration. If the np param is supposed to be ignored how can I change the sim duration?

I don’t have KiCad here to check anything but what you set in VPulse has nothing to do with how long is the simulation. It have to be set in simulation parameters.

As piotr mentioned, simulation time is independent from the number of pulses. If you set np to 5 then the right half of your simulation plot will probably bee a flat line.

When you are adding a transient simulation (or editing it) you can set the final time at which the simulation stops.

Please read the original post carefully before responding.

Piotr: I clearly stated that that simulations ignore any value given to np. The default value of np is uninitialized, yet sims still run for a fixed 10 msec. How do you explain this?

paulvdh: You stated “…you can set the final time at which the simulation stops.” I clearly asked "if …the np param is … ignored how can I change the sim duration?".

If simulator has a bug in v9.0.2 running on Windows please let me know. That any given setting of np is ignored seems to be a definite bug.

@ pascor You can specify the sim length with the .tran command and it is independent of np. see result
vpulse


If you still have problems you can post your project and the steps you do to make the change.

And what?
Do you think that I didn’t sow it. I sow it, but as I have tried Spice in KiCad 1.5 year ago for one day only I don’t remember what parameters VPulse has.
So I say no word about np.

But you said:

What suggest that you were trying to do everything you can but you get always the same sim duration. So I just suggested that you probably will find this setting in simulation parameters. But after doing it only once long time ago I even don’t remember how it is set up.
I’m sorry I tried to help.

Please get out of your own bubble. You are completely mis diagnosing the issue, as both Piotr and I have already stated before. Read our posts again and spend some more thought at what it really means.

@janharm Yes, you can also set the transient parameters as text lines in the schematic, but I guess that doing it via the menu is the recommended way these days. Doing it as a text line is still quicker to edit though.

My “bubble”? There appears to be no way to set the simulation duration parameter “via the menu”. I was told wrong (set the value of np) and incomplete information (“It [the sim duration] has to be set in simulation parameters”.). No mention was made how to do this. How should I have guessed the simulator accepts parameters in both the vpulse properties and unattached text fields placed anywhere in the schematic. This is incongruent, especially since they could easily conflict with each other.

I have found no information about the simulator accepting “transient parameters as text lines in the schematic”. The only parameters I found are in the simulation model of the vpulse properties but it does not include any duration field (at the moment).

You cannot set the transient simulation duration by voltage source parameters.

Transient simulation settings are set by
Eeschema —> Inspect → Simulator → New Analysis Tab → Tran → Final Time
You may save the settings in a workbook file to have them available next time thre tran sim is started (or the simulation project is opened).
And there may be other ways to define the tran sim parameters (like janharm said).

Please have a look at the documentation at Schematic Editor | 9.0 | English | Documentation | KiCad

There is also my introductory series of videos at https://www.youtube.com/@holger8105/videos and a tutorial at KiCad Eeschema as GUI for ngspice, tutorial for setting up the simulation.

I told you everything I know.
We have here so called ‘long weekend’ (from Thursday to Sunday) so I am not at work, but at home. At home I have Win7 PC while KiCad since V6 needs at least Win10 so I don’t have KiCad here.
I was using PSpice in 90s. There were no parameters set by texts at schematic. When I found info, that KiCad also have Spice I have just checked it is working (probably with KiCad V7) and then didn’t used any more.
I don’t know what is written in KiCad schematic manual, but I would expect there should be enough information to set time of simulation when you already got from me info that it should be set for simulation and not for VPULSE.

Piotr: Thanks for your info. I think LTSpice created the use of text embedded in the schematic to set simulation parameters.

I now understand the source of my confusion: Simulation parameters are listed at several places at once! 1- In my vpulse generator; 2- Free-roaming text embedded in the schematic page, e.g., ".tran 1u 20m ";

- SCHEMATIC SIM PARAMETERS

3- In the simulator’s toolbar “Simulation:Edit Analysis Tab…”. This is where the sim duration is defined. Apparently the .tran schematic text statement initially determines what ‘time step’ and ‘final time’ (sim duration) values will be seen in the ‘Simulation > Edit Analysis Tab’. Editing these values will override the .tran statement’s values set in the schematic.

- SIMULATOR ANALYSIS TAB

In the future I hope Kicad will remove the ability to set simulation parameters in the schematic and allow them to be set only in the simulator window. The current implementation is probably a hack to allow reading and conversion of older schematic types with minimum processing.

I never had a big need to use Spice. As in 90s visiting Cebit I’ve got PSpice demo version (limited to 30 nets, I think) it was enough for all my needs ever. When I heard of LTSpice I was surprised seeing all these texts at schematic being used to set anything. In PSpice I had everything set by menu (simulation parameters) and by symbol properties (double click and dialog box with parameters to be set). Variables and equations (I sow in LTSpice) are not needed in PSpice. You have symbols to be used for mathematical operations on signals and you edit what these symbols do by double clicking them and then specifying equations or just some parameters (there are a set of symbols doing different things).
But I know LTSpice is popular and KiCad is able (or will be able - I don’t know) import LTSpice simulation schematics. Because of it I suppose that your hope expressed in the sentence I quoted is vain.