LT_spice

download LT_spice

of 9

description

vbv

Transcript of LT_spice

  • LTspice IV: Overview and Demo

    ECE 464: POWER ELECTRONICSUNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN

    CONTENTS

    I Introduction 2

    II User Interface 2

    II-A Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    II-B Unit Convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    III Creating the Circuit 4

    III-A Passive Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    III-B Voltage Controlled Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    III-C SPICE directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    IV Simulation Results 7

    IV-A Fourier Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    IV-B Exporting Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

  • I. INTRODUCTION

    LTspice IV is a circuit simulator that allows you to build and simulate different schematics. Its very useful for a variety ofsituations, and can be used for ideal as well as real components. The purpose of this tutorial pdf is to provide a basic overviewof how LTspice can be used for ECE 464 and 469 and demonstrate a basic switched-mode power converter- in this case, abuck converter nominally set to step down from 20 to 15V, with 15W and switching at 1 MHz. Please note - understandingthe operation of a buck converter will help explain the motivation for circuit creation and the waveforms observed, but is notnecessary to understand how to use LTspice.

    For more advanced topics not covered here, a plethora of documentation and help is available on various forums and e-boards,so Google away!

    Downloading LTSpice

    Windows version: LTspiceIV.exeLinux users: Download the Windows version above and open with Wine.Mac OS X version: LTspiceIV v2.dmg or LTSPICE W WINE.dmg or follow the same instructions for Linux users.

    II. USER INTERFACE

    The menu bar in LTspice will appear like Fig.1. In this case, a new file has already been created, which makes certainbuttons and functions clickable.

    Fig. 1.

    Heres a quick overview of the buttons and menu items that will be relevant, from left to right. More details will be providedin the relevant sections of the tutorial.

    Running man: Run simulation - based on instructions Magnifying glasses: Zoom in, pan, zoom out, and zoom out to fit all data/components Graphs: Select traces to view and autorange graphs. Windows: Tile, Cascade, or Close windows Pencil: Draw a wire Ground: Add a ground Boxed A: Label a net Resistor: Add a resistor Cap: Add a capacitor Inductor: Add an inductor Diode: Add a diode AND gate: Add a component - opens up a window that looks like Fig. 2. The items surrounded by brackets are subfolders

    with more components to select from. Hands: Move and Drag - both move selected items around the schematic. The difference is that Move does not necessarily

    maintain electrical connections, while Drag does, distorting wires around to fit. Arrows: Undo and Redo Es: Rotate and Flip Horizontally Aa: Text comment .op: SPICE directive

  • Fig. 2.

    A. Keyboard Shortcuts

    For many of the above buttons, there are some handy keyboard shortcuts that can save you some time:

    F1: Help menu F2: Add a component F3: Draw a line F4: Label net F5: Delete (also Ctrl+X) F6: Duplicate (also Ctrl+C) F7: Move F8: Drag F9: Undo shift+F9: Redo R: Add resistor C: Add capacitor L: Add inductor D: Add diode G: Add ground S: SPICE directive Ctrl+R: Rotate Ctrl+E: Flip Horizontally Ctrl+A: Add Trace (for graphing results) ESC: Cancel

    B. Unit Convention

    When assigning values, use the following convention for prefixes:

  • f: femto p: pico n: nano u: micro m: milli k: kilo meg: mega g: giga

    Its the standard prefix convention with the exception of mega - make sure you use meg instead of m (e.g.- 10MEGHzinstead of 10MHz for 10 megahertz.)

    Units (volts, hertz, ohms) are automatically assumed, but adding them does not negatively affect anything.American and European conventions are both valid - 1.8k and 1k8 are both acceptable values for a 1.8k resistor.

    III. CREATING THE CIRCUIT

    This section will detail how to build the buck converter circuit and set up the simulation commands.

    A. Passive Components

    Lets begin with the passive components - the voltage source, input and output capacitor, inductor, diode, and load resistor.The voltage source (and current source, if needed) can be found under the component menu, and everything else can be easilyadded using the menu bar or keyboard shortcuts.

    To label the components with a name beyond an enumerated system, you can right click on the label and change the name(ie- change the input capacitor from C1 to Cin).

    If you right click any of the components, youll come up with a menu that looks like one of Fig. 3. For the voltage source,this menu is accessed by right clicking the source and clicking Advanced. From here, you can see that you can providebasic values of each component as well as parasitics, if this is known. Alternatively, if there is a specific part that you wantto use, clicking the button saying Select or Pick New Diode will open a database of parts to select from.

    (a) Diode (b) Capacitor (c) Inductor (d) Resistor

    Fig. 3. Component Details

    For now, lets give the following values to the components:

    Input Voltage: 20 V Inductor: 7.5 H Input Capacitor: 10 F Output Capacitor: 500 nF

  • Load Resistor: 15

    We will use an ideal voltage source with no series resistances. Lets also add labels to the nodes, clearly denoting the input,output, switching, and ground nodes. At this point, the circuit looks like Fig. 4.

    Fig. 4.

    B. Voltage Controlled Switch

    In this demo circuit, we will use an ideal switch with some on state resistance. Instead of using a particular transistor model,we instead use the voltage controlled switch, labeled sw under the component listing. This is a four terminal device asseen in Fig. 5. As the name suggests, the switch is open or closed, depending on the voltage across the positive and negativeterminals.

    Fig. 5.

    To create the switching waveform that we need, we need a voltage source that creates a square wave. Lets add a secondvoltage source to go across the switchs control terminals. Pulling up the advanced menu as in Fig. 6, we can see that thereare a variety of functions that we can generate with a voltage source. For the periodic square wave, select PULSE.

    This function has the voltage source switch between two values. For now, set the values as such:

    Vinitial[V]: 1 Von[V]: -1 Tdelay[s]: 0.75u Trise[s]: 0 Tfall[s]: 0 Ton[s]: 0.25u

  • Fig. 6.

    Tperiod[s]: 1u Ncycles: 1000

    This creates a PULSE command detailing that the voltage source will start with a value of 1 (so the switch is closed), andchange to -1 at t=.75s for a duration of .25s, with a period of 1s for 1000 cycles, or 1ms.

    Why is a pulse between 1 and -1 sufficient for the voltage switch? This will be because of the model used for the switch.LTspice requires a .model command detailing how the switch operates. This brings us to our next topic of SPICE directives.

    C. SPICE directives

    All active devices (diodes, transistors, switches, etc.) require models to define the device physics and properties. For thisdemo, we can safely use the default diode model and not worry about entering a specific model or selecting a part from thedatabase.

    The switch requires a model in order for a simulation to run - trying to run a simulation without a switch model returnsan error! To add a model, click the button for SPICE directive and type in .model SW SW(). This indicates that the modelfor any devices with value SW (which includes the switch were using!) will assume the default model SW with all defaultparameters.

    You can find the parameters of the switch model in the help menu. There are a variety of parameters we can define for thisparticular switch, but for now, lets only specify a lower on-state resistance; the other parameters will automatically use thedefault values listed. Right click the directive you typed in previously and change it so it reads .model SW SW(Ron=500u).NOTE: One of the default parameters is a threshold voltage of 0V. This indicates that the switch will close with any positivevoltage across the control terminals, and open with a negative voltage, explaining why the PULSE between 1 and -1 is sufficientfor this example.

    You also need a SPICE directive to indicate the simulation that will be run. You can type this in directly using the SPICEdirective option, but under Simulate in the menu, there is an option labeled Edit Simulation Cmd. Using this, we can takeadvantage of the template LTspice offers to construct the simulation directive. In this example, we want to look at the transientsimulation, up to 1ms.

    In the command window that pops up (like in Fig. 7), enter 1m in the Stop Time box - the other boxes can be safely ignoredfor now.

  • Fig. 7.

    After entering in the SPICE directives and setting everything up, your circuit may look something like Fig. 8. This examplefile can also be found here. Please note! Directive and command lines will be placed directly on the schematic, so arrangethem in such a way to avoid clutter and make things clear!

    Fig. 8.

    IV. SIMULATION RESULTS

    This section will detail how to view waveforms following the simulation run.To run the simulation, simply press the Run button. The first time you run it, no waveform is selected as default, so instead

    you simply get a black window. When you click the Pick Visible Traces button in the menu, or select Visible Traces from

  • the Plot Settings menu, the window in Fig. 9. The available options are the voltage at a particular node compared to groundor the current through a device.

    Please note: the nodes are based upon the labels you give. If there are no labels, the nodes will be enumerated n001, n002,etc. It is much easier to work with if you have the significant nodes labeled. Please note: positive current is defined as thecurrent into the top node of a device in the default orientation.

    For now, ctrl+click V(vin) and V(vout) to select both, and lets see what that looks like.

    Fig. 9.

    Fig. 10a shows the voltage results below. Nothing too interesting with regards to the input voltage, and we dont care toomuch about the transient results before the system settles to a periodic steady state solution. We can zoom in using either themagnifying glass button, or by clicking the axes to change the range. Zooming in, we can find the image from Fig. 10b. Ifyou ctrl+click the trace name, you pull up information on the average and RMS value of the signal for the current intervaldefined by the graph.

    Note: Ive re-sized the graph window and changed the trace color by right clicking on the signal name at the top of thegraph to make the screen easier to view here in this demo, but the default color of the second trace is blue.

    If necessary, additional graph panes can be added from Plot SettingsAdd Plot Pane, and the horizontal axes can besynced to look at the same time interval.

    (Similarly, you can observe the current waveforms - for the sake of brevity, those screenshots are omitted. )Examining the signal waveforms can allow you to observe and analyze how the converter operates. It also lets you check if

    KCL and KVL for periodic steady state circuits is maintained. Checking the current through the output capacitor, for example,can let you see that the average current in a period is nearly 0. The fact that it isnt could indicate that the system is stillsettling to a steady state, but depending on what time interval youre looking at, if the average current is a couple orders ofmagnitude lower than the RMS value, the system can reasonably be assumed to be in periodic steady state.

    What about the voltage across the inductor? We will need to look at Vout-Vx (or Vx-Vout, whichever orientation you preferas long as you stay consistent) to see that. Under Plot Settings then Add trace, you can enter an expression to graph. Thisallows us to look at voltage across nodes, as well as the power dissipated/sourced by relevant devices (voltage source, loadresistor).

    A. Fourier Analysis

    For some signals, visualizing and understanding the frequency content will help greatly. LTspice allows you to take signalsand run a Fast Fourier transform (FFT) to generate a frequency response curve for signals. Fig. IV-A shows two currentwaveforms (through the load resistor and output capacitor) in the time domain and frequency domain.

  • (a) (b)

    Fig. 10.

    To do this, you will find FFT under the View menu. Here, you can select specifics like which waveform to include(although it looks like expressions you generate are not available to select), and the time range. Because of the initial transience,its important to specify a time interval where the system is in periodic steady state!

    (a) (b)

    Fig. 11.

    B. Exporting Waveforms

    If you would like access to the data to plot in Matlab, you can export the information. Under the File menu, you will findExport. If you are in the time domain graphs, you can select any of the voltage/current waveforms for any node/device inthe schematic or any currently plotted expressions. If you are exporting fft data, you can only select from waveform signalsthat you included then.

    IntroductionUser InterfaceKeyboard ShortcutsUnit Convention

    Creating the CircuitPassive ComponentsVoltage Controlled SwitchSPICE directives

    Simulation ResultsFourier AnalysisExporting Waveforms