This
program
computes
the
total
harmonic
distortion
(THD)
as
dened
by
the
following
equation:
T
H
D
=
p
V
2
2
+
V
2
3
+
1
1
1
V
1
2
100
[%]
(11
0
1)
Where
,
V
1
Fundamental
[V]
V
2
The
second
harmonic
[V]
V
3
The
third
harmonic
[V]
.
.
.
THD
takes
into
account
the
power
in
all
the
harmonics
.
Because
an
innite
number
of
the
harmonics
cannot
be
measured,
a
nite
number
will
have
to
suce
.
Before
running
the
program,
measure
the
signal
and
display
the
fundamental
and
harmonics
to
be
computed
on
the
analyzer
display
(in
the
dBm
format).
d
a
10
!
20
!
Figure
11-2.
Total
Harmonic
Distortion
30
!
40
Vf=1
50
ASSIGN
@Hp4396
TO
717
!
When
iBASIC
is
used,
replace
"717"
to
"800"
60
OUTPUT
@Hp4396;"CLES;*SRE
4;ESNB
96"
70
ON
INTR
7
GOTO
Done
!
\
When
iBASIC
is
used,
80
ENABLE
INTR
7;2
!
/
replace
"7"
to
"8"
90
OUTPUT
@Hp4396;"STOP?"
100
ENTER
@Hp4396;Fstop
110
OUTPUT
@Hp4396;"PRSMKRS"
120
OUTPUT
@Hp4396;"MKR
ON;SEAM
PEAK"
130
OUTPUT
@Hp4396;"OUTPMKR?"
140
ENTER
@Hp4396;Vf,Vf2,Ff
!
Fundamental
150
Vf=SQR(10^(Vf/10)*.05)
!
Vf
in
V
160
"Fundamental"
170
Fr=Ff
180
I=2
190
S=0
200
LOOP
210
Fh=Ff*I
220
EXIT
IF
Fstop<=Fh
230
OUTPUT
@Hp4396;"DMKR
TRAC;MKRPRM
";Fh-Fr/2
240
OUTPUT
@Hp4396;"DMKR
ON"
250
OUTPUT
@Hp4396;"MKRPRM
";Fr
260
OUTPUT
@Hp4396;"PARS
ON;SEARSTR"
270
OUTPUT
@Hp4396;"SEAM
PEAK;DMKR
OFF"
280
OUTPUT
@Hp4396;"OUTPMKR?"
290
ENTER
@Hp4396;Vh,Vh2,F
300
Vh=10^(Vh/10)*.05
!
Vh^2
in
V^2
310
I;"
harmonic"
Figure
11-2.
Sample
Program
:
T
otal
Harmonic
Distortion
(THD)
(1/2)
11-2
Using
Application
Programs