10 !Calculate even- and odd-order harmonic power as a 20 !percentage of fundamental power. Assumes 400-line 30 !power spectrum data (dBVrms) in Trace A spanning 40 !0 to 25.6kHz and a fundamental of 640Hz (line 10). 50 !2/3/20 ADP 60 !Clear instrument 70 CLEAR 8 80 !Get Trace A power spectrum from instrument 90 DIM Power(400) 100 OUTPUT 8;"CALCULATE1:DATA?" 110 ENTER 8 USING "#,K";Power(*) 120 !Get fundamental voltage 130 Fundamental=10^(Power(10)/20) 140 !Sum squared voltage values of even harmonic lines 150 FOR Line=20 TO 400 STEP 20 160 Even=Even+10^(Power(Line)/10) 170 NEXT Line 180 !Likewise for odd harmonic lines 190 FOR Line=30 TO 400 STEP 20 200 Odd=Odd+10^(Power(Line)/10) 210 NEXT Line 220 !Even, odd, and total harmonic voltage as a 230 !percentage of the fundamental voltage 240 Even_pct=SQRT(Even)/Fundamental*100 250 Odd_pct=SQRT(Odd)/Fundamental*100 260 Total_pct=SQRT(Even+Odd)/Fundamental*100 270 !Display even, odd, and total distortion as 280 !percentage of fundamental voltage 290 DISP USING "K,DD,K,DD,K,DD,K";"Even:",Even_pct,"% Odd:",Odd_pct,"% Total:",Total_pct,"%" 300 END