Source code coming soon. The GitHub repository is private for now and opens to everyone very soon.
BetterSPICE Beta 0.8.1 Join the beta Download soon

Calculators Parts

LED resistor calculator

Enter the supply, the LED forward voltage, how many LEDs are in series and the current you want. The resistor is R = (Vs − N · Vf) / I, rounded to the nearest standard value in the series you pick, and the calculator gives the power in the resistor and in each LED.

The forward voltage changes with the current. The calculator takes the datasheet Vf at its test current and moves it to your working current with the Shockley equation, the same LED model the simulator uses. Solve the current instead and it tells you what a resistor you already have will give.

The calculator

The app's own calculator window, built from the BetterSPICE 0.8.1 source. What needs a schematic is greyed out here: placing the circuit, running it, applying values to parts and picking parts from the library. Open it in its own window.

The formulas it uses

These are the formulas the calculator shows, copied from its source code. The results in the window above come from the same code as the app.

Formulas

  • R = (Vs − N · Vf) / I
  • Vf(I) = n · Vt · ln(I / IS + 1) + I · Rs
  • P(R) = I² · R
  • P(LED) = Vf · I
  • Vf is taken at the working current from the datasheet value at the test current, with the LED model of the simulator.

Sources. Ohm's law across the series resistor. LED forward voltage by the Shockley equation fitted to the datasheet Vf at the test current, as the BetterSPICE LED part does (docs/DEVICES.md). Standard values from IEC 60063.

Simple and Advanced

Simple is the main values, one set of results and a plot. Advanced is the full design view: the operating range with its corners, tolerance and temperature, checks with their margin (a green tick, an amber warning or a red cross), the parts to order with the ratings they need, warnings that give the fact, the number and the fix, and plots over the whole range. A value typed in one view is the same in the other.

In the app it also places the circuit and checks it

In the app, the buttons under the result act on your circuit: Place as circuit. The circuit is drawn with library symbols, wires, a source and probes, placed at a free spot in the view, and the analysis that checks it runs at once. With parts selected, Apply to the selected parts writes the result into them, as one undo step.

The last tab of the Advanced view, Verify in simulation, places the calculator's circuit and runs it, with measurements whose pass limits are the calculator's own numbers. A row the simulator cannot check says so and why. More in the manual: LED resistor.