I’m having trouble getting a spice simulation of a MOSFET LED driver circuit working. I’m using the manufacturer’s spice model of the FET, and I initially suspected the issue was not mapping the KiCAD symbol pinout to the model pinout correctly. However, I’ve tried every permutation of 1,2,3 as the alternate node sequence, and I still get no switching of the FET.
From the little I know about ngSpice in KiCad, you have to enter voltages for your voltage sources, and you also have to specify which sort of simulation to run in KiCad.
This may be a better place to start. I have not ran any of those examples myself, but I assume you can just open them and run them.
I also noticed your schematic has the old .sch extension, which is for KiCad V5.
The most current KiCad version is V6.0.5 and you can get it for free from the KiCad website:
The schematic file should contain the setup for the voltage sources, I thought, but I am also pretty darn unfamiliar with where KiCAD stores simulation data – I am usually just laying out PCBs, like KiCAD was intended.
I have already set up my voltage sources, and set up a transient analysis. Sometime like a 1 us step size for 1 ms. I can see a nice sine wave at the “FET” label, but the voltage is a constant 3.3V at the “LED” label, and there is no current flow. I’ve breadboarded this circuit just to prove out that it does, in fact work – hoping to tune some component values, though.
I’ve been running the old version of KiCAD because that’s what the Debian package manager supplies, but I’m thinking it’s perhaps time to move to a newer version, even if I’ve got to do things manually. I’ve heard v6 has a lot of improvements.
Lots of things wrong here:
1: you need to use the resistors and capacitors from the “pspice” library. Yes, they look ugly, live with it.
2: same for the diode symbol: either from “pspice” or “Simulation_PSPICE”. Add appropriate model to the component.
3: your voltage sources need values. Right-click on “VSOURCE” and edit the “Spice_Model” value. V2 is probably DC. Have fun with V1.
Are you sure about that?
I’ve run some simulations with the standard resistors, and they simulated just fine.
I’ve even used the battery symbol from the default libraries, typed in a voltage for the value and it also worked.
The sallen_key from the demo projects also uses “normal” resistors.
But that’s pretty much my limit with experience with ngSpice in KiCad.
I tested a simple RC circuit sim, and it worked with the normal cap and resistor symbols.
The output of the spice sim says that it’s using default values for the LED, but just to be sure I also tried subbing in a resistor, with no effect.
Hm – looks like parts of my data didn’t get copied over. I did have values in the voltage source spice models. V1 was a DC 3.3 V, and V2 was a 38kHz AC 2.5V amplitude and 2.5V offset
No, I’m not sure. But ngspice has so many quirks/bugs that I try to be on the safe side. Otherwise simulation turns into even more of a nightmare. I use R and C from “pspice” to eliminate them as error sources.
Can you run the sallen_key demo project?
It has values for the voltage sources directly in the schematic, and also an .ac dec 10 1 1Meg Spice directive to tell ngSpice what sort of simulation to run. I’m seeing neither in your schematic.
Looks like I’ll need to update to v6 to do that – working on that now. Debian is a huge pain on that front, but I’m stuck with that for now.
Debian places a strong emphasis on system stability, which I didn’t realize when I installed it basically means running ages old packages all the time. Working on getting v6 so I can at least eliminate old bugs as my source of problems.
I like Debian very much, but I do not see it as a “usable” user friendly distribution. I see it more as a distribution that is mainly maintained as a foundation for more user friendly distributions. Debian is also very strict about “non-free” content (partly?) for this reason.
Maybe Debian also fits well for servers, where stability is more important than new features.
I can’t stand the colors and weird menu of Ubuntu, and don’t really trust Canonical either, so I settled for Linux Mint as my daily OS with a pretty simple Xfce as desktop. I find Mint very user (even beginner) friendly. It “Just Works”, both on 10 year old hardware, and on my new Ryzen 5600G and 107cm 4k monitor. Installation from USB stick takes about 5 minutes. (10 to 15 on older hardware). Why do you feel you’re stuck on Debian? A partition is easy to shrink with Gparted, and Linux distributions usually tolerate each other well. If you’ve got a free SATA port (or fast USB3) you can even install another linux distribution on a separate storage device and use your BIOS to select a boot drive. Mint is distributed as Live distribution, so you can test drive it directly from an USB stick. (I think most distributions do this these days).
The sallen_key demo is also available for KiCad V5. Possibly you have to install the KiCad_demo package separately to get them. Just do an apt search kicad to see what else is available. I do seem to remember I had to fiddle a bit with it to get it to work on KiCad V5, but I can’t remember details anymore.
There is eternal tension in distros between stability and new features/applications. It’s not just a case of new versions of applications are discouraged, it’s also that new versions may rely on newer dependencies (e.g. libraries) and upgrading those might put basic applications at risk of malfunction. That’s why there are so many workarounds: spinoff distros (e.g. those that use bleeding edge branches of Debian), PPAs, backports (someone has to do the work to adapt to older dependencies), Flatpaks, Appimages, virtual machines, multiple OS booting, etc. It’s bad enough when it’s one’s own machine, but the solutions may be more limited if it’s the company’s machine.
Anyway all of us have to find a comfortable spot in the spectrum. Some people chase distros and love to dodge rotating blades. Some are very risk adverse (“what do you mean I can’t run the latest Firefox on my XP?”).
I think the risk there was the discomfort of revising their habits.
As with a lot of things the vantage point changes the assessment. For your accident insurer the risk is that you will make a claim. For you the risk is that their payment may not cover your loss.
Holger is pretty much the most knowledgeable person concerning ngSpice here on this forum (he maintains the ngSpice software itself). and with his modifications, the mister-sir.7z file at least does “something”, see screenshot for current though D1:
Edit: This screenshot is with a faulty 2 3 1 sequence:
I had a look though his changes (also neatly provided in an extra text file (“steps_done.txt”), and I did not understand the changes to the node sequence he made. So I turned them to “2 1 3”, and this increased the current through D1 by about 4 orders of magnitude:
And that’s what I was hoping to solve! I figured one of my resistor values had to be off – the LED output on the breadboarded circuit was way too weak.
I was curious enough to play a bit more with it. so I changed the simulation parameter to:
.tran 100n 200u
To enhance the time resolution a bit and have less repetitive signals at the end and then re-ran the simulation, but this did not work. The time scale keeps on the first milli second. I have to close the simulation window and open it again (and re-run the simulation again) for these time parameters to take effect. This smells like a bug to me.