I am trying to create a battery model in LTSpice. The battery model is comprised of a voltage source and a series resistance. However, I need the voltage source to change as the amount of charge in the battery changes (the differential of the charge = current out of the battery). In addition, the resistance needs to be a function of the current.

Can someone tell me how to do this LTSpice? The voltage sources I see are constants or sines or pulses. I cannot seem to make them a function of something (in my case the charge). Similarly for the resistance.

  • \$\begingroup\$ What battery chemistry are you modeling? Or do I get to pick anything I want -- like lead-acid, for example? Also, in general, have you looked at B sources? \$\endgroup\$ – jonk Nov 11 '16 at 5:33
  • \$\begingroup\$ Some papers to consider for ideas: mdpi.com/1996-1073/4/4/582/pdf and nrel.gov/transportation/energystorage/pdfs/evs17paper2.pdf and there are many more. \$\endgroup\$ – jonk Nov 11 '16 at 5:44
  • \$\begingroup\$ You can also find some models in the LTspice Yahoo Groups (registration needed), or, IIRC, the Intusoft manual (I am really not sure now). \$\endgroup\$ – a concerned citizen Nov 11 '16 at 6:35
  • \$\begingroup\$ If you are operating in the middle/sweet spot of the SOC curve, a ginormous capacitor in series with a resistor will get you very close to a battery. Closer to <20 % and >80 % SOC, you need more stuff to model it. \$\endgroup\$ – winny Nov 11 '16 at 10:13

You can do that by using a "Arbitrary Behavioral Voltage or Current Sources" where you can define the arbitrarily define the behavior of you current source. I will not go in to the details of Arbitrary Behavioral Voltage or Current Sources since this is found in the Help of LTSpice

Additionally from http://ltwiki.org/index.php5?title=Undocumented_LTspice You can find the following section:

Resistors Behavioral Resistors Create a behavioral resistor by right-mouse-button clicking on its Value field and edit its value to read: R=. This feature is undocumented, but is considered permissible to use. The expression syntax is the same as for a general behavioral source (see B-sources in Help). The resistance must not go to zero and negative values can lead to convergence problems, so it is advisable to restrict its values to within a meaningful range as per the following Value example: R = limit(1,100k,V(1,2)*I(V1)) ; R stays between 1 ohm and 100k To plot an I-V curve, start by using the differential cursor to plot the voltage across the resistor. First click and hold down the left-mouse-button (red probe icon) on one side of the resistor and then drag and drop the black probe icon on the other side. Finish by dragging the mouse pointer over the x-axis (a ruler icon will appear) and the click the left mouse button to bring up the Horizontal Axis menu. Change the Quantity Plotted from "time" to "I(R1)" (assuming R1 is your behavioral resistor).


Instead of LTspice, I use Cadence Spectre which uses VerilogA as a modelling language. VerilogA allows you to build almost anything the simulator can handle. However LTspice does not appear to support VerilogA. :-(

But what you could do is build a model from controlled sources (voltage controlled current source etc) and other elements which are available.

For example, you could use a capacitor to represent the charge level, like 0 V is empty, 100 V is full. Then use a voltage controlled voltage source which has a formula to convert that 0 - 100 V to the real battery voltage. For the series resistor you would need a resistor with a value depending on the 0 - 100 V also via a formula. Not sure if LTSpice can do that though.

  • 2
    \$\begingroup\$ LTspice does have behavioural sources, as well as behavioural R=<...>, L=Flux(x), and C=Q(x) elements. However, I'm afraid that the OP may not be an experimented user, but the options are there. \$\endgroup\$ – a concerned citizen Nov 11 '16 at 12:00

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.