How to do the calculation in LTSpice?

Status
Not open for further replies.

wolfrain

Junior Member level 1
Joined
Nov 14, 2009
Messages
19
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Southampton
Activity points
1,454
First, thank you for your attention!

I`ve got a circuit and want to measure the frequency of the output. And I went to the Help and do the searching for a while, then I`ve got the .MEAS guide to do the measurement of the plotting.

Here is my codes in .meas for my case.

.MEAS TRAN Time_1 V(output) WHEN V(output) = 3.3*0.5 cross = 25 // Rise
.MEAS TRAN Time_2 V(output) WHEN V(output) = 3.3*0.5 cross = 27 // Fall

As you can see, I measure the time between two specific point of V(output), which means the period of the Voutput. But what I want is the frequency of this output, and I cannot figure out how to programme it to do this automatically. I try adding sth like "Freq = 1 / (Time_2-Time_1)", and it doesn`t work.

Again, thank you for your watching.
 

Hi wolfrain,

you can insert this as a Spice Directive:

.MEAS TRAN t2 V(Out_Osc) WHEN V(Out_Osc) = {Vdd*3/5} rise=10
.MEAS TRAN t1 V(Out_Osc) WHEN V(Out_Osc) = {Vdd*3/5} rise=9
.MEAS TRAN freq1 PARAM 1/(t2-t1)

in this case Vdd is a parameter (Vdd=5.0). The measure will be done when the signal rises and reaches 3.0V.

After run is completed go to View/Spice Error Log, scroll down and you will see something like this:

t2: v(out_osc)=3 AT 4.96755e-007
t1: v(out_osc)=3 AT 4.49039e-007
freq1: 1/(t2-t1)=2.09573e+007

In this Case only one period was considered. You can also consider let's say 6 periods and make an average, like this:

.MEAS TRAN t4 V(Out_Osc) WHEN V(Out_Osc) = {Vdd*3/5} rise=10
.MEAS TRAN t3 V(Out_Osc) WHEN V(Out_Osc) = {Vdd*3/5} rise=4
.MEAS TRAN freq2 PARAM 6/(t4-t3)

the results will look like this:

t4: v(out_osc)=3 AT 4.96755e-007
t3: v(out_osc)=3 AT 2.10457e-007
freq2: 6/(t4-t3)=2.09572e+007

in both measurements the frequency is about 21MHz.

You can also place the cursors in the waveform viewer (cursor1 and cursor2) and you can read the frequency there directly.

Hope this helped!

Regards,
 
Although the coursework passed already, but still thanks a lot for your kindly help!
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…