## ngspice-devel

 [Ngspice-devel] Fourier transform using Ngspice From: Oscad Team - 2013-07-26 07:06:28 Attachments: Message as HTML ```Hi, Can any one explain how to find fourier transfom using Ngspice. Thanks Shambhu ```
 Re: [Ngspice-devel] Fourier transform using Ngspice From: Les Howell - 2013-07-26 09:16:20 ```On Fri, 2013-07-26 at 12:36 +0530, Oscad Team wrote: > Hi, > > > Can any one explain how to find fourier transfom using Ngspice. > > > > > Thanks > Shambhu the fourier command can be invoked in the interpreter as fourier frequency vector where vector is the connection you want to see, and frequency is the fundamental. It will by default return the fundamental and three harmonics (n=4) If you want to get more frequencies in this fourier series use the command set nfreqs=xxx where xxx is the number of frequencies you want to see. To get a full fourier series from the fft, the command fft vector will set the vector to the complex result of the fft. This can then be plotted using the plot db(mag(vector)) The basic fourier command is well documented. I had to hunt for documentation that described how to get the fft to work and produce the full spectrum. Be aware however that the sample size is not a power of 2 unless you can contrive to make it so. By default the series is windowed using I think Hanning. However you can set the windowing function using set specwindow=name, and name can be blackman, hanning, none, etc. There is a command that lists the specwindows available, but I forget what that is. The results will be a bit clearer if you invoke the linearize command on the vector first. Because ngspice is driven by the rise time of the signals internally, the results are not linear in time, the faster the rise, the more samples that ngspice generates. The linearize function cleans this up, although I am unsure of the cleanup process. So the sequence to get a fourier transform where the vector of interest is "out" would look something like this: n g s p i c e 8> s e t p l o t t r a n 1 n g s p i c e 9> l i n e a r i z e V ( 2 ) n g s p i c e 9> s e t s p e c w i n d o w = b l a c k m a n n g s p i c e 10> f f t V ( 2 ) n g s p i c e 11> p l o t mag (V ( 2 ) ) the alternative plot command is "plot db(mag(V(2))" the V function calls a vector created for the circuit node. In this case node 2. One additional comment that is not clear about the linkages: When a symbol is created, the pin sequence is that demanded by the spice model. for example, most opamps have the model.cir similar to: The following is from TI's website: *///////////////////////////////////////////////// *LM7171A Operational Amplifier Macro-Model *///////////////////////////////////////////////// * * connections: non-inverting input * | inverting input * | | positive power supply * | | | negative power supply * | | | | output * | | | | | * | | | | | .SUBCKT LM7171A/NS 3 2 4 5 6 * *Features *Very High Slew Rate *Wide Unity-Gain-Bandwidth Product *High CMRR ************************************** The model then looks like: v 20121123 2 L 310 1010 310 10 3 0 0 0 -1 -1 L 310 1010 1010 510 3 0 0 0 -1 -1 L 310 10 1010 510 3 0 0 0 -1 -1 P 1300 500 1000 500 1 0 0 { T 1400 400 5 10 0 0 0 0 1 pintype=out T 845 495 5 10 1 1 0 6 1 pinlabel=out T 1300 600 5 10 0 0 0 0 1 pinseq=5 T 1100 600 5 10 1 1 0 0 1 pinnumber=6 } P 0 700 300 700 1 0 0 { T -100 700 5 10 0 0 0 6 1 pintype=in T 355 695 5 10 1 1 0 0 1 pinlabel=+ T 205 745 5 10 1 1 0 6 1 pinnumber=3 T -100 900 5 10 0 0 0 6 1 pinseq=1 } P 0 400 300 400 1 0 0 { T 0 200 5 10 0 0 0 6 1 pintype=in T 355 395 5 10 1 1 0 0 1 pinlabel=- T 205 445 5 10 1 1 0 6 1 pinnumber=2 T -100 400 5 10 0 0 0 6 1 pinseq=2 } P 700 1000 700 700 1 0 0 { T 1500 1100 5 10 0 0 0 0 1 pintype=pwr T 700 1000 5 10 1 1 0 0 1 pinlabel=+Vs T 1500 900 5 10 0 0 0 0 1 pinseq=3 T 500 800 5 10 1 1 0 0 1 pinnumber=7 } P 700 0 700 300 1 0 0 { T 800 200 5 10 0 0 180 6 1 pintype=pwr T 1045 300 5 10 1 1 180 0 1 pinlabel=-Vs T 595 250 5 10 1 1 180 6 1 pinnumber=4 T 700 0 5 10 0 0 180 6 1 pinseq=4 } T 705 1905 8 10 0 0 0 0 1 device=LM7171BIN T 420 1505 8 10 0 0 0 0 1 footprint=DIP-8-300 T -195 2705 8 10 0 0 0 0 1 file=/home/lesh/gaf/SPICE/TI_spice/LM7171B.MOD T 5 205 8 10 1 1 0 0 1 refdes=U? T 5 1705 8 10 0 0 0 0 1 dist-license=TI Op Amp T 10 1010 9 10 1 0 0 0 1 LM7171 T 605 2105 8 10 0 0 0 0 1 numslots=0 T 580 1330 8 10 0 0 0 0 1 model-name=LM7171B_NS This is a copy of the LM7171B_NS model from TI. As you look at the pins, you will note that pin3 has a pin sequence number of 1. This matches the subcircuit definition. Since this opamp comes in several different packages, the footprint is not part of the symbol. When you add the component to a schematic choose the appropriate footprint. The symbol calls the subcircuit. To get the netlist in the form for ngspice call gnetlist -g spice-sdb -o name.cir name.sch If the design has some flaws, you can get a pretty detailed list of them by running the drc2 design rule check version 2 in gnetlist. For example: gnetlist -g drc2 -o name.drc name.sch This should get you most of the way there. Note that the default reference for dbv is 1v. Also note that most of this is documented in the ngspice manual, found here: http://ngspice.sourceforge.net/docs/ngspice-manual.pdf This link is to version 25. there are older revisions available on the links at the website. there are also some very good tutorials on line if you google them. good luck ```
 Re: [Ngspice-devel] Fourier transform using Ngspice From: Holger Vogt - 2013-07-26 15:45:22 ```Shambhu, see actual manual: 15.5.4 17.5.24 17.5.25 Holger ```
 Re: [Ngspice-devel] Fourier transform using Ngspice From: Oscad Team - 2013-07-29 06:56:38 Attachments: Message as HTML ```ThankYou:) On Fri, Jul 26, 2013 at 9:15 PM, Holger Vogt wrote: > Shambhu, > > see actual manual: > 15.5.4 > 17.5.24 > 17.5.25 > > Holger > > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > Ngspice-devel mailing list > Ngspice-devel@... > https://lists.sourceforge.net/lists/listinfo/ngspice-devel > ```
 Re: [Ngspice-devel] Fourier transform using Ngspice From: Holger Vogt - 2013-08-13 20:38:37 ```There is a new method to call the fast fourier transform, which has been provided by Dietmar. Functions fft and ifft (invers fourier transform) are added to the list of functions, taking a vector as the argument (see actual manual chapt. 17.2). For example you may now directly write plot mag(fft(v(18))) in a .control section or interactively. Holger ```