New simulation examples are following here.
This time I am using KiCad 8. The new simulator interface is offering a lot of enhancements, which make it absolutely worthwile to have a look at this development. ngspice-41 is typically involved. Sometimes I am using ngspice-42 to benefit from the ngspice improvements.
The previous examples (KiCad 6, ngspice-38) are visible at Simulation examples for KiCad/Eeschema/ngspice .
The examples provided should run out-of-the-box: Extract the *.7z file into a directory of your choice. Open the project (or directly open the *.kicad_sch in Eeschema 7.99) → Inspect → Simulator → Run (green triangle).
The circuits shown below are not optimized, but may serve as a good starting point.
Potentiometer with tunable control
epot.7z (4.7 KB)
How to set up the tuner tool:
Potentiometer models
Attached you will find a small collection of potentiometer models
potentiometers.7z (6.8 KB)
How to use ngspice parameters to set device parameters and the .control section for printing values.
params.7z (4.9 KB)
Boost Converter
The first example is a simple boost converter, powering up 2.5 V to about 6 to 7 V. The switch is a power MOS device, the load is switched from 120 to 60 Ohms.
Boost.7z (7.2 KB)
Regulated boost converter
The previous example has been a ‘free-running’ converter. Load-switching and variation in input voltage will require some regulation. The following example adds a reference voltage, an error amplifier and a PWM (pulse-width modulation) stage to the simple boost converter. Here ngspice-42 is required, as it contains an improved PWM generator.
The output load is switched at 13ms from 60 to 20 Ohms. The two cursors clearly show that the output voltage regulation is working.
boost-complete.7z (12.8 KB)
Here is a version which does not need ngspice-42, as it relies on a pwm generator made with the vernerable one-shot code model.
boost-regulated-os.7z (12.6 KB)
Buck Converter
A simple buck converter with power NMOS
Buck.7z (7.1 KB)
Royer Converter
The next one is a Royer converter, as described in Royer Converter – Mikrocontroller.net (in German).
Royer.7z (10.6 KB)
LLC Converter
The next one is a resonant LLC converter:
This is an update, now using the switch symbol from library Simulation_SPICE, and there are ngspice switch models attached to these symbols.
LLC.7z (10.5 KB)
Digital PWM amplifier
This is the very basic prototype of a digital amplifier. You have a sine source, a PWM modulator with digital ouput, an anlog filter and the analog load.
The digital output consists of two inverse digital signals dn and dp:
The analog plot compares the sine input versus the differential output voltage on the load resistor R1:
pwm-audio.7z (6.9 KB)
Digital PWM amplifier update
This is an update to the basic class D amplifier: Use parameters for the PWM modulator, increase the output voltage to 200V: this yields in an output power of 2.7 kW. And nothing explodes (a benefit of the simulation)!
pwm-audio-2.7z (7.0 KB)
This one benefits again from the new PWM generator in ngspice-42, as the old one shows some dimples in the output, due to missing pulses.
Another Class-D 2.5 kW audio amplifier
with half bridge MOS driver and a ‘home made’ audio driver circuit model (pwm, non-inverted and inverted outputs, dead-time, hi-side and low-side outputs).
The simple Class-D-s uses the one-shot PWM (already available in ngspice-41 and older), the slightly more complex Class-D uses the somewhat faster new PWM from ngspice-42.
Class-D.7z (20.4 KB)
Analog multiplier
A circuit to demonstrate using a code model inside of a subcircuit.
The ouput is dressed in beautiful colors:
analog-multiplier.7z (5.0 KB)
You may do amplitude modulation studies, e.g. by setting V2 to
dc=0 ampl=1 f=100k
and V1 to dc=0.6 ampl=0.4 f=1k
, just to obtain
Generic symbols with generic models
The next circuit uses symbols and models from the Simulation_Spice library (opamp and npn transistor). So for a quick analysis there is no need to search for specific device models. Transient and small signal ac is simulated.
intro4.7z (8.9 KB)
IBIS interface simulation
Some “finger execises” in the new IBIS module are shown next. IBIS allows to simulate drivers and receivers (the I/O of ICs and their connections) without resorting to the inner functions of the participating ICs. Typically a sequence “Driver – Interconnecting tracks – Receiver” is simulated. Still somewhat experimental.
ibis-test.7z (61.8 KB)
Amplifier with controlled gain
using the TI TCA810.
gain-ctrl-amp.7z (8.1 KB)
Up-Down Counter
The up-down counter uses a home-made symbol, a home-made counter model exploiting the ngspice/XSPICE state machine, and user-defined signals for plotting. Please have a look at README before starting the project.
up-down-counter.7z (6.2 KB)
Triangle generator with MAX9000
MAX9000.7z (45.9 KB)
The venerable ICL8038
THis project contains a new spice model for the ICL8038, some info how to create such a model from the circuit diagram in the data sheet, the project to create a subcircuit for the model and an example circuit.
ICL8038.7z (72.6 KB)
The model circuit
The example circuit
The output, scaled
Generating a negative voltage from a positive supply with LTC1044
LTC1044.lib contains a new behavioral ngspice model. The project is
LTC1044.7z (7.6 KB)
The circuit
and some output of a transient simulation
Another 555 circuit example
The resulting output is
and the project (including a bipolar 555 model generated by KiCad).
555bip.7z (7.5 KB)
Logic simulation: comparison of full adders
ngspice event based logic simulation to compare a ripple carry approach with NAND gates with an integrated 74HC283.
The simulation project (gtkwave is required for plotting)
FullAdd.7z (22.9 KB)
The ouput looks like
Logic simulation: divide by 4 with 7474
digi7474.7z (7.9 KB)
Step-Down converter with LM2576
LM2576.7z (10.3 KB)
Step-Down converter with LMR33630
LMR33630-StepDown.7z (21.2 KB)
This is one of the more delicate simulation examples. The original LMR33630 model contained bugs and incompatibilities, so needed to be edited. Simulation is slow as we need very short time steps. It will simulate only with the appropriate ngspice options chosen, and it will need about 6 GB of memory for the results, as all nodes also from inside of the model will be saved at each time step.
Results are however good: Changing the load by a factor of 5 will be regulated quickly, changing the input voltage by 2 V is barely to be seen at the output.
This example also has led to some improvements to KiCad/ngspice: The incompatibilty and the excessive memory usage will be removed in ngspice-43.