 Fluke Corporation. All Rights Reserved.                   MET/CAL Procedure
=============================================================================
INSTRUMENT:            Sub Initialize /uWCTR
INSTRUMENT:            Sub Reset /uWCTR
INSTRUMENT:            Sub Measure /uWCTR
INSTRUMENT:            Sub Setup /uWCTR
INSTRUMENT:            Sub Read /uWCTR
DATE:                  2007-12-14
AUTHOR:                Fluke
REVISION:              $Revision: 24551 $
ADJUSTMENT THRESHOLD:  70%
NUMBER OF TESTS:       4
NUMBER OF LINES:       316
CONFIGURATION:         HP 5352B
=============================================================================
#
#  Procedure Author:
#        DAC, DFM
#
#  Compatibility:
#        MET/CAL 7.20 or later
#
#  Subprocedures:
#        None
#
#  Required Files:
#        user_config_instr.ini
#
#  This procedure is intended for use with MET/CAL calibration software;
#  the terms and conditions set forth in your MET/CAL license apply to this
#  procedure.
#
#  Due to Fluke's policy of continuously updating our products, this procedure
#  may contain minor differences in methods used and/or specifications to
#  those found in the manual or other documentation. While every effort has
#  been made to ensure that this procedure is accurate, Fluke cannot be held
#  responsible for the consequences of error or omissions found within this
#  procedure.
#
#  The copyright in this procedure is owned by Fluke Corporation.
#
#  Example Usage:
#
#    Initialize HF Counter parameters
#
#        CALL         Sub Initialize /uWCTR
#
#  Parameters       Values
#  ---------------  ---------------------------------------------------------
#  @uWCTR_Func       Freq_Ch1
#  @uWCTR_Func       Freq_Ch2
#
#  @uWCTR_Ch1Imp     LoZ | HiZ
#  @uWCTR_Ch2Imp     LoZ | HiZ
#
#
#  @uWCTR_Meas_Time  <NR3>[][<prefix>]s
#
#  @uWCTR_ROSC       Int | Ext
#
#
#  Example Usage:
#
#    Reset
#
#        CALL         Sub Reset IEEE /uWCTR
#
 STEP    FSC    RANGE NOMINAL        TOLERANCE     MOD1        MOD2  3  4 CON

  1.001  JMPL         INITIALIZE                   PSUBI("Initialize")
  1.002  JMPL         RESET                        PSUBI("Reset")
  1.003  JMPL         SETUP                        PSUBI("Measure")
  1.004  JMPL         SETUP                        PSUBI("Setup")
  1.005  JMPL         READ                         PSUBI("Read")
  1.006  DISP         Subprocedure not found!
  1.007  END

  1.008  EVAL   Increment test number

# =============================== Initialize =================================

  2.001  LABEL        INITIALIZE
# Get and store device name.
  2.002  MATH         @uWCTR_DevName = INSTR("uWCTR")

# Get and store programming section name.
  2.003  MATH         Parameter = "ProgSecName"
  2.004  MATH         @uWCTR_ProgSecName = RINFE(@uWCTR_DevName, Parameter)

# Get and store FSC.
  2.005  MATH         @uWCTR_FSC = RINFE(@uWCTR_ProgSecName, "FSC")

# Get and store terminal names.
  2.006  MATH         @uWCTR_Ch1 = RINF(@uWCTR_ProgSecName, "ChHF")

  2.007  IF           EMPTY(@uWCTR_Ch1)
  2.008  MATH         @uWCTR_Ch1 = RINFE(@uWCTR_ProgSecName, "Ch1")
  2.009  ENDIF

  2.010  MATH         @uWCTR_Ch2    = RINF(@uWCTR_ProgSecName, "Ch2")
  2.011  MATH         @uWCTR_RefIn  = RINFE(@uWCTR_ProgSecName, "RefIn")
  2.012  MATH         @uWCTR_RefOut = RINFE(@uWCTR_ProgSecName, "RefOut")
  2.013  MATH         @uWCTR_IF_OUT = RINF(@uWCTR_ProgSecName, "IF_Out")

# Initialize parameters to the empty string (unset).
  2.014  MATH         @uWCTR_Func     = ""
  2.015  MATH         @uWCTR_Ch1Imp   = ""
  2.016  MATH         @uWCTR_Ch2Imp   = ""
  2.017  MATH         @uWCTR_MeasTime = ""
  2.018  MATH         @uWCTR_ROSC     = ""
# Unset flag to trigger operator message to manually select reference source.
  2.019  MATH         @uWCTR_ROSC_Set = 0

# Get programming string for RESET FSC.
  2.020  MATH         ResetCmd = RINF(@uWCTR_ProgSecName, "ResetFSC")

# If RESET_FSC is defined, establish the RESET FSC.
  2.021  IF           NOT(EMPTY(ResetCmd))

  2.022  IF           ZCMPI(ResetCmd, "[SDC]")
  2.023  RESET        [@uWCTR][SDC]
  2.024  ELSE
  2.025  RESET        [@uWCTR][V ResetCmd]
  2.026  ENDIF

  2.027  ENDIF

# See if input termination other than EOI is specified.
  2.028  MATH         InputTerm = RINF(@uWCTR_ProgSecName, "TERM")

# See CR or LF termination was specified...
  2.029  IF           ZCMPI(InputTerm, "CR")
  2.030  IEEE         [@uWCTR][TERM CR]
  2.031  ELSEIF       ZCMPI(InputTerm, "LF")
  2.032  IEEE         [@uWCTR][TERM LF]
  2.033  ENDIF

  2.034  END

  2.035  EVAL   Increment test number

# ================================= Reset ====================================

  3.001  LABEL        RESET
  3.002  MATH         @uWCTR_Cmd = RINFE(@uWCTR_ProgSecName, "Reset")
  3.003  CALL         Sub Send Command /uWCTR
  3.004  END

  3.005  EVAL   Increment test number

# ============================== Setup or Measure ============================

  4.001  LABEL        SETUP

# -----  Function

# First see if this the high frequency channel of a low frequency counter.
  4.002  IF           ZCMPI(@uWCTR_Func, "Freq_Ch1")
  4.003  MATH         @uWCTR_Cmd = RINF(@uWCTR_ProgSecName, "FreqChHF")
  4.004  ELSE
  4.005  MATH         @uWCTR_Cmd = ""
  4.006  ENDIF

  4.007  IF           EMPTY(@uWCTR_Cmd)
  4.008  MATH         @uWCTR_Cmd = RINFE(@uWCTR_ProgSecName, @uWCTR_Func)
  4.009  ENDIF

  4.010  CALL         Sub Send Command /uWCTR

# -----  Measuring Time

  4.011  MATH         ModeStr = RINF(@uWCTR_ProgSecName, "MeasTime")

# If mode string was found, use it. If not, use default and skip.
  4.012  IF           NOT(EMPTY(ModeStr))

  4.013  IF           NOT(EMPTY(@uWCTR_MeasTime))
# Convert to base units and insert in programming string.
  4.014  MATH         MeasTime = BASE(@uWCTR_MeasTime)
  4.015  MATH         MeasTimeCmd = RINFE(@uWCTR_ProgSecName, "MeasTime")
  4.016  MATH         @uWCTR_Cmd = REPL("<val>", MeasTime, MeasTimeCmd)
  4.017  CALL         Sub Send Command /uWCTR
  4.018  ENDIF

  4.019  ENDIF

# -----  Reference Oscillator

  4.020  IF           NOT(EMPTY(@uWCTR_ROSC))

  4.021  IF           ZCMPI(@uWCTR_ROSC, "Int")
  4.022  MATH         RefOsc = "RefOscInt"
  4.023  ELSE
  4.024  MATH         RefOsc = "RefOscExt"
  4.025  ENDIF

  4.026  MATH         RefSelect = RINF(@uWCTR_ProgSecName, "RefSelect")

  4.027  IF           ZCMPI(RefSelect, "Manual")

  4.028  IF           NOT(@uWCTR_ROSC_Set)
  4.029  MATH         Switch = RINFE(@uWCTR_ProgSecName, "RefOscSwitch")
  4.030  MATH         Setting = RINFE(@uWCTR_ProgSecName, RefOsc)
  4.031  DISP         Set [V @uWCTR_DevName] [V Switch] switch to [V Setting].
  4.032  MATH         @uWCTR_ROSC_Set = 1
  4.033  ENDIF        ; Prompt to set Reference Oscillator switch

  4.034  ELSEIF       ZCMPI(RefSelect, "Auto")
#                     Automatic selection.  Nothing to do.
  4.035  ELSE
  4.036  MATH         @uWCTR_Cmd = RINFE(@uWCTR_ProgSecName, RefOsc)
  4.037  CALL         Sub Send Command /uWCTR
  4.038  ENDIF

  4.039  ENDIF        ; IF Reference Oscillator

# -----  Channel 1 Input Impedance

  4.040  MATH         ModeStr1 = RINF(@uWCTR_ProgSecName, "Ch1Imp50_Ohm")
  4.041  MATH         ModeStr2 = RINF(@uWCTR_ProgSecName, "Ch1Imp1_MOhm")

# If mode strings were found, use it. If not, use default and skip.
  4.042  IF           NOT(EMPTY(ModeStr1)) && NOT(EMPTY(ModeStr2))

  4.043  IF           NOT(EMPTY(@uWCTR_Ch1Imp))

  4.044  IF           ZCMPI(@uWCTR_Ch1Imp, "LoZ")
  4.045  MATH         Imp = "Ch1Imp50_Ohm"
  4.046  ELSE
  4.047  MATH         Imp = "Ch1Imp1_MOhm"
  4.048  ENDIF

  4.049  MATH         @uWCTR_Cmd = RINFE(@uWCTR_ProgSecName, Imp)
  4.050  CALL         Sub Send Command /uWCTR
  4.051  ENDIF

  4.052  ENDIF

# -----  Channel 2 Input Impedance

  4.053  MATH         ModeStr1 = RINF(@uWCTR_ProgSecName, "Ch2Imp50_Ohm")
  4.054  MATH         ModeStr2 = RINF(@uWCTR_ProgSecName, "Ch2Imp1_MOhm")

# If mode strings were found, use it. If not, use default and skip.
  4.055  IF           NOT(EMPTY(ModeStr1)) && NOT(EMPTY(ModeStr2))

  4.056  IF           NOT(EMPTY(@uWCTR_Ch2Imp))

  4.057  IF           ZCMPI(@uWCTR_Ch2Imp, "LoZ")
  4.058  MATH         Imp = "Ch2Imp50_Ohm"
  4.059  ELSE
  4.060  MATH         Imp = "Ch2Imp1_MOhm"
  4.061  ENDIF

  4.062  MATH         @uWCTR_Cmd = RINFE(@uWCTR_ProgSecName, Imp)
  4.063  CALL         Sub Send Command /uWCTR
  4.064  ENDIF

  4.065  ENDIF

# Exit here if Setup.
  4.066  IF           PSUBI("Setup")
  4.067  END
  4.068  ENDIF

# Drop through for Measure.

# ============================== Read or Measure ============================

  4.069  LABEL        READ
# See if there is an initiate command.
  4.070  MATH         @uWCTR_Cmd = RINF(@uWCTR_ProgSecName, "Initiate")

# If there is an initiate command, send it.
  4.071  IF           NOT(EMPTY(@uWCTR_Cmd))
  4.072  CALL         Sub Send Command /uWCTR
  4.073  ENDIF

# See if there is an input terminator.
  4.074  MATH         InputTerm = RINF(@uWCTR_ProgSecName, "InputTerminator")

  4.075  IF           NOT(ZCMP(InputTerm, ""))

  4.076  IF           ZCMPI(InputTerm, "CR")
  4.077  IEEE         [TERM CR]
  4.078  ELSEIF       ZCMPI(InputTerm, "LF") || ZCMPI(InputTerm, "CRLF")
  4.079  IEEE         [TERM LF]
  4.080  ELSE
  4.081  DISP         Flexible driver "uWCTR" does not
  4.081  DISP         support "InputTerminator = [V InputTerm]"
  4.081  DISP         in [91][V @uWCTR_ProgSecName][93] section of
  4.081  DISP         "user_config_instr.ini".
  4.082  ENDIF

  4.083  ENDIF

# See if there is a fetch command.
  4.084  MATH         @uWCTR_Cmd = RINF(@uWCTR_ProgSecName, "Fetch")

# If there is no fetch command simply get the reading.
  4.085  IF           EMPTY(@uWCTR_Cmd)
  4.086  IEEE         [@uWCTR][I]
# Otherwise send the fetch command and get the reading.
  4.087  ELSEIF       ZCMPI(@uWCTR_FSC, "SCPI")
  4.088  SCPI         [@uWCTR][V @uWCTR_Cmd][I]
  4.089  ELSEIF       ZCMPI(@uWCTR_FSC, "IEEE2")
  4.090  IEEE2        [@uWCTR][V @uWCTR_Cmd][I]
  4.091  ELSE
  4.092  IEEE         [@uWCTR][V @uWCTR_Cmd][I]
  4.093  ENDIF

  4.094  END
