Forums

SPICE tarnsient analysis of oscillators - sampling time

Started by Unknown March 5, 2019
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. 
On 05/03/2019 10:54, dakupoto@gmail.com wrote:
> 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 ?
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
On Tue, 5 Mar 2019 02:54:14 -0800 (PST), dakupoto@gmail.com wrote:

>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.
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
On Tuesday, March 5, 2019 at 5:54:17 AM UTC-5, daku...@gmail.com wrote:
> 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.
This is a simplified rundown. Other sources say up to 50 points per cycle of expected sine output. http://spicesim.blogspot.com/p/in-transient-simulation-spice.html
John Larkin wrote...
> > On Tue, 5 Mar 2019, dakupoto@gmail.com wrote: > >> 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,
[ snip ]
> > LT Spice goes for sim speed, so it tends to use coarse time steps.
[ snip ]
>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.
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
John Larkin <jjlarkin@highlandtechnology.com> wrote:

> On Tue, 5 Mar 2019 02:54:14 -0800 (PST), dakupoto@gmail.com wrote:
>>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.
> 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.
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 https://drive.google.com/open?id=1ZsbpkV0aaKS5LURIb1dfu_ndshsSaYtf 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
On Tue, 05 Mar 2019 22:45:09 GMT, Steve Wilson <no@spam.com> wrote:

>John Larkin <jjlarkin@highlandtechnology.com> wrote: > >> On Tue, 5 Mar 2019 02:54:14 -0800 (PST), dakupoto@gmail.com wrote: > >>>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. > >> 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. > >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.
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
Steve Wilson <no@spam.com> wrote:

> John Larkin <jjlarkin@highlandtechnology.com> wrote:
>> 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.
> 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
> https://drive.google.com/open?id=1ZsbpkV0aaKS5LURIb1dfu_ndshsSaYtf
LC oscillators with low Q will have a small frequency error. See Equation (3), Radiotron Designer's Handbook, Chapter 9, Tuned Circuits, page 449: http://preview.tinyurl.com/hmnpj2r This information is valuable. I have not been able to find it anywhere else on the internet.
John Larkin <jjlarkin@highland_snip_technology.com> wrote:

> On Tue, 05 Mar 2019 22:45:09 GMT, Steve Wilson <no@spam.com> wrote:
>>John Larkin <jjlarkin@highlandtechnology.com> wrote: >> >>> On Tue, 5 Mar 2019 02:54:14 -0800 (PST), dakupoto@gmail.com wrote:
>>>>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.
>>> 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.
>>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.
> 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.
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 http://ltwiki.org/LTspiceHelp/LTspiceHelp/ _OPTIONS_Set_simulator_options.htm This can increase the plot file by 50 times. See http://ltwiki.org/LTspiceHelpXVII/LTspiceHelp/html/Compression.htm The problem then is running out of available disk space. This is important if you are running on a small SSD.
On Wed, 06 Mar 2019 00:34:42 GMT, Steve Wilson <no@spam.com> wrote:

>John Larkin <jjlarkin@highland_snip_technology.com> wrote: > >> On Tue, 05 Mar 2019 22:45:09 GMT, Steve Wilson <no@spam.com> wrote: > >>>John Larkin <jjlarkin@highlandtechnology.com> wrote: >>> >>>> On Tue, 5 Mar 2019 02:54:14 -0800 (PST), dakupoto@gmail.com wrote: > >>>>>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. > >>>> 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. > >>>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. > >> 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. > >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.
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