5
\$\begingroup\$

I have this very simple circuit in KiCad:

A schematic showing a battery, a resistor and an LED

I'm trying to simulate the current through the LED, but whatever I do (change voltage of BT1, change resistance of R1, change model of D1), nothing ever happens. The simulator just acts as if the diode was not there.

Here's the netlist I'm getting:

.title KiCad schematic
.model __D1 D
.save all
.probe alli
.tran 100m 10

VBT1 Net-_BT1-+_ 0 DC 10 
R1 Net-_D1-A_ Net-_BT1-+_ 1
D1 0 Net-_D1-A_ __D1
.end

Here's the result, showing that I(D1) is always zero:

Image showing a constant current of Zero

How do I properly simulate an LED or ordinary diode?

\$\endgroup\$
2
  • 3
    \$\begingroup\$ I seem to recall that KiCad had a bug where simulated diodes had their anode and cathode swapped from what the symbol said they should be. I'm not sure if that's been fixed yet. \$\endgroup\$
    – Hearth
    Jan 4 at 13:51
  • \$\begingroup\$ @Hearth That apparently seems to be the case. If I turn the diode around, I get a nonzero current. Is there a workaround or something? \$\endgroup\$
    – PMF
    Jan 4 at 13:57

1 Answer 1

4
\$\begingroup\$

Thanks to the hint of @Hearth and the issue here I found the solution. One has to swap the pins in the Sim.Pins property of the LED, to 1=K, 2=A (default is the other way round). This aligns the simulation direction with the drawing.

\$\endgroup\$
5
  • \$\begingroup\$ I don’t believe it’s a bug. KiCad always has a discrepancy between physical pin numbering snd SPICE pin numbering. It always had a mechanism to adjust the pins for this. There used to be an “Alternate Node Sequence” field but it looks like they changed it recently to Sim.pins but there’s still a way to do it in the GUI via the Simulation Model Editor. What looks like they just started doing, though, is assuming a default for undefined diode models. Historically, it did not do this which is better in my opinion. It forced the user to understand the diode model they are using. \$\endgroup\$
    – Ste Kulov
    Jan 5 at 0:02
  • \$\begingroup\$ For example, if they assumed the default pin ordering along with the default diode model D, you would put the LED on your schematic thinking you’re simulating an LED. But the default diode model D simulates a basic silicon PN junction diode. It’s better to throw a “no diode model found” error instead of simulating something completely different than what was intended by the user. That’s just my opinion. Ok, I’ll shutup now. \$\endgroup\$
    – Ste Kulov
    Jan 5 at 0:07
  • \$\begingroup\$ @SteKulov As a Noob user of KiCad, I wasn't aware that one could change the pin assignment, and looking at the linked issue, the developers aren't sure how to fix it, either. For me it's just confusing that the default simulation is opposite to what the drawing says. \$\endgroup\$
    – PMF
    Jan 5 at 7:07
  • \$\begingroup\$ And your BJTs and MOSFETs will have similar problems, so be careful. And it’s not just KiCad, it’s all SPICE programs you always gotta check your pin orders. Anyway, I just wanted to make clear that even though you got the pin order sorted out, you’re still simulating a silicon PN junction diode in place of your LED until you define a specific LED model for it. \$\endgroup\$
    – Ste Kulov
    Jan 5 at 7:29
  • 1
    \$\begingroup\$ @SteKulov I know. I do have better models for an LED (found various parameter sets online), but due to the above problem those didn't work either, so I thought that without the basic model working, anything else just adds complexity. \$\endgroup\$
    – PMF
    Jan 5 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.