*ESR? Sweep Complete


This VBScript program polls for the completion of a sweep.

How to run this program:

This VBScript (*.vbs) program can be run as a macro in the analyzer. To do this, copy the following code into a text editor file such as Notepad and save it on the analyzer hard drive as NewMeas.vbs. Learn how to setup and run the macro.

See Other SCPI Example Programs

sub SweepAndPoll

Write "SYST:PRES"          ' Preset

Write "SENS:SWE:MODE HOLD" ' Put the channel into hold mode

Write "*ESE 1"             ' Turn on the *ESR? bit

Write "*CLS"               ' Clear any pending status

Write "SENS:SWE:TIME 2"    ' Set the sweep time to 2 seconds

Write "SENS:SWE:MODE SING" ' Initiate a sweep, but don't wait for complete

Write "*OPC"               ' Request notification on sweep complete

done = 0

count = 0

while (done <> 1)

                Write "*ESR?"      ' Check if sweep is complete

                done = Read()

                count = count + 1

                wscript.echo "Sweep not completed. Try#:" & count

                wscript.sleep 100 ' Wait for 100 ms

wend

wscript.echo "Sweep Completed. Try#: " & count

end Sub

 

 

' Infrastructure to setup the Write/Read functions

dim LastReadBuffer

Sub Write(command)

LastReadBuffer = s.Execute(command)

end sub

 

Function Read()

Read = LastReadBuffer

end function

 

' Setup and Call SweepAndPoll

set app = CreateObject("Agilentpna835x.application")

set s = app.scpistringparser

SweepAndPoll