Tuesday, 15 January 2008

LT SPICE - Modelling, Parametrics, Steps and More

For a second year semiconductor project at the University Of Southampton (ECS) I had to investigate the operation of a silicon solar cell manufactured within our institution. As part of my report I wanted to model the electronic properties of the device accurately using a SPICE circuit simulator. My software of choice was LT Spice which is available from Linear Technologies for free. Whilst it is powerful and comprehensive it is much easier to learn to use than its better known cousin - OrCAD / PSPICE. Despite its shallow learning cure I found it difficult to find information on some of the more advanced and interesting features. In this post I will explain how to use some of these features (the ones that I needed for my report, anyway).

Creating IV curves
To view the IV curve of a device/sub-circuit, which is often very interesting and important it is necessary to vary the load resistance and measure the its voltage and current. In LT Spice this can be achieved by changing the load resistance value to a parameter. Parameters can be varied dynamically during the simulation as I will show now:
  • Instead of entering a resistance value for R1, type '{RL}'. RL is the name of the parameter, whilst the '{}' tell LT Spice that you are entering a parameter.
  • Click: EDIT>TEXT
  • Check the 'SPICE Directive box'
  • Type 'STEP param RL 1 1000 1' - increment RL from 1 to 1000, 1Ohm at a time
  • Ensure that the Simulation type selected is 'Operational Point' -.op
  • Run the Simulation
  • Hover mouse over x-axis until it turns into a ruler. Left click and change 'Quantity Plotted' to the voltage node at the top end of resistor (or whichever voltage is of interested)
  • Then add a plot of the current through RL to observe the IV graph
Changing Model Parameters Dynamically - Temperature
LT SPICE has a global parameter for temperature called 'temp'. This is no different from the parameter RL in the previous paragraph, except that it is already defined, (it has to be for components such as diodes and transistors). If you wish to see how temperature affects your circuit, you need first to ensure there are some temperature dependent components in your circuit (else nothing will change).
  • Create another SPICE directive (see above - you can reuse the existing text box if you wish).
  • To set the temperature to a single value, type: 'temp=30' the units are Celsius.
  • To sweep the temperature and observe the effects, type: '.STEP param temp 10 50 1' to raise temp from 10 to 50 Celsius in single degree increments.
To change the way a component behaves with temperature e.g. modelling a thermistor:
  • Replace the components value with a parameter, e.g. replace resistance with {THERM}
  • In a SPICE directive, define the new parameter, e.g. '.param THERM='(temp*0.05)+1000'
  • The parameter can depend upon any other parameter, circuit voltage or current, e.g. THERM has a linear relationship to temperature
Creating bespoke models - Custom diode

Making you own models is as simple as writing a few lines of text and is even easier if you have an understanding of Netlists. For those who don't I will illustrate how to create a simple custom diode model.

  • Add an ideal diode to the circuit (SHORT_CUT=D)
  • Press CTRL and RIGHT-CLICK on the diode
  • Change the box labelled InstName to 'mydiode'. This is the Instance name.
  • Change the 'SpiceModel' box to 'mymodel'. This is the name of the device model.
  • Ensure all the other boxes are empty
  • In a new spice directive text box, we define the model: '.model mymodel D (Is=1.88e-5 N=3.89)'
  • The: '.model' part tells SPICE to expect a model definition.
  • The: 'mymodel' part tells SPICE to link components with a SpiceModel = 'mymodel' to this definition.
  • The: 'D(' part tells SPICE we are defining a diode. L() = Inductor; C() = Capacitor; R() = Resistor etc.
The contents of the brackets are the model's parameters. You do not have to define all of the available parameters, but it is good to check that the default values are appropriate. It is not necessary to use absolute values, parameters can be used too.

More complex models can be built using hierarchical blocks, allowing complex circuits to be viewed as single abstracted component. I will write about this in future posts.

Hopefully you now have enough information to begin creating, editing and designing your own models. Remember to start simple and gradually add extra parameters. Watch out for syntax and try viewing the Netlist file for syntax errors if you have trouble.


Figure One - Example of Parametric Sweep



Figure Two - Example of Temperature Dependence



Figure Three - Example of Custom Diode Model

5 comments:

Anonymous said...

thanks for the tip on how to change the diode parameters

how did you figure it out? The ltspice documentation isn't very clear.

Anonymous said...

thank you so much

Anonymous said...

Hello thanks for the description
I have one Question:
You wrote:"The parameter can depend upon any other parameter, circuit voltage or current..."
I tried it for circuit voltage but it doesn't work. I think i have a wrong syntax.
('WARNING: Can't resolve .param rvar=100+v(geh2)'). Where rvar is the name of the Resistor and V(geh2) is the voltage of one Resistor node.
If you can help me please contact tom.stallinger 'at' gmx.at

Chagrı_1903 said...

the standard component library does not contain an ideal diode. How can I make an ideal diode model available to LTSpice users?

Anonymous said...

Hi, thanks for your help.
Is it possible that the parameter depend on frequency? If it is, how to do that?