功率校准

E5071C

功率校准

有关样本程序的其他主题

概述

这个程序说明如何进行功率校准。

这个程序(如下图所示)是通过用USB/GPIB接口在E5071C功率计(E4418B)之间进行连接,而用GPIB电缆在E5071C与外部控制器之间进行连接来运行。然后,程序通过利用功率传感器(E4412A)执行对E5071C的功率校准。所得到的功率校准数据组存入文件。

对E5071C、功率计和外部控制器进行连接。

参见针对这个编程的功率校准

用Excel VBA编写的样本程序

Sub pow_cal_Click()

    '

    Dim defrm As Long

    Dim vi As Long

    Dim SwpType As String, StartPower As String, StopPower As String, CwFreq As String

    Dim Nop As Long, NumOfAve As String, Limit As Double, CorrData() As Double

    Dim Result As String * 10000, OpcRes As String * 2, Res As Variant

    Dim i As Long, Stat As VbMsgBoxResult

    Dim err As String * 50, ErrNo As Variant

    Const TimeOutTime = 50000 ' TimeOut time should be greater than the measurement time.

    ' Assign a GPIB address to the I/O pass.

    Call viOpenDefaultRM(defrm)

    Call viOpen(defrm, "GPIB0::17::INSTR", 0, 0, vi)

    Call viSetAttribute(vi, VI_ATTR_TMO_VALUE, TimeOutTime)

    '

    SwpType = "POW"         ' Sweep type               : POWER

    Nop = 21                ' Number of points         : 41

    StartPower = "-20"      ' Start Power              : -20 dBm

    StopPower = "-10"       ' Stop Power               : -10 dBm

    CwFreq = "1E9"          ' CW frequency             : 1 GHz

    NumOfAve = "4"          ' Number of averaging      : 4

    Limit = 10              ' Limit for corrected data : 10 dBm

    '

    Call viVPrintf(vi, ":SYST:PRES" + vbLf, 0) ' Presetting the analyzer

    Call viVPrintf(vi, ":SYST:COMM:GPIB:PMET:ADDR 13" + vbLf, 0) ' Setting GPIB address of the power meter to ENA

    '

    ' Setting measurement conditions

    Call viVPrintf(vi, ":SENS1:SWE:TYPE " & SwpType & vbLf, 0)

    Call viVPrintf(vi, ":SENS1:SWE:POIN " & CStr(Nop) & vbLf, 0)

    Call viVPrintf(vi, ":SOUR1:POW:STAR " & StartPower & vbLf, 0)

    Call viVPrintf(vi, ":SOUR1:POW:STOP " & StopPower & vbLf, 0)

    Call viVPrintf(vi, ":SENS1:FREQ " & CwFreq & vbLf, 0)

    

    Stat = MsgBox("Do you perform zeroing and calibrating the power sensor?", vbYesNo)

    

    If Stat = vbYes Then

        MsgBox "Zero and calibrate the power sensor by using the power meter, then press [OK] key.", vbOKOnly

    End If

    

MeasStart:

    '

    ' Connecting the power sensor A to the port-1 of ENA

    Call viVPrintf(vi, "*CLS" + vbLf, 0)

    Stat = MsgBox("Set the power sensor connected to the port 1 in the ENA, then press [OK] key.", vbOKOnly)

    '

    ' Performing power calibration measurement

    Call viVPrintf(vi, ":SOUR1:POW:PORT1:CORR:COLL:AVER " & NumOfAve & vbLf, 0)

    Call viVPrintf(vi, ":SOUR1:POW:PORT1:CORR:COLL ASEN" + vbLf, 0)

    Call viVPrintf(vi, "*OPC?" + vbLf, 0)

    Call viVScanf(vi, "%t", OpcRes)

    '

    ' Error hnadling at power meter measurement

    Call viVQueryf(vi, ":SYST:ERR?" & vbLf, "%t", err)

    ErrNo = Split(err, ",")

    '

    If Val(ErrNo(0)) = 0 Then

        ReDim CorrData(Nop)

    

        Call viVPrintf(vi, ":FORM:DATA ASC" + vbLf, 0)

        Call viVPrintf(vi, ":SOUR1:POW:PORT1:CORR:DATA?" + vbLf, 0)

        Call viVScanf(vi, "%t", Result)

        Res = Split(Result, ",")

    

        If fnLim(vi, Nop, Limit, Res) Then

            MsgBox "Power meter calibration measurement is complete.", vbOKOnly

            For i = 1 To Nop

                Cells(i + 5, 2) = i

                Cells(i + 5, 3) = Res(i - 1)

            Next i

        Else

            GoTo ReCalibration

        End If

    Else

        MsgBox "Error", vbOKOnly

        GoTo ReCalibration

    End If

ProgEnd:

    Call viClose(vi)

    Call viClose(defrm)

    Exit Sub

ReCalibration:

        Stat = MsgBox("Do you perform the power meter calibration measurement again?", vbYesNo)

        If Stat = vbYes Then

            GoTo MeasStart

        Else

            GoTo ProgEnd

        End If

End Sub

Function fnLim(vi As Long, Nop As Long, Limit As Double, Res As Variant) As Boolean

    For i = 1 To Nop

        If Abs(Res(i - 1)) > Limit Then

            Call viVPrintf(vi, "SOUR1:POW:PORT1:CORR OFF" + vbLf, 0)

            MsgBox "The corrected data is out of limit!", vbOKOnly

            fnLim = False

            Exit Function

        End If

    Next i

    fnLim = True

End Function

在HT Basic中的样本程序 (pow_cal.htb)

10 DIM Swp_type$[11],Inp_char$[9],Buff$[9],Err_mes$[50],File$[20]

20 DIM Corr_data(1:1601)

30 REAL Start_p,Stop_p,Cw_freq,Limit

40 INTEGER Nop,Pow_rang,Num_avg,Err_no,Verifier,Data_size,I

50 CLEAR SCREEN

60 !

70 ASSIGN @Agte507x TO 717

80 !

90 Swp_type$="POW" !Sweep type : POWER

100 Nop=41 !Number of points : 41

110 Pow_rang=0 !Power Range :-20 to +12 dBm

120 Start_p=-2.0E+1 !Start Power :-20 dBm

130 Stop_p=-1.0E+1 !Stop Power :-10 dBm

140 Cw_freq=1.0E+9 !CW frequency : 1 GHz

150 Num_avg=4 !Number of averaging : 4

160 Limit=10 !limit for corrected data : 10 dBm

170 !

180 ! Presetting the analyzer

190 !

200 OUTPUT @Agte507x;":SYST:PRES"

210 !

220 ! Setting GPIB address of the power meter to E5071C

230 !

240 OUTPUT @Agte507x;":SYST:COMM:GPIB:PMET:ADDR 13"

250 !

260 ! Setting measurement conditions

270 !

280 OUTPUT @Agte507x;":SENS1:SWE:TYPE "&Swp_type$

290 OUTPUT @Agte507x;":SENS1:SWE:POIN ";Nop

300 OUTPUT @Agte507x;":SOUR1:POW:ATT ";Pow_rang

310 OUTPUT @Agte507x;":SOUR1:POW:STAR ";Start_p

320 OUTPUT @Agte507x;":SOUR1:POW:STOP ";Stop_p

330 OUTPUT @Agte507x;":SENS1:FREQ ";Cw_freq

340 !

350 PRINT "Do you perform zeroing and calibrating the power sensor?"

360 PRINT

370 INPUT "[Y/N]",Inp_char$

380 IF UPC$(Inp_char$)="Y" THEN

390 PRINT "Zero and calibrate the power sensor by using the power meter, then press [Enter] key."

400 PRINT

410 INPUT "",Inp_char$

420 END IF

430 !

440 Meas_start: !

450 !

460 ! Connecting the power sensor to the port 1 in the ENA

470 !

480 OUTPUT @Agte507x;"*CLS"

490 PRINT "Set the power sensor connected to the port 1 in the ENA, then press [Enter] key."

500 PRINT

510 INPUT "",Inp_char$

520 !

530 ! Performing power calibration measurement

540 !

550 OUTPUT @Agte507x;":SOUR1:POW:PORT1:CORR:COLL:AVER ";Num_avg

560 OUTPUT @Agte507x;":SOUR1:POW:PORT1:CORR:COLL ASEN"

570 OUTPUT @Agte507x;"*OPC?"

580 ENTER @Agte507x;Buff$

590 !

600 ! Error hnadling at power meter measurement

610 !

620 OUTPUT @Agte507x;":SYST:ERR?"

630 ENTER @Agte507x;Err_no,Err_mes$

640 !

650 IF Err_no=0 THEN

660 REDIM Corr_data(1:Nop)

670 OUTPUT @Agte507x;":FORM:DATA ASC"

680 OUTPUT @Agte507x;":SOUR1:POW:PORT1:CORR:DATA?"

690 ENTER @Agte507x;Corr_data(*)

700 Verifier=FNLim(@Agte507x,Nop,Limit,Corr_data(*))

710 IF Verifier=-1 THEN

720 PRINT "Do you perform the power meter calibration measurement again?"

730 PRINT

740 INPUT "[Y/N]",Inp_char$

750 IF UPC$(Inp_char$)="Y" THEN GOTO Meas_start

760 IF UPC$(Inp_char$)<>"Y" THEN GOTO Prog_stop

770 END IF

780 PRINT "Power meter calibration measurement is complete."

790 PRINT

800 ELSE

810 PRINT "Error: "&Err_mes$

820 PRINT

830 PRINT "Do you perform the power meter calibration measurement again?"

840 PRINT

850 INPUT "[Y/N]",Inp_char$

860 IF UPC$(Inp_char$)="Y" THEN GOTO Meas_start

870 IF UPC$(Inp_char$)<>"Y" THEN GOTO Prog_stop

880 END IF

890 !

900 ! Installing the corrected data to a file

910 !

920 File$="CORR_DATA"

930 Data_size=Nop*8

940 ON ERROR GOTO Skip_purge

950 PURGE File$

960 Skip_purge: OFF ERROR

970 PRINT "The file installing power correction data: "&File$

980 PRINT

990 CREATE File$,Data_size

1000 ASSIGN @File TO File$;FORMAT ON

1010 FOR I=1 TO Nop

1020 OUTPUT @File USING "3D,3X,MD.4DE";I,Corr_data(I)

1030 NEXT I

1040 ASSIGN @File TO *

1050 !

1060 PRINT "Installing the corrected data to the file is DONE."

1070 !

1080 GOTO Prog_end

1090 !

1100 Prog_stop: !

1110 PRINT "Program Interruption"

1120 !

1130 Prog_end: !

1140 !

1150 END

1160 !

1170 ! Limit Test Function for the Corrected Data

1180 !

1190 DEF FNLim(@Agte507x,INTEGER Nop,REAL Limit,REAL Corr_data(*))

1200 INTEGER I

1210 !

1220 FOR I=1 TO Nop

1230 IF ABS(Corr_data(I))>Limit THEN

1240 OUTPUT @Agte507x;"SOUR1:POW:PORT1:CORR OFF"

1250 PRINT "The corrected data is out of limit!"

1260 PRINT

1270 RETURN -1

1280 GOTO Fn_exit

1290 END IF

1300 NEXT I

1310 !

1320 RETURN 0

1330 !

1340 Fn_exit: !

1350 !

1360 FNEND