 2008 Fluke Corporation, All rights reserved               MET/CAL Procedure
=============================================================================
INSTRUMENT:            Sub Dynamic Settling /DMM
DATE:                  2008-11-25 13:41:48
AUTHOR:                Fluke
REVISION:              $Revision: 2619 $
ADJUSTMENT THRESHOLD:  70%
NUMBER OF TESTS:       1
NUMBER OF LINES:       170
CONFIGURATION:         Digital Multimeter
=============================================================================
#
#  Description:
#        This subprocedure takes a rolling average of @NumberReadings.  The
#        subprocedure exits when one the following conditions exists:
#
#        1. The standard deviation <= @StdDevLmt, or
#
#        2. Move than 100 averages have been taken, the allowed standard
#           deviation has not been achieved, and the operator decided to
#           terminate the procedure.
#
#        3. If @DMM_Readings is defined in the calling procedure, the
#           readings used to compute the standard deviation are written to
#           the file in the form:
#
#             Reading1
#             Reading2
#             Reading3
#                .
#                .
#                .
#
#  Procedure Author:
#        DAC
#
#  Model(s) Covered:
#        DMM's in user_config_instr.ini
#
#  Compatibility:
#        MET/CAL 7.20 SP1 (7.20x) or later
#
#  Subprocedures:
#        Sub Setup /DMM
#        Sub Read /DMM
#
#  Required Files:
#        None
#
#  Additional Equipment Required:
#        None
#
#  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.
#
#  Input:
#    @NumberReadings - Number of readings taken for rolling average
#    @StdDevLmt      - Allowed standard deviation
#  Output:
#    @Avg
#    @StdDev
#
 STEP    FSC    RANGE NOMINAL        TOLERANCE     MOD1        MOD2  3  4 CON

  1.001  IF           0
  1.002  IEEE         [@DMM]
  1.003  ENDIF

  1.004  MATH         @Error = 0

  1.005  IF           (@NumberReadings < 2) || (@NumberReadings > 32)
  1.006  DISP         @NumberReadings must be 2 to 32.
  1.007  MATH         @Error = 1
  1.008  END
  1.009  ENDIF

  1.010  CALL         Sub Setup /DMM

# Get first set of readings.
  1.011  MATH         Index = 1

  1.012  DO
  1.013  HEAD         -2 Initial Readings: [V Index] of [V @NumberReadings]
  1.014  CALL         Sub Read /DMM

# If a data file has been specified, write the data out.
  1.015  IF           ISVAR("@DMM_Readings")
  1.016  MATH         APPEND(@DMM_Readings, MEM)
  1.017  ENDIF

  1.018  MATH         LSET(Index, MEM)
  1.019  MATH         Index = Index + 1
  1.020  UNTIL        Index > @NumberReadings

  1.021  HEAD         -2
  1.022  MATH         @Avg    = AVG_L(1, @NumberReadings)
  1.023  MATH         @StdDev = SDEV_L(1, @NumberReadings)
# Initialize bail out counter.
  1.024  MATH         AvgNum = 1
  1.025  MATH         StartTime = UTIME()

# Perform rolling average until standard deviation is within limit.
  1.026  WHILE        (@StdDev > @StdDevLmt) && NOT(@Error)
  1.027  MATH         ET = UTIME() - StartTime
  1.028  MATH         SD = FMT(@StdDev, "%.2g")
  1.029  MATH         FET = FTIME(ET)
  1.030  MEM2         =[V FET], Limit = [V @StdDevLmt], StdDev = [V SD]
  1.031  HEAD         -2 [MEM2]
  1.032  MATH         Index = 2

# Shift readings down so new reading can be put in L[<@NumberReadings>].
# L[1] < L[2], L[2] < L[3],... L[<@NumberReadings - 1>] = L[<@NumberReadings>]
  1.033  DO
  1.034  MATH         LSET((Index - 1), LGET(Index))
  1.035  MATH         Index = Index + 1
  1.036  UNTIL        Index > @NumberReadings

  1.037  CALL         Sub Read /DMM

  1.038  IF           ISVAR("@DMM_Readings")
  1.039  MATH         APPEND(@DMM_Readings, MEM)
  1.040  ENDIF

  1.041  MATH         LSET(@NumberReadings, MEM)
  1.042  MATH         AvgNum = AvgNum + 1

  1.043  IF           AvgNum > 100
  1.044  OPBR         -z 100 [V @DMM_DevName] rolling averages have been taken
  1.044  OPBR         and the allowed standard deviation of [V @StdDevLmt]
  1.044  OPBR         has not been achieved.
  1.044  OPBR
  1.044  OPBR         Do you wish to continue averaging?

  1.045  IF           MEM1
# Re-initialize bail out counter.
  1.046  MATH         AvgNum = 1
  1.047  ELSE
  1.048  MATH         @Error = 1
  1.049  ENDIF

  1.050  ENDIF

  1.051  IF           NOT(@Error)
  1.052  MATH         @Avg    = AVG_L(1, @NumberReadings)
  1.053  MATH         @StdDev = SDEV_L(1, @NumberReadings)
  1.054  ENDIF

  1.055  ENDW

  1.056  HEAD         -2

  1.057  IF           ISVAR("@DMM_Readings")
  1.058  MATH         CLOSE(@DMM_Readings)
  1.059  ENDIF

  1.060  END
