Averaging

Other topics about Sample Programs

Overview

The sample program performs averaging and reports the completion of the averaging.

Sample Program in Excel VBA

Sub SampleAveTrigger()

  Dim ValueX As Long

  

  '*** The variables of the resource manager and the instrument I/O are declared.

  Dim ioMgr As VisaComLib.ResourceManager

  Dim MyEna As VisaComLib.FormattedIO488

 

  '*** The memory area of the resource manager and the instrument I/O are acquired.

  Set ioMgr = New VisaComLib.ResourceManager

  Set MyEna = New VisaComLib.FormattedIO488

  

  '*** Open the instrument.

  Set MyEna.IO = ioMgr.Open("GPIB0::17::INSTR")

  MyEna.IO.timeout = 10000

 

  '*** Main

  MyEna.WriteString ":SYST:PRES", True

  

  Application.Wait [Now() + "0:00:01"]

  

  MyEna.WriteString ":SENS1:FREQ:CENT 947.5E6", True

  MyEna.WriteString ":SENS1:FREQ:SPAN 100E6", True

  MyEna.WriteString ":CALC1:PAR1:DEF S21", True

  MyEna.WriteString ":SENS:BAND 10", True

  MyEna.WriteString ":SENS:SWE:POIN 21", True

  MyEna.WriteString ":SENS:AVER:COUN 2", True

  MyEna.WriteString ":SENS:AVER ON", True

  MyEna.WriteString ":TRIG:AVER ON", True

  

  MyEna.WriteString ":TRIG:SOUR BUS", True

  MyEna.WriteString ":INIT:CONT ON", True

    

  ' MyEna.WriteString "INIT", True ' This is necessary when INIT:CONT OFF

  MyEna.WriteString ":TRIG:SING", True ' :TRIG:IMM can not wait the sweep end by *OPC?

  MyEna.WriteString "*OPC?", True

  Dummy = MyEna.ReadNumber

  MyEna.WriteString ":CALC1:MARK1:STAT ON", True

  MyEna.WriteString ":CALC1:MARK1:FUNC:TYPE MAX", True

  MyEna.WriteString "CALC1:MARK1:FUNC:EXEC", True

  MyEna.WriteString ":CALC1:MARK1:X?", True

  ValueX = MyEna.ReadNumber

  Cells(1, 1).Value = Val(ValueX)

  

 '*** end procedure

  MyEna.IO.Close

End Sub