Solved: Need help with how to create a current controlled voltage source symbol

I do not know how to create a current controlled voltage source symbol in order to place into my schematic.

I already hand jammed the values using the node voltage method and the text book already gives the answer of 24V, I am just trying to get savvy in creating these schematics and simulating them for overall proficiency improvement and yep the ccvs is a sticking point. Not frustrated, I just found a problem which justifies me digging into this deeper, learning :slight_smile: . LtSpice has the ccvs model and symbol, online circuit simulator has it too- done them there. I have found online the basic premise of how to go about creating a symbol, on other simulators, no issues. But kicad encourages me to make my own, cool no prob, but how?

Circuit I am trying to simulate is:

image

Attempt 1:


Simply inserting VDC from kicad library and change parameters


image
Gives wrong value, something like 90V at Vo across R4, its supposed to be 24V. I try and multiply Vh by the V1 current “i(v1)” but the program complains. Kinda worn down.

So I draw up my own symbols:

and

image


I am trying to figure out how to use the model shown in the ngspice manual for ccvs page 93:

4.2.4
Hxxxx: Linear Current-Controlled Voltage Sources (CCVS)
General form:
HXXXXXXX N+ N- VNAM VALUE
Examples:
HX 5 17 VZ 0.5K

Not sure how to implement it, create a word document in a file location and follow chapter 2.2 of the ngspice manual?

Anywhoo, I would like to simply insert a “normal” voltage source at the ccvs location and simply edit the “value” by multiplying “20*i(v1)” and be done. Not working.

I did not really find anything else on this forum like this except this one, kinda:

Any takers?

If you want to use a value like 20*i(v1) simply use a B-source. It has two terminals and the current is controlled by an expression.

EDIT: remove wrong info about H-sources.

I also don’t know what on Earth is going on with the symbol you created. Why are there two resistors in there? H-sources don’t have any resistors. You’re also confusing pin functions in symbols. Pins 3 and 1 in your final schematic are floating. Graphical lines in symbols don’t create electrical connections. Only use pins for places where the symbol’s final user will connect wires to.

1 Like

Hi,
I think the best way to create a Hsource is to insert a VSOURCE (like your V1) and rename it to H1. In the value field, just write the transresistance in ohms. For example, 20 * I(V1). If it complains you can try with adding braces {20*I(V1)} or even value={…}

You can also draw your diamond symbol as you did, indeed you can add it to the KiCad official library if you like. See here e.g.: https://github.com/KiCad/kicad-symbols/pull/2904

1 Like

I tried both ferdymercury and radix methods and I was able to get results with the latter. I guess the Bsource is “generic”? I was understanding that it was strictly for voltage controlled voltage source


I tried numerous times every which way but loose it seemed using ferdymercury’s method, until I began comparing sources properties. The “vsource” in pspcice library still would not work but the “vdc” in the simulation_spice library worked using ferdymercury’s way, YEAH. Both methods ended up working.

What seemed to make the difference were the symbol properties when right clicking on the symbol to edit the fields, and maybe specifically the Spice_Primitive field to “B”, because it did not work when it was a “V”:


Maybe a youtube vid is in the near future eh :slight_smile. Actually Im going to attempt to recreate a diamond symbol that looks just like the textbooks, “shouldnt be to hard eh”:

https://www.uta.edu/ee/hw/pspice/pspice02.htm


All good now,
Thanks to both of you for your guidance!

2 Likes

It’s always best to use the linear dependent sources (E, G, H, F) when and where you can. In general, they compute faster and cause less convergence issues.

I’m not sure how ngspice specifically handles it, but in other SPICE3 based engines when you reference a device current in the definition of a B-source it uses a quasi-static approach. This means any B-source that is in the same circuit loop with a current it’s referencing has no instantaneous feedback. A common issue I see on Stack Exchange (Example 1 and Example 2) is students using B-sources for these circuit analysis homework problems and the circuit fails to converge or gives nonsense answers. Just something to be aware of. It’s also possible ngspice has the ability to auto-detect a B-source definition as linear and auto-map it behind the scenes to one of the 4 linear sources.

1 Like

Glad you found out.

Concerning my method with a VSOURCE, I think it only works if you add a new VSOURCE and change the name and value before you run the simulation. Otherwise, the Spice Primitive field gets auto-populated too soon with the default V or B based on the REF name, and then it does not get overwritten anymore even if you change V1 to H1.

In any case, you can always adapt later the auto-created Spice_Primitive field. And verify later by clicking on Simulation, Show SPICE netlist if the result is as intended.

Side comment, Bsources and Isources have the wrong arrow direction, see bug report: