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

12 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?

Anonymous said...

The line:

"To set the temperature to a single value, type: 'temp=30' the units are Celsius."

Should read:

"To set the temperature to a single value, type: '.temp=30' the units are Celsius."

The "." is critical.

Robert Thurman said...

I know this post is old but for anyone visiting...

In order to set the temperature of a resistor you do not need to override the nominal temperature i.e. setting the TEMP variable. The resistor definition includes the temperature coefficient, component tolerance, and nominal temperature, along with a bunch of other information. Remember LTSpice at its core utilizes a SPICE3 engine, meaning it utilizes the same parameters as the SPICE3 engines. Therefore you can implement varying of the nominal temperature by implementing a .STEP TEMP -55 125 5 and it will vary the nominal temperature from -55C to 125C in increments of 5C. You can also add the temp co. which is typically in PPM per degrees C and utilize a monte carlo analysis to vary the tolerance to get a better idea of how the resistor values will vary. Let me know if anyone has any questions.

Robert Thurman said...

I know this post is old but for anyone visiting...

In order to set the temperature of a resistor you do not need to override the nominal temperature i.e. setting the TEMP variable. The resistor definition includes the temperature coefficient, component tolerance, and nominal temperature, along with a bunch of other information. Remember LTSpice at its core utilizes a SPICE3 engine, meaning it utilizes the same parameters as the SPICE3 engines. Therefore you can implement varying of the nominal temperature by implementing a .STEP TEMP -55 125 5 and it will vary the nominal temperature from -55C to 125C in increments of 5C. You can also add the temp co. which is typically in PPM per degrees C and utilize a monte carlo analysis to vary the tolerance to get a better idea of how the resistor values will vary. Let me know if anyone has any questions.

Jens said...

Hi there. We are trying to simulate a network of of diodes with different temperature each. In a matter of fact, that's a solar module with PV-cells of different solar cell temperature.
How can I apply a non-global temperature to a model?

rokn elbeet said...

ما تهتم به شركة كشف تسربات المياه بالرياض هو البحث عن كيفة علاج مشاكل تسريبات المياه التي تطرأ علي المكان فجأة بواسطة اجهزة الكشف الحدية التي تستخدمها شركة كشف تسربات بالرياض والتي تسعي للوصول الي افضل النتائج المثالية القادرة علي حل هذه المشكلة بدون تدمير فالاعتماد علي الاساليب الحديثة يساعدكم في الحصول علي نتيجة مثالية في مصلحة العميل فنحن لا نكتفي بتقديم هذه الاعمال في مدينة الرياض فقط بلا لدينا الفنين المتميزة الذي يقدمون شركة كشف تسربات المياه بالدمام التي تعمل علي حل مشكلة البيت بدون الاعتماد علي ا اساليب تقليدية التي تستخدما بعض مقدمي خدمة شركة كشف تسربات بالدمام فلا تتكايل بشأن هذا العمل بالذات لانه يحل لك الكثير من المشاكل

Nusrat Borsha said...

cabled weather stations and gadgets can be get in wireless or portable models as well.Moreover, both of it will be of supreme quality but it depends on from where you're buying and what quality it has.

رضا رمضان said...

شركتنا من المتميزون في اعمال الاصلاح بدون هدم او تكسير من خلال شركة ركن البيت التي تقدم الكثير والكثير في عمل اللازم وتصحيح الاخطاء التي تسببها تسريبات المياه فنحن مثلا

شركة كشف تسربات المياه بجدة تقدم خدمة لعمل الاصلاح بدون اي خراب ونقدم النصيحة للعملاء بالابتعاد عن الاعمال التي تؤدي الي هذا الخراب فتعاملك مع شركة كشف تسربات بجدة لديها الخبرة الكافية تساعدك في الحفاظ علي منزلك كما اننا نتمكن في اننا سوف نرتقي بخدمة لاننا نقوم بالعمل السليم لها كما يوجد لدينا خدمات العوازل التي تمنع التسريبات من الاسقف لكم والحوائط والخزانات من خلال شركة تسمي الاولي في مجالها لذلك نحن نقدم شركة عزل خزانات بالرياض التي تعتبر في عل الخزانات الارضية من الداخل بواسطة مواد متميزة كما نقدم لكم شركة عزل اسطح بالرياض لعمل العوازل التي تمنع جميع التسريبات في الاسقف