Simulate CD4538 with ngspice

Hi, I have been trying to create a simulation of a CD4538 with KiCad 6 and discovered this post. I downloaded the file and created a symbol for a single device using the same node names as the .lib file and changed the alternate node sequence to correspond. I have powered the device from 5V DC and applied a pulse generator to the A input. Unfortunately I get no response from the device. Can anyone give advice?

Note: Compatibility modes selected: ps lt
Circuit: KiCad schematic
Background thread stopped with timeout = 0
Reducing trtol to 1 for xspice ‘A’ devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Initial Transient Solution

Node Voltage

/q_out 0
net-r2-pad1 4.5
vdd 5
net-c1-pad1 0
net-c1-pad2 3.34714
/pulse 0
xu1.1 0
xu1.clear 4.5
xu1.9 0
xu1.9a 0
xu1.3 0
xu1.4 3.35049
xu1.5 2.61952
xu1.6 4.05593
xu1.7 3.3327
xu1.8 5
xu1.t2a 3.34714
v1#branch 0
v.xu1.v1#branch 1.52495e-26
v.xu1.v2#branch 0
v2#branch -0.00192831
a.xu1.adacout#branch_1_0 -4.5e-06
a.xu1.adacout#branch_1_1 0
a.xu1.adacen#branch_1_0 -0.0045
a.xu1.adacin#branch_1_0 0
Reference value : 0.00000e+00

No. of Data Rows : 5245
Background thread stopped with timeout = 0
Reset re-loads circuit KiCad schematic
Circuit: KiCad schematic

I felt it would have been better to split this off to a new thread rather than append to an old thread which may or may not be relevant. You can always link to the old thread if you think it might provide more background.

Thank you. I posted it in the old thread because I think the participants of that discussion seemed to have the know how to help me but I’m happy to give it a run as a new thread.

I think it’s better to start a new thread if the relevance is not clear so that participants can come with fresh eyes. And it’s easier for new viewers not to have to digest all the preceding posts.


Your resistance values are very high even for CMOS. Try with 100k instead.
Which model are you using?

No idea why it doesn’t simulate. in real life the circuit looks fine. It should deliver a 10mS pulse at the output with the R1 & C1 values shown.
I’d also swap R2 & R3 to 100KΩ

Edit: I take back the comment about working.

Pin 1 & C1 connection needs a GND.

Thanks to everyone for the suggestions. I have used this circuit several times and it does work in real life. Here is what I know so far.

  1. Pin 1 doesn’t need a ground IRL for the 4538 and 4098 but does for the 4528. I have used all three devices in the past. In the simulation I was advised not to ground pin 1 as it gives an error. I can confirm that.
  2. I have tried this simulation with various combinations of component values, different inputs and trying odd things like taking enable to ground.
  3. IRL I have used up to 2.2M as a timing resistor with success.
    All I get out is a straight line at 0V.

@retiredfeline I would like to upload my symbol and lib files but I get a message that new users can’t do that.

This shows what you need to accomplish to get to Level 1 (Basic) to be allowed to to upload.
It is not a great deal (you’re probably more than half way there), otherwise you will have to wait for an Admin to bump your promotion.

A clarification:
“Enter at least five topics” means open and read, not necessarily post and this all has to happen after you have registered :slightly_smiling_face:

does show that there has been a transient simulation. What is its output?

In the top post you have submitted the ‘initial transient solution’. Please edit your post and mark the ngspice output text as code. Now it looks rather ugly.

Also the ‘initial transient solution’ does not tell us much. Please post the ngspice netlist instead.
Eeschema → File → Export → Netlist… → Spice → Export Netlist.

Better even to get a zipped copy of your project (including all spice model libraries).

Hi Holger

Thank you for your prompt response. I was just getting a 0V straight line output but I have just resolved the problem. I read the data sheet again and saw that the devices are tested with tr & tf <= 20nS. I had them set at 100nS for my pulse generator as I that is what I am expecting from my input device. I reduced them to 10nS and it works. I have usually used the HEF4538 and the Nexperia data sheet says that the inputs have Schmitt trigger action to accept slower rise and fall times so I have never really looked at it closely before. Thank you for an excellent explanation of matching a spice file to a KiCad symbol in the earlier topic.