* Z:\home\khalils\Downloads\files\data\raw_asc\3195213d7954_THDmeter-rev0.asc
* Generated by LTspice 26.0.1 for Windows.
* To plot freq on the horiz axis \nchange the quantity plotted to \n"V(f)*<f2>Hz/1V" (e.g. f2=20k) \nand click "Logarithmic"
* Sweep Parameters:\nf1 = start freq f2= stop freq\nTs = sweep duration
* .step param Vdc list 0 4 8
* .step param K list 10m .1 1 10
* Nonlinear Test "Amplifier"
* Delayed\nIntegrator\nReset
* "DFT"\ncosine\noutput
* "DFT"\nsine\noutput
* Averaged\nraw\noutput
* Cycle sample period
* Cycle synchronous S/H clock
* THD output\n(in percent)
* "DFT" sine integrator
* "DFT" cosine integrator
* cycle-by-cycle average
* Swept Sine Audio THD Measurement Generator - Rev 0 - Aug 2006 - analogspiceman@yahoo.com
* Swept Sine-Cosine Source
A1 f 0 0 0 0 C S 0 MODULATOR space=0 mark={f2} Vhigh={sqrt(2)} Vlow={-sqrt(2)}
A2 S 0 0 0 0 0 clk 0 BUF tripdt=1n ref=0
A3 1 0 clk 0 0 0 To 0 SAMPLEHOLD tripdt=1n
A4 2 0 clk 0 0 0 So 0 SAMPLEHOLD tripdt=1n
A5 3 0 clk 0 0 0 Co 0 SAMPLEHOLD tripdt=1n
A6 clk 0 0 0 0 4 0 0 BUF tripdt=1n Td=4n
A7 clk 0 0 4 0 0 R 0 AND tripdt=0n3 Td=3n
R1 o N001 1k
B4 3 0 V=sdt(V(C)*V(o),0,V(R))/V(per)
D1 P001 o 1N750
D2 P001 N002 1N750
B1 f 0 V={f2/f1}**((time-2/f1)/Ts-1)
B3 2 0 V=sdt(V(S)*V(o),0,V(R))/V(per)
B6 THD 0 V=100*abs(1-hypot(V(So),V(Co)))/V(To)
E1 N001 0 s 0 {K}
B2 1 0 V=sqrt(sdt(V(o)**2,0,V(R))/V(per))
B5 per 0 V=sdt(1,0,V(R))
V1 0 N002 {Vdc}
.model D D
.lib C:\users\khalils\AppData\Local\LTspice\lib\cmp\standard.dio
.tran 0 {Ts+2/f1} {2/f1} {100u/f1} uic
.param f1=20 f2=20k Ts=2000m
.options plotwinsize=0 numdgt=8 reltol=10u
.param Vdc=0 K=1
.backanno
.end

* LTspice schematic (.asc):
Version 4
SHEET 1 1364 680
WIRE 512 -336 496 -336
WIRE 688 -336 592 -336
WIRE 752 -336 688 -336
WIRE 176 -304 144 -304
WIRE 288 -304 256 -304
WIRE 320 -304 288 -304
WIRE 288 -288 288 -304
WIRE 960 -288 928 -288
WIRE 144 -272 144 -304
WIRE 752 -272 720 -272
WIRE 96 -208 80 -208
WIRE 144 -144 144 -192
WIRE 176 -144 144 -144
WIRE 288 -144 288 -160
WIRE 288 -144 256 -144
WIRE 512 -144 496 -144
WIRE 688 -144 592 -144
WIRE 752 -144 688 -144
WIRE 144 -128 144 -144
WIRE 960 -96 928 -96
WIRE 720 -80 720 -272
WIRE 752 -80 720 -80
WIRE 512 48 496 48
WIRE 688 48 592 48
WIRE 752 48 688 48
WIRE 960 96 928 96
WIRE 352 112 320 112
WIRE 720 112 720 -80
WIRE 752 112 720 112
WIRE 112 176 80 176
WIRE 144 176 112 176
WIRE 304 176 288 176
WIRE 320 176 320 112
WIRE 320 176 304 176
WIRE 352 176 320 176
WIRE 688 176 416 176
WIRE 720 176 720 112
WIRE 720 176 688 176
WIRE 80 208 80 176
WIRE 720 208 720 176
WIRE 864 208 720 208
WIRE 960 224 928 224
WIRE 304 240 288 240
WIRE 320 240 304 240
WIRE 512 256 496 256
WIRE 608 256 592 256
WIRE 720 256 720 208
WIRE 752 256 720 256
WIRE 832 256 816 256
WIRE 864 256 832 256
WIRE 80 320 80 288
WIRE 848 384 832 384
WIRE 944 384 928 384
IOPIN 96 -256 In
IOPIN 320 -304 Out
IOPIN 944 384 Out
IOPIN 352 112 Out
RECTANGLE Normal 384 0 48 -352 1
SYMBOL bv 944 384 M270
WINDOW 3 -32 56 VBottom 0
WINDOW 0 32 56 VTop 0
SYMATTR Value V=100*abs(1-hypot(V(So),V(Co)))/V(To)
SYMATTR InstName B6
SYMBOL zener 304 -224 M0
WINDOW 0 -8 16 Right 0
WINDOW 3 -8 40 Right 0
SYMATTR InstName D2
SYMATTR Value 1N750
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL bv 608 -336 M270
WINDOW 3 -32 56 VBottom 0
WINDOW 0 32 56 VTop 0
SYMATTR Value V=sqrt(sdt(V(o)**2,0,V(R))/V(per))
SYMATTR InstName B2
SYMBOL bv 80 192 R0
WINDOW 3 -32 160 Left 0
WINDOW 0 -32 8 Left 0
SYMATTR Value V={f2/f1}**((time-2/f1)/Ts-1)
SYMATTR InstName B1
SYMBOL res 272 -320 R90
WINDOW 0 0 56 VBottom 0
WINDOW 3 32 56 VTop 0
SYMATTR InstName R1
SYMATTR Value 1k
SYMBOL bv 608 -144 M270
WINDOW 3 -32 56 VBottom 0
WINDOW 0 32 56 VTop 0
SYMATTR Value V=sdt(V(S)*V(o),0,V(R))/V(per)
SYMATTR InstName B3
SYMBOL SpecialFunctions\\sample 832 -112 R0
WINDOW 3 16 80 Center 0
WINDOW 0 8 -48 Center 0
SYMATTR Value tripdt=1n
SYMATTR InstName A4
SYMBOL e 144 -288 R0
WINDOW 0 40 47 Left 0
WINDOW 3 37 75 Left 0
SYMATTR InstName E1
SYMATTR Value {K}
SYMBOL SpecialFunctions\\sample 832 80 R0
WINDOW 3 16 80 Center 0
WINDOW 0 8 -48 Center 0
SYMATTR Value tripdt=1n
SYMATTR InstName A5
SYMBOL Digital\\buf1 352 112 R0
WINDOW 3 0 96 Left 0
WINDOW 123 0 114 Left 0
WINDOW 0 0 34 Left 0
SYMATTR Value tripdt=1n
SYMATTR Value2 ref=0
SYMATTR InstName A2
SYMBOL SpecialFunctions\\modulate2 144 176 R0
WINDOW 3 0 112 Left 0
WINDOW 123 0 130 Left 0
WINDOW 39 0 148 Left 0
WINDOW 0 0 -46 Left 0
SYMATTR Value space=0 mark={f2}
SYMATTR Value2 Vhigh={sqrt(2)}
SYMATTR SpiceLine Vlow={-sqrt(2)}
SYMATTR InstName A1
SYMBOL voltage 160 -144 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 -32 56 VBottom 0
WINDOW 123 0 0 Left 0
WINDOW 39 -55 56 VBottom 0
SYMATTR InstName V1
SYMATTR Value {Vdc}
SYMBOL zener 272 -224 M180
WINDOW 0 40 48 Left 0
WINDOW 3 40 24 Left 0
SYMATTR InstName D1
SYMATTR Value 1N750
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL Digital\\and 896 176 R0
WINDOW 3 -32 112 Left 0
WINDOW 0 -32 18 Left 0
WINDOW 123 -32 130 Left 0
SYMATTR Value tripdt=0n3
SYMATTR InstName A7
SYMATTR Value2 Td=3n
SYMBOL Digital\\inv 752 192 R0
WINDOW 0 0 34 Left 0
WINDOW 3 0 96 Left 0
WINDOW 123 0 114 Left 0
SYMATTR InstName A6
SYMATTR Value tripdt=1n
SYMATTR Value2 Td=4n
SYMBOL SpecialFunctions\\sample 832 -304 R0
WINDOW 3 16 80 Center 0
WINDOW 0 8 -48 Center 0
SYMATTR Value tripdt=1n
SYMATTR InstName A3
SYMBOL bv 608 48 M270
WINDOW 3 -32 56 VBottom 0
WINDOW 0 32 56 VTop 0
SYMATTR Value V=sdt(V(C)*V(o),0,V(R))/V(per)
SYMATTR InstName B4
SYMBOL bv 608 256 M270
WINDOW 3 -32 56 VBottom 0
WINDOW 0 32 56 VTop 0
SYMATTR Value V=sdt(1,0,V(R))
SYMATTR InstName B5
FLAG 96 -256 s
FLAG 112 176 f
FLAG 80 320 0
FLAG 320 -304 o
FLAG 304 176 S
FLAG 496 -144 0
FLAG 688 -336 1
FLAG 304 240 C
FLAG 496 48 0
FLAG 688 -144 2
FLAG 960 224 R
FLAG 832 384 0
FLAG 944 384 THD
FLAG 960 -96 So
FLAG 960 96 Co
FLAG 496 -336 0
FLAG 960 -288 To
FLAG 496 256 0
FLAG 608 256 per
FLAG 80 -208 0
FLAG 144 -128 0
FLAG 688 176 clk
FLAG 688 48 3
FLAG 832 256 4
FLAG 352 112 s
TEXT 40 416 Left 0 !.tran 0 {Ts+2/f1} {2/f1} {100u/f1} uic
TEXT 40 392 Left 0 !.param f1=20 f2=20k Ts=2000m
TEXT 400 376 Left 0 ;To plot freq on the horiz axis \nchange the quantity plotted to \n"V(f)*<f2>Hz/1V" (e.g. f2=20k) \nand click "Logarithmic"
TEXT 48 32 Left 0 ;Sweep Parameters:\nf1 = start freq  f2= stop freq\nTs = sweep duration
TEXT 112 -24 Left 0 ;.step param Vdc list 0 4 8
TEXT 40 440 Left 0 !.options plotwinsize=0 numdgt=8 reltol=10u
TEXT 112 -48 Left 0 ;.step param K list 10m .1 1 10
TEXT 112 -72 Left 0 !.param Vdc=0 K=1
TEXT 216 -368 Center 0 ;Nonlinear Test "Amplifier"
TEXT 968 152 Center 0 ;Delayed\nIntegrator\nReset
TEXT 968 24 Center 0 ;"DFT"\ncosine\noutput
TEXT 968 -168 Center 0 ;"DFT"\nsine\noutput
TEXT 968 -360 Center 0 ;Averaged\nraw\noutput
TEXT 552 192 Center 0 ;Cycle sample period
TEXT 552 152 Center 0 ;Cycle synchronous S/H clock
TEXT 968 328 Center 0 ;THD output\n(in percent)
TEXT 552 -208 Center 0 ;"DFT" sine integrator
TEXT 552 -16 Center 0 ;"DFT" cosine integrator
TEXT 552 -272 Center 0 ;cycle-by-cycle average
TEXT 512 -424 Center 0 ;Swept Sine Audio THD Measurement Generator - Rev 0 - Aug 2006 - analogspiceman@yahoo.com
TEXT 200 104 Center 0 ;Swept Sine-Cosine Source