1
\$\begingroup\$

Just started using LTspice and I'm struggling with what is probably a total newbie mistake on a DC operating point test.

Created a basic circuit, 10V voltage source and 1k resistor in series, and I'm not getting exactly 10mA current.

Voltage source has zero internal resistance.

Resistor has zero tolerance.

When I run I get correct value of 0.01A on the results text, but not on the circuit label. What am I doing wrong? Thanks

LTspice screenshot

\$\endgroup\$
  • \$\begingroup\$ Floating point math is not, in general, completely accurate. That's all you're seeing here. \$\endgroup\$ – Brian Drummond Jun 26 '16 at 12:52
  • \$\begingroup\$ You did see that it's reporting mA and not A? 9.9999998 mA = 0.0099999998 A which is effectively 0.01 A. \$\endgroup\$ – Transistor Jun 26 '16 at 12:54
  • \$\begingroup\$ Thanks yes I was aware of this, but not having much understanding of spice yet I wanted to check it wasn't my error. \$\endgroup\$ – Jamie T Jun 26 '16 at 13:15
0
\$\begingroup\$

As already said by Barry, that is the effect of roundoff error. You can improve those results by increasing the internal precision used by LTspice's engine with the following SPICE directive:

.OPTION numdgt = 12

this will force the engine to use double precision floating point numbers for calculations (by default it uses single precision).

To add such a directive on the schematic use the menu edit/spice directive and enter the text above. Then place the floating box that pops up anywhere on the schematic.

Note that this could slow down some complex simulations (not necessarily, it also depends on your CPU, OS, etc.).

For beginners it is reassuring to see simple results not (visibly) affected by roundoff, but keep in mind that as long as computations are done in binary in the CPU there will always be numbers that are "round" when expressed in decimal, but cannot be expressed exactly in binary, and so they will lead to roundoff even in simple calculations, no matter what level of precision the CPU uses internally.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

That is simply roundoff error of the internal computer calculations. Note that the error represents only 0.000002 % and is negligible for any practical application.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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