SPICE tarnsient analysis of oscillators - sampling time

Could some electronics guru here please clarify this a bit ? I am experimenting with SPICE transient analysis of oscillator, and I am unsure as to what to set as the ideal sampling time, given that most oscillators will generate a fundamental and a few harmonics. For example, suppose that I have a 500 MHz differential oscillator, and I set the sampling time as

1/(15.0*time period of fundamental), would that be sufficient to satisfy the Nyquist criterion, and also capture the fundamental and the first two harmonics ? The reason I ask is that I have noticed that with this scheme, the fundamental is always at 250 MHz, and the first harmonic is at 500 MHz. This is peculiar. Is there something wrong in my assumption ? Thanks in advance.
Reply to
dakupoto
Loading thread data ...

Sounds to me like a lost factor of two somewhere.

Try sampling times of 1/(30*tau) and 1/(60*tau) the latter ought to allow all harmonics out to 5th to be cleanly expressed without aliasing.

The Babylonians chose base 60 for a very good reason.

--
Regards, 
Martin Brown
Reply to
Martin Brown

LT Spice goes for sim speed, so it tends to use coarse time steps. If you shock a simple LC and let it ring, at default settings the resonant frequency will be off by percentages. Similarly, oscillator sims will be unrealistic.

I set the max time step to be small, way under 1% of the fastest thing I expect to ever see in a circuit. Crank it down until the sim stops changing, or until you can't stand the time it takes to run.

Nyquist isn't the issue here.

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

[ snip ]
[ snip ]

I agree, you'll want very small time steps. In the old days, with slow computers, we'd not stress over multi-hour runs. And as for the issue of the data sampling time step, what's the issue, dakupoto, don't you have Giga-byte hard drives?

--
 Thanks, 
    - Win
Reply to
Winfield Hill

False. Your sim took the difference between the LC tank and a sine wave.

You didn't know the default series resistance of an inductor is 1 milliohm, so the tank voltage decayed. Your measurement could not tell the difference between phase and amplitude (simple trig) so you claimed a frequency error. How you converted your measurement to frequency error is beyond me.

I have attached a simple sim showing the frequency error is unmeasurable when you set the tank ESR to zero. Let it run for 1,000 cycles. After 1,000 cycles, the tank voltage and sine wave overlap exactly. The frequency difference is too small to measure.

Oscillator sims are similarly as accurate as the component values you enter plus strays. See

formatting link

Here is the sim. Plot the LC and Sin voltages on the same graph.

Version 4 SHEET 1 1008 680 WIRE 352 -160 176 -160 WIRE 400 -160 352 -160 WIRE 496 -160 400 -160 WIRE 176 -112 176 -160 WIRE 352 -112 352 -160 WIRE 496 -112 496 -160 WIRE 176 16 176 -32 WIRE 352 16 352 -32 WIRE 496 16 496 -48 WIRE 320 112 176 112 WIRE 352 112 320 112 WIRE 176 128 176 112 WIRE 176 224 176 208 FLAG 400 -160 LC FLAG 176 16 0 FLAG 352 16 0 FLAG 496 16 0 FLAG 176 224 0 FLAG 320 112 Sin SYMBOL ind 336 -128 R0 WINDOW 0 45 22 Left 2 WINDOW 3 42 47 Left 2 SYMATTR InstName L1 SYMATTR Value {N} SYMATTR SpiceLine Rser=0 SYMBOL cap 480 -48 M180 WINDOW 0 24 56 Left 2 WINDOW 3 24 8 Left 2 SYMATTR InstName C1 SYMATTR Value {N} SYMBOL current 176 -112 R0 WINDOW 0 -70 50 Left 2 WINDOW 3 -165 99 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName I1 SYMATTR Value PULSE(1 0 1) SYMBOL voltage 176 112 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value SINE(0 1 1 1) TEXT 192 -296 Left 2 ;'1 Hz LC Osc Infinte Q TEXT 464 -264 Left 2 !.options numdgt=15 TEXT 656 -264 Left 2 !.param N = 1 / (2 * pi) TEXT 192 -256 Left 2 !.tran 0 1000 0 100u

Reply to
Steve Wilson

Maybe so, but I often have to force the time step down to get a useful simulation. And that sometimes makes simulation times silly. There is a reason that the max time step can be set. When precision matters, I reduce it until the sim doesn't change.

Make a pure, 1 volt, 1 Hz sine wave V source. Run that for 5 seconds and zoom the top of the sine. It's chunky line segments. Change the time step to 1 us and it looks a lot better.

--

John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  

jlarkin att highlandtechnology dott com 
http://www.highlandtechnology.com
Reply to
John Larkin

LC oscillators with low Q will have a small frequency error. See Equation (3), Radiotron Designer's Handbook, Chapter 9, Tuned Circuits, page 449:

formatting link

This information is valuable. I have not been able to find it anywhere else on the internet.

Reply to
Steve Wilson

The optimum time step depends on dv/dt. For sinusoidal waveforms I usually start at period/1e4. For picosecond waveforms, you may have to go way down.

You can change the waveform compression by setting

.options plotwinsize=0

See

formatting link

This can increase the plot file by 50 times. See

formatting link

The problem then is running out of available disk space. This is important if you are running on a small SSD.

Reply to
Steve Wilson

My point, which was disputed, is that one often has to override LT's default (adaptive?) time step. You seem to agree.

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

That is not what I said. I said specificantly to set the time step to tau/1e4 for sinusoidal waveforms then crank down as needed. Fast risetimes may reqire smaller time steps. I think doing a transient anlysis without setting the maximum time step is a big mistake. It will simply waste your time.

Without it, the resulting waveform can show straight line segments. You can set

.options plotwinsize=0

but this requires more disk space.

You are completely ignoring the superb accuracy of LTspce as I pointed out in my first post. It is far better than the several percent error you claim. After much trial and error, I found the discrepancy to be in the parts per billion. That is far better than any components you can find.

Reply to
Steve Wilson

For most things, like opamp circuits and simple RC stuff, the default is good enough. For tweaking say an oscillator, it pays to explore the effect of setting the time step.

I tried a 1 Hz ringing LC with parasitic-free L and C. The difference in ringing frequency between the transient default (no time step specified) and specifying 1 or 10 us max time step was about 400 PPM, but some time steps were kind of weird; the change of ring period vs step size was not monotonic.

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

You are doing something wrong. Are you using the modified trap option? Are you using a pure sine wave as a comparison?

I get 120 milliseconds difference in zero crossings after 1,000 cycles with no time step specified. That is 120 ppm.

Always specify the maximum time step.

Reply to
Steve Wilson

After 10 cycles, I see about 500 PPM in my LC. Not so different. It means that you might not want to design crystal oscillators in time domain.

The thing I remember about my previous much-maligned dual sine wave experiment is that setting a small dt fixed the frequency error. So it wasn't a simple ESR problem. I'll try to find that one.

LT Spice is mathematically chaotic, especially when it uses its default time step algorithm. There are probably cases that are especialy bad, and maybe I get lucky finding them. I am usually lucky.

I'm not doing anything wrong. I design electronics and most of it works first time, and we sell it.

You just have to be careful when you drive things. And not believe everything just because a computer was involved.

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

You need time domain to adjust the crystal drive. Too little and the oscillator may not start. Too much and you may fracture the crystal.

You cannot get this information any other way.

Crystal oscillators have a long startup time due to the high Q. You cannot make meaningful measurements after hundreds of milliseconds of cycles. I show how to bypass the long startup in my oscillator.zip article which you ignored

formatting link

Your problem was ESR. You took the difference between the LC and the sine signals but you didn't know the default ESR for an inductor is 1 milliohm. So the LC signal decayed. Your measurement cannot tell the difference between phase and amplitude changes and you came to the wrong conclusion.

LTspice repeats exactly given the same data. There is nothing chaotic about it.

Always specify the maximum time step.

That has nothing to do with the topic.

Nonsense. You use the computer for everything. When was the last time you picked up a slide rule. You just have to be careful about the data you enter.

LTspice is as accurate as the models you give it.

Reply to
Steve Wilson

Are you here to discuss electronics, or just to be obnoxious?

--

John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  

jlarkin att highlandtechnology dott com 
http://www.highlandtechnology.com
Reply to
John Larkin

I discussed electronics and system design. I posted links to oscillator design that you ignored. I showed your ignorance of LTspice caused you to make false claims about its performance. You completely failed to acknowledge any of my posts and still insisted your original erroneous analysis about the accuracy of LTspice was correct.

LTspice is vital in electronics design. If you can show that any of my replies is wrong, please post.

Reply to
Steve Wilson

OK, obnoxious.

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

This is way, way to tight and will result in unnecessary run times and large files. The maximum step time for oscillators should typically be set to around 1/50 to 1/100 of the period, on rare occasions maybe to as low as

1/500. What mainly governs the max time step choice, is the requirement to get the oscillator to start.

To get accuracy reltol should be set. Typically 100u, although for low phase noise (-180dBc) using PSS/PNOISE in a simulator supporting such analysis, going down to 10u or 1u may be necessary.

The adaptive time step control of Spice will automatically set the time steps to whatever is required to satisfy the accuracy setting, without evaluation of millions of redundant time points. It will go down to 10^-21 if necessary.

If you need to set the max time step to 1/1e4 of the period, something is wrong.

-- Kevin Aylward

formatting link
- SuperSpice
formatting link

Reply to
Kevin Aylward

Ahmmmmm.... I am assuming you mean Spice. LTSpice has some deficiencies.

-- Kevin Aylward

formatting link
- SuperSpice
formatting link

Reply to
Kevin Aylward

Sure. Most things like this have some quirks. I've mostly become aware of these things in LT Spice. The sims are usually nicely predictive of what the hardware ultimately does, even for picosecond stuff.

Most of my sims never see production. They are prods to thinking, and ways to archive good and bad ideas.

More parts makers should supply models and working examples of LT Spice for their parts. A few do.

--

John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  

jlarkin att highlandtechnology dott com 
http://www.highlandtechnology.com
Reply to
John Larkin

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.