Trying to simulate the soft latch in EEVblog #262

Hi i am trying to simulate the soft latch presented in EEVblog #262. Here is my schematic:

The switch is uses following model mostly scraped from elsewhere on this forum but modified a bit:

.SUBCKT MyButton_NO 1 2
S1 1 2 n001 0 MySW_NO
* Initial value, pulsed value, delay time, rise time, fall time,  width, total*
V1 n001 0 pulse(0 10 1.5 0.02 0.05 0.5 2)
.model MySW_NO sw vt=1 vh=0.2 ron=1 roff=1000MEG
.ENDS MyButton_NO

The models for the BJT is taken from and MOSFET is taken from helpful kicad spice library on github. But for clarity the models are:

.model 2N3904 NPN(IS=1E-14 VAF=100 Bf=300 IKF=0.4 XTB=1.5 BR=4 CJC=4E-12 CJE=8E-12 RB=20 RC=0.1 RE=0.1 TR=250E-9 TF=350E-12 ITF=1 VTF=2 XTF=3 Vceo=40 Icrating=200m mfg=Philips)

with alternate sequence of 3 2 1 should be 2 1 3

and for brevity the MOSFET definition can be found here. I’m using alternate sequence of 3 1 2

Now this does not seem to work i am possibly

  • Not understanding the way alternate sequence is used.
  • For some reason when i test parts of the model i need to pull low down with a very high resistor to get the button to work. Whats up with that.

Any ideas whats wrong?

Edit:

Reading the spice source appears that my pins are correct. And indeed i need to add a load on output. Still I m a bit puzzled since it starts up only once and the simulation starts with very negative values.

vout

MOSFET alternate node sequence should be 2 1 3. Its a PMOS with Drain to the right.

Yes, i seem to have fixed that already. Thanks for the heads up though

If the problem persists, you may post the project here (as a zip file) including all the model files. I could have a look then.

here you go

Button_sim.zip (87.2 KB)

There are problems with the initial conditions. You might give V1 a soft start. Instead of dc(12) you may put
dc 0 pulse 0 12 0 100m 100m 10 10
to the voltage source (like switching the power on).

Yes that helps a bit though it still does not seem to work correctly.

Ok, so the problem is with the IRF9540N model if is switch to a BSS84 then it works more or less correctly if i do the slow start suggested by Holger (thanks).

if i change the button pulse train to pulse(0 10 3 0.02 0.05 0.01 2). So that first pulse happens at 3, and the pulse is very brief then i get:

pulse-2

where red is out and blue is the button press.

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