Pspice To Ltspice Converter Weight

I am designing a buck-boost regulator for a course at school and I would like to use the OnSemi ntk3139p PMOS transistor. OnSemi provides a few spice models for this part and I am getting stuck converting the Pspice file so that it is usable in LTspice. I realize I could pick something else, but I wanted to take this opportunity to dive into some of the nitty gritty in spice.

Portal to Information about Murata Products and uptodate information. Buckboost Converter Design 1. VoltSec Balance fD, steadystate transfer function We can implement the double pole double throw switch by one.

Some of the references I have been following for spice are:

  • There are more but I don't have 10 reputation points yet to post them

The Pspice file in question is listed bellow:

My crack at converting it is:

I have rearranged some of the lines so that they resemble some of the other subcircuit LTspice files that I have been looking at with the netlist first and the model definitions second and I have added the parenthesis to the parameters of the model directives. Most of the subcircuit file makes sense to me but a few of the devices I am not sure about such as FI2. I think this is a current dependent current source but it may not be used properly here. I am not sure where I am going wrong here as the error I am getting in LTspice is

The way I implement my NTK3139P.sub is:

  • I save the NTK3139P.sub file in C:Program Files (x86)LTCLTCspiceIVlibsub
  • Open LTspice
  • Create New symbol
    • Pin numbers coorelate with subcircuit definitions
    • In attributes: Prefix = X, Value = ntk3139p
    • Saved where it can be seen by LTSpice
  • Restart LTspice
  • Create super simple schematic to test it with the FET, a resistor, a voltage source, and ground
  • Run a .tran 1 simulation
  • The aforementioned error occurs

Any help debugging this and/or explanations of where I went wrong or a friendly point to some more general spice literature would be appreciated!

Author: Dmitry Nizhegorodov (dmitrynizh@hotmail.com). My other projects and articles

Copyright © 2001-2013 Dmitry Nizhegorodov

    1. Zero Node and Other Assorted Oddities
      1.1 A Zero Node
      1.2 Starting a brand new project... from scratch?
      1.3 Transformers and grounding
      1.4 A 1M resistor gotcha
      1.5 Small assorted gotchas
    2. What is the best setup for tube transient analysis?
    3. How to Show Plate Curves, Loadlines and Max Dissipation Curves
      3.1 Plate Curves
      3.2 Loadlines in PSPICE
      3.3 Dissipation
      3.4 Push-pull plate curves
    4. A Real Transformer
    5. X-Y mode tricks
    6. Collecting and Plotting Distortion Data
    7. Seamless SPICE Sync: Instant FOURIER output plotter

1. Zero Node and Other Assorted Oddities

1.1 A Zero Node

An otherwise healthy circuit will not work unless there is at least one node part named 0. This is true for most versions of SPICE. I believe a zero node is used as a reference point to calculate voltages and currents against.

I use a grounding-symbol node for this purpose. To come up with such node, I created a grounding part using the parts menu (an icon will work, too), double-clicked on it to open its property dialog and then set its NAME and NODENAME properties to 0. After that I always do Ctrl-c, Ctrl-v on such node if I need an another one. By the way, '0' need not be displayed on the schematics page; to hide, it double-click on the part - this will show the properties list, single-click on 'NODENAME' and the press button 'Display'. In the popped-up dialog, select 'Do not Display' and press 'OK' button. Then you can cut and paste this node whenever you need a ground. Note that 'NAME' need not be 0; if you want to have several grounds with different names, then you can change NAME from 0 to anything like G1 etc. and have the property value displayed.

1.2 Starting a brand new project... from scratch?

I avoid starting projects from scratch. Instead, in the 'New Project' dialog box which pops up after a name and directory selection dialog is done, I chose an option 'Based On' and find a project which is a best prototype for a new design. In my opinion this saves tons of time.

1.3 Transformers and grounding

PSPICE, as well as most variants of SPICE will complain if the sub-circuit that is formed by the output taps of a tube output transformer and the load is disconnected from the main circuit.

The easiest solution is to connect one wire to the ground.

1.4 A 1M resistor gotcha

1M resistors were pretty popular as values of volume pots or grid resistors in old tube schematics and thus SPICE tube circuit modeling may need these. What is so special about that? 1M entered in PSPICE as a value for a resistor will ruin your day. The circuit will suddenly start working in the most strange way.

The gotcha is in the 'M'. PSPICE is not case sensitive and it does not understands that 1M is not a 1m! In other words, your 1M pot or greed shunt or feedback resistor will be actually processed by SPICE as 1 milli-Ohm resistor, something infinitely close to a straight wire in the world of tube circuits. Instead of typing 1M you must type 1Meg or 1meg.

My 'workaround' for this is in not using Mega-Ohms at all. I limit myself to 'K', and on rare occasions when I do need a 1M resistor I punch in '1000k' instead.

1.5 Small assorted gotchas

Parametric sweep checkbox.
Just because you entered some data in parametric sweep dialog box does not mean you're running a parametric sweep until you check the 'Parametric Sweep' box!

2. What is the best setup for tube transient analysis?

There is probably no 'best' setup, but for quick runs with precision sufficient for audio applications I use the following PSPICE setting for 'Edit Simulation Profile', 'Analysis Type': 'Time Domain (Transient ):

For better precision I use slightly more dense steps - 5 or even 1 us.

3. How to Show Plate Curves, Loadlines and Max Dissipation Curves

3.1 Plate Curves

I borrowed the following technique from www.next-power.net/next-tube/. The article that discussed the technique is in currently available only in Russian, hence I point directly to a zip file with a PSPICE project that computes plate curves. The project does a DC sweep over anode voltages, with secondary sweep, where the secondary sweep steps across grid voltage range.

To set up a new plate-curves project in PSPICE/ORCAD from scratch:

(1) Create a fresh project, and create this simple schematics by dropping parts from 'Place'->'Part' dialog.

(2) Navigate the menubar: PSpice -> Edit Simulation Profile -> Analysis Type, and select DC Sweep. In Options, Primary Settings select Sweep Variable tab Global Paramater, and type 'V' in Paramater Name. Sweep Type set to Linear and specify Start = 0, End = 400, Increment = 10. Check checkbox Secondary Sweep, then also select Sweep Variable tab Global Paramater, and then type 'VG' in Paramater Name. Sweep Type set to Linear and specify Start = 0, End = 14, Increment = 1.

(3) Add global parameters V and VG using the menu bar selection: PSpice -> Place Optimizer Parameter; double click on the Optimizer Parameters construct and in the dialog type V in the Name field and press 'Add', and then type VG, press, 'Add' and then 'OK'.

Now Press Run and if everything is fine, you'll see place curves.

Note: you'll likely need to adjust the Y scape. doubel click on it and switch to User Defined, providing suitable range. For 6p14p, 0 to 80-100ma is enough.

I have a PC folder which 'curves' where I maintain a separate project for each tube I use in my PSPICE modeling often.

3.2 Loadlines in PSPICE

Once plate curves are plotted, it is easy to add a loadline (the pink line on the plot on the right) The idea is to add a trace (button Add Trace) with a formula of this shape:

where Ystart is the point where the load line will cross the Y grid line, Xvar is the variable used for the X coordinate, and load is load resistance. Example:

For loadline that goes across a specifc point Px,Py, use this:

Thus, for the above curve to go over a 20V, 5mA point:

3.3 Dissipation

Finally, a power dissipation curve can be plotted with the following formula:

where power is max power dissipation but could be any value for power you're interested, and Xvar is voltage such as V_V1.

This works because power = V * I.

3.4 Push-pull plate curves

If you've seen plots with 'composite' loadlines for push-pull tubes, you wonder how to do it in PSPICE. It is not completely trivial, yet not hard. A little trick is needed, for which the step of adding optimizer parameters see above shows its usefulness. Composite curves will show up if one tube runs DC sweep as above, while another is swept with plate DC that steps down from the max. If the max is set to 400 then the DC on the second plate must be set to {400 - V}. Exactly similar setting must be done for the grid. If the sweep is from 0 to 20 (meaning we're interested in -10V idle bias), then the second tube should see {20 - VG}. Make sure the secondary sweep is from 0 to 20, not to 14 as above.

4. A Real Transformer

TBD

5. X-Y mode tricks

For an experienced eye, a 2-channel oscilloscope set in X-Y mode can be an indispensable source of information about a circuit. It is possible to guess about overloading characteristics, phase distortion, THD and even about relative weight of harmonics of different orders. PSPICE can help to train your eyes in reading X-Y figures.

Here is how to switch to X-Y mode in PSPICE

Some details: To enter X-Y mode, I click on the X axis on a data plot and press the Axis Variable button, By default, the variable is Time. I then tell PSPICE to use an axis variable related to my input signal. PSPICE will display a straight line or an elliptic curve or a bent line - depending on the distortion the circuit introduces. For my SET amps, I often get a thin elliptic curve slightly bent in one direction:

The 'gap' between the sides of the ellipse is proportional to the phase shift between the input and the output. 0 phase gives a straight line, -90 and 90 give a circle. A delay of 45 degrees will give a thick, wide oval. The bending reflects harmonics - any assymetry in the shape of the ellips indicates distortion. Low-order harmonic distortion if evident from gentle, smooth bending, sharper knees mean high-order distortion. Even harmonics are evident from assymetrical, single-ended (yes! pun intended) bends. Odd harmonics are evident from symmetrical, s-like patterns. A distinct knee indicates hard single-ended clipping, more rounded one - soft clipping. Symmetrical knees indicate push-pull style of clipping. When one knee is sharp and the opposite one is soft, it indicates either a series of tubes going into various conditions, or a single tube going into above-zero-grid voltage region on the Up swing and and into dense, over-bias region on a down swing.

For example, the figure shown above indicates no clipping, small phase shift and clear presence of 2nd order distortion and a touch of 3rd order. Indeed, the FFT analysis gives this data:

Five % of 2nd order distortion is clearly visible as downward bend of the upper side of the curve. A 1.3 % of 3rd is harder to spot but is is evident from a slight S-shaping of the curve.

Adding a staright line helps in disovering deviations. A line that intersects the curve in any desired point can be easily added with the help from the Cursor Display. For the above curve, -1v alone X corresponds to -8.57V alone Y. I add a new trace (Add Trace button) as V(V2+)* 8.57:

My next X-Y trick is phase shift compensation. Often a phase shift makes it hard to judge deviations of a shape from a straight line. Since A Sin input is what most often used for transient analysis, I add another, identical Sin input with a different phase. The phase I find in the FFT data - 2.862E+00 for the example above. I add such Sin node, (it is OK to leave it unconnected), cut&paste the phase value, and re-run simulation, then use the new signal as X variable:

Finally, to get better reading of 'deviation' from a bisecting line, I substitute the phase-corrected source multiplied by the same coefficient as above:

6. Collecting and Plotting Distortion Data

Very often I want to pas a signal of several different voltages through an amp, collect distortion data for each run, and then show that data on a plot. I came up with the following method. I run repeated simulation and collect distortion data for several runs in a text file. I extract the data from PSPICE-generated *.out reports. Here is an example:

I pipe files containing this data (*.out files in PSPICE/OrCad, *.log files in LTSpice) through an awk script I wrote. The script converts spice output files into a data file format understood by a plotter application:

spice2plot.sh out.txt > d.plt

I use PTPLOT release 2.0 as my plotter.

The script, spice2plot.sh, is in AWK which is common on Linux/Unix boxes. It has several control options that allow me to show output signal as voltage amplitude or RMS, or wattage into specified load, also as amplitude or RMS:

The source is Here

For example, here is how PSPICE/OrCad output file example1.out is converted to file d1.plt:

spice2plot.sh example1.out > d.plt

whichdisplays

The same input data fiel example1.out can be plotted in logarithmic scale:

spice2plot.sh example1.out l > dl.plt

which gives

finally, how about Watts RMS into 16 ohm:

spice2plot.sh oexample1.out lrp 16 > d1rp16.plt

7. Seamless SPICE Sync: Instant FOURIER output plotter

Further improvement of the above 2-step plotting solution is to have zero steps. That is, somehow be able to instantly see SPICE results in the format described above with no conversion commands involved.

Click to download spice2plot.jar. The tools is free in public domain and is a wrapper to the PTPLOT core plotter. The code in the jar is a 'listener' of FOURIER results coming from your spice application - OrCad or LTSpice. You only need to launch the listener once providing it the name of your spice output file. The listener will keep the plot in sync with the results: each time you re-run your simulation, you instantly see the plot updated.

A typical configuration is LTSpice and spice2plot.jar running simultaneously as illustrated with this screenshot:

Notice that spice2plot's data is updates as soon LTSpice produces the new data - even if the spice2plot window is not 'active'. For this reason it is much more useful to have the two windows side-by-side. The following screenshot illustrates this and also demonstrates the technique of saving interim results.

Here, the bottom window was originally the one synced-up with LTSpice. Then at one point I felt I've captured an interesting results and I saved the distortion data in a file with extension plt using SaveAs menu of spice2plot. Then I disabled autorefresh and then launched a second spice2plot window and set it to autorefresh. Now I cam continue tweaking the circuit further, doing instant comparisons of new results (top windows) with the saved result (bottom window).

Refresh color alert: when the new data is pulled, the refresh message at the bottom is highlighted with red color for 2 seconds, then turns to black.

Author: Dmitry Nizhegorodov (dmitrynizh@hotmail.com). My other projects and articles