Creating a Current Controlled Voltage Source (CCVS) (NGSPICE Hxxxx) for simulation?

Hello all,

like it says in the title, I can’t figure out how to create a Current Controlled Voltage Source to use in my KiCad simulation. I did a quick search but there wasn’t a lot of recent discussion on the topic. I did notice a thread from 2021 where this was discussed but that unfortunately went a bit over my head (should’ve majored in electrical engineering I guess :grin:). What I’m trying to do is find/make/configure a symbol that works in the KiCad simulation like an HSOURCE described in the NGSPICE documentation:

image

I’m actually a mechanical engineer working on my thesis, and started using KiCad as a part of my thesis to build and simulate a simple resistor network. The model itself is actually modelling electric motor thermal behavior. So far it’s been a breeze, since I’ve only needed voltage sources, current sources, and resistors.

Now, however, I noticed that the simulation_SPICE library doesn’t have a current controlled voltage source available. I’m in desperate need of such a symbol. Do some of you more experienced KiCad users know how to create one? As mentioned, I’m still a total novice when it comes to KiCad. Any help is much appreciated.

For simulating a device in KiCad/ngspice, you will need a symbol to be placed on the Eeschema canvas, and a spice model, attached to the symbol.

Indeed a symbol and model for CCVS are not available in the Simulation_SPICE library.

What we need to do is: mis-use (without or with modification) an existing symbol, and define a model. As always, there several ways to achieve a solution. One is:

Lets take the E souce symbol (VCVS), which ahs 4 pins (3,4 as input, 1,2 as output)
Rename it to H1, HSource and remove the type= line.

Define a model:
Models may be put into a ngspice subcircuit. The template with 4 pins is

.subckt MyHsource out+ out- in+ in- params: gain = 500
.ends

Inside of the subcircuit

* H Source
.subckt MyHsource out+ out+ in+ in-  params: gain = 500
* output
Hsub out+ out- Vnam {gain}
*input is a voltage source with V=0 to measure the current
Vnam in+ in- 0
.ends

Put this model into a file (say myh.lib) and attach it to the symbol.

See example at
HSource.7z (5.2 KB)

Thank you Holger! This was exactly what I was looking for, an excellent concise explanation and a simple example that really helped me develop my KiCad skills. This helped my work immensely.

Just for info, I have made a merge request Simulation_SPICE: Add FSOURCE and HSOURCE (!4629) · Merge requests · KiCad / KiCad Libraries / KiCad Symbols · GitLab to add the FSOURCE and HSOURCE to the Simulation_SPICE library. These symbols integrate with KiCads Simulation Model Editor and should be more ergonomic to use.

Or this personal symbols of mine - intend to have the size shrink 40% for more dense schematic…

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