Maker Pro
Maker Pro

LTSpice - crystal simulation error

R

Ramon Crichlow

Thanks to Linear Technologies for making available such easy to use
and powerful freeware. However I am having the following problem
modeling a crystal:

Using matlab I plotted the impedance of the crystal vs. frequency.
When I simulate with LTSpice using the exact same values I get a
different response. I have used the alternate solver, set the time
step very small (1000 steps per period), and played with the tolerance
settings, all to no avail.
These were the parameters I was using for the crystal:

Rseries = 100 OHM Lseries=2.2e-6 H Cseries=0.2181756e-14 F
Cparallel=3e-12 F

This crystal was placed in parallel with a sine voltage source with
frequency 72.647000 MHZ and 1mV (peak to peak)

The magnitude of the current through the crystal in transient analysis
given by LTspice to be 2.1e-6 A (peak to peak)

The correct value for should be 8.2e-6 A (peak to peak)

Anybody have any ideas? (My guess is roundoff error)
 
L

Leon Heller

Ramon said:
Thanks to Linear Technologies for making available such easy to use
and powerful freeware. However I am having the following problem
modeling a crystal:

Using matlab I plotted the impedance of the crystal vs. frequency.
When I simulate with LTSpice using the exact same values I get a
different response. I have used the alternate solver, set the time
step very small (1000 steps per period), and played with the tolerance
settings, all to no avail.
These were the parameters I was using for the crystal:

Rseries = 100 OHM Lseries=2.2e-6 H Cseries=0.2181756e-14 F
Cparallel=3e-12 F

This crystal was placed in parallel with a sine voltage source with
frequency 72.647000 MHZ and 1mV (peak to peak)

The magnitude of the current through the crystal in transient analysis
given by LTspice to be 2.1e-6 A (peak to peak)

The correct value for should be 8.2e-6 A (peak to peak)

Anybody have any ideas? (My guess is roundoff error)

Have you got a resistor in series with the source?

Leon
 
R

Ramon Crichlow

Leon Heller said:
Have you got a resistor in series with the source?

Leon

No. The voltage source is ideal, and there are no components other
than the crystal and the voltage source.
 
M

Mike Engelhardt

Ramon,
Using matlab I plotted the impedance of the crystal vs. frequency.
When I simulate with LTSpice using the exact same values I get a
different response. I have used the alternate solver, set the time
step very small (1000 steps per period), and played with the tolerance
settings, all to no avail.
These were the parameters I was using for the crystal:

Rseries = 100 OHM Lseries=2.2e-6 H Cseries=0.2181756e-14 F
Cparallel=3e-12 F

This crystal was placed in parallel with a sine voltage source with
frequency 72.647000 MHZ and 1mV (peak to peak)

The magnitude of the current through the crystal in transient analysis
given by LTspice to be 2.1e-6 A (peak to peak)

The correct value for should be 8.2e-6 A (peak to peak)

Anybody have any ideas? (My guess is roundoff error)

This sort of error usually comes from LTspice not having a default
series inductance resistance of zero, or by having the "Supply a
min. inductor damping if no Rpar is given" check box checked on
the Tools=>Control Panel=>Hacks pane. However, it hard to tell
here, because the current as I understand your Xtal should be
1.37uA, not something in the amp range:

* Rseries = 100 Lseries=2.2e-6 Cseries=0.2181756e-14 Cparallel=3e-12
R2 N001 N002 100
L2 N002 N003 2.2e-6
C3 N001 0 3e-12
C4 N003 0 0.2181756e-14
V1 N001 0 sin(0 1m 72.647Meg)
..tran 10u 10u 0 .1n
..probe I(V1)
..end

BTW, you don't need all those components and nodes to model an Xtal.
You can use a single component with no internal nodes to act exactly
the same but computationally faster:

Cx n001 0 .2181756e-14 Cpar=3p Lser=2.2e-6 Rser=100

--Mike
 
H

Helmut Sennewald

Ramon Crichlow said:
Thanks to Linear Technologies for making available such easy to use
and powerful freeware. However I am having the following problem
modeling a crystal:

Using matlab I plotted the impedance of the crystal vs. frequency.
When I simulate with LTSpice using the exact same values I get a
different response. I have used the alternate solver, set the time
step very small (1000 steps per period), and played with the tolerance
settings, all to no avail.
These were the parameters I was using for the crystal:

Rseries = 100 OHM Lseries=2.2e-6 H Cseries=0.2181756e-14 F
Cparallel=3e-12 F

Hello Ramon,
the series inductance L must be 2.2e-3H if this should be a 72.xxx MHz
crystal.

I simulated first with a .AC analysis with L=2.2e-3H .
I have got 8.1uA for 1mV input.
Command: .ac lin 1000 72.646e6 72.648e6

Then I tried the .TRAN analysis also with L=2.2e-3H.
Yes, the current was wrong. I couldn't believe that the numerical precision
is so bad. I tried some simulator options without success.
Finally I simply reduced the time step to 0.01n and have got the correct
value of 8.1uA for 1mV input.
I have also disabled the option "Hacks->Supply a min. inductor damping..."
This should be always done when crystals are used.
Crystal circuits always have long time constants until the steady state(max.
current)
is reached. Be warned about a long simulation time of more then 100us.
Take a break until it's finished. Run time about 800sec/Fcpu[GHz].
Command: .tran 0 200u 0 0.01n

Summary of a successful .TRAN simulation in this case:
Disable "Hacks->Supply a min. inductor damping..."
Use a small timestep: .tran 0 200u 0 0.01n

Hint: Crystal circuits are normally analysed in the frequency domain.
So a .AC analysis is the best and natural choice.

Best Regards
Helmut




Version 4
SHEET 1 880 680
WIRE -48 16 -160 16
WIRE -160 16 -160 96
WIRE -160 176 -160 192
WIRE 32 16 96 16
WIRE 176 16 272 16
WIRE 336 16 448 16
WIRE 448 16 448 192
WIRE 128 -80 448 -80
WIRE 448 -80 448 16
WIRE -160 16 -160 -80
WIRE -160 -80 64 -80
FLAG -160 192 0
FLAG 448 192 0
SYMBOL voltage -160 80 R0
WINDOW 123 24 132 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value SINE(0 1e-3 72.647e6)
SYMATTR Value2 AC 1e-3
SYMBOL res -64 32 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 0 56 VBottom 0
SYMATTR InstName R1
SYMATTR Value 100
SYMBOL ind 80 32 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 5 56 VBottom 0
SYMATTR InstName L1
SYMATTR Value 2.2e-3
SYMBOL cap 272 32 R270
WINDOW 0 32 32 VTop 0
WINDOW 3 0 32 VBottom 0
SYMATTR InstName C1
SYMATTR Value 0.2181756e-14
SYMBOL cap 128 -64 M270
WINDOW 0 32 32 VTop 0
WINDOW 3 0 32 VBottom 0
SYMATTR InstName C2
SYMATTR Value 3e-12
TEXT -184 -160 Left 0 ;.ac lin 1000 72.646e6 72.648e6
TEXT -184 -128 Left 0 !.tran 0 200u 0 0.01n
 
P

Paul Burridge

Then I tried the .TRAN analysis also with L=2.2e-3H.
Yes, the current was wrong. I couldn't believe that the numerical precision
is so bad.

Hi, Helmut.
To what do you attribute the problem of the numerical precision to? Is
it a fault of the simulation package you're using, or was it temporary
carelessness on your part (highly unlikely I willingly concede) :)
What can be done to avoid this problem? Does it only occur with xtal
simulations?
Thanks.

p.
 
R

Ramon Crichlow

Helmut Sennewald said:
Ramon Crichlow said:
Thanks to Linear Technologies for making available such easy to use
and powerful freeware. However I am having the following problem
modeling a crystal:

Using matlab I plotted the impedance of the crystal vs. frequency.
When I simulate with LTSpice using the exact same values I get a
different response. I have used the alternate solver, set the time
step very small (1000 steps per period), and played with the tolerance
settings, all to no avail.
These were the parameters I was using for the crystal:

Rseries = 100 OHM Lseries=2.2e-6 H Cseries=0.2181756e-14 F
Cparallel=3e-12 F

Hello Ramon,
the series inductance L must be 2.2e-3H if this should be a 72.xxx MHz
crystal.

I simulated first with a .AC analysis with L=2.2e-3H .
I have got 8.1uA for 1mV input.
Command: .ac lin 1000 72.646e6 72.648e6

Then I tried the .TRAN analysis also with L=2.2e-3H.
Yes, the current was wrong. I couldn't believe that the numerical precision
is so bad. I tried some simulator options without success.
Finally I simply reduced the time step to 0.01n and have got the correct
value of 8.1uA for 1mV input.
I have also disabled the option "Hacks->Supply a min. inductor damping..."
This should be always done when crystals are used.
Crystal circuits always have long time constants until the steady state(max.
current)
is reached. Be warned about a long simulation time of more then 100us.
Take a break until it's finished. Run time about 800sec/Fcpu[GHz].
Command: .tran 0 200u 0 0.01n

Summary of a successful .TRAN simulation in this case:
Disable "Hacks->Supply a min. inductor damping..."
Use a small timestep: .tran 0 200u 0 0.01n

Hint: Crystal circuits are normally analysed in the frequency domain.
So a .AC analysis is the best and natural choice.

Best Regards
Helmut




Version 4
SHEET 1 880 680
WIRE -48 16 -160 16
WIRE -160 16 -160 96
WIRE -160 176 -160 192
WIRE 32 16 96 16
WIRE 176 16 272 16
WIRE 336 16 448 16
WIRE 448 16 448 192
WIRE 128 -80 448 -80
WIRE 448 -80 448 16
WIRE -160 16 -160 -80
WIRE -160 -80 64 -80
FLAG -160 192 0
FLAG 448 192 0
SYMBOL voltage -160 80 R0
WINDOW 123 24 132 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value SINE(0 1e-3 72.647e6)
SYMATTR Value2 AC 1e-3
SYMBOL res -64 32 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 0 56 VBottom 0
SYMATTR InstName R1
SYMATTR Value 100
SYMBOL ind 80 32 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 5 56 VBottom 0
SYMATTR InstName L1
SYMATTR Value 2.2e-3
SYMBOL cap 272 32 R270
WINDOW 0 32 32 VTop 0
WINDOW 3 0 32 VBottom 0
SYMATTR InstName C1
SYMATTR Value 0.2181756e-14
SYMBOL cap 128 -64 M270
WINDOW 0 32 32 VTop 0
WINDOW 3 0 32 VBottom 0
SYMATTR InstName C2
SYMATTR Value 3e-12
TEXT -184 -160 Left 0 ;.ac lin 1000 72.646e6 72.648e6
TEXT -184 -128 Left 0 !.tran 0 200u 0 0.01n

Yes you are correct I made a typo the inductance should be 2.2e-3 H.

The hacks->supply min. inductor was the problem - thanks to you and
mike englehardt for pointing this out.
 
H

Helmut Sennewald

Paul Burridge said:
Hi, Helmut.
To what do you attribute the problem of the numerical precision to? Is
it a fault of the simulation package you're using, or was it temporary
carelessness on your part (highly unlikely I willingly concede) :)

Hello Paul,
The problem was not the simulator(LTSPICE) in this case.
"To err is human."
What can be done to avoid this problem?

I would simulate only with the .TRAN analysis if the time domain is
really necessary. This is the case for example, if someone is
interested in the nonlinear behaviour of a circuit.

The .AC simulation is much easier for the simulator. It has to solve
only a set of linear equations. This can be done with very high accuracy.
Does it only occur with xtal simulations?

The simulator has to solve numerically a set of differential equations
in the .TRAN analysis. This cannot be done crrectly when the derivative
of a signal is only roughly estimated by too large timesteps.
Especially all circuits with very narrow bandwidth compared to their
center frequency must be calculated extemely precise. Any small error
in the simulated period results in a big amplitude error, because
of the steep filter slope.
Think of a crystal filter where your applied frequency is something
off the crystal center frequency. This will result in a large
amplitude error.
The timestep is critical with any circuit having a filter with
high Q(uality factor).

Best Regards,
Helmut
 
Top