New to KiCad simulator - Possible bug and simulation problem

Hi,

I’m very new to Spice simulation and tried to simulate a simple transistor amplifier.
For this, I created a small project which schematic is shown below (as well as the spice sreenshot).
At first, I got the following errors (I replaced ‘*’ by ‘x’ as some comments wouldn’t show correctly in bold) :

Note: can’t find the initialization file spinit.
xxxxxxxx
xx ngspice-42 shared library
xx Creation Date: Jan 19 2024 07:06:53
xxxxxxxx
Note: No compatibility mode selected!
Circuit: *
Warning: No job (tran, ac, op etc.) defined:
run simulation not started
Error: vector frequency not found!
Error: vector frequency not found!

However, the error changed after closing the simulator and schematic editor and opening them again.
The same happens after closing KiCAD and re-opening the project :

List of plots available:
Current const Constant values (constants)
Note: Compatibility modes selected: ps lt a
Error in line inc. bjts
Not enough parameters
Error: ngspice.dll cannot recover and awaits to be detached

Any help appreciated :slight_smile:

I see several issues, and you’ve obviously not run ERC to highlight them.
First, using global labels is OK, but a wire is safer. Redraw. That removes four of them
Second, for the output, don’t use a global label, but a connector of some kind from the library.
Third, your capacitors are “1”. “1” what? p, n, u? And I’m not certain that “K” is acceptable for resistors, normally “k” is used.
Fourth, the simulator expects C-B-E as pins for a BJT. Yours is B-E-C. Fix the pin sequencing.

That should be a good starting point. And run ERC before simulating.

Thanks for your suggestions.
I applied the mods (J1 excluded from simulation) but still get the same text output.

The schematic looks OK now.
But does the transistor have a Spice model? You need to add this yourself.

Yes, I used the model from the manufacturer:

*SRC=BC817-40;DI_BC817-40;BJTs NPN; Si; 45.0V 0.800A 220MHz Diodes
Inc. BJTs
.MODEL DI_BC817-40 NPN (IS=4.04n NF=1.00 BF=822 VAF=121
+ IKF=0.273 ISE=2.86n NE=2.00 BR=4.00 NR=1.00
+ VAR=20.0 IKR=0.675 RE=0.227 RB=0.907 RC=90.7m
+ XTB=1.5 CJE=107p VJE=1.10 MJE=0.500 CJC=34.7p VJC=0.300 MJC=0.300
+ TF=651p TR=108n EG=1.12 )

By the way, it looks like you don’t have to follow the CBE pin sequence: when selecting the Spice model, the Pin Assignment tab allows setting the correspondances between the Symbol pins and the Model Pins.

Yes, that’s what I meant by watching the pin sequencing. It’s done under “Symbol Properties”.
You seems to have changed the symbol pins instead, which is unnecessary.

Yes but the change was only local to the schematic. I switched back to the original symbol and corrected the pin sequence in the tab.

Still, I get the same errors. And always this dll issue when closing the simulator and opening it again, even if I close KiCAD.

Try using this one (I know it works):

BC817-40.lib (1.5 KB)

The .dll thing I can’t respond to, I’m not an MS user, but run a stable OS instead.

Reproduced your circuit, it runs beautifully in simulation:

1 Like

Thanks ! Works better although I can only see gains.
How can I see the output voltage (AC) depending on the V2 frequency (80mV audio signal, say from 100Hz to 10kHz) ?

Use “AC” analysis. This will give you a Bode plot.

Tried that but only get gains (dB) and can’t right-click the scales.
How do you inject a sine wave ranging from 100Hz to 10kHz and plot the output voltage ?

You can’t. But gain x input voltage gives you the same. I get this:

dB’s is what you want. If you have no experience with them, then learn how to use them.
It took me some time to interpret the graph posted by ML9104. Amplitude changes between 8.996dB and 8.934dB which is a negligible change of 0.06dB. Phase looks weird, but it goes from -180 degrees to +180 degrees, so it mostly shows a math anomaly, but is (nearly) “flat” otherwise. To get meaningful info about the AC analysis, you have to do it over a bigger frequency range.

Phase looks normal. The flip from -180 degrees to +180 degrees is standard in all simulators etc. I know of.
Just for fun, I ran a sim from 0.01 Hz to 1 MHz. Here it is:

The intial high-pass is of course from the input capacitor. The high-frequency response is a bit disappointing, but with a 330k resistor for base biasing, I guess the BC817 is starved of base current.

1 Like

R1 with apparent input capacitance of the transistor caused by the Miller effect is the low pass filter.
Transistor working in common emitter system has the lower band than in common base or common collector.

Thanks for your feedback.
I’m trying to determine the output level of this circuit when used as LF amplifier with a 80mV input level.
I could easily scope it but what interests me is to simulate it in order to easily change values to eventually adapt the output level which shouldn’t exceed 200mV.

I have been playing with electronics since I was 10. My conclusion from studies was: Oh shit, everything I know intuitively can be calculated! There were no personal computers back then - you couldn’t simulate a circuit, you had to calculate gain in the midband, poles of the characteristics for low and high frequencies.

Have in mind that AC simulation is ‘small signal simulation’. It don’t counts such things like output voltage limiting by supply. Transient simulation shows you how signals really look like.

Some additional remarks:
There is a bug in the BC817 model file posted in Post 4. KiCad/ngspice complains

**Error in line inc. bjts**
**Not enough parameters**

Why not take this message seriously? The model file contains a line Inc. BJTs. What is that? If a line starts with I, ngspice looks for a current source, with parameters like 2 nodes and a value. This is not there. Well I know that this is a mis-placed line break, and Inc. BJTs belongs to the end of the line above. Unfortunately such things are strictly forbidden, as they always will lead to mis-interpretation and error.

Using global labels for input and output is o.k., if we are doing simulation only. A global label eases readability, and you want to plot out versus in.

Of course you can (with some effort though).
Please have a look at Generate chirp signal in Kicad .
Another way may be using the function generator ICL8038, see More simulation examples for KiCad/Eeschema/ngspice