Specifications

Chapter 4 89
Preparation for Accurate Measurement
Calibration
4. Preparation for
Accurate Measurement
Example program using macro (E4991A VBA)
Example 4-4 shows an example program that enables the calibration function by
transferring the calibration coefficient array saved in Example 4-2. This is saved under the
filename cal_inp.bas on the sample programs disk.
Line 70 Sets the GPIB address.
Line 90 Substitutes a variable for the file name for storing the calibration
coefficient array.
Lines 110 - 180 Confirms whether the calibration function should be set to on. If yes,
completes the program.
Lines 200 - 210 Reads the number of measurement points and substitutes a variable for
it.
Lines 230 - 250 Re-allocates a value to the range of the calibration coefficient array
using the number of measurement points.
Lines 300 - 320 Reads the calibration coefficient array stored in the external computer.
Lines 360 - 420 Transfers the calibration coefficient array from the external computer
to the E4991A.
Example 4-4 Transfer of calibration coefficient array (macro)
10 Sub Main()
20 Dim file As String
30 Dim Cal_a1() As Double, Cal_a2() As Double
40 Dim Cal_b1() As Double, Cal_b2() As Double
50 Dim Cal_c1() As Double, Cal_c2() As Double
60 Dim a1_data As String, a2_data As String
70 Dim b1_data As String, b2_data As String
80 Dim c1_data As String, c2_data As String
90 Dim Corr As Integer, Nop_cal As Integer
100 Dim iFileNo As Integer, i As Integer
110
120 SCPI.Output "SENS:CORR1?"
130 SCPI.Enter Corr
140 If Corr = 0 Then
150 MsgBox "It is unable to transfer calibration coefficient
data to E4991A", vbOKOnly + vbExclamation, "Transfer"
160 GoTo Prog_end
170 End If
180
190 SCPI.Output "SWE:POIN?"
200 SCPI.Enter Nop_cal
210
220 ReDim Cal_a1(1 To Nop_cal * 2), Cal_a2(1 To Nop_cal * 2)
230 ReDim Cal_b1(1 To Nop_cal * 2), Cal_b2(1 To Nop_cal * 2)
240 ReDim Cal_c1(1 To Nop_cal * 2), Cal_c2(1 To Nop_cal * 2)
250
260 ' -> Load Data
270
280 file = "a:\CAL_COEF"
290 iFileNo = FreeFile
300
310 Open file For Input As iFileNo