Learning about oscillators in LTSpice

Yes, 100 samples per second does yield 50Hz Nyquist, but a formula should use values based upon some type of reality. LTspice's ACTUAL sampling rate is related to the maximum step size set in the .tran command. Which by default is 1000 steps. By setting the argument in the random function to (100*time); you have forced the 'effective' useable rate to be much less, only due to the resulting 'flatness' of your noise source.

You did NOT match the use of your random function to the use of the sampling rate. Threw away a lot of capability. Setting the random function to (100*time) only causes the function to change at 100Hz rate, BUT the random function is smoothed. Since random is smoothed, it's VERY difficult to get the noise spectrum flat, in this case, still not flat even over the very small range between 200mHz to 25Hz. Plus, the noise characteristic doesn't even 'look' right. White noise is more 'spikey'. For example, a 1 Vrms white noise source will actually have, every now and then, 6 Volts pop out of it, where as that random function will ALWAYS be within +/-0.5 volts and NEVER be outside that range.

The Bandwidth is set by the run length. The Nyquist rate is related to the maximum time step. Therefore, the following gets you BW of 10Hz and Nyquist rate of 100kHz: .tran 0 100m 0 5u

I do it in the spectral domain, multiply a noise spectrum by

1/sqrt(frequency) then convert back to the time domain and use those values. Creates noise that plots with the 1/f shape and obviously looks correct with that meandering characteristic one sees at the output of an OpAmp.

No, statement of fact.

. . . Have you yet figured out how to make the two noise sources using random()?

Reply to
RobertMacy
Loading thread data ...

On Sat, 26 Jul 2014 13:44:18 -0700, RobertMacy wrote:

What number is more "real" than 50? 50 is a perfectly respectable number.

LTspice's ACTUAL sampling rate

Sure. Why not? If you don't like the sample rate in my example, change it. It's there in plain sight. I did the demo for visibility.

Of course it isn't flat. It's noise. Look at real wideband noise on a spectrum analyzer some time. It's noisy!

Plus, the noise characteristic

The single Random(time) call obviously has a uniform probability distribution. EE101. If you want it to be more Gaussian, sum a few of them. Statistics101.

The extreme example of a non-Gaussian PDF is a TTL serial data stream, specifically the output of a pseudo-random shift register. That can be turned into nearly perfect bandlimited white noise with a simple RC lowpass filter; see AoE for details. Similarly, a lowpass filter is another, simple way to improve the statistics of random(time), and fix your complaint about the rolloff shape.

I was looking for a simple way to graph probability density functions in LT Spice. Some other time maybe.

The random(K*TIME) function changes K times per second regardless of the LT Spice time step. So going to smaller time steps doesn't change the spectrum. See example below where K=1.

Post an LT Spice demo.

You've done nothing but whine, and present a Thompson-Fermat claim of a marvelous solution that you don't have room to post.

If you want to discuss things, great. If you want to whine and bitch, you should try to be right.

I can make any number of them. Of arbitrary bandwidth and amplitude, and as Gaussian as you like. This ain't hard.

Below is a set of examples, which I did for future reference.

The product XC, and its lowpass filtered version XCLP, are fun. The N1 and N2 sources start identical, and take one second to drift out of correlation.

I think the 3.94 values (to make 1 volt RMS) should actually be 3.464, the square root of 12, but maybe the LT Spice smoothing changes the statistics or something.

Version 4 SHEET 1 1268 680 WIRE -352 -272 -432 -272 WIRE -272 -272 -352 -272 WIRE 112 -272 -16 -272 WIRE 176 -272 112 -272 WIRE 624 -272 576 -272 WIRE 656 -272 624 -272 WIRE 880 -272 736 -272 WIRE 976 -272 880 -272 WIRE 1040 -272 976 -272 WIRE -432 -240 -432 -272 WIRE -16 -240 -16 -272 WIRE 576 -192 576 -272 WIRE 880 -192 880 -272 WIRE -432 -128 -432 -160 WIRE -16 -128 -16 -160 WIRE 576 -48 576 -112 WIRE 880 -48 880 -128 WIRE -352 112 -432 112 WIRE -272 112 -352 112 WIRE 112 112 -16 112 WIRE 176 112 112 112 WIRE 608 112 576 112 WIRE 656 112 608 112 WIRE 880 112 736 112 WIRE 976 112 880 112 WIRE 1040 112 976 112 WIRE -432 144 -432 112 WIRE -16 144 -16 112 WIRE 880 192 880 112 WIRE -432 256 -432 224 WIRE -16 256 -16 224 WIRE 880 336 880 256 WIRE -320 448 -432 448 WIRE -112 448 -240 448 WIRE 96 448 -32 448 WIRE 288 448 176 448 WIRE 464 448 368 448 WIRE 656 448 544 448 WIRE 720 448 656 448 WIRE 880 448 800 448 WIRE 944 448 880 448 WIRE 1024 448 944 448 WIRE -432 496 -432 448 WIRE 880 496 880 448 WIRE 880 608 880 560 FLAG -16 256 0 FLAG 112 112 N1 FLAG -16 -128 0 FLAG 112 -272 N2 FLAG 576 -48 0 FLAG 880 -48 0 FLAG 880 336 0 FLAG 608 112 N1 FLAG 976 -272 XCLP FLAG 976 112 N1LP FLAG 624 -272 XC FLAG -432 -128 0 FLAG -352 -272 T FLAG -432 256 0 FLAG -352 112 R FLAG 880 608 0 FLAG 656 448 SUM FLAG 944 448 SLP FLAG -432 496 0 SYMBOL bv -16 128 R0 WINDOW 0 97 46 Left 2 WINDOW 3 51 95 Left 2 SYMATTR InstName B1 SYMATTR Value V= 3.94 * ( random(100*time) - 0.5 ) SYMBOL bv -16 -256 R0 WINDOW 0 84 55 Left 2 WINDOW 3 50 100 Left 2 SYMATTR InstName B2 SYMATTR Value V= 3.94 * ( random(101*time) - 0.5 ) SYMBOL bv 576 -208 R0 WINDOW 0 52 78 Left 2 WINDOW 3 27 130 Left 2 SYMATTR InstName B3 SYMATTR Value V= V(N1) * V(N2) SYMBOL res 752 -288 R90 WINDOW 0 74 54 VBottom 2 WINDOW 3 79 54 VTop 2 SYMATTR InstName R3 SYMATTR Value 1 SYMBOL cap 864 -192 R0 WINDOW 0 83 16 Left 2 WINDOW 3 77 55 Left 2 SYMATTR InstName C1 SYMATTR Value 0.16 SYMBOL res 752 96 R90 WINDOW 0 75 54 VBottom 2 WINDOW 3 85 56 VTop 2 SYMATTR InstName R4 SYMATTR Value 1 SYMBOL cap 864 192 R0 WINDOW 0 75 21 Left 2 WINDOW 3 69 58 Left 2 SYMATTR InstName C2 SYMATTR Value 0.16 SYMBOL bv -432 -256 R0 WINDOW 0 86 44 Left 2 WINDOW 3 58 85 Left 2 SYMATTR InstName B4 SYMATTR Value V=TIME SYMBOL bv -432 128 R0 WINDOW 0 89 50 Left 2 WINDOW 3 47 91 Left 2 SYMATTR InstName B5 SYMATTR Value V=random(TIME) SYMBOL bv -224 448 R90 WINDOW 0 71 59 VBottom 2 WINDOW 3 80 58 VTop 2 SYMATTR InstName B6 SYMATTR Value V=random(721*time) - 0.5 SYMBOL bv -16 448 R90 WINDOW 0 71 59 VBottom 2 WINDOW 3 142 62 VTop 2 SYMATTR InstName B7 SYMATTR Value V=random(420*time) - 0.5 SYMBOL bv 192 448 R90 WINDOW 0 71 59 VBottom 2 WINDOW 3 89 58 VTop 2 SYMATTR InstName B8 SYMATTR Value V=random(1234*time) - 0.5 SYMBOL bv 384 448 R90 WINDOW 0 71 59 VBottom 2 WINDOW 3 141 49 VTop 2 SYMATTR InstName B9 SYMATTR Value V=random(555*time) - 0.5 SYMBOL res 816 432 R90 WINDOW 0 76 55 VBottom 2 WINDOW 3 81 55 VTop 2 SYMATTR InstName R5 SYMATTR Value 1 SYMBOL cap 864 496 R0 WINDOW 0 86 16 Left 2 WINDOW 3 82 55 Left 2 SYMATTR InstName C3 SYMATTR Value 0.016 SYMBOL bv 560 448 R90 WINDOW 0 71 59 VBottom 2 WINDOW 3 87 45 VTop 2 SYMATTR InstName B10 SYMATTR Value V=random(1690*time) - 0.5 TEXT 184 -368 Left 2 !.tran 0 10 0 100u TEXT -8 -416 Left 2 ;Some time-domain noise sources J Larkin July 26, 2014

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation
Reply to
John Larkin

You missed the whole point. Now THAT comment is blather.

You missed the whole point again.

Only works *IF* you sum a few INDEPENDENT noise sources! As you found out later by having to use the K multiplying factor to try to change the function's coherency.

Where do you assume complaint?! That was an observation, albeit an observation that makes it less desirable to use that function, but still an observation. Very importantly, take a look at trying to actually use that function as a 'calibrated' noise source. To actually use any noise source it must be calibrated in terms of resistor value AND BW! With your example, you'll be 'adjusting' every noise source to get each to produce the 'correct' value.

When I plotted the probability density function for your multisource technique, and looked at its distribution, it only took about four of the uniform distributions to get a 'decent' gaussian shape, interesting. Didn't know so few could go so far.

Not quite correct. By making the K factor small, you've caused the random function's K value to dominate, so LTspice .tran maximum steps ultimately have no effect. However, the true LIMITING maximum frequency is set by .tran's maximum step. The 'useable' frequency range can only be set to a frequency smaller than that.

Discussing is not whining and bitching. Note three times you missed the point and regarding a simple, easy to verify statement you are wrong, yet I've never stooped to calling you an idiot. Instead, I continue to discuss, and again, ask you for your example TWO calibrated noise sources. You still haven't produced them, although purport how 'simple' it is to do.

"...ain't hard"? Then where are your two calibrated noise sources?

With your questioning sqrt(12), there's hope! yes, LTspice changes things a bit. It 'smooths' the function, which doesn't change the statistics [or may be semantics] but changes the spectral content by rolling off the high frequency end.

How valuable is a noise source that you must wait for 1 second?! and then there's a beat in there? [Look closely at your low pass output 'noise' signal.] Interesting statistics. Did you ever analyze the statistics of these 'added' noise sources to determine how many of these noise sources you must add together to reach a specific level of confidence? Hold it! don't assume uncorrelated noise sources either, because the random function is replicated. You only get some type of non-correlation [as you found out] by varying the K multiplier term in the argument.

In review:

  1. You still haven't produced your claimed simple noise sources. So far, you've made a lot of symbols on a schematic. [Note, I recommend using use multiple current sources, not voltage sources, else you unnecessarily increase the number of nodes in the kernel's analyses.] Although a bit uncontrollable, using random() is an interesting approach. [In other words, so far your solution does NOT meet requirements.]
  2. You chide me by saying I'm whining and bitching [no idea where THAT'S coming from] rather than respond to legitimate attempt to discuss.
  3. You actually declare I'm wrong without supporting that claim. When YOUR claim(s) is/are wrong.
  4. And STILL you have not produced two simple CALIBRATED noise sources. Which you declared several times as an easy task.

So summarizing: wrong, name calling, wrong, didn't produce.

Again, since using Aioe for access to these usenet groups, I'm limited by number of quote lines AND number of reply lines. It is NOT possible to quote completely, nor possible to post very long copies of a program. I even have to reply to this post to include the example of trying to calibrate your proposed multi-source noise source.

NOTE: If any lurkers out there are interested, let me know. I'll see if there's a way to post somewhere a complete description of the basics, of the 'gotcha's', the step by steps, and a set of small programs that can be used on free PC tools to do this. Of course, up front, I say tremendous thanks to Alex Bordodynov for his excellent help in streamlining/automating the technique.

Reply to
RobertMacy

here is the LTspice schematic showing the diffiuclty at 'calibrating' your noise source.

Version 4 SHEET 1 27404 860 WIRE 1984 -336 1808 -336 WIRE 2096 -336 1984 -336 WIRE 2128 -336 2096 -336 WIRE 1808 -304 1808 -336 WIRE 1984 -304 1984 -336 WIRE 1808 -192 1808 -224 WIRE 1984 -192 1984 -224 FLAG 1984 -192 0 FLAG 1808 -192 0 FLAG 2096 -336 noise SYMBOL res 1968 -320 R0 SYMATTR InstName R1 SYMATTR Value 1 SYMBOL bv 1808 -320 R0 WINDOW 0 -67 10 Left 2 WINDOW 3 -414 168 Left 2 SYMATTR InstName B1 SYMATTR Value V=(random(100*time)-0.5)/0.20353/1.134/0.98523 TEXT 1448 -272 Left 2 !.tran 5 TEXT 1448 -336 Left 2 !.options plotwinsize=0;\n.param fmax=50 TEXT 2256 -312 Left 2 ;Why does it take three attempts to find the constant to make this 1Vrms?\nV=random(100*time)-0.5 produces

203.53mVrms\nV=(random(100*time)-0.5)/0.20353 produces 1.134Vrms\nV=(random(100*time)-0.5)/0.20353/1.134 produces 985.23mVrms\nV=(random(100*time)-0.5)/0.20353/1.134/0.98523 produces 1.0005Vrms\nnote: k=4.3977, not the expected sqrt(12)=3.4641, odd. TEXT 1704 -408 Left 3 ;Uncontrollable Aspects of Using Random Function as a Noise Source

oops, guess it wasn't that long!

Reply to
RobertMacy

I didn't find that out "later". I've known that for decades. And changing the K factor does deconhere the sources. Throw in some sines or something if you want, but I don't think they are necessary.

What's wrong with that? If you used a zener diode noise source, you'd have a trimpot or something to adjust the RMS noise voltage.

The crest factor for a single source is already over 2. Four sources gets you to

4, which is OK.

LT Spice smooths the steps (and I don't know how he manages to do that) so the spectrum rolls off well below Nyquist. So, tune the K values and filter the output until it makes the noise you want.

N1 is a calibrated (1 volt RMS) noise source. N2 is an identical but uncorrelated source. My sum thing is a pretty Gaussian source. You should be able to copy/paste the Gaussian source, select some different K values, and get a second, independent Gaussian source. Scaling the RMS voltage is easy too. Surely you don't need help doing any of that.

N1. N2.

There's no need to wait any time. I purposely selected K values of 100 and 101 to demonstrate 1 second decoherence, just for fun.

and then

All obvious. And we're simulating noisy analog circuits, not generating crypto keys for the NSA.

N1. N2.

Filter it to the desired spectral shape and bandwidth. Then measure the RMS voltage and scale to whatever you need. I can't believe that I have to explain stuff this simple.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation
Reply to
John Larkin

The problem here is that, with only one simple function on the screen, LT Spice uses huge time steps and gets the RMS value wrong. LT Spice is quirky that way. I wish it allowed me to specify the exact, invariant time step; that would help with a number of issues.

Try setting the max time step to 10u or 100u. Then things scale sensibly. The correct RMS value of 'noise', unscaled, seems to be 251.1 mV.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation
Reply to
John Larkin

You can also use a Box-Mueller transform to get independent Gaussian noise sources (see below).

There are some odd FFT effects. If you run it for 8 seconds with .options plotwinsize=0, the vanilla trapezoid method, the default time stepping behaviour, and the longest available FFT, you get right around

-40 dBV out to about 1 kHz, at which point it drops to about -48 dBV. If you run it for a bit over two seconds with all compression turned off, the FFT starts out at about -24 dBV and drops to about -45 dBV between 300 Hz and 3 kHz.

Finer details are hard to recognize, because in an FFT of noise, the variance equals the mean unless you average scans or do frequency binning.

Some extra work will be required to get this method to be a reliable noise source for transient analysis. Of course a variable-stepsize simulation will require that the data be resampled before it can do an FFT, so it's unclear whether the artifacts are coming from the transient simulation or the transform calculation.

I also still doubt very much whether op amp macromodels are going to do the right thing when they go nonlinear.

Cheers

Phil Hobbs

Version 4 SHEET 1 1656 900 WIRE -224 192 -256 192 WIRE -224 208 -224 192 WIRE 144 304 128 304 WIRE 384 304 368 304 WIRE -224 320 -224 288 WIRE 128 352 128 304 WIRE 368 352 368 304 WIRE -240 400 -256 400 WIRE -240 416 -240 400 WIRE 128 464 128 432 WIRE 368 464 368 432 WIRE -240 512 -240 496 FLAG 128 464 0 FLAG 144 304 n1 FLAG 368 464 0 FLAG 384 304 n2 FLAG -240 512 0 FLAG -224 320 0 FLAG -256 400 gn1 FLAG -256 192 gn2 SYMBOL bv 128 336 R0 SYMATTR InstName B2 SYMATTR Value V=rand(50000*time) SYMBOL bv 368 336 R0 SYMATTR InstName B1 SYMATTR Value V=rand(50000*time-20000) SYMBOL bv -240 400 R0 SYMATTR InstName B3 SYMATTR Value V=sqrt(-2*ln(v(n2)))*cos(2*pi*v(n1)) SYMBOL bv -224 192 R0 WINDOW 3 60 49 Left 2 SYMATTR InstName B4 SYMATTR Value V=sqrt(-2*ln(v(n2)))*sin(2*pi*v(n1)) TEXT 208 368 Left 2 !.tran 8m

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

Thanks for jumping in, Phil.

That is ABSOLUTELY true!!!

Using simple minded pair of input current noise sources and a single input voltage noise source only work within approximately 1/2 the CLOSED loop bandwidth for obvious reasons. AND, they don't work if the OpAmp pops out of linear behaviour, again for obvious reasons. However still interesting if you're designing a receiver, or pre-amp.

Jim Thompson's OpAmp model with resistor and transistor noise sources stuck in into a few judicious places does seem to get much closer to simulating over much wider conditions, like out of bandwidth and into slew rate limit. So as usual, complexity versus accuracy is the trade off.

Reply to
RobertMacy

It turns out that the default behaviour is pretty sensible if you pick the right parameters. Using the vanilla trapezoid with maxstep = 1u and all compression turned off, a transient of 2.097152 s (2**22 data points at maximum time resolution) comes out with a pretty flat spectrum that looks pretty much exactly as you'd expect.

1 VRMS with a 50 kHz bandwidth is -47 dBV/Hz, which (by eyeball accuracy) is what you actually get. The random staircase function shows the expected sinc function rolloff with a first null at 50 kHz.

So it looks like there is no major impediment to using this method, as long as you keep Mike from getting too clever on you. ;)

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

rand(time) and random(time) do make different spectra (expected) and different RMS values (unexpected?) because of the soft transitions of 'random.' I can't imagine what might be the algorithm for those transitions.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation
Reply to
John Larkin

Probably tanh() or atan(). Mike uses atan() for his soft switches.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

I would guess that you could also figure out how in just one pass, I get SuperSpice to figure out the values of all the resisters and mosfet sizes to achieve a a specified set of voltages and currents. Standard optimisers iterate out the results.

formatting link

Kevin Aylward

formatting link
formatting link
- SuperSpice

Reply to
Kevin Aylward

If I do random(time), the transition shape is independent of the sim dt. If I do random(99*time) the shape is scaled in time but looks the same. So random() is aware of the '99'. Somehow. Maybe it remembers the time of the previous invocation.

Mike must have all sorts of tricks in there.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation
Reply to
John Larkin
[snip]

I use TANH for my switches... G-sources, switching from low to high conductance... works quite nicely with no convergence issues. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142     Skype: skypeanalog  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

Well, he probably has a list of the samples and just uses the equivalent of a spline to get the smooth edges. Not too hard to code. Also the transitions are a small fraction of the width of the stair steps, so they won't cause problems as long as you're well below the Nyquist limit of the sampled staircase. (You can see the sinc function lobes in the FFT.)

rand(time) is a random staircase with a sample period of 1 second and smoothish transitions. I used rand(50000*time) and rand(50000*time+20000) as independent noise sources, which they are if there's nothing in the system with a memory longer than 0.4 seconds.

Looks like it works fine with no funnies, as long as you turn off the excess Mike cleverness and use a long enough FFT. Good medicine--I'll have to try it sometime.

It would be useful if there were a way to frequency-bin the FFT--a 2 million sample FFT with a 1000-pixel wide graph should be able to be averaged X1000, which would make the relative uncertainty

delta_H = 10*log(1+sqrt(1000)) ~ 0.15 dB.

That would make much nicer plots, for sure.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

no, those two are not very incoherent

V(N1) and V(N2) both have 1 Vrms, but

V(N2,N1), which has a 1 Vrms also, has a different spectral content by over 8dB.

Reply to
RobertMacy

kudos, you got pretty close with those two, BUT the max time run was 8mS ?! and the PDF is skewed to negative value, like 0.12 in +/- 1 range.

see notes attached:

Version 4 SHEET 1 1656 900 WIRE -480 208 -512 208 WIRE -480 224 -480 208 WIRE -1040 240 -1056 240 WIRE -800 240 -816 240 WIRE -1056 288 -1056 240 WIRE -816 288 -816 240 WIRE 128 288 0 288 WIRE 144 288 128 288 WIRE 0 320 0 288 WIRE -480 336 -480 304 WIRE -160 336 -176 336 WIRE -48 336 -160 336 WIRE -160 384 -176 384 WIRE -48 384 -160 384 WIRE -1056 400 -1056 368 WIRE -816 400 -816 368 WIRE -496 416 -512 416 WIRE -496 432 -496 416 WIRE 0 432 0 400 WIRE -496 528 -496 512 FLAG -1056 400 0 FLAG -1040 240 n1 FLAG -816 400 0 FLAG -800 240 n2 FLAG -496 528 0 FLAG -480 336 0 FLAG -512 416 gn1 FLAG -512 208 gn2 FLAG 0 432 0 FLAG -160 336 gn2 FLAG -160 384 gn1 FLAG 128 288 out SYMBOL bv -1056 272 R0 SYMATTR InstName B2 SYMATTR Value V=rand(50000*time) SYMBOL bv -816 272 R0 SYMATTR InstName B1 SYMATTR Value V=rand(50000*time-20000) SYMBOL bv -496 416 R0 SYMATTR InstName B3 SYMATTR Value V=sqrt(-2*ln(v(n2)))*cos(2*pi*v(n1)) SYMBOL bv -480 208 R0 WINDOW 3 60 49 Left 2 SYMATTR Value V=sqrt(-2*ln(v(n2)))*sin(2*pi*v(n1)) SYMATTR InstName B4 SYMBOL e 0 304 R0 SYMATTR InstName E1 SYMATTR Value {1/sqrt(2)} TEXT -1048 456 Left 2 !.tran 8m TEXT -1256 496 Left 2 ;ARRRGGG! can't run for more than 8mS, else nulls out!!\ngn1,2's PDF appears to 'peak' somewhere near -0.12 in the range of

+/- 1\nout PDF appears to 'peak' somewhere near +0.09 in the range of +/- 1
Reply to
RobertMacy

whew

Since limited by length here, will try to put everything in.

Basically start with a set of PWL files for LTspice to use:

description of Vn1.txt

PWL file with 0 0 at the start. after that the time is actually the count, and each value is a gaussian random value with an rms value of 1. The STEP is required to thwart LTspice from the likelihood of linearly interpolating between two diverse points, thus destroying high frequency energy in the PWL noise file. Note, to test any schematic before full implementation, simply use 'dummy' files containing nothing but two terms,

0 0.

An example of a typical Vn1.txt PWL file is to do this for 220001 steps:

0.0 0 0.1 -0.131558 1.0 -0.131558 1.1 0.867919 2.0 0.867919 2.1 -1.33285 3.0 -1.33285 3.1 1.50479 4.0 1.50479 4.1 0.266214 5.0 0.266214 . . . 109999.0 -0.0523589 109999.1 -0.622929 110000.0 -0.622929

Each file is then scaled both in VALUE and in TIME to be used in the schematic.

Then make a bunch of non-coherent files and use the PROPERLY.

Herre is an octave [runs on 2.1.50a] funcion that creates a single file:

function [N]=noisefile(filename,N); % this function creates a text file compatible with LTspice PWL noise input % optional input N defualts to 100000 steps to make the file 110001 entries. % use the form [N]=noisefile(filename,[N]); where the filename is a text variable % and optional N defaults to 100000 % Note N is returned as a courtesy and .txt is added to the name of the file if ((nargin==0) || (nargin>2)) help noisefile; return; endif

if (nargin==1) N=100000; endif

if ( sum(isalpha(filename))

Reply to
RobertMacy

I discussed how to fix that in later posts, like so. I asked on the Yahoo LTspice group whether there's any way to do frequency binning on the LTspice FFT function. So far, it doesn't look like it.

Cheers

Phil Hobbs

Version 4 SHEET 1 1656 900 WIRE -224 192 -256 192 WIRE -224 208 -224 192 WIRE -96 288 -112 288 WIRE 208 288 192 288 WIRE -224 320 -224 288 WIRE -112 336 -112 288 WIRE 192 336 192 288 WIRE -240 400 -256 400 WIRE -240 416 -240 400 WIRE -112 448 -112 416 WIRE 192 448 192 416 WIRE -240 512 -240 496 FLAG -112 448 0 FLAG -96 288 n1 FLAG 192 448 0 FLAG 208 288 n2 FLAG -240 512 0 FLAG -224 320 0 FLAG -256 400 gn1 FLAG -256 192 gn2 SYMBOL bv -112 320 R0 SYMATTR InstName B2 SYMATTR Value V=rand(-50000*time) SYMBOL bv 192 320 R0 SYMATTR InstName B1 SYMATTR Value V=rand(50000*time-20000) SYMBOL bv -240 400 R0 SYMATTR InstName B3 SYMATTR Value V=sqrt(-2*ln(v(n2)))*cos(2*pi*v(n1)) SYMBOL bv -224 192 R0 WINDOW 3 60 49 Left 2 SYMATTR Value V=sqrt(-2*ln(v(n2)))*sin(2*pi*v(n1)) SYMATTR InstName B4 TEXT -32 352 Left 2 !.tran 2.097152 TEXT 192 504 Left 2 !.options plotwinsize=0 maxstep=1u

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

I saw that, ....but didn't understand the purpose of the discussion and deleted the thread. didn't know you started it, thought John Woodgate, UK started it. oops.

Check a reply to John Larking, the FULL details of how to do the .transoise technique are in there.

From experience, watch out for LTspice's many, many 'adjustments' that skew results much more than expected. Sometimes I just give up and EXPORT to control the processing done to the signal. The biggest is the way the FFT starts rounding down BEFORE it should, and the other is the way it SPREADS energy when you think it shouldn't. Don't get me wrong, Mike's a GENIUS when it comes to how to handle the unknown signals, waveforms conditions, etc. sheer genius.

Notice how the technique doesn't require much thought process, so you can concentrate on the design, not the tool. plus, doesn't add many nodes.

Reply to
RobertMacy

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.