Download as pdf or txt
Download as pdf or txt
You are on page 1of 144

Keysight InfiniiVision 3000 X-Series Oscilloscopes

Programmer's Guide

40 Programming Examples
VISA COM Examples / 1174
VISA Examples / 1207
VISA.NET Examples / 1260
SICL Examples / 1279
SCPI.NET Examples / 1299

Example programs are ASCII text files that can be cut from the help file and pasted
into your favorite text editor.
See Also • You can find additional programming examples for the InfiniiVision
3000 X-Series oscilloscopes on the Keysight Technologies website at:
www.keysight.com/find/3000X-Series-examples

1173
40 Programming Examples

VISA COM Examples


• "VISA COM Example in Visual Basic" on page 1174
• "VISA COM Example in C#" on page 1183
• "VISA COM Example in Visual Basic .NET" on page 1192
• "VISA COM Example in Python" on page 1200

VISA COM Example in Visual Basic


To run this example in Visual Basic for Applications (VBA):
1 Start the application that provides Visual Basic for Applications (for example,
Microsoft Excel).
2 Press ALT+F11 to launch the Visual Basic editor.
3 Reference the Keysight VISA COM library:
a Choose Tools > References... from the main menu.
b In the References dialog, check the "VISA COM 5.9 Type Library".
c Click OK.
4 Choose Insert > Module.
5 Cut-and-paste the code that follows into the editor.
6 Edit the program to use the VISA address of your oscilloscope, and save the
changes.
7 Run the program.
'
' Keysight VISA COM Example in Visual Basic
' -------------------------------------------------------------------
' This program illustrates a few commonly-used programming
' features of your Keysight oscilloscope.
' -------------------------------------------------------------------

Option Explicit

Public myMgr As VisaComLib.ResourceManager


Public myScope As VisaComLib.FormattedIO488
Public varQueryResult As Variant
Public strQueryResult As String

' For Sleep subroutine.


Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'
' Main Program
' -------------------------------------------------------------------

Sub Main()

1174 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

On Error GoTo VisaComError

' Create the VISA COM I/O resource.


Set myMgr = New VisaComLib.ResourceManager
Set myScope = New VisaComLib.FormattedIO488
Set myScope.IO = _
myMgr.Open("USB0::0x0957::0x17A6::US50210029::0::INSTR")
myScope.IO.Clear ' Clear the interface.
myScope.IO.Timeout = 10000 ' Set I/O communication timeout.

' Initialize - start from a known state.


Initialize

' Capture data.


Capture

' Analyze the captured waveform.


Analyze

Exit Sub

VisaComError:
MsgBox "VISA COM Error:" + vbCrLf + Err.Description
End

End Sub

'
' Initialize the oscilloscope to a known state.
' -------------------------------------------------------------------

Private Sub Initialize()

On Error GoTo VisaComError

' Get and display the device's *IDN? string.


strQueryResult = DoQueryString("*IDN?")
Debug.Print "Identification string: " + strQueryResult

' Clear status and load the default setup.


DoCommand "*CLS"
DoCommand "*RST"

Exit Sub

VisaComError:
MsgBox "VISA COM Error:" + vbCrLf + Err.Description
End

End Sub

'
' Capture the waveform.
' -------------------------------------------------------------------

Private Sub Capture()

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1175


40 Programming Examples

On Error GoTo VisaComError

' Use auto-scale to automatically configure oscilloscope.


' -----------------------------------------------------------------
DoCommand ":AUToscale"

' Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
DoCommand ":TRIGger:MODE EDGE"
Debug.Print "Trigger mode: " + _
DoQueryString(":TRIGger:MODE?")

' Set EDGE trigger parameters.


DoCommand ":TRIGger:EDGE:SOURce CHANnel1"
Debug.Print "Trigger edge source: " + _
DoQueryString(":TRIGger:EDGE:SOURce?")

DoCommand ":TRIGger:EDGE:LEVel 1.5"


Debug.Print "Trigger edge level: " + _
DoQueryString(":TRIGger:EDGE:LEVel?")

DoCommand ":TRIGger:EDGE:SLOPe POSitive"


Debug.Print "Trigger edge slope: " + _
DoQueryString(":TRIGger:EDGE:SLOPe?")

' Save oscilloscope configuration.


' -----------------------------------------------------------------
varQueryResult = DoQueryIEEEBlock_UI1(":SYSTem:SETup?")

' Output setup string to a file:


Dim strPath As String
strPath = "c:\scope\config\setup.dat"
Dim hFile As Long
hFile = FreeFile
Open strPath For Binary Access Write Lock Write As hFile
Put hFile, , varQueryResult ' Write data.
Close hFile ' Close file.
Debug.Print "Setup bytes saved: " + CStr(LenB(varQueryResult))

' Change settings with individual commands:


' -----------------------------------------------------------------

' Set vertical scale and offset.


DoCommand ":CHANnel1:SCALe 0.05"
Debug.Print "Channel 1 vertical scale: " + _
DoQueryString(":CHANnel1:SCALe?")

DoCommand ":CHANnel1:OFFSet -1.5"


Debug.Print "Channel 1 vertical offset: " + _
DoQueryString(":CHANnel1:OFFSet?")

' Set horizontal scale and offset.


DoCommand ":TIMebase:SCALe 0.0002"
Debug.Print "Timebase scale: " + _
DoQueryString(":TIMebase:SCALe?")

DoCommand ":TIMebase:POSition 0.0"


Debug.Print "Timebase position: " + _

1176 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

DoQueryString(":TIMebase:POSition?")

' Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution).


DoCommand ":ACQuire:TYPE NORMal"
Debug.Print "Acquire type: " + _
DoQueryString(":ACQuire:TYPE?")

' Or, configure by loading a previously saved setup.


' -----------------------------------------------------------------
Dim varSetupString As Variant
strPath = "c:\scope\config\setup.dat"
Open strPath For Binary Access Read As hFile ' Open file for input.
Get hFile, , varSetupString ' Read data.
Close hFile ' Close file.
' Write learn string back to oscilloscope using ":SYSTem:SETup"
' command:
DoCommandIEEEBlock ":SYSTem:SETup", varSetupString
Debug.Print "Setup bytes restored: " + CStr(LenB(varSetupString))

' Capture an acquisition using :DIGitize.


' -----------------------------------------------------------------
DoCommand ":DIGitize CHANnel1"

Exit Sub

VisaComError:
MsgBox "VISA COM Error:" + vbCrLf + Err.Description
End

End Sub

'
' Analyze the captured waveform.
' -------------------------------------------------------------------

Private Sub Analyze()

On Error GoTo VisaComError

' Make a couple of measurements.


' -----------------------------------------------------------------
DoCommand ":MEASure:SOURce CHANnel1"
Debug.Print "Measure source: " + _
DoQueryString(":MEASure:SOURce?")

DoCommand ":MEASure:FREQuency"
varQueryResult = DoQueryNumber(":MEASure:FREQuency?")
MsgBox "Frequency:" + vbCrLf + _
FormatNumber(varQueryResult / 1000, 4) + " kHz"

DoCommand ":MEASure:VAMPlitude"
varQueryResult = DoQueryNumber(":MEASure:VAMPlitude?")
MsgBox "Vertical amplitude:" + vbCrLf + _
FormatNumber(varQueryResult, 4) + " V"

' Download the screen image.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1177


40 Programming Examples

' -----------------------------------------------------------------
' Get screen image.
DoCommand ":HARDcopy:INKSaver OFF"
Dim byteData() As Byte
byteData = DoQueryIEEEBlock_UI1(":DISPlay:DATA? PNG, COLor")

' Save screen image to a file.


Dim strPath As String
strPath = "c:\scope\data\screen.png"
If Len(Dir(strPath)) Then
Kill strPath ' Remove file if it exists.
End If

Dim hFile As Long


hFile = FreeFile
Open strPath For Binary Access Write Lock Write As hFile
Put hFile, , byteData ' Write data.
Close hFile ' Close file.
MsgBox "Screen image (" + CStr(UBound(byteData) + 1) + _
" bytes) written to " + strPath

' Download waveform data.


' -----------------------------------------------------------------

' Set the waveform points mode.


DoCommand ":WAVeform:POINts:MODE RAW"
Debug.Print "Waveform points mode: " + _
DoQueryString(":WAVeform:POINts:MODE?")

' Get the number of waveform points available.


Debug.Print "Waveform points available: " + _
DoQueryString(":WAVeform:POINts?")

' Set the waveform source.


DoCommand ":WAVeform:SOURce CHANnel1"
Debug.Print "Waveform source: " + _
DoQueryString(":WAVeform:SOURce?")

' Choose the format of the data returned (WORD, BYTE, ASCII):
DoCommand ":WAVeform:FORMat BYTE"
Debug.Print "Waveform format: " + _
DoQueryString(":WAVeform:FORMat?")

' Display the waveform settings:


Dim Preamble()
Dim intFormat As Integer
Dim intType As Integer
Dim lngPoints As Long
Dim lngCount As Long
Dim dblXIncrement As Double
Dim dblXOrigin As Double
Dim lngXReference As Long
Dim sngYIncrement As Single
Dim sngYOrigin As Single
Dim lngYReference As Long

1178 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Preamble() = DoQueryNumbers(":WAVeform:PREamble?")

intFormat = Preamble(0)
intType = Preamble(1)
lngPoints = Preamble(2)
lngCount = Preamble(3)
dblXIncrement = Preamble(4)
dblXOrigin = Preamble(5)
lngXReference = Preamble(6)
sngYIncrement = Preamble(7)
sngYOrigin = Preamble(8)
lngYReference = Preamble(9)

If intFormat = 0 Then
Debug.Print "Waveform format: BYTE"
ElseIf intFormat = 1 Then
Debug.Print "Waveform format: WORD"
ElseIf intFormat = 4 Then
Debug.Print "Waveform format: ASCii"
End If

If intType = 0 Then
Debug.Print "Acquisition type: NORMal"
ElseIf intType = 1 Then
Debug.Print "Acquisition type: PEAK"
ElseIf intType = 2 Then
Debug.Print "Acquisition type: AVERage"
ElseIf intType = 3 Then
Debug.Print "Acquisition type: HRESolution"
End If

Debug.Print "Waveform points: " + _


FormatNumber(lngPoints, 0)

Debug.Print "Waveform average count: " + _


FormatNumber(lngCount, 0)

Debug.Print "Waveform X increment: " + _


Format(dblXIncrement, "Scientific")

Debug.Print "Waveform X origin: " + _


Format(dblXOrigin, "Scientific")

Debug.Print "Waveform X reference: " + _


FormatNumber(lngXReference, 0)

Debug.Print "Waveform Y increment: " + _


Format(sngYIncrement, "Scientific")

Debug.Print "Waveform Y origin: " + _


FormatNumber(sngYOrigin, 0)

Debug.Print "Waveform Y reference: " + _


FormatNumber(lngYReference, 0)

' Get the waveform data


varQueryResult = DoQueryIEEEBlock_UI1(":WAVeform:DATA?")

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1179


40 Programming Examples

Debug.Print "Number of data values: " + _


CStr(UBound(varQueryResult) + 1)

' Set up output file:


strPath = "c:\scope\data\waveform_data.csv"

' Open file for output.


Open strPath For Output Access Write Lock Write As hFile

' Output waveform data in CSV format.


Dim lngDataValue As Long
Dim lngI As Long

For lngI = 0 To UBound(varQueryResult)


lngDataValue = varQueryResult(lngI)

' Write time value, voltage value.


Print #hFile, _
FormatNumber(dblXOrigin + (lngI * dblXIncrement), 9) + _
", " + _
FormatNumber(((lngDataValue - lngYReference) * _
sngYIncrement) + sngYOrigin)

Next lngI

' Close output file.


Close hFile ' Close file.
MsgBox "Waveform format BYTE data written to " + _
"c:\scope\data\waveform_data.csv."

Exit Sub

VisaComError:
MsgBox "VISA COM Error:" + vbCrLf + Err.Description
End

End Sub

Private Sub DoCommand(command As String)

On Error GoTo VisaComError

myScope.WriteString command
CheckInstrumentErrors

Exit Sub

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + CStr(Err.Number) + ", " + _
Err.Source + ", " + _
Err.Description, vbExclamation, "VISA COM Error"
End

End Sub

Private Sub DoCommandIEEEBlock(command As String, data As Variant)

1180 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

On Error GoTo VisaComError

Dim strErrors As String

myScope.WriteIEEEBlock command, data


CheckInstrumentErrors

Exit Sub

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + CStr(Err.Number) + ", " + _
Err.Source + ", " + _
Err.Description, vbExclamation, "VISA COM Error"
End

End Sub

Private Function DoQueryString(query As String) As String

On Error GoTo VisaComError

myScope.WriteString query
DoQueryString = myScope.ReadString
CheckInstrumentErrors

Exit Function

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + CStr(Err.Number) + ", " + _
Err.Source + ", " + _
Err.Description, vbExclamation, "VISA COM Error"
End

End Function

Private Function DoQueryNumber(query As String) As Variant

On Error GoTo VisaComError

myScope.WriteString query
DoQueryNumber = myScope.ReadNumber
CheckInstrumentErrors

Exit Function

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + CStr(Err.Number) + ", " + _
Err.Source + ", " + _
Err.Description, vbExclamation, "VISA COM Error"
End

End Function

Private Function DoQueryNumbers(query As String) As Variant()

On Error GoTo VisaComError

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1181


40 Programming Examples

Dim strErrors As String

myScope.WriteString query
DoQueryNumbers = myScope.ReadList
CheckInstrumentErrors

Exit Function

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + CStr(Err.Number) + ", " + _
Err.Source + ", " + _
Err.Description, vbExclamation, "VISA COM Error"
End

End Function

Private Function DoQueryIEEEBlock_UI1(query As String) As Variant

On Error GoTo VisaComError

myScope.WriteString query
DoQueryIEEEBlock_UI1 = myScope.ReadIEEEBlock(BinaryType_UI1)
CheckInstrumentErrors

Exit Function

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + CStr(Err.Number) + ", " + _
Err.Source + ", " + _
Err.Description, vbExclamation, "VISA COM Error"
End

End Function

Private Sub CheckInstrumentErrors()

On Error GoTo VisaComError

Dim strErrVal As String


Dim strOut As String

myScope.WriteString ":SYSTem:ERRor?" ' Query any errors data.


strErrVal = myScope.ReadString ' Read: Errnum,"Error String".
While Val(strErrVal) <> 0 ' End if find: 0,"No Error".
strOut = strOut + "INST Error: " + strErrVal
myScope.WriteString ":SYSTem:ERRor?" ' Request error message.
strErrVal = myScope.ReadString ' Read error message.
Wend

If Not strOut = "" Then


MsgBox strOut, vbExclamation, "INST Error Messages"
myScope.FlushWrite (False)
myScope.FlushRead

End If

Exit Sub

1182 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

VisaComError:
MsgBox "VISA COM Error: " + vbCrLf + Err.Description

End Sub

VISA COM Example in C#


To compile and run this example in Microsoft Visual Studio 2008:
1 Open Visual Studio.
2 Create a new Visual C#, Windows, Console Application project.
3 Cut-and-paste the code that follows into the C# source file.
4 Edit the program to use the VISA address of your oscilloscope.
5 Add a reference to the VISA COM 5.9 Type Library:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Add Reference....
c In the Add Reference dialog, select the COM tab.
d Select VISA COM 5.9 Type Library; then click OK.
6 Build and run the program.

For more information, see the VISA COM Help that comes with Keysight IO
Libraries Suite.
/*
* Keysight VISA COM Example in C#
* -------------------------------------------------------------------
* This program illustrates a few commonly used programming
* features of your Keysight oscilloscope.
* -------------------------------------------------------------------
*/

using System;
using System.IO;
using System.Text;
using Ivi.Visa.Interop;
using System.Runtime.InteropServices;

namespace InfiniiVision
{
class VisaComInstrumentApp
{
private static VisaComInstrument myScope;

public static void Main(string[] args)


{
try
{
myScope = new

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1183


40 Programming Examples

VisaComInstrument("USB0::0x0957::0x17A6::US50210029::0::INSTR"
);
myScope.SetTimeoutSeconds(10);

// Initialize - start from a known state.


Initialize();

// Capture data.
Capture();

// Analyze the captured waveform.


Analyze();
}
catch (System.ApplicationException err)
{
Console.WriteLine("*** VISA COM Error : " + err.Message);
}
catch (System.SystemException err)
{
Console.WriteLine("*** System Error Message : " + err.Message);
}
catch (System.Exception err)
{
System.Diagnostics.Debug.Fail("Unexpected Error");
Console.WriteLine("*** Unexpected Error : " + err.Message);
}
finally
{
myScope.Close();
}
}

/*
* Initialize the oscilloscope to a known state.
* --------------------------------------------------------------
*/
private static void Initialize()
{
string strResults;

// Get and display the device's *IDN? string.


strResults = myScope.DoQueryString("*IDN?");
Console.WriteLine("*IDN? result is: {0}", strResults);

// Clear status and load the default setup.


myScope.DoCommand("*CLS");
myScope.DoCommand("*RST");
}

/*
* Capture the waveform.
* --------------------------------------------------------------
*/
private static void Capture()
{
// Use auto-scale to automatically configure oscilloscope.
myScope.DoCommand(":AUToscale");

1184 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

// Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.DoCommand(":TRIGger:MODE EDGE");
Console.WriteLine("Trigger mode: {0}",
myScope.DoQueryString(":TRIGger:MODE?"));

// Set EDGE trigger parameters.


myScope.DoCommand(":TRIGger:EDGE:SOURce CHANnel1");
Console.WriteLine("Trigger edge source: {0}",
myScope.DoQueryString(":TRIGger:EDGE:SOURce?"));

myScope.DoCommand(":TRIGger:EDGE:LEVel 1.5");
Console.WriteLine("Trigger edge level: {0}",
myScope.DoQueryString(":TRIGger:EDGE:LEVel?"));

myScope.DoCommand(":TRIGger:EDGE:SLOPe POSitive");
Console.WriteLine("Trigger edge slope: {0}",
myScope.DoQueryString(":TRIGger:EDGE:SLOPe?"));

// Save oscilloscope configuration.


byte[] ResultsArray; // Results array.
int nLength; // Number of bytes returned from instrument.
string strPath;

// Query and read setup string.


ResultsArray = myScope.DoQueryIEEEBlock(":SYSTem:SETup?");
nLength = ResultsArray.Length;

// Write setup string to file.


strPath = "c:\\scope\\config\\setup.stp";
FileStream fStream = File.Open(strPath, FileMode.Create);
fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Setup bytes saved: {0}", nLength);

// Change settings with individual commands:

// Set vertical scale and offset.


myScope.DoCommand(":CHANnel1:SCALe 0.05");
Console.WriteLine("Channel 1 vertical scale: {0}",
myScope.DoQueryString(":CHANnel1:SCALe?"));

myScope.DoCommand(":CHANnel1:OFFSet -1.5");
Console.WriteLine("Channel 1 vertical offset: {0}",
myScope.DoQueryString(":CHANnel1:OFFSet?"));

// Set horizontal scale and offset.


myScope.DoCommand(":TIMebase:SCALe 0.0002");
Console.WriteLine("Timebase scale: {0}",
myScope.DoQueryString(":TIMebase:SCALe?"));

myScope.DoCommand(":TIMebase:POSition 0.0");
Console.WriteLine("Timebase position: {0}",
myScope.DoQueryString(":TIMebase:POSition?"));

// Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution


).

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1185


40 Programming Examples

myScope.DoCommand(":ACQuire:TYPE NORMal");
Console.WriteLine("Acquire type: {0}",
myScope.DoQueryString(":ACQuire:TYPE?"));

// Or, configure by loading a previously saved setup.


byte[] DataArray;
int nBytesWritten;

// Read setup string from file.


strPath = "c:\\scope\\config\\setup.stp";
DataArray = File.ReadAllBytes(strPath);
nBytesWritten = DataArray.Length;

// Restore setup string.


myScope.DoCommandIEEEBlock(":SYSTem:SETup", DataArray);
Console.WriteLine("Setup bytes restored: {0}", nBytesWritten);

// Capture an acquisition using :DIGitize.


myScope.DoCommand(":DIGitize CHANnel1");
}

/*
* Analyze the captured waveform.
* --------------------------------------------------------------
*/
private static void Analyze()
{
byte[] ResultsArray; // Results array.
int nLength; // Number of bytes returned from instrument.
string strPath;

// Make a couple of measurements.


// -----------------------------------------------------------
myScope.DoCommand(":MEASure:SOURce CHANnel1");
Console.WriteLine("Measure source: {0}",
myScope.DoQueryString(":MEASure:SOURce?"));

double fResult;
myScope.DoCommand(":MEASure:FREQuency");
fResult = myScope.DoQueryNumber(":MEASure:FREQuency?");
Console.WriteLine("Frequency: {0:F4} kHz", fResult / 1000);

myScope.DoCommand(":MEASure:VAMPlitude");
fResult = myScope.DoQueryNumber(":MEASure:VAMPlitude?");
Console.WriteLine("Vertical amplitude: {0:F2} V", fResult);

// Download the screen image.


// -----------------------------------------------------------
myScope.DoCommand(":HARDcopy:INKSaver OFF");

// Get the screen data.


ResultsArray =
myScope.DoQueryIEEEBlock(":DISPlay:DATA? PNG, COLor");
nLength = ResultsArray.Length;

// Store the screen data to a file.


strPath = "c:\\scope\\data\\screen.png";

1186 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

FileStream fStream = File.Open(strPath, FileMode.Create);


fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Screen image ({0} bytes) written to {1}",
nLength, strPath);

// Download waveform data.


// -----------------------------------------------------------

// Set the waveform points mode.


myScope.DoCommand(":WAVeform:POINts:MODE RAW");
Console.WriteLine("Waveform points mode: {0}",
myScope.DoQueryString(":WAVeform:POINts:MODE?"));

// Get the number of waveform points available.


Console.WriteLine("Waveform points available: {0}",
myScope.DoQueryString(":WAVeform:POINts?"));

// Set the waveform source.


myScope.DoCommand(":WAVeform:SOURce CHANnel1");
Console.WriteLine("Waveform source: {0}",
myScope.DoQueryString(":WAVeform:SOURce?"));

// Choose the format of the data returned (WORD, BYTE, ASCII):


myScope.DoCommand(":WAVeform:FORMat BYTE");
Console.WriteLine("Waveform format: {0}",
myScope.DoQueryString(":WAVeform:FORMat?"));

// Display the waveform settings:


double[] fResultsArray;
fResultsArray = myScope.DoQueryNumbers(":WAVeform:PREamble?");

double fFormat = fResultsArray[0];


if (fFormat == 0.0)
{
Console.WriteLine("Waveform format: BYTE");
}
else if (fFormat == 1.0)
{
Console.WriteLine("Waveform format: WORD");
}
else if (fFormat == 2.0)
{
Console.WriteLine("Waveform format: ASCii");
}

double fType = fResultsArray[1];


if (fType == 0.0)
{
Console.WriteLine("Acquire type: NORMal");
}
else if (fType == 1.0)
{
Console.WriteLine("Acquire type: PEAK");
}
else if (fType == 2.0)
{

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1187


40 Programming Examples

Console.WriteLine("Acquire type: AVERage");


}
else if (fType == 3.0)
{
Console.WriteLine("Acquire type: HRESolution");
}

double fPoints = fResultsArray[2];


Console.WriteLine("Waveform points: {0:e}", fPoints);

double fCount = fResultsArray[3];


Console.WriteLine("Waveform average count: {0:e}", fCount);

double fXincrement = fResultsArray[4];


Console.WriteLine("Waveform X increment: {0:e}", fXincrement);

double fXorigin = fResultsArray[5];


Console.WriteLine("Waveform X origin: {0:e}", fXorigin);

double fXreference = fResultsArray[6];


Console.WriteLine("Waveform X reference: {0:e}", fXreference);

double fYincrement = fResultsArray[7];


Console.WriteLine("Waveform Y increment: {0:e}", fYincrement);

double fYorigin = fResultsArray[8];


Console.WriteLine("Waveform Y origin: {0:e}", fYorigin);

double fYreference = fResultsArray[9];


Console.WriteLine("Waveform Y reference: {0:e}", fYreference);

// Read waveform data.


ResultsArray = myScope.DoQueryIEEEBlock(":WAVeform:DATA?");
nLength = ResultsArray.Length;
Console.WriteLine("Number of data values: {0}", nLength);

// Set up output file:


strPath = "c:\\scope\\data\\waveform_data.csv";
if (File.Exists(strPath)) File.Delete(strPath);

// Open file for output.


StreamWriter writer = File.CreateText(strPath);

// Output waveform data in CSV format.


for (int i = 0; i < nLength - 1; i++)
writer.WriteLine("{0:f9}, {1:f6}",
fXorigin + ((float)i * fXincrement),
(((float)ResultsArray[i] - fYreference)
* fYincrement) + fYorigin);

// Close output file.


writer.Close();
Console.WriteLine("Waveform format BYTE data written to {0}",
strPath);
}
}

1188 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

class VisaComInstrument
{
private ResourceManagerClass m_ResourceManager;
private FormattedIO488Class m_IoObject;
private string m_strVisaAddress;

// Constructor.
public VisaComInstrument(string strVisaAddress)
{
// Save VISA address in member variable.
m_strVisaAddress = strVisaAddress;

// Open the default VISA COM IO object.


OpenIo();

// Clear the interface.


m_IoObject.IO.Clear();
}

public void DoCommand(string strCommand)


{
// Send the command.
m_IoObject.WriteString(strCommand, true);

// Check for inst errors.


CheckInstrumentErrors(strCommand);
}

public void DoCommandIEEEBlock(string strCommand,


byte[] DataArray)
{
// Send the command to the device.
m_IoObject.WriteIEEEBlock(strCommand, DataArray, true);

// Check for inst errors.


CheckInstrumentErrors(strCommand);
}

public string DoQueryString(string strQuery)


{
// Send the query.
m_IoObject.WriteString(strQuery, true);

// Get the result string.


string strResults;
strResults = m_IoObject.ReadString();

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return results string.


return strResults;
}

public double DoQueryNumber(string strQuery)


{
// Send the query.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1189


40 Programming Examples

m_IoObject.WriteString(strQuery, true);

// Get the result number.


double fResult;
fResult = (double)m_IoObject.ReadNumber(
IEEEASCIIType.ASCIIType_R8, true);

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return result number.


return fResult;
}

public double[] DoQueryNumbers(string strQuery)


{
// Send the query.
m_IoObject.WriteString(strQuery, true);

// Get the result numbers.


double[] fResultsArray;
fResultsArray = (double[])m_IoObject.ReadList(
IEEEASCIIType.ASCIIType_R8, ",;");

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return result numbers.


return fResultsArray;
}

public byte[] DoQueryIEEEBlock(string strQuery)


{
// Send the query.
m_IoObject.WriteString(strQuery, true);

// Get the results array.


System.Threading.Thread.Sleep(2000); // Delay before reading.
byte[] ResultsArray;
ResultsArray = (byte[])m_IoObject.ReadIEEEBlock(
IEEEBinaryType.BinaryType_UI1, false, true);

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return results array.


return ResultsArray;
}

private void CheckInstrumentErrors(string strCommand)


{
// Check for instrument errors.
string strInstrumentError;
bool bFirstError = true;

do // While not "0,No error".


{

1190 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

m_IoObject.WriteString(":SYSTem:ERRor?", true);
strInstrumentError = m_IoObject.ReadString();

if (!strInstrumentError.ToString().StartsWith("+0,"))
{
if (bFirstError)
{
Console.WriteLine("ERROR(s) for command '{0}': ",
strCommand);
bFirstError = false;
}
Console.Write(strInstrumentError);
}
} while (!strInstrumentError.ToString().StartsWith("+0,"));
}

private void OpenIo()


{
m_ResourceManager = new ResourceManagerClass();
m_IoObject = new FormattedIO488Class();

// Open the default VISA COM IO object.


try
{
m_IoObject.IO =
(IMessage)m_ResourceManager.Open(m_strVisaAddress,
AccessMode.NO_LOCK, 0, "");
}
catch (Exception e)
{
Console.WriteLine("An error occurred: {0}", e.Message);
}
}

public void SetTimeoutSeconds(int nSeconds)


{
m_IoObject.IO.Timeout = nSeconds * 1000;
}

public void Close()


{
try
{
m_IoObject.IO.Close();
}
catch { }

try
{
Marshal.ReleaseComObject(m_IoObject);
}
catch { }

try
{
Marshal.ReleaseComObject(m_ResourceManager);
}

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1191


40 Programming Examples

catch { }
}
}
}

VISA COM Example in Visual Basic .NET


To compile and run this example in Microsoft Visual Studio 2008:
1 Open Visual Studio.
2 Create a new Visual Basic, Windows, Console Application project.
3 Cut-and-paste the code that follows into the C# source file.
4 Edit the program to use the VISA address of your oscilloscope.
5 Add a reference to the VISA COM 5.9 Type Library:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Add Reference....
c In the Add Reference dialog, select the COM tab.
d Select VISA COM 5.9 Type Library; then click OK.
e Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment and choose
Properties; then, select "InfiniiVision.VisaComInstrumentApp" as the Startup
object.
6 Build and run the program.

For more information, see the VISA COM Help that comes with Keysight IO
Libraries Suite.
'
' Keysight VISA COM Example in Visual Basic .NET
' -------------------------------------------------------------------
' This program illustrates a few commonly used programming
' features of your Keysight oscilloscope.
' -------------------------------------------------------------------

Imports System
Imports System.IO
Imports System.Text
Imports Ivi.Visa.Interop
Imports System.Runtime.InteropServices

Namespace InfiniiVision
Class VisaComInstrumentApp
Private Shared myScope As VisaComInstrument

Public Shared Sub Main(ByVal args As String())


Try
myScope = New _
VisaComInstrument("USB0::0x0957::0x17A6::US50210029::0::INSTR"

1192 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

)
myScope.SetTimeoutSeconds(10)

' Initialize - start from a known state.


Initialize()

' Capture data.


Capture()

' Analyze the captured waveform.


Analyze()

Catch err As System.ApplicationException


Console.WriteLine("*** VISA Error Message : " + err.Message)
Catch err As System.SystemException
Console.WriteLine("*** System Error Message : " + err.Message)
Catch err As System.Exception
System.Diagnostics.Debug.Fail("Unexpected Error")
Console.WriteLine("*** Unexpected Error : " + err.Message)
Finally
myScope.Close()
End Try
End Sub

' Initialize the oscilloscope to a known state.


' --------------------------------------------------------------

Private Shared Sub Initialize()


Dim strResults As String

' Get and display the device's *IDN? string.


strResults = myScope.DoQueryString("*IDN?")
Console.WriteLine("*IDN? result is: {0}", strResults)

' Clear status and load the default setup.


myScope.DoCommand("*CLS")
myScope.DoCommand("*RST")

End Sub

' Capture the waveform.


' --------------------------------------------------------------

Private Shared Sub Capture()

' Use auto-scale to automatically configure oscilloscope.


myScope.DoCommand(":AUToscale")

' Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.DoCommand(":TRIGger:MODE EDGE")
Console.WriteLine("Trigger mode: {0}", _
myScope.DoQueryString(":TRIGger:MODE?"))

' Set EDGE trigger parameters.


myScope.DoCommand(":TRIGger:EDGE:SOURce CHANnel1")
Console.WriteLine("Trigger edge source: {0}", _
myScope.DoQueryString(":TRIGger:EDGE:SOURce?"))

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1193


40 Programming Examples

myScope.DoCommand(":TRIGger:EDGE:LEVel 1.5")
Console.WriteLine("Trigger edge level: {0}", _
myScope.DoQueryString(":TRIGger:EDGE:LEVel?"))

myScope.DoCommand(":TRIGger:EDGE:SLOPe POSitive")
Console.WriteLine("Trigger edge slope: {0}", _
myScope.DoQueryString(":TRIGger:EDGE:SLOPe?"))

' Save oscilloscope configuration.


Dim ResultsArray As Byte() ' Results array.
Dim nLength As Integer ' Number of bytes returned from inst.
Dim strPath As String
Dim fStream As FileStream

' Query and read setup string.


ResultsArray = myScope.DoQueryIEEEBlock(":SYSTem:SETup?")
nLength = ResultsArray.Length

' Write setup string to file.


strPath = "c:\scope\config\setup.stp"
fStream = File.Open(strPath, FileMode.Create)
fStream.Write(ResultsArray, 0, nLength)
fStream.Close()
Console.WriteLine("Setup bytes saved: {0}", nLength)

' Change settings with individual commands:

' Set vertical scale and offset.


myScope.DoCommand(":CHANnel1:SCALe 0.05")
Console.WriteLine("Channel 1 vertical scale: {0}", _
myScope.DoQueryString(":CHANnel1:SCALe?"))

myScope.DoCommand(":CHANnel1:OFFSet -1.5")
Console.WriteLine("Channel 1 vertical offset: {0}", _
myScope.DoQueryString(":CHANnel1:OFFSet?"))

' Set horizontal scale and offset.


myScope.DoCommand(":TIMebase:SCALe 0.0002")
Console.WriteLine("Timebase scale: {0}", _
myScope.DoQueryString(":TIMebase:SCALe?"))

myScope.DoCommand(":TIMebase:POSition 0.0")
Console.WriteLine("Timebase position: {0}", _
myScope.DoQueryString(":TIMebase:POSition?"))

' Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution)


.
myScope.DoCommand(":ACQuire:TYPE NORMal")
Console.WriteLine("Acquire type: {0}", _
myScope.DoQueryString(":ACQuire:TYPE?"))

' Or, configure by loading a previously saved setup.


Dim DataArray As Byte()
Dim nBytesWritten As Integer

' Read setup string from file.

1194 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

strPath = "c:\scope\config\setup.stp"
DataArray = File.ReadAllBytes(strPath)
nBytesWritten = DataArray.Length

' Restore setup string.


myScope.DoCommandIEEEBlock(":SYSTem:SETup", DataArray)
Console.WriteLine("Setup bytes restored: {0}", nBytesWritten)

' Capture an acquisition using :DIGitize.


myScope.DoCommand(":DIGitize CHANnel1")

End Sub

' Analyze the captured waveform.


' --------------------------------------------------------------

Private Shared Sub Analyze()

Dim fResult As Double


Dim ResultsArray As Byte() ' Results array.
Dim nLength As Integer ' Number of bytes returned from inst.
Dim strPath As String

' Make a couple of measurements.


' ------------------------------------------------------------
myScope.DoCommand(":MEASure:SOURce CHANnel1")
Console.WriteLine("Measure source: {0}", _
myScope.DoQueryString(":MEASure:SOURce?"))

myScope.DoCommand(":MEASure:FREQuency")
fResult = myScope.DoQueryNumber(":MEASure:FREQuency?")
Console.WriteLine("Frequency: {0:F4} kHz", fResult / 1000)

myScope.DoCommand(":MEASure:VAMPlitude")
fResult = myScope.DoQueryNumber(":MEASure:VAMPlitude?")
Console.WriteLine("Vertical amplitude: {0:F2} V", fResult)

' Download the screen image.


' ------------------------------------------------------------
myScope.DoCommand(":HARDcopy:INKSaver OFF")

' Get the screen data.


ResultsArray = myScope.DoQueryIEEEBlock(":DISPlay:DATA? PNG, COLor
")
nLength = ResultsArray.Length

' Store the screen data to a file.


strPath = "c:\scope\data\screen.png"
Dim fStream As FileStream
fStream = File.Open(strPath, FileMode.Create)
fStream.Write(ResultsArray, 0, nLength)
fStream.Close()
Console.WriteLine("Screen image ({0} bytes) written to {1}", _
nLength, strPath)

' Download waveform data.


' ------------------------------------------------------------

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1195


40 Programming Examples

' Set the waveform points mode.


myScope.DoCommand(":WAVeform:POINts:MODE RAW")
Console.WriteLine("Waveform points mode: {0}", _
myScope.DoQueryString(":WAVeform:POINts:MODE?"))

' Get the number of waveform points available.


Console.WriteLine("Waveform points available: {0}", _
myScope.DoQueryString(":WAVeform:POINts?"))

' Set the waveform source.


myScope.DoCommand(":WAVeform:SOURce CHANnel1")
Console.WriteLine("Waveform source: {0}", _
myScope.DoQueryString(":WAVeform:SOURce?"))

' Choose the format of the data returned (WORD, BYTE, ASCII):
myScope.DoCommand(":WAVeform:FORMat BYTE")
Console.WriteLine("Waveform format: {0}", _
myScope.DoQueryString(":WAVeform:FORMat?"))

' Display the waveform settings:


Dim fResultsArray As Double()
fResultsArray = myScope.DoQueryNumbers(":WAVeform:PREamble?")

Dim fFormat As Double = fResultsArray(0)


If fFormat = 0 Then
Console.WriteLine("Waveform format: BYTE")
ElseIf fFormat = 1 Then
Console.WriteLine("Waveform format: WORD")
ElseIf fFormat = 2 Then
Console.WriteLine("Waveform format: ASCii")
End If

Dim fType As Double = fResultsArray(1)


If fType = 0 Then
Console.WriteLine("Acquire type: NORMal")
ElseIf fType = 1 Then
Console.WriteLine("Acquire type: PEAK")
ElseIf fType = 2 Then
Console.WriteLine("Acquire type: AVERage")
ElseIf fType = 3 Then
Console.WriteLine("Acquire type: HRESolution")
End If

Dim fPoints As Double = fResultsArray(2)


Console.WriteLine("Waveform points: {0:e}", fPoints)

Dim fCount As Double = fResultsArray(3)


Console.WriteLine("Waveform average count: {0:e}", fCount)

Dim fXincrement As Double = fResultsArray(4)


Console.WriteLine("Waveform X increment: {0:e}", fXincrement)

Dim fXorigin As Double = fResultsArray(5)


Console.WriteLine("Waveform X origin: {0:e}", fXorigin)

Dim fXreference As Double = fResultsArray(6)

1196 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Console.WriteLine("Waveform X reference: {0:e}", fXreference)

Dim fYincrement As Double = fResultsArray(7)


Console.WriteLine("Waveform Y increment: {0:e}", fYincrement)

Dim fYorigin As Double = fResultsArray(8)


Console.WriteLine("Waveform Y origin: {0:e}", fYorigin)

Dim fYreference As Double = fResultsArray(9)


Console.WriteLine("Waveform Y reference: {0:e}", fYreference)

' Get the waveform data.


ResultsArray = myScope.DoQueryIEEEBlock(":WAVeform:DATA?")
nLength = ResultsArray.Length
Console.WriteLine("Number of data values: {0}", nLength)

' Set up output file:


strPath = "c:\scope\data\waveform_data.csv"
If File.Exists(strPath) Then
File.Delete(strPath)
End If

' Open file for output.


Dim writer As StreamWriter = File.CreateText(strPath)

' Output waveform data in CSV format.


For index As Integer = 0 To nLength - 1
' Write time value, voltage value.
writer.WriteLine("{0:f9}, {1:f6}", _
fXorigin + (CSng(index) * fXincrement), _
((CSng(ResultsArray(index)) - fYreference) _
* fYincrement) + fYorigin)
Next

' Close output file.


writer.Close()
Console.WriteLine("Waveform format BYTE data written to {0}", _
strPath)

End Sub

End Class

Class VisaComInstrument
Private m_ResourceManager As ResourceManagerClass
Private m_IoObject As FormattedIO488Class
Private m_strVisaAddress As String

' Constructor.
Public Sub New(ByVal strVisaAddress As String)

' Save VISA address in member variable.


m_strVisaAddress = strVisaAddress

' Open the default VISA COM IO object.


OpenIo()

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1197


40 Programming Examples

' Clear the interface.


m_IoObject.IO.Clear()

End Sub

Public Sub DoCommand(ByVal strCommand As String)

' Send the command.


m_IoObject.WriteString(strCommand, True)

' Check for inst errors.


CheckInstrumentErrors(strCommand)

End Sub

Public Sub DoCommandIEEEBlock(ByVal strCommand As String, _


ByVal DataArray As Byte())

' Send the command to the device.


m_IoObject.WriteIEEEBlock(strCommand, DataArray, True)

' Check for inst errors.


CheckInstrumentErrors(strCommand)

End Sub

Public Function DoQueryString(ByVal strQuery As String) As String


' Send the query.
m_IoObject.WriteString(strQuery, True)

' Get the result string.


Dim strResults As String
strResults = m_IoObject.ReadString()

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return results string.


Return strResults
End Function

Public Function DoQueryNumber(ByVal strQuery As String) As Double


' Send the query.
m_IoObject.WriteString(strQuery, True)

' Get the result number.


Dim fResult As Double
fResult = _
CDbl(m_IoObject.ReadNumber(IEEEASCIIType.ASCIIType_R8, True))

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return result number.


Return fResult
End Function

1198 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Public Function DoQueryNumbers(ByVal strQuery As String) As _


Double()
' Send the query.
m_IoObject.WriteString(strQuery, True)

' Get the result numbers.


Dim fResultsArray As Double()
fResultsArray = _
m_IoObject.ReadList(IEEEASCIIType.ASCIIType_R8, ",;")

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return result numbers.


Return fResultsArray
End Function

Public _
Function DoQueryIEEEBlock(ByVal strQuery As String) As Byte()
' Send the query.
m_IoObject.WriteString(strQuery, True)

' Get the results array.


System.Threading.Thread.Sleep(2000) ' Delay before reading data.
Dim ResultsArray As Byte()
ResultsArray = _
m_IoObject.ReadIEEEBlock(IEEEBinaryType.BinaryType_UI1, _
False, True)

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return results array.


Return ResultsArray
End Function

Private Sub CheckInstrumentErrors(ByVal strCommand As String)


' Check for instrument errors.
Dim strInstrumentError As String
Dim bFirstError As Boolean = True
Do ' While not "0,No error".
m_IoObject.WriteString(":SYSTem:ERRor?", True)
strInstrumentError = m_IoObject.ReadString()

If Not strInstrumentError.ToString().StartsWith("+0,") Then


If bFirstError Then
Console.WriteLine("ERROR(s) for command '{0}': ", _
strCommand)
bFirstError = False
End If
Console.Write(strInstrumentError)
End If
Loop While Not strInstrumentError.ToString().StartsWith("+0,")
End Sub

Private Sub OpenIo()


m_ResourceManager = New ResourceManagerClass()

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1199


40 Programming Examples

m_IoObject = New FormattedIO488Class()

' Open the default VISA COM IO object.


Try
m_IoObject.IO = _
DirectCast(m_ResourceManager.Open(m_strVisaAddress, _
AccessMode.NO_LOCK, 0, ""), IMessage)
Catch e As Exception
Console.WriteLine("An error occurred: {0}", e.Message)
End Try
End Sub

Public Sub SetTimeoutSeconds(ByVal nSeconds As Integer)


m_IoObject.IO.Timeout = nSeconds * 1000
End Sub

Public Sub Close()


Try
m_IoObject.IO.Close()
Catch
End Try

Try
Marshal.ReleaseComObject(m_IoObject)
Catch
End Try

Try
Marshal.ReleaseComObject(m_ResourceManager)
Catch
End Try
End Sub
End Class
End Namespace

VISA COM Example in Python


You can use the Python programming language with the "comtypes" package to
control Keysight oscilloscopes.
The Python language and "comtypes" package can be downloaded from the web
at http://www.python.org/ and
http://starship.python.net/crew/theller/comtypes/, respectively.
To run this example with Python and "comtypes":
1 Cut-and-paste the code that follows into a file named "example.py".
2 Edit the program to use the VISA address of your oscilloscope.
3 If "python.exe" can be found via your PATH environment variable, open a
Command Prompt window; then, change to the folder that contains the
"example.py" file, and enter:
python example.py

1200 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

#
# Keysight VISA COM Example in Python using "comtypes"
# *********************************************************
# This program illustrates a few commonly used programming
# features of your Keysight oscilloscope.
# *********************************************************

# Import Python modules.


# ---------------------------------------------------------
import string
import time
import sys
import array

from comtypes.client import GetModule


from comtypes.client import CreateObject

# Run GetModule once to generate comtypes.gen.VisaComLib.


if not hasattr(sys, "frozen"):
GetModule("C:\Program Files (x86)\IVI Foundation\VISA\VisaCom\
GlobMgr.dll")

import comtypes.gen.VisaComLib as VisaComLib

# Global variables (booleans: 0 = False, 1 = True).


# ---------------------------------------------------------

# =========================================================
# Initialize:
# =========================================================
def initialize():
# Get and display the device's *IDN? string.
idn_string = do_query_string("*IDN?")
print "Identification string '%s'" % idn_string

# Clear status and load the default setup.


do_command("*CLS")
do_command("*RST")

# =========================================================
# Capture:
# =========================================================
def capture():

# Use auto-scale to automatically set up oscilloscope.


print "Autoscale."
do_command(":AUToscale")

# Set trigger mode.


do_command(":TRIGger:MODE EDGE")
qresult = do_query_string(":TRIGger:MODE?")
print "Trigger mode: %s" % qresult

# Set EDGE trigger parameters.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1201


40 Programming Examples

do_command(":TRIGger:EDGE:SOURce CHANnel1")
qresult = do_query_string(":TRIGger:EDGE:SOURce?")
print "Trigger edge source: %s" % qresult

do_command(":TRIGger:EDGE:LEVel 1.5")
qresult = do_query_string(":TRIGger:EDGE:LEVel?")
print "Trigger edge level: %s" % qresult

do_command(":TRIGger:EDGE:SLOPe POSitive")
qresult = do_query_string(":TRIGger:EDGE:SLOPe?")
print "Trigger edge slope: %s" % qresult

# Save oscilloscope setup.


setup_bytes = do_query_ieee_block(":SYSTem:SETup?")
nLength = len(setup_bytes)
f = open("c:\scope\config\setup.stp", "wb")
f.write(bytearray(setup_bytes))
f.close()
print "Setup bytes saved: %d" % nLength

# Change oscilloscope settings with individual commands:

# Set vertical scale and offset.


do_command(":CHANnel1:SCALe 0.05")
qresult = do_query_number(":CHANnel1:SCALe?")
print "Channel 1 vertical scale: %f" % qresult

do_command(":CHANnel1:OFFSet -1.5")
qresult = do_query_number(":CHANnel1:OFFSet?")
print "Channel 1 offset: %f" % qresult

# Set horizontal scale and offset.


do_command(":TIMebase:SCALe 0.0002")
qresult = do_query_string(":TIMebase:SCALe?")
print "Timebase scale: %s" % qresult

do_command(":TIMebase:POSition 0.0")
qresult = do_query_string(":TIMebase:POSition?")
print "Timebase position: %s" % qresult

# Set the acquisition type.


do_command(":ACQuire:TYPE NORMal")
qresult = do_query_string(":ACQuire:TYPE?")
print "Acquire type: %s" % qresult

# Or, configure by loading a previously saved setup.


f = open("c:\scope\config\setup.stp", "rb")
setup_bytes = f.read()
f.close()
do_command_ieee_block(":SYSTem:SETup", array.array('B', setup_bytes))
print "Setup bytes restored: %d" % len(setup_bytes)

# Capture an acquisition using :DIGitize.


do_command(":DIGitize CHANnel1")

# =========================================================

1202 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

# Analyze:
# =========================================================
def analyze():

# Make measurements.
# --------------------------------------------------------
do_command(":MEASure:SOURce CHANnel1")
qresult = do_query_string(":MEASure:SOURce?")
print "Measure source: %s" % qresult

do_command(":MEASure:FREQuency")
qresult = do_query_string(":MEASure:FREQuency?")
print "Measured frequency on channel 1: %s" % qresult

do_command(":MEASure:VAMPlitude")
qresult = do_query_string(":MEASure:VAMPlitude?")
print "Measured vertical amplitude on channel 1: %s" % qresult

# Download the screen image.


# --------------------------------------------------------
do_command(":HARDcopy:INKSaver OFF")

image_bytes = do_query_ieee_block(":DISPlay:DATA? PNG, COLor")


nLength = len(image_bytes)
f = open("c:\scope\data\screen.png", "wb")
f.write(bytearray(image_bytes))
f.close()
print "Screen image written to c:\scope\data\screen.png."

# Download waveform data.


# --------------------------------------------------------

# Set the waveform points mode.


do_command(":WAVeform:POINts:MODE RAW")
qresult = do_query_string(":WAVeform:POINts:MODE?")
print "Waveform points mode: %s" % qresult

# Get the number of waveform points available.


do_command(":WAVeform:POINts 10240")
qresult = do_query_string(":WAVeform:POINts?")
print "Waveform points available: %s" % qresult

# Set the waveform source.


do_command(":WAVeform:SOURce CHANnel1")
qresult = do_query_string(":WAVeform:SOURce?")
print "Waveform source: %s" % qresult

# Choose the format of the data returned:


do_command(":WAVeform:FORMat BYTE")
print "Waveform format: %s" % do_query_string(":WAVeform:FORMat?")

# Display the waveform settings from preamble:


wav_form_dict = {
0 : "BYTE",
1 : "WORD",
4 : "ASCii",
}

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1203


40 Programming Examples

acq_type_dict = {
0 : "NORMal",
1 : "PEAK",
2 : "AVERage",
3 : "HRESolution",
}

(
wav_form,
acq_type,
wfmpts,
avgcnt,
x_increment,
x_origin,
x_reference,
y_increment,
y_origin,
y_reference
) = do_query_numbers(":WAVeform:PREamble?")

print "Waveform format: %s" % wav_form_dict[wav_form]


print "Acquire type: %s" % acq_type_dict[acq_type]
print "Waveform points desired: %d" % wfmpts
print "Waveform average count: %d" % avgcnt
print "Waveform X increment: %1.12f" % x_increment
print "Waveform X origin: %1.9f" % x_origin
print "Waveform X reference: %d" % x_reference # Always 0.
print "Waveform Y increment: %f" % y_increment
print "Waveform Y origin: %f" % y_origin
print "Waveform Y reference: %d" % y_reference # Always 125.

# Get numeric values for later calculations.


x_increment = do_query_number(":WAVeform:XINCrement?")
x_origin = do_query_number(":WAVeform:XORigin?")
y_increment = do_query_number(":WAVeform:YINCrement?")
y_origin = do_query_number(":WAVeform:YORigin?")
y_reference = do_query_number(":WAVeform:YREFerence?")

# Get the waveform data.


data_bytes = do_query_ieee_block(":WAVeform:DATA?")
nLength = len(data_bytes)
print "Number of data values: %d" % nLength

# Open file for output.


strPath = "c:\scope\data\waveform_data.csv"
f = open(strPath, "w")

# Output waveform data in CSV format.


for i in xrange(0, nLength - 1):
time_val = x_origin + (i * x_increment)
voltage = (data_bytes[i] - y_reference) * y_increment + y_origin
f.write("%E, %f\n" % (time_val, voltage))

# Close output file.


f.close()
print "Waveform format BYTE data written to %s." % strPath

1204 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

# =========================================================
# Send a command and check for errors:
# =========================================================
def do_command(command):
myScope.WriteString("%s" % command, True)
check_instrument_errors(command)

# =========================================================
# Send a command and check for errors:
# =========================================================
def do_command_ieee_block(command, data):
myScope.WriteIEEEBlock(command, data, True)
check_instrument_errors(command)

# =========================================================
# Send a query, check for errors, return string:
# =========================================================
def do_query_string(query):
myScope.WriteString("%s" % query, True)
result = myScope.ReadString()
check_instrument_errors(query)
return result

# =========================================================
# Send a query, check for errors, return string:
# =========================================================
def do_query_ieee_block(query):
myScope.WriteString("%s" % query, True)
result = myScope.ReadIEEEBlock(VisaComLib.BinaryType_UI1, \
False, True)
check_instrument_errors(query)
return result

# =========================================================
# Send a query, check for errors, return values:
# =========================================================
def do_query_number(query):
myScope.WriteString("%s" % query, True)
result = myScope.ReadNumber(VisaComLib.ASCIIType_R8, True)
check_instrument_errors(query)
return result

# =========================================================
# Send a query, check for errors, return values:
# =========================================================
def do_query_numbers(query):
myScope.WriteString("%s" % query, True)
result = myScope.ReadList(VisaComLib.ASCIIType_R8, ",;")
check_instrument_errors(query)
return result

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1205


40 Programming Examples

# =========================================================
# Check for instrument errors:
# =========================================================
def check_instrument_errors(command):

while True:
myScope.WriteString(":SYSTem:ERRor?", True)
error_string = myScope.ReadString()
if error_string: # If there is an error string value.

if error_string.find("+0,", 0, 3) == -1: # Not "No error".


print "ERROR: %s, command: '%s'" % (error_string, command)
print "Exited because of error."
sys.exit(1)

else: # "No error"


break

else: # :SYSTem:ERRor? should always return string.


print "ERROR: :SYSTem:ERRor? returned nothing, command: '%s'" \
% command
print "Exited because of error."
sys.exit(1)

# =========================================================
# Main program:
# =========================================================
rm = CreateObject("VISA.GlobalRM", \
interface=VisaComLib.IResourceManager)
myScope = CreateObject("VISA.BasicFormattedIO", \
interface=VisaComLib.IFormattedIO488)
myScope.IO = \
rm.Open("TCPIP0::a-mx3104a-90028.cos.is.keysight.com::inst0::INSTR")

# Clear the interface.


myScope.IO.Clear
print "Interface cleared."

# Set the Timeout to 15 seconds.


myScope.IO.Timeout = 15000 # 15 seconds.
print "Timeout set to 15000 milliseconds."

# Initialize the oscilloscope, capture data, and analyze.


initialize()
capture()
analyze()

print "End of program"

1206 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

VISA Examples
• "VISA Example in C" on page 1207
• "VISA Example in Visual Basic" on page 1216
• "VISA Example in C#" on page 1226
• "VISA Example in Visual Basic .NET" on page 1237
• "VISA Example in Python (PyVISA 1.5 and older)" on page 1247
• "VISA Example in Python (PyVISA 1.6 and newer)" on page 1253

VISA Example in C
To compile and run this example in Microsoft Visual Studio 2008:
1 Open Visual Studio.
2 Create a new Visual C++, Win32, Win32 Console Application project.
3 In the Win32 Application Wizard, click Next >. Then, check Empty project, and
click Finish.
4 Cut-and-paste the code that follows into a file named "example.c" in the
project directory.
5 In Visual Studio 2008, right-click the Source Files folder, choose Add > Add
Existing Item..., select the example.c file, and click Add.
6 Edit the program to use the VISA address of your oscilloscope.
7 Choose Project > Properties.... In the Property Pages dialog, update these project
settings:
a Under Configuration Properties, Linker, Input, add "visa32.lib" to the
Additional Dependencies field.
b Under Configuration Properties, C/C++, Code Generation, select
Multi-threaded DLL for the Runtime Library field.
c Click OK to close the Property Pages dialog.
8 Add the include files and library files search paths:
a Choose Tools > Options....
b In the Options dialog, under Projects and Solutions, select VC++ Directories.
c Show directories for Include files, and add the include directory (for example,
Program Files (x86)\IVI Foundation\VISA\WinNT\Include).
d Show directories for Library files, and add the library files directory (for
example, Program Files (x86)\IVI Foundation\VISA\WinNT\lib\msc).
e Click OK to close the Options dialog.
9 Build and run the program.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1207


40 Programming Examples

/*
* Keysight VISA Example in C
* ------------------------------------------------------------------
* This program illustrates a few commonly-used programming
* features of your Keysight oscilloscope.
*/

#include <stdio.h> /* For printf(). */


#include <string.h> /* For strcpy(), strcat(). */
#include <time.h> /* For clock(). */
#include <visa.h> /* Keysight VISA routines. */

#define VISA_ADDRESS "USB0::0x0957::0x17A6::US50210029::0::INSTR"


#define IEEEBLOCK_SPACE 5000000

/* Function prototypes */
void initialize(void); /* Initialize to known state. */
void capture(void); /* Capture the waveform. */
void analyze(void); /* Analyze the captured waveform. */

void do_command(char *command); /* Send command. */


int do_command_ieeeblock(char *command); /* Command w/IEEE block. */
void do_query_string(char *query); /* Query for string. */
void do_query_number(char *query); /* Query for number. */
void do_query_numbers(char *query); /* Query for numbers. */
int do_query_ieeeblock(char *query); /* Query for IEEE block. */
void check_instrument_errors(); /* Check for inst errors. */
void error_handler(); /* VISA error handler. */

/* Global variables */
ViSession defaultRM, vi; /* Device session ID. */
ViStatus err; /* VISA function return value. */
char str_result[256] = {0}; /* Result from do_query_string(). */
double num_result; /* Result from do_query_number(). */
unsigned char ieeeblock_data[IEEEBLOCK_SPACE]; /* Result from
do_query_ieeeblock(). */
double dbl_results[10]; /* Result from do_query_numbers(). */

/* Main Program
* --------------------------------------------------------------- */
void main(void)
{
/* Open the default resource manager session. */
err = viOpenDefaultRM(&defaultRM);
if (err != VI_SUCCESS) error_handler();

/* Open the session using the oscilloscope's VISA address. */


err = viOpen(defaultRM, VISA_ADDRESS, VI_NULL, VI_NULL, &vi);
if (err != VI_SUCCESS) error_handler();

/* Set the I/O timeout to fifteen seconds. */


err = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 15000);
if (err != VI_SUCCESS) error_handler();

/* Initialize - start from a known state. */


initialize();

1208 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

/* Capture data. */
capture();

/* Analyze the captured waveform. */


analyze();

/* Close the vi session and the resource manager session. */


viClose(vi);
viClose(defaultRM);
}

/* Initialize the oscilloscope to a known state.


* --------------------------------------------------------------- */
void initialize (void)
{
/* Clear the interface. */
err = viClear(vi);
if (err != VI_SUCCESS) error_handler();

/* Get and display the device's *IDN? string. */


do_query_string("*IDN?");
printf("Oscilloscope *IDN? string: %s\n", str_result);

/* Clear status and load the default setup. */


do_command("*CLS");
do_command("*RST");
}

/* Capture the waveform.


* --------------------------------------------------------------- */
void capture (void)
{
int num_bytes;
FILE *fp;

/* Use auto-scale to automatically configure oscilloscope. */


do_command(":AUToscale");

/* Set trigger mode (EDGE, PULSe, PATTern, etc., and input source. */
do_command(":TRIGger:MODE EDGE");
do_query_string(":TRIGger:MODE?");
printf("Trigger mode: %s\n", str_result);

/* Set EDGE trigger parameters. */


do_command(":TRIGger:EDGE:SOURce CHANnel1");
do_query_string(":TRIGger:EDGE:SOURce?");
printf("Trigger edge source: %s\n", str_result);

do_command(":TRIGger:EDGE:LEVel 1.5");
do_query_string(":TRIGger:EDGE:LEVel?");
printf("Trigger edge level: %s\n", str_result);

do_command(":TRIGger:EDGE:SLOPe POSitive");
do_query_string(":TRIGger:EDGE:SLOPe?");
printf("Trigger edge slope: %s\n", str_result);

/* Save oscilloscope configuration. */

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1209


40 Programming Examples

/* Read system setup. */


num_bytes = do_query_ieeeblock(":SYSTem:SETup?");
printf("Read setup string query (%d bytes).\n", num_bytes);

/* Write setup string to file. */


fp = fopen ("c:\\scope\\config\\setup.stp", "wb");
num_bytes = fwrite(ieeeblock_data, sizeof(unsigned char), num_bytes,
fp);
fclose (fp);
printf("Wrote setup string (%d bytes) to ", num_bytes);
printf("c:\\scope\\config\\setup.stp.\n");

/* Change settings with individual commands:

/* Set vertical scale and offset. */


do_command(":CHANnel1:SCALe 0.05");
do_query_string(":CHANnel1:SCALe?");
printf("Channel 1 vertical scale: %s\n", str_result);

do_command(":CHANnel1:OFFSet -1.5");
do_query_string(":CHANnel1:OFFSet?");
printf("Channel 1 offset: %s\n", str_result);

/* Set horizontal scale and offset. */


do_command(":TIMebase:SCALe 0.0002");
do_query_string(":TIMebase:SCALe?");
printf("Timebase scale: %s\n", str_result);

do_command(":TIMebase:POSition 0.0");
do_query_string(":TIMebase:POSition?");
printf("Timebase position: %s\n", str_result);

/* Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution). *


/
do_command(":ACQuire:TYPE NORMal");
do_query_string(":ACQuire:TYPE?");
printf("Acquire type: %s\n", str_result);

/* Or, configure by loading a previously saved setup. */

/* Read setup string from file. */


fp = fopen ("c:\\scope\\config\\setup.stp", "rb");
num_bytes = fread (ieeeblock_data, sizeof(unsigned char),
IEEEBLOCK_SPACE, fp);
fclose (fp);
printf("Read setup string (%d bytes) from file ", num_bytes);
printf("c:\\scope\\config\\setup.stp.\n");

/* Restore setup string. */


num_bytes = do_command_ieeeblock(":SYSTem:SETup", num_bytes);
printf("Restored setup string (%d bytes).\n", num_bytes);

/* Capture an acquisition using :DIGitize. */


do_command(":DIGitize CHANnel1");
}

1210 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

/* Analyze the captured waveform.


* --------------------------------------------------------------- */
void analyze (void)
{
double wav_format;
double acq_type;
double wav_points;
double avg_count;
double x_increment;
double x_origin;
double x_reference;
double y_increment;
double y_origin;
double y_reference;

FILE *fp;
int num_bytes; /* Number of bytes returned from instrument. */
int i;

/* Make a couple of measurements.


* ------------------------------------------------------------- */
do_command(":MEASure:SOURce CHANnel1");
do_query_string(":MEASure:SOURce?");
printf("Measure source: %s\n", str_result);

do_command(":MEASure:FREQuency");
do_query_number(":MEASure:FREQuency?");
printf("Frequency: %.4f kHz\n", num_result / 1000);

do_command(":MEASure:VAMPlitude");
do_query_number(":MEASure:VAMPlitude?");
printf("Vertical amplitude: %.2f V\n", num_result);

/* Download the screen image.


* ------------------------------------------------------------- */
do_command(":HARDcopy:INKSaver OFF");

/* Read screen image. */


num_bytes = do_query_ieeeblock(":DISPlay:DATA? PNG, COLor");
printf("Screen image bytes: %d\n", num_bytes);

/* Write screen image bytes to file. */


fp = fopen ("c:\\scope\\data\\screen.png", "wb");
num_bytes = fwrite(ieeeblock_data, sizeof(unsigned char), num_bytes,
fp);
fclose (fp);
printf("Wrote screen image (%d bytes) to ", num_bytes);
printf("c:\\scope\\data\\screen.png.\n");

/* Download waveform data.


* ------------------------------------------------------------- */

/* Set the waveform points mode. */


do_command(":WAVeform:POINts:MODE RAW");
do_query_string(":WAVeform:POINts:MODE?");
printf("Waveform points mode: %s\n", str_result);

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1211


40 Programming Examples

/* Get the number of waveform points available. */


do_query_string(":WAVeform:POINts?");
printf("Waveform points available: %s\n", str_result);

/* Set the waveform source. */


do_command(":WAVeform:SOURce CHANnel1");
do_query_string(":WAVeform:SOURce?");
printf("Waveform source: %s\n", str_result);

/* Choose the format of the data returned (WORD, BYTE, ASCII): */


do_command(":WAVeform:FORMat BYTE");
do_query_string(":WAVeform:FORMat?");
printf("Waveform format: %s\n", str_result);

/* Display the waveform settings: */


do_query_numbers(":WAVeform:PREamble?");

wav_format = dbl_results[0];
if (wav_format == 0.0)
{
printf("Waveform format: BYTE\n");
}
else if (wav_format == 1.0)
{
printf("Waveform format: WORD\n");
}
else if (wav_format == 2.0)
{
printf("Waveform format: ASCii\n");
}

acq_type = dbl_results[1];
if (acq_type == 0.0)
{
printf("Acquire type: NORMal\n");
}
else if (acq_type == 1.0)
{
printf("Acquire type: PEAK\n");
}
else if (acq_type == 2.0)
{
printf("Acquire type: AVERage\n");
}
else if (acq_type == 3.0)
{
printf("Acquire type: HRESolution\n");
}

wav_points = dbl_results[2];
printf("Waveform points: %e\n", wav_points);

avg_count = dbl_results[3];
printf("Waveform average count: %e\n", avg_count);

x_increment = dbl_results[4];
printf("Waveform X increment: %e\n", x_increment);

1212 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

x_origin = dbl_results[5];
printf("Waveform X origin: %e\n", x_origin);

x_reference = dbl_results[6];
printf("Waveform X reference: %e\n", x_reference);

y_increment = dbl_results[7];
printf("Waveform Y increment: %e\n", y_increment);

y_origin = dbl_results[8];
printf("Waveform Y origin: %e\n", y_origin);

y_reference = dbl_results[9];
printf("Waveform Y reference: %e\n", y_reference);

/* Read waveform data. */


num_bytes = do_query_ieeeblock(":WAVeform:DATA?");
printf("Number of data values: %d\n", num_bytes);

/* Open file for output. */


fp = fopen("c:\\scope\\data\\waveform_data.csv", "wb");

/* Output waveform data in CSV format. */


for (i = 0; i < num_bytes - 1; i++)
{
/* Write time value, voltage value. */
fprintf(fp, "%9f, %6f\n",
x_origin + ((float)i * x_increment),
(((float)ieeeblock_data[i] - y_reference) * y_increment)
+ y_origin);
}

/* Close output file. */


fclose(fp);
printf("Waveform format BYTE data written to ");
printf("c:\\scope\\data\\waveform_data.csv.\n");
}

/* Send a command to the instrument.


* --------------------------------------------------------------- */
void do_command(command)
char *command;
{
char message[80];

strcpy(message, command);
strcat(message, "\n");
err = viPrintf(vi, message);
if (err != VI_SUCCESS) error_handler();

check_instrument_errors();
}

/* Command with IEEE definite-length block.


* --------------------------------------------------------------- */
int do_command_ieeeblock(command, num_bytes)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1213


40 Programming Examples

char *command;
int num_bytes;
{
char message[80];
int data_length;

strcpy(message, command);
strcat(message, " #8%08d");
err = viPrintf(vi, message, num_bytes);
if (err != VI_SUCCESS) error_handler();

err = viBufWrite(vi, ieeeblock_data, num_bytes, &data_length);


if (err != VI_SUCCESS) error_handler();

check_instrument_errors();

return(data_length);
}

/* Query for a string result.


* --------------------------------------------------------------- */
void do_query_string(query)
char *query;
{
char message[80];

strcpy(message, query);
strcat(message, "\n");

err = viPrintf(vi, message);


if (err != VI_SUCCESS) error_handler();

err = viScanf(vi, "%t", str_result);


if (err != VI_SUCCESS) error_handler();

check_instrument_errors();
}

/* Query for a number result.


* --------------------------------------------------------------- */
void do_query_number(query)
char *query;
{
char message[80];

strcpy(message, query);
strcat(message, "\n");

err = viPrintf(vi, message);


if (err != VI_SUCCESS) error_handler();

err = viScanf(vi, "%lf", &num_result);


if (err != VI_SUCCESS) error_handler();

check_instrument_errors();
}

1214 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

/* Query for numbers result.


* --------------------------------------------------------------- */
void do_query_numbers(query)
char *query;
{
char message[80];

strcpy(message, query);
strcat(message, "\n");

err = viPrintf(vi, message);


if (err != VI_SUCCESS) error_handler();

err = viScanf(vi, "%,10lf\n", dbl_results);


if (err != VI_SUCCESS) error_handler();

check_instrument_errors();
}

/* Query for an IEEE definite-length block result.


* --------------------------------------------------------------- */
int do_query_ieeeblock(query)
char *query;
{
char message[80];
int data_length;

strcpy(message, query);
strcat(message, "\n");
err = viPrintf(vi, message);
if (err != VI_SUCCESS) error_handler();

data_length = IEEEBLOCK_SPACE;
err = viScanf(vi, "%#b\n", &data_length, ieeeblock_data);
if (err != VI_SUCCESS) error_handler();

if (data_length == IEEEBLOCK_SPACE )
{
printf("IEEE block buffer full: ");
printf("May not have received all data.\n");
}

check_instrument_errors();

return(data_length);
}

/* Check for instrument errors.


* --------------------------------------------------------------- */
void check_instrument_errors()
{
char str_err_val[256] = {0};
char str_out[800] = "";

err = viQueryf(vi, ":SYSTem:ERRor?\n", "%t", str_err_val);


if (err != VI_SUCCESS) error_handler();
while(strncmp(str_err_val, "+0,No error", 3) != 0 )

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1215


40 Programming Examples

{
strcat(str_out, ", ");
strcat(str_out, str_err_val);
err = viQueryf(vi, ":SYSTem:ERRor?\n", "%t", str_err_val);
if (err != VI_SUCCESS) error_handler();
}

if (strcmp(str_out, "") != 0)
{
printf("INST Error%s\n", str_out);
err = viFlush(vi, VI_READ_BUF);
if (err != VI_SUCCESS) error_handler();
err = viFlush(vi, VI_WRITE_BUF);
if (err != VI_SUCCESS) error_handler();
}
}

/* Handle VISA errors.


* --------------------------------------------------------------- */
void error_handler()
{
char err_msg[1024] = {0};

viStatusDesc(vi, err, err_msg);


printf("VISA Error: %s\n", err_msg);
if (err < VI_SUCCESS)
{
exit(1);
}
}

VISA Example in Visual Basic


To run this example in Visual Basic for Applications:
1 Start the application that provides Visual Basic for Applications (for example,
Microsoft Excel).
2 Press ALT+F11 to launch the Visual Basic editor.
3 Add the visa32.bas file to your project:
a Choose File > Import File....
b Navigate to the header file, visa32.bas (installed with Keysight IO Libraries
Suite and found in the Program Files (x86)\IVI Foundation\VISA\WinNT\
Include), select it, and click Open.
4 Choose Insert > Module.
5 Cut-and-paste the code that follows into the editor.
6 Edit the program to use the VISA address of your oscilloscope, and save the
changes.
7 Run the program.

1216 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

'
' Keysight VISA Example in Visual Basic
' -------------------------------------------------------------------
' This program illustrates a few commonly-used programming
' features of your Keysight oscilloscope.
' -------------------------------------------------------------------

Option Explicit

Public err As Long ' Error returned by VISA function calls.


Public drm As Long ' Session to Default Resource Manager.
Public vi As Long ' Session to instrument.

' Declare variables to hold numeric values returned by


' viVScanf/viVQueryf.
Public dblQueryResult As Double
Public Const ByteArraySize = 5000000
Public retCount As Long
Public byteArray(ByteArraySize) As Byte
Public paramsArray(2) As Long
Public Const DblArraySize = 20
Public dblArray(DblArraySize) As Double

' Declare fixed length string variable to hold string value returned
' by viVScanf/viVQueryf.
Public strQueryResult As String * 200

' For Sleep subroutine.


Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'
' Main Program
' -------------------------------------------------------------------

Sub Main()

' Open the default resource manager session.


err = viOpenDefaultRM(drm)
If (err <> VI_SUCCESS) Then HandleVISAError drm

' Open the session using the oscilloscope's VISA address.


err = viOpen(drm, _
"USB0::0x0957::0x17A6::US50210029::0::INSTR", 0, 15000, vi)
If (err <> VI_SUCCESS) Then HandleVISAError drm

' Set the I/O timeout to ten seconds.


err = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 10000)
If (err <> VI_SUCCESS) Then HandleVISAError vi

' Initialize - start from a known state.


Initialize

' Capture data.


Capture

' Analyze the captured waveform.


Analyze

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1217


40 Programming Examples

' Close the vi session and the resource manager session.


err = viClose(vi)
err = viClose(drm)

End Sub

'
' Initialize the oscilloscope to a known state.
' -------------------------------------------------------------------

Private Sub Initialize()

' Clear the interface.


err = viClear(vi)
If Not (err = VI_SUCCESS) Then HandleVISAError vi

' Get and display the device's *IDN? string.


strQueryResult = DoQueryString("*IDN?")
MsgBox "*IDN? string: " + strQueryResult, vbOKOnly, "*IDN? Result"

' Clear status and load the default setup.


DoCommand "*CLS"
DoCommand "*RST"

End Sub

'
' Capture the waveform.
' -------------------------------------------------------------------

Private Sub Capture()

' Use auto-scale to automatically configure oscilloscope.


' -----------------------------------------------------------------
DoCommand ":AUToscale"

' Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
DoCommand ":TRIGger:MODE EDGE"
Debug.Print "Trigger mode: " + _
DoQueryString(":TRIGger:MODE?")

' Set EDGE trigger parameters.


DoCommand ":TRIGger:EDGE:SOURce CHANnel1"
Debug.Print "Trigger edge source: " + _
DoQueryString(":TRIGger:EDGE:SOURce?")

DoCommand ":TRIGger:EDGE:LEVel 1.5"


Debug.Print "Trigger edge level: " + _
DoQueryString(":TRIGger:EDGE:LEVel?")

DoCommand ":TRIGger:EDGE:SLOPe POSitive"


Debug.Print "Trigger edge slope: " + _
DoQueryString(":TRIGger:EDGE:SLOPe?")

' Save oscilloscope configuration.


' -----------------------------------------------------------------

1218 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Dim lngSetupStringSize As Long


lngSetupStringSize = DoQueryIEEEBlock_Bytes(":SYSTem:SETup?")
Debug.Print "Setup bytes saved: " + CStr(lngSetupStringSize)

' Output setup string to a file:


Dim strPath As String
strPath = "c:\scope\config\setup.dat"
If Len(Dir(strPath)) Then
Kill strPath ' Remove file if it exists.
End If

' Open file for output.


Dim hFile As Long
hFile = FreeFile
Open strPath For Binary Access Write Lock Write As hFile
Dim lngI As Long
For lngI = 0 To lngSetupStringSize - 1
Put hFile, , byteArray(lngI) ' Write data.
Next lngI
Close hFile ' Close file.

' Change settings with individual commands:


' -----------------------------------------------------------------

' Set vertical scale and offset.


DoCommand ":CHANnel1:SCALe 0.05"
Debug.Print "Channel 1 vertical scale: " + _
DoQueryString(":CHANnel1:SCALe?")

DoCommand ":CHANnel1:OFFSet -1.5"


Debug.Print "Channel 1 vertical offset: " + _
DoQueryString(":CHANnel1:OFFSet?")

' Set horizontal scale and position.


DoCommand ":TIMebase:SCALe 0.0002"
Debug.Print "Timebase scale: " + _
DoQueryString(":TIMebase:SCALe?")

DoCommand ":TIMebase:POSition 0.0"


Debug.Print "Timebase position: " + _
DoQueryString(":TIMebase:POSition?")

' Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution).


DoCommand ":ACQuire:TYPE NORMal"
Debug.Print "Acquire type: " + _
DoQueryString(":ACQuire:TYPE?")

' Or, configure by loading a previously saved setup.


' -----------------------------------------------------------------
strPath = "c:\scope\config\setup.dat"
Open strPath For Binary Access Read As hFile ' Open file for input.
Dim lngSetupFileSize As Long
lngSetupFileSize = LOF(hFile) ' Length of file.
Get hFile, , byteArray ' Read data.
Close hFile ' Close file.
' Write learn string back to oscilloscope using ":SYSTem:SETup"
' command:

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1219


40 Programming Examples

Dim lngRestored As Long


lngRestored = DoCommandIEEEBlock(":SYSTem:SETup", lngSetupFileSize)
Debug.Print "Setup bytes restored: " + CStr(lngRestored)

' Capture an acquisition using :DIGitize.


' -----------------------------------------------------------------
DoCommand ":DIGitize CHANnel1"

End Sub

'
' Analyze the captured waveform.
' -------------------------------------------------------------------

Private Sub Analyze()

' Make a couple of measurements.


' -----------------------------------------------------------------
DoCommand ":MEASure:SOURce CHANnel1"
Debug.Print "Measure source: " + _
DoQueryString(":MEASure:SOURce?")

DoCommand ":MEASure:FREQuency"
dblQueryResult = DoQueryNumber(":MEASure:FREQuency?")
MsgBox "Frequency:" + vbCrLf + _
FormatNumber(dblQueryResult / 1000, 4) + " kHz"

DoCommand ":MEASure:VAMPlitude"
dblQueryResult = DoQueryNumber(":MEASure:VAMPlitude?")
MsgBox "Vertical amplitude:" + vbCrLf + _
FormatNumber(dblQueryResult, 4) + " V"

' Download the screen image.


' -----------------------------------------------------------------
DoCommand ":HARDcopy:INKSaver OFF"

' Get screen image.


Dim lngBlockSize As Long
lngBlockSize = DoQueryIEEEBlock_Bytes(":DISPlay:DATA? PNG, COLor")
Debug.Print "Screen image bytes: " + CStr(lngBlockSize)

' Save screen image to a file:


Dim strPath As String
strPath = "c:\scope\data\screen.png"
If Len(Dir(strPath)) Then
Kill strPath ' Remove file if it exists.
End If
Dim hFile As Long
hFile = FreeFile
Open strPath For Binary Access Write Lock Write As hFile
Dim lngI As Long
For lngI = 0 To lngBlockSize - 1
Put hFile, , byteArray(lngI) ' Write data.
Next lngI
Close hFile ' Close file.
MsgBox "Screen image written to " + strPath

1220 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

' Download waveform data.


' -----------------------------------------------------------------

' Set the waveform points mode.


DoCommand ":WAVeform:POINts:MODE RAW"
Debug.Print "Waveform points mode: " + _
DoQueryString(":WAVeform:POINts:MODE?")

' Get the number of waveform points available.


Debug.Print "Waveform points available: " + _
DoQueryString(":WAVeform:POINts?")

' Set the waveform source.


DoCommand ":WAVeform:SOURce CHANnel1"
Debug.Print "Waveform source: " + _
DoQueryString(":WAVeform:SOURce?")

' Choose the format of the data returned (WORD, BYTE, ASCII):
DoCommand ":WAVeform:FORMat BYTE"
Debug.Print "Waveform format: " + _
DoQueryString(":WAVeform:FORMat?")

' Display the waveform settings:


Dim intFormat As Integer
Dim intType As Integer
Dim lngPoints As Long
Dim lngCount As Long
Dim dblXIncrement As Double
Dim dblXOrigin As Double
Dim lngXReference As Long
Dim sngYIncrement As Single
Dim lngYOrigin As Long
Dim lngYReference As Long
Dim strOutput As String

Dim lngNumNumbers As Long


lngNumNumbers = DoQueryNumbers(":WAVeform:PREamble?")

intFormat = dblArray(0)
intType = dblArray(1)
lngPoints = dblArray(2)
lngCount = dblArray(3)
dblXIncrement = dblArray(4)
dblXOrigin = dblArray(5)
lngXReference = dblArray(6)
sngYIncrement = dblArray(7)
lngYOrigin = dblArray(8)
lngYReference = dblArray(9)

If intFormat = 0 Then
Debug.Print "Waveform format: BYTE"
ElseIf intFormat = 1 Then
Debug.Print "Waveform format: WORD"
ElseIf intFormat = 2 Then
Debug.Print "Waveform format: ASCii"

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1221


40 Programming Examples

End If

If intType = 0 Then
Debug.Print "Acquisition type: NORMal"
ElseIf intType = 1 Then
Debug.Print "Acquisition type: PEAK"
ElseIf intType = 2 Then
Debug.Print "Acquisition type: AVERage"
ElseIf intType = 3 Then
Debug.Print "Acquisition type: HRESolution"
End If

Debug.Print "Waveform points: " + _


FormatNumber(lngPoints, 0)

Debug.Print "Waveform average count: " + _


FormatNumber(lngCount, 0)

Debug.Print "Waveform X increment: " + _


Format(dblXIncrement, "Scientific")

Debug.Print "Waveform X origin: " + _


Format(dblXOrigin, "Scientific")

Debug.Print "Waveform X reference: " + _


FormatNumber(lngXReference, 0)

Debug.Print "Waveform Y increment: " + _


Format(sngYIncrement, "Scientific")

Debug.Print "Waveform Y origin: " + _


FormatNumber(lngYOrigin, 0)

Debug.Print "Waveform Y reference: " + _


FormatNumber(lngYReference, 0)

' Get the waveform data


Dim lngNumBytes As Long
lngNumBytes = DoQueryIEEEBlock_Bytes(":WAVeform:DATA?")
Debug.Print "Number of data values: " + CStr(lngNumBytes)

' Set up output file:


strPath = "c:\scope\data\waveform_data.csv"

' Open file for output.


Open strPath For Output Access Write Lock Write As hFile

' Output waveform data in CSV format.


Dim lngDataValue As Long

For lngI = 0 To lngNumBytes - 1


lngDataValue = CLng(byteArray(lngI))

' Write time value, voltage value.


Print #hFile, _
FormatNumber(dblXOrigin + (lngI * dblXIncrement), 9) + _
", " + _

1222 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

FormatNumber(((lngDataValue - lngYReference) _
* sngYIncrement) + lngYOrigin)

Next lngI

' Close output file.


Close hFile ' Close file.
MsgBox "Waveform format BYTE data written to " + _
"c:\scope\data\waveform_data.csv."

End Sub

Private Sub DoCommand(command As String)

err = viVPrintf(vi, command + vbLf, 0)


If (err <> VI_SUCCESS) Then HandleVISAError vi

CheckInstrumentErrors

End Sub

Private Function DoCommandIEEEBlock(command As String, _


lngBlockSize As Long)

retCount = lngBlockSize

Dim strCommandAndLength As String


strCommandAndLength = command + " %#" + _
Format(lngBlockSize) + "b"

err = viVPrintf(vi, strCommandAndLength + vbLf, paramsArray(1))


If (err <> VI_SUCCESS) Then HandleVISAError vi

DoCommandIEEEBlock = retCount

CheckInstrumentErrors

End Function

Private Function DoQueryString(query As String) As String

Dim strResult As String * 200

err = viVPrintf(vi, query + vbLf, 0)


If (err <> VI_SUCCESS) Then HandleVISAError vi

err = viVScanf(vi, "%t", strResult)


If (err <> VI_SUCCESS) Then HandleVISAError vi

DoQueryString = strResult

CheckInstrumentErrors

End Function

Private Function DoQueryNumber(query As String) As Variant

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1223


40 Programming Examples

Dim dblResult As Double

err = viVPrintf(vi, query + vbLf, 0)


If (err <> VI_SUCCESS) Then HandleVISAError vi

err = viVScanf(vi, "%lf" + vbLf, VarPtr(dblResult))


If (err <> VI_SUCCESS) Then HandleVISAError vi

DoQueryNumber = dblResult

CheckInstrumentErrors

End Function

Private Function DoQueryNumbers(query As String) As Long

Dim dblResult As Double

' Send query.


err = viVPrintf(vi, query + vbLf, 0)
If (err <> VI_SUCCESS) Then HandleVISAError vi

' Set up paramsArray for multiple parameter query returning array.


paramsArray(0) = VarPtr(retCount)
paramsArray(1) = VarPtr(dblArray(0))

' Set retCount to max number of elements array can hold.


retCount = DblArraySize

' Read numbers.


err = viVScanf(vi, "%,#lf" + vbLf, paramsArray(0))
If (err <> VI_SUCCESS) Then HandleVISAError vi

' retCount is now actual number of values returned by query.


DoQueryNumbers = retCount

CheckInstrumentErrors

End Function

Private Function DoQueryIEEEBlock_Bytes(query As String) As Long

' Send query.


err = viVPrintf(vi, query + vbLf, 0)
If (err <> VI_SUCCESS) Then HandleVISAError vi

' Set up paramsArray for multiple parameter query returning array.


paramsArray(0) = VarPtr(retCount)
paramsArray(1) = VarPtr(byteArray(0))

' Set retCount to max number of elements array can hold.


retCount = ByteArraySize

' Get unsigned integer bytes.


err = viVScanf(vi, "%#b" + vbLf, paramsArray(0))
If (err <> VI_SUCCESS) Then HandleVISAError vi

1224 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

err = viFlush(vi, VI_READ_BUF)


If (err <> VI_SUCCESS) Then HandleVISAError vi

err = viFlush(vi, VI_WRITE_BUF)


If (err <> VI_SUCCESS) Then HandleVISAError vi

' retCount is now actual number of bytes returned by query.


DoQueryIEEEBlock_Bytes = retCount

CheckInstrumentErrors

End Function

Private Sub CheckInstrumentErrors()

On Error GoTo ErrorHandler

Dim strErrVal As String * 200


Dim strOut As String

err = viVPrintf(vi, ":SYSTem:ERRor?" + vbLf, 0) ' Query any errors.


If (err <> VI_SUCCESS) Then HandleVISAError vi

err = viVScanf(vi, "%t", strErrVal) ' Read: Errnum,"Error String".


If (err <> VI_SUCCESS) Then HandleVISAError vi

While Val(strErrVal) <> 0 ' End if find: 0,"No Error".


strOut = strOut + "INST Error: " + strErrVal

err = viVPrintf(vi, ":SYSTem:ERRor?" + vbLf, 0) ' Request error.


If (err <> VI_SUCCESS) Then HandleVISAError vi

err = viVScanf(vi, "%t", strErrVal) ' Read error message.


If (err <> VI_SUCCESS) Then HandleVISAError vi

Wend

If Not strOut = "" Then


MsgBox strOut, vbExclamation, "INST Error Messages"

err = viFlush(vi, VI_READ_BUF)


If (err <> VI_SUCCESS) Then HandleVISAError vi

err = viFlush(vi, VI_WRITE_BUF)


If (err <> VI_SUCCESS) Then HandleVISAError vi

End If

Exit Sub

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1225


40 Programming Examples

Private Sub HandleVISAError(session As Long)

Dim strVisaErr As String * 200


Call viStatusDesc(session, err, strVisaErr)
MsgBox "*** VISA Error : " + strVisaErr, vbExclamation

' If the error is not a warning, close the session.


If err < VI_SUCCESS Then
If session <> 0 Then Call viClose(session)
End
End If

End Sub

VISA Example in C#
To compile and run this example in Microsoft Visual Studio 2008:
1 Open Visual Studio.
2 Create a new Visual C#, Windows, Console Application project.
3 Cut-and-paste the code that follows into the C# source file.
4 Edit the program to use the VISA address of your oscilloscope.
5 Add Keysight's VISA header file to your project:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Click Add and then click Add Existing Item...
c Navigate to the header file, visa32.cs (installed with Keysight IO Libraries
Suite and found in the Program Files (x86)\IVI Foundation\VISA\WinNT\
Include directory), select it, but do not click the Open button.
d Click the down arrow to the right of the Add button, and choose Add as Link.

You should now see the file underneath your project in the Solution Explorer.
It will have a little arrow icon in its lower left corner, indicating that it is a
link.
6 Build and run the program.

For more information, see the tutorial on using VISA in Microsoft .NET in the VISA
Help that comes with Keysight IO Libraries Suite.
/*
* Keysight VISA Example in C#
* -------------------------------------------------------------------
* This program illustrates a few commonly used programming
* features of your Keysight oscilloscope.
* -------------------------------------------------------------------
*/

using System;
using System.IO;
using System.Text;

1226 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

namespace InfiniiVision
{
class VisaInstrumentApp
{
private static VisaInstrument myScope;

public static void Main(string[] args)


{
try
{
myScope = new
VisaInstrument("USB0::0x0957::0x17A6::US50210029::0::INSTR");
myScope.SetTimeoutSeconds(10);

// Initialize - start from a known state.


Initialize();

// Capture data.
Capture();

// Analyze the captured waveform.


Analyze();

}
catch (System.ApplicationException err)
{
Console.WriteLine("*** VISA Error Message : " + err.Message);
}
catch (System.SystemException err)
{
Console.WriteLine("*** System Error Message : " + err.Message);
}
catch (System.Exception err)
{
System.Diagnostics.Debug.Fail("Unexpected Error");
Console.WriteLine("*** Unexpected Error : " + err.Message);
}
finally
{
myScope.Close();
}
}

/*
* Initialize the oscilloscope to a known state.
* --------------------------------------------------------------
*/
private static void Initialize()
{
StringBuilder strResults;

// Get and display the device's *IDN? string.


strResults = myScope.DoQueryString("*IDN?");
Console.WriteLine("*IDN? result is: {0}", strResults);

// Clear status and load the default setup.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1227


40 Programming Examples

myScope.DoCommand("*CLS");
myScope.DoCommand("*RST");
}

/*
* Capture the waveform.
* --------------------------------------------------------------
*/
private static void Capture()
{
// Use auto-scale to automatically configure oscilloscope.
myScope.DoCommand(":AUToscale");

// Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.DoCommand(":TRIGger:MODE EDGE");
Console.WriteLine("Trigger mode: {0}",
myScope.DoQueryString(":TRIGger:MODE?"));

// Set EDGE trigger parameters.


myScope.DoCommand(":TRIGger:EDGE:SOURce CHANnel1");
Console.WriteLine("Trigger edge source: {0}",
myScope.DoQueryString(":TRIGger:EDGE:SOURce?"));

myScope.DoCommand(":TRIGger:EDGE:LEVel 1.5");
Console.WriteLine("Trigger edge level: {0}",
myScope.DoQueryString(":TRIGger:EDGE:LEVel?"));

myScope.DoCommand(":TRIGger:EDGE:SLOPe POSitive");
Console.WriteLine("Trigger edge slope: {0}",
myScope.DoQueryString(":TRIGger:EDGE:SLOPe?"));

// Save oscilloscope configuration.


byte[] ResultsArray; // Results array.
int nLength; // Number of bytes returned from instrument.
string strPath;

// Query and read setup string.


nLength = myScope.DoQueryIEEEBlock(":SYSTem:SETup?",
out ResultsArray);

// Write setup string to file.


strPath = "c:\\scope\\config\\setup.stp";
FileStream fStream = File.Open(strPath, FileMode.Create);
fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Setup bytes saved: {0}", nLength);

// Change settings with individual commands:

// Set vertical scale and offset.


myScope.DoCommand(":CHANnel1:SCALe 0.05");
Console.WriteLine("Channel 1 vertical scale: {0}",
myScope.DoQueryString(":CHANnel1:SCALe?"));

myScope.DoCommand(":CHANnel1:OFFSet -1.5");
Console.WriteLine("Channel 1 vertical offset: {0}",
myScope.DoQueryString(":CHANnel1:OFFSet?"));

1228 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

// Set horizontal scale and position.


myScope.DoCommand(":TIMebase:SCALe 0.0002");
Console.WriteLine("Timebase scale: {0}",
myScope.DoQueryString(":TIMebase:SCALe?"));

myScope.DoCommand(":TIMebase:POSition 0.0");
Console.WriteLine("Timebase position: {0}",
myScope.DoQueryString(":TIMebase:POSition?"));

// Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution


).
myScope.DoCommand(":ACQuire:TYPE NORMal");
Console.WriteLine("Acquire type: {0}",
myScope.DoQueryString(":ACQuire:TYPE?"));

// Or, configure by loading a previously saved setup.


byte[] DataArray;
int nBytesWritten;

// Read setup string from file.


strPath = "c:\\scope\\config\\setup.stp";
DataArray = File.ReadAllBytes(strPath);

// Restore setup string.


nBytesWritten = myScope.DoCommandIEEEBlock(":SYSTem:SETup",
DataArray);
Console.WriteLine("Setup bytes restored: {0}", nBytesWritten);

// Capture an acquisition using :DIGitize.


myScope.DoCommand(":DIGitize CHANnel1");
}

/*
* Analyze the captured waveform.
* --------------------------------------------------------------
*/
private static void Analyze()
{
byte[] ResultsArray; // Results array.
int nLength; // Number of bytes returned from instrument.
string strPath;

// Make a couple of measurements.


// -----------------------------------------------------------
myScope.DoCommand(":MEASure:SOURce CHANnel1");
Console.WriteLine("Measure source: {0}",
myScope.DoQueryString(":MEASure:SOURce?"));

double fResult;
myScope.DoCommand(":MEASure:FREQuency");
fResult = myScope.DoQueryNumber(":MEASure:FREQuency?");
Console.WriteLine("Frequency: {0:F4} kHz", fResult / 1000);

myScope.DoCommand(":MEASure:VAMPlitude");
fResult = myScope.DoQueryNumber(":MEASure:VAMPlitude?");
Console.WriteLine("Vertical amplitude: {0:F2} V", fResult);

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1229


40 Programming Examples

// Download the screen image.


// -----------------------------------------------------------
myScope.DoCommand(":HARDcopy:INKSaver OFF");

// Get the screen data.


nLength = myScope.DoQueryIEEEBlock(":DISPlay:DATA? PNG, COLor",
out ResultsArray);

// Store the screen data to a file.


strPath = "c:\\scope\\data\\screen.png";
FileStream fStream = File.Open(strPath, FileMode.Create);
fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Screen image ({0} bytes) written to {1}",
nLength, strPath);

// Download waveform data.


// -----------------------------------------------------------

// Set the waveform points mode.


myScope.DoCommand(":WAVeform:POINts:MODE RAW");
Console.WriteLine("Waveform points mode: {0}",
myScope.DoQueryString(":WAVeform:POINts:MODE?"));

// Get the number of waveform points available.


myScope.DoCommand(":WAVeform:POINts 10240");
Console.WriteLine("Waveform points available: {0}",
myScope.DoQueryString(":WAVeform:POINts?"));

// Set the waveform source.


myScope.DoCommand(":WAVeform:SOURce CHANnel1");
Console.WriteLine("Waveform source: {0}",
myScope.DoQueryString(":WAVeform:SOURce?"));

// Choose the format of the data returned (WORD, BYTE, ASCII):


myScope.DoCommand(":WAVeform:FORMat BYTE");
Console.WriteLine("Waveform format: {0}",
myScope.DoQueryString(":WAVeform:FORMat?"));

// Display the waveform settings:


double[] fResultsArray;
fResultsArray = myScope.DoQueryNumbers(":WAVeform:PREamble?");

double fFormat = fResultsArray[0];


if (fFormat == 0.0)
{
Console.WriteLine("Waveform format: BYTE");
}
else if (fFormat == 1.0)
{
Console.WriteLine("Waveform format: WORD");
}
else if (fFormat == 2.0)
{
Console.WriteLine("Waveform format: ASCii");
}

1230 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

double fType = fResultsArray[1];


if (fType == 0.0)
{
Console.WriteLine("Acquire type: NORMal");
}
else if (fType == 1.0)
{
Console.WriteLine("Acquire type: PEAK");
}
else if (fType == 2.0)
{
Console.WriteLine("Acquire type: AVERage");
}
else if (fType == 3.0)
{
Console.WriteLine("Acquire type: HRESolution");
}

double fPoints = fResultsArray[2];


Console.WriteLine("Waveform points: {0:e}", fPoints);

double fCount = fResultsArray[3];


Console.WriteLine("Waveform average count: {0:e}", fCount);

double fXincrement = fResultsArray[4];


Console.WriteLine("Waveform X increment: {0:e}", fXincrement);

double fXorigin = fResultsArray[5];


Console.WriteLine("Waveform X origin: {0:e}", fXorigin);

double fXreference = fResultsArray[6];


Console.WriteLine("Waveform X reference: {0:e}", fXreference);

double fYincrement = fResultsArray[7];


Console.WriteLine("Waveform Y increment: {0:e}", fYincrement);

double fYorigin = fResultsArray[8];


Console.WriteLine("Waveform Y origin: {0:e}", fYorigin);

double fYreference = fResultsArray[9];


Console.WriteLine("Waveform Y reference: {0:e}", fYreference);

// Read waveform data.


nLength = myScope.DoQueryIEEEBlock(":WAVeform:DATA?",
out ResultsArray);
Console.WriteLine("Number of data values: {0}", nLength);

// Set up output file:


strPath = "c:\\scope\\data\\waveform_data.csv";
if (File.Exists(strPath)) File.Delete(strPath);

// Open file for output.


StreamWriter writer = File.CreateText(strPath);

// Output waveform data in CSV format.


for (int i = 0; i < nLength - 1; i++)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1231


40 Programming Examples

writer.WriteLine("{0:f9}, {1:f6}",
fXorigin + ((float)i * fXincrement),
(((float)ResultsArray[i] - fYreference) *
fYincrement) + fYorigin);

// Close output file.


writer.Close();
Console.WriteLine("Waveform format BYTE data written to {0}",
strPath);
}
}

class VisaInstrument
{
private int m_nResourceManager;
private int m_nSession;
private string m_strVisaAddress;

// Constructor.
public VisaInstrument(string strVisaAddress)
{
// Save VISA address in member variable.
m_strVisaAddress = strVisaAddress;

// Open the default VISA resource manager.


OpenResourceManager();

// Open a VISA resource session.


OpenSession();

// Clear the interface.


int nViStatus;
nViStatus = visa32.viClear(m_nSession);
}

public void DoCommand(string strCommand)


{
// Send the command.
VisaSendCommandOrQuery(strCommand);

// Check for inst errors.


CheckInstrumentErrors(strCommand);
}

public int DoCommandIEEEBlock(string strCommand,


byte[] DataArray)
{
// Send the command to the device.
string strCommandAndLength;
int nViStatus, nLength, nBytesWritten;

nLength = DataArray.Length;
strCommandAndLength = String.Format("{0} #8%08d",
strCommand);

// Write first part of command to formatted I/O write buffer.


nViStatus = visa32.viPrintf(m_nSession, strCommandAndLength,

1232 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

nLength);
CheckVisaStatus(nViStatus);

// Write the data to the formatted I/O write buffer.


nViStatus = visa32.viBufWrite(m_nSession, DataArray, nLength,
out nBytesWritten);
CheckVisaStatus(nViStatus);

// Check for inst errors.


CheckInstrumentErrors(strCommand);

return nBytesWritten;
}

public StringBuilder DoQueryString(string strQuery)


{
// Send the query.
VisaSendCommandOrQuery(strQuery);

// Get the result string.


StringBuilder strResults = new StringBuilder(1000);
strResults = VisaGetResultString();

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return string results.


return strResults;
}

public double DoQueryNumber(string strQuery)


{
// Send the query.
VisaSendCommandOrQuery(strQuery);

// Get the result string.


double fResults;
fResults = VisaGetResultNumber();

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return string results.


return fResults;
}

public double[] DoQueryNumbers(string strQuery)


{
// Send the query.
VisaSendCommandOrQuery(strQuery);

// Get the result string.


double[] fResultsArray;
fResultsArray = VisaGetResultNumbers();

// Check for inst errors.


CheckInstrumentErrors(strQuery);

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1233


40 Programming Examples

// Return string results.


return fResultsArray;
}

public int DoQueryIEEEBlock(string strQuery,


out byte[] ResultsArray)
{
// Send the query.
VisaSendCommandOrQuery(strQuery);

// Get the result string.


int length; // Number of bytes returned from instrument.
length = VisaGetResultIEEEBlock(out ResultsArray);

// Check for inst errors.


CheckInstrumentErrors(strQuery);

// Return string results.


return length;
}

private void VisaSendCommandOrQuery(string strCommandOrQuery)


{
// Send command or query to the device.
string strWithNewline;
strWithNewline = String.Format("{0}\n", strCommandOrQuery);
int nViStatus;
nViStatus = visa32.viPrintf(m_nSession, strWithNewline);
CheckVisaStatus(nViStatus);
}

private StringBuilder VisaGetResultString()


{
StringBuilder strResults = new StringBuilder(1000);

// Read return value string from the device.


int nViStatus;
nViStatus = visa32.viScanf(m_nSession, "%1000t", strResults);
CheckVisaStatus(nViStatus);

return strResults;
}

private double VisaGetResultNumber()


{
double fResults = 0;

// Read return value string from the device.


int nViStatus;
nViStatus = visa32.viScanf(m_nSession, "%lf", out fResults);
CheckVisaStatus(nViStatus);

return fResults;
}

private double[] VisaGetResultNumbers()

1234 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

{
double[] fResultsArray;
fResultsArray = new double[10];

// Read return value string from the device.


int nViStatus;
nViStatus = visa32.viScanf(m_nSession, "%,10lf\n",
fResultsArray);
CheckVisaStatus(nViStatus);

return fResultsArray;
}

private int VisaGetResultIEEEBlock(out byte[] ResultsArray)


{
// Results array, big enough to hold a PNG.
ResultsArray = new byte[300000];
int length; // Number of bytes returned from instrument.

// Set the default number of bytes that will be contained in


// the ResultsArray to 300,000 (300kB).
length = 300000;

// Read return value string from the device.


int nViStatus;
nViStatus = visa32.viScanf(m_nSession, "%#b", ref length,
ResultsArray);
CheckVisaStatus(nViStatus);

// Write and read buffers need to be flushed after IEEE block?


nViStatus = visa32.viFlush(m_nSession, visa32.VI_WRITE_BUF);
CheckVisaStatus(nViStatus);

nViStatus = visa32.viFlush(m_nSession, visa32.VI_READ_BUF);


CheckVisaStatus(nViStatus);

return length;
}

private void CheckInstrumentErrors(string strCommand)


{
// Check for instrument errors.
StringBuilder strInstrumentError = new StringBuilder(1000);
bool bFirstError = true;

do // While not "0,No error"


{
VisaSendCommandOrQuery(":SYSTem:ERRor?");
strInstrumentError = VisaGetResultString();

if (!strInstrumentError.ToString().StartsWith("+0,"))
{
if (bFirstError)
{
Console.WriteLine("ERROR(s) for command '{0}': ",
strCommand);
bFirstError = false;

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1235


40 Programming Examples

}
Console.Write(strInstrumentError);
}
} while (!strInstrumentError.ToString().StartsWith("+0,"));
}

private void OpenResourceManager()


{
int nViStatus;
nViStatus =
visa32.viOpenDefaultRM(out this.m_nResourceManager);
if (nViStatus < visa32.VI_SUCCESS)
throw new
ApplicationException("Failed to open Resource Manager");
}

private void OpenSession()


{
int nViStatus;
nViStatus = visa32.viOpen(this.m_nResourceManager,
this.m_strVisaAddress, visa32.VI_NO_LOCK,
visa32.VI_TMO_IMMEDIATE, out this.m_nSession);
CheckVisaStatus(nViStatus);
}

public void SetTimeoutSeconds(int nSeconds)


{
int nViStatus;
nViStatus = visa32.viSetAttribute(this.m_nSession,
visa32.VI_ATTR_TMO_VALUE, nSeconds * 1000);
CheckVisaStatus(nViStatus);
}

public void CheckVisaStatus(int nViStatus)


{
// If VISA error, throw exception.
if (nViStatus < visa32.VI_SUCCESS)
{
StringBuilder strError = new StringBuilder(256);
visa32.viStatusDesc(this.m_nResourceManager, nViStatus,
strError);
throw new ApplicationException(strError.ToString());
}
}

public void Close()


{
if (m_nSession != 0)
visa32.viClose(m_nSession);
if (m_nResourceManager != 0)
visa32.viClose(m_nResourceManager);
}
}
}

1236 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

VISA Example in Visual Basic .NET


To compile and run this example in Microsoft Visual Studio 2008:
1 Open Visual Studio.
2 Create a new Visual Basic, Windows, Console Application project.
3 Cut-and-paste the code that follows into the Visual Basic .NET source file.
4 Edit the program to use the VISA address of your oscilloscope.
5 Add Keysight's VISA header file to your project:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Add and then choose Add Existing Item...
c Navigate to the header file, visa32.vb (installed with Keysight IO Libraries
Suite and found in the Program Files (x86)\IVI Foundation\VISA\WinNT\
Include directory), select it, but do not click the Open button.
d Click the down arrow to the right of the Add button, and choose Add as Link.

You should now see the file underneath your project in the Solution Explorer.
It will have a little arrow icon in its lower left corner, indicating that it is a
link.
e Right-click the project again and choose Properties; then, select
"InfiniiVision.VisaInstrumentApp" as the Startup object.
6 Build and run the program.

For more information, see the tutorial on using VISA in Microsoft .NET in the VISA
Help that comes with Keysight IO Libraries Suite.
'
' Keysight VISA Example in Visual Basic .NET
' -------------------------------------------------------------------
' This program illustrates a few commonly-used programming
' features of your Keysight oscilloscope.
' -------------------------------------------------------------------

Imports System
Imports System.IO
Imports System.Text

Namespace InfiniiVision
Class VisaInstrumentApp
Private Shared myScope As VisaInstrument

Public Shared Sub Main(ByVal args As String())


Try
myScope = _
New VisaInstrument("USB0::0x0957::0x17A6::US50210029::0::INSTR
")
myScope.SetTimeoutSeconds(10)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1237


40 Programming Examples

' Initialize - start from a known state.


Initialize()

' Capture data.


Capture()

' Analyze the captured waveform.


Analyze()

Catch err As System.ApplicationException


Console.WriteLine("*** VISA Error Message : " + err.Message)
Catch err As System.SystemException
Console.WriteLine("*** System Error Message : " + err.Message)
Catch err As System.Exception
Debug.Fail("Unexpected Error")
Console.WriteLine("*** Unexpected Error : " + err.Message)
End Try
End Sub

'
' Initialize the oscilloscope to a known state.
' --------------------------------------------------------------

Private Shared Sub Initialize()


Dim strResults As StringBuilder

' Get and display the device's *IDN? string.


strResults = myScope.DoQueryString("*IDN?")
Console.WriteLine("*IDN? result is: {0}", strResults)

' Clear status and load the default setup.


myScope.DoCommand("*CLS")
myScope.DoCommand("*RST")

End Sub

'
' Capture the waveform.
' --------------------------------------------------------------

Private Shared Sub Capture()

' Use auto-scale to automatically configure oscilloscope.


myScope.DoCommand(":AUToscale")

' Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.DoCommand(":TRIGger:MODE EDGE")
Console.WriteLine("Trigger mode: {0}", _
myScope.DoQueryString(":TRIGger:MODE?"))

' Set EDGE trigger parameters.


myScope.DoCommand(":TRIGger:EDGE:SOURce CHANnel1")
Console.WriteLine("Trigger edge source: {0}", _
myScope.DoQueryString(":TRIGger:EDGE:SOURce?"))

myScope.DoCommand(":TRIGger:EDGE:LEVel 1.5")
Console.WriteLine("Trigger edge level: {0}", _

1238 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

myScope.DoQueryString(":TRIGger:EDGE:LEVel?"))

myScope.DoCommand(":TRIGger:EDGE:SLOPe POSitive")
Console.WriteLine("Trigger edge slope: {0}", _
myScope.DoQueryString(":TRIGger:EDGE:SLOPe?"))

' Save oscilloscope configuration.


Dim ResultsArray As Byte() ' Results array.
Dim nLength As Integer ' Number of bytes returned from inst.
Dim strPath As String
Dim fStream As FileStream

' Query and read setup string.


nLength = myScope.DoQueryIEEEBlock(":SYSTem:SETup?", _
ResultsArray)

' Write setup string to file.


strPath = "c:\scope\config\setup.stp"
fStream = File.Open(strPath, FileMode.Create)
fStream.Write(ResultsArray, 0, nLength)
fStream.Close()
Console.WriteLine("Setup bytes saved: {0}", nLength)

' Change settings with individual commands:

' Set vertical scale and offset.


myScope.DoCommand(":CHANnel1:SCALe 0.05")
Console.WriteLine("Channel 1 vertical scale: {0}", _
myScope.DoQueryString(":CHANnel1:SCALe?"))

myScope.DoCommand(":CHANnel1:OFFSet -1.5")
Console.WriteLine("Channel 1 vertical offset: {0}", _
myScope.DoQueryString(":CHANnel1:OFFSet?"))

' Set horizontal scale and position.


myScope.DoCommand(":TIMebase:SCALe 0.0002")
Console.WriteLine("Timebase scale: {0}", _
myScope.DoQueryString(":TIMebase:SCALe?"))

myScope.DoCommand(":TIMebase:POSition 0.0")
Console.WriteLine("Timebase position: {0}", _
myScope.DoQueryString(":TIMebase:POSition?"))

' Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution)


.
myScope.DoCommand(":ACQuire:TYPE NORMal")
Console.WriteLine("Acquire type: {0}", _
myScope.DoQueryString(":ACQuire:TYPE?"))

' Or, configure by loading a previously saved setup.


Dim DataArray As Byte()
Dim nBytesWritten As Integer

' Read setup string from file.


strPath = "c:\scope\config\setup.stp"
DataArray = File.ReadAllBytes(strPath)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1239


40 Programming Examples

' Restore setup string.


nBytesWritten = myScope.DoCommandIEEEBlock(":SYSTem:SETup", _
DataArray)
Console.WriteLine("Setup bytes restored: {0}", nBytesWritten)

' Capture an acquisition using :DIGitize.


myScope.DoCommand(":DIGitize CHANnel1")

End Sub

'
' Analyze the captured waveform.
' --------------------------------------------------------------

Private Shared Sub Analyze()

Dim fResult As Double


Dim ResultsArray As Byte() ' Results array.
Dim nLength As Integer ' Number of bytes returned from inst.
Dim strPath As String

' Make a couple of measurements.


' ------------------------------------------------------------
myScope.DoCommand(":MEASure:SOURce CHANnel1")
Console.WriteLine("Measure source: {0}", _
myScope.DoQueryString(":MEASure:SOURce?"))

myScope.DoCommand(":MEASure:FREQuency")
fResult = myScope.DoQueryNumber(":MEASure:FREQuency?")
Console.WriteLine("Frequency: {0:F4} kHz", fResult / 1000)

myScope.DoCommand(":MEASure:VAMPlitude")
fResult = myScope.DoQueryNumber(":MEASure:VAMPlitude?")
Console.WriteLine("Vertical amplitude: {0:F2} V", fResult)

' Download the screen image.


' ------------------------------------------------------------
myScope.DoCommand(":HARDcopy:INKSaver OFF")

' Get the screen data.


nLength = myScope.DoQueryIEEEBlock(":DISPlay:DATA? PNG, COLor", _
ResultsArray)

' Store the screen data to a file.


strPath = "c:\scope\data\screen.png"
Dim fStream As FileStream
fStream = File.Open(strPath, FileMode.Create)
fStream.Write(ResultsArray, 0, nLength)
fStream.Close()
Console.WriteLine("Screen image ({0} bytes) written to {1}", _
nLength, strPath)

' Download waveform data.


' ------------------------------------------------------------

' Set the waveform points mode.


myScope.DoCommand(":WAVeform:POINts:MODE RAW")

1240 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Console.WriteLine("Waveform points mode: {0}", _


myScope.DoQueryString(":WAVeform:POINts:MODE?"))

' Get the number of waveform points available.


myScope.DoCommand(":WAVeform:POINts 10240")
Console.WriteLine("Waveform points available: {0}", _
myScope.DoQueryString(":WAVeform:POINts?"))

' Set the waveform source.


myScope.DoCommand(":WAVeform:SOURce CHANnel1")
Console.WriteLine("Waveform source: {0}", _
myScope.DoQueryString(":WAVeform:SOURce?"))

' Choose the format of the data returned (WORD, BYTE, ASCII):
myScope.DoCommand(":WAVeform:FORMat BYTE")
Console.WriteLine("Waveform format: {0}", _
myScope.DoQueryString(":WAVeform:FORMat?"))

' Display the waveform settings:


Dim fResultsArray As Double()
fResultsArray = myScope.DoQueryNumbers(":WAVeform:PREamble?")

Dim fFormat As Double = fResultsArray(0)


If fFormat = 0 Then
Console.WriteLine("Waveform format: BYTE")
ElseIf fFormat = 1 Then
Console.WriteLine("Waveform format: WORD")
ElseIf fFormat = 2 Then
Console.WriteLine("Waveform format: ASCii")
End If

Dim fType As Double = fResultsArray(1)


If fType = 0 Then
Console.WriteLine("Acquire type: NORMal")
ElseIf fType = 1 Then
Console.WriteLine("Acquire type: PEAK")
ElseIf fType = 2 Then
Console.WriteLine("Acquire type: AVERage")
ElseIf fType = 3 Then
Console.WriteLine("Acquire type: HRESolution")
End If

Dim fPoints As Double = fResultsArray(2)


Console.WriteLine("Waveform points: {0:e}", fPoints)

Dim fCount As Double = fResultsArray(3)


Console.WriteLine("Waveform average count: {0:e}", fCount)

Dim fXincrement As Double = fResultsArray(4)


Console.WriteLine("Waveform X increment: {0:e}", fXincrement)

Dim fXorigin As Double = fResultsArray(5)


Console.WriteLine("Waveform X origin: {0:e}", fXorigin)

Dim fXreference As Double = fResultsArray(6)


Console.WriteLine("Waveform X reference: {0:e}", fXreference)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1241


40 Programming Examples

Dim fYincrement As Double = fResultsArray(7)


Console.WriteLine("Waveform Y increment: {0:e}", fYincrement)

Dim fYorigin As Double = fResultsArray(8)


Console.WriteLine("Waveform Y origin: {0:e}", fYorigin)

Dim fYreference As Double = fResultsArray(9)


Console.WriteLine("Waveform Y reference: {0:e}", fYreference)

' Get the waveform data.


nLength = myScope.DoQueryIEEEBlock(":WAVeform:DATA?", _
ResultsArray)
Console.WriteLine("Number of data values: {0}", nLength)

' Set up output file:


strPath = "c:\scope\data\waveform_data.csv"
If File.Exists(strPath) Then
File.Delete(strPath)
End If

' Open file for output.


Dim writer As StreamWriter = File.CreateText(strPath)

' Output waveform data in CSV format.


For index As Integer = 0 To nLength - 1
' Write time value, voltage value.
writer.WriteLine("{0:f9}, {1:f6}", _
fXorigin + (CSng(index) * fXincrement), _
((CSng(ResultsArray(index)) - fYreference) _
* fYincrement) + fYorigin)
Next

' Close output file.


writer.Close()
Console.WriteLine("Waveform format BYTE data written to {0}", _
strPath)

End Sub

End Class

Class VisaInstrument
Private m_nResourceManager As Integer
Private m_nSession As Integer
Private m_strVisaAddress As String

' Constructor.
Public Sub New(ByVal strVisaAddress As String)
' Save VISA address in member variable.
m_strVisaAddress = strVisaAddress

' Open the default VISA resource manager.


OpenResourceManager()

' Open a VISA resource session.


OpenSession()

1242 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

' Clear the interface.


Dim nViStatus As Integer
nViStatus = visa32.viClear(m_nSession)
End Sub

Public Sub DoCommand(ByVal strCommand As String)


' Send the command.
VisaSendCommandOrQuery(strCommand)

' Check for inst errors.


CheckInstrumentErrors(strCommand)

End Sub

Public Function DoCommandIEEEBlock(ByVal strCommand As String, _


ByVal DataArray As Byte()) As Integer

' Send the command to the device.


Dim strCommandAndLength As String
Dim nViStatus As Integer
Dim nLength As Integer
Dim nBytesWritten As Integer

nLength = DataArray.Length
strCommandAndLength = [String].Format("{0} #8{1:D8}", _
strCommand, nLength)

' Write first part of command to formatted I/O write buffer.


nViStatus = visa32.viPrintf(m_nSession, strCommandAndLength)
CheckVisaStatus(nViStatus)

' Write the data to the formatted I/O write buffer.


nViStatus = visa32.viBufWrite(m_nSession, DataArray, nLength, _
nBytesWritten)
CheckVisaStatus(nViStatus)

' Check for inst errors.


CheckInstrumentErrors(strCommand)

Return nBytesWritten
End Function

Public Function DoQueryString(ByVal strQuery As String) _


As StringBuilder
' Send the query.
VisaSendCommandOrQuery(strQuery)

' Get the result string.


Dim strResults As New StringBuilder(1000)
strResults = VisaGetResultString()

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return string results.


Return strResults
End Function

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1243


40 Programming Examples

Public Function DoQueryNumber(ByVal strQuery As String) As Double


' Send the query.
VisaSendCommandOrQuery(strQuery)

' Get the result string.


Dim fResults As Double
fResults = VisaGetResultNumber()

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return string results.


Return fResults
End Function

Public Function DoQueryNumbers(ByVal strQuery As String) _


As Double()
' Send the query.
VisaSendCommandOrQuery(strQuery)

' Get the result string.


Dim fResultsArray As Double()
fResultsArray = VisaGetResultNumbers()

' Check for instrument errors (another command and result).


CheckInstrumentErrors(strQuery)

' Return string results.


Return fResultsArray
End Function

Public Function DoQueryIEEEBlock(ByVal strQuery As String, _


ByRef ResultsArray As Byte()) As Integer
' Send the query.
VisaSendCommandOrQuery(strQuery)

' Get the result string.


System.Threading.Thread.Sleep(2000) ' Delay before reading data.
Dim length As Integer
' Number of bytes returned from instrument.
length = VisaGetResultIEEEBlock(ResultsArray)

' Check for inst errors.


CheckInstrumentErrors(strQuery)

' Return string results.


Return length
End Function

Private Sub VisaSendCommandOrQuery(ByVal strCommandOrQuery _


As String)
' Send command or query to the device.
Dim strWithNewline As String
strWithNewline = [String].Format("{0}" & Chr(10) & "", _
strCommandOrQuery)
Dim nViStatus As Integer

1244 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

nViStatus = visa32.viPrintf(m_nSession, strWithNewline)


CheckVisaStatus(nViStatus)
End Sub

Private Function VisaGetResultString() As StringBuilder


Dim strResults As New StringBuilder(1000)

' Read return value string from the device.


Dim nViStatus As Integer
nViStatus = visa32.viScanf(m_nSession, "%1000t", strResults)
CheckVisaStatus(nViStatus)

Return strResults
End Function

Private Function VisaGetResultNumber() As Double


Dim fResults As Double = 0

' Read return value string from the device.


Dim nViStatus As Integer
nViStatus = visa32.viScanf(m_nSession, "%lf", fResults)
CheckVisaStatus(nViStatus)

Return fResults
End Function

Private Function VisaGetResultNumbers() As Double()


Dim fResultsArray As Double()
fResultsArray = New Double(9) {}

' Read return value string from the device.


Dim nViStatus As Integer
nViStatus = visa32.viScanf(m_nSession, _
"%,10lf" & Chr(10) & "", fResultsArray)
CheckVisaStatus(nViStatus)

Return fResultsArray
End Function

Private Function VisaGetResultIEEEBlock(ByRef ResultsArray _


As Byte()) As Integer
' Results array, big enough to hold a PNG.
ResultsArray = New Byte(299999) {}
Dim length As Integer
' Number of bytes returned from instrument.
' Set the default number of bytes that will be contained in
' the ResultsArray to 300,000 (300kB).
length = 300000

' Read return value string from the device.


Dim nViStatus As Integer
nViStatus = visa32.viScanf(m_nSession, "%#b", length, _
ResultsArray)
CheckVisaStatus(nViStatus)

' Write and read buffers need to be flushed after IEEE block?
nViStatus = visa32.viFlush(m_nSession, visa32.VI_WRITE_BUF)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1245


40 Programming Examples

CheckVisaStatus(nViStatus)

nViStatus = visa32.viFlush(m_nSession, visa32.VI_READ_BUF)


CheckVisaStatus(nViStatus)

Return length
End Function

Private Sub CheckInstrumentErrors(ByVal strCommand As String)


' Check for instrument errors.
Dim strInstrumentError As New StringBuilder(1000)
Dim bFirstError As Boolean = True
Do ' While not "0,No error"
VisaSendCommandOrQuery(":SYSTem:ERRor?")
strInstrumentError = VisaGetResultString()

If Not strInstrumentError.ToString().StartsWith("+0,") Then


If bFirstError Then
Console.WriteLine("ERROR(s) for command '{0}': ", _
strCommand)
bFirstError = False
End If
Console.Write(strInstrumentError)
End If
Loop While Not strInstrumentError.ToString().StartsWith("+0,")
End Sub

Private Sub OpenResourceManager()


Dim nViStatus As Integer
nViStatus = visa32.viOpenDefaultRM(Me.m_nResourceManager)
If nViStatus < visa32.VI_SUCCESS Then
Throw New _
ApplicationException("Failed to open Resource Manager")
End If
End Sub

Private Sub OpenSession()


Dim nViStatus As Integer
nViStatus = visa32.viOpen(Me.m_nResourceManager, _
Me.m_strVisaAddress, visa32.VI_NO_LOCK, _
visa32.VI_TMO_IMMEDIATE, Me.m_nSession)
CheckVisaStatus(nViStatus)
End Sub

Public Sub SetTimeoutSeconds(ByVal nSeconds As Integer)


Dim nViStatus As Integer
nViStatus = visa32.viSetAttribute(Me.m_nSession, _
visa32.VI_ATTR_TMO_VALUE, nSeconds * 1000)
CheckVisaStatus(nViStatus)
End Sub

Public Sub CheckVisaStatus(ByVal nViStatus As Integer)


' If VISA error, throw exception.
If nViStatus < visa32.VI_SUCCESS Then
Dim strError As New StringBuilder(256)
visa32.viStatusDesc(Me.m_nResourceManager, nViStatus, strError)
Throw New ApplicationException(strError.ToString())

1246 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

End If
End Sub

Public Sub Close()


If m_nSession <> 0 Then
visa32.viClose(m_nSession)
End If
If m_nResourceManager <> 0 Then
visa32.viClose(m_nResourceManager)
End If
End Sub
End Class
End Namespace

VISA Example in Python (PyVISA 1.5 and older)


You can use the Python programming language with the PyVISA package to
control Keysight Infiniium Series oscilloscopes.
The Python language and PyVISA package can be downloaded from the web at
http://www.python.org/ and http://pyvisa.sourceforge.net/, respectively.
To run this example with Python and PyVISA:
1 Cut-and-paste the code that follows into a file named "example.py".
2 Edit the program to use the VISA address of your oscilloscope.
3 If "python.exe" can be found via your PATH environment variable, open a
Command Prompt window; then, change to the folder that contains the
"example.py" file, and enter:
python example.py

# *********************************************************
# This program illustrates a few commonly-used programming
# features of your Keysight oscilloscope.
# *********************************************************

# Import modules.
# ---------------------------------------------------------
import visa
import string
import struct
import sys

# Global variables (booleans: 0 = False, 1 = True).


# ---------------------------------------------------------
debug = 0

# =========================================================
# Initialize:
# =========================================================
def initialize():

# Get and display the device's *IDN? string.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1247


40 Programming Examples

idn_string = do_query_string("*IDN?")
print "Identification string: '%s'" % idn_string

# Clear status and load the default setup.


do_command("*CLS")
do_command("*RST")

# =========================================================
# Capture:
# =========================================================
def capture():

# Use auto-scale to automatically set up oscilloscope.


print "Autoscale."
do_command(":AUToscale")

# Set trigger mode.


do_command(":TRIGger:MODE EDGE")
qresult = do_query_string(":TRIGger:MODE?")
print "Trigger mode: %s" % qresult

# Set EDGE trigger parameters.


do_command(":TRIGger:EDGE:SOURce CHANnel1")
qresult = do_query_string(":TRIGger:EDGE:SOURce?")
print "Trigger edge source: %s" % qresult

do_command(":TRIGger:EDGE:LEVel 1.5")
qresult = do_query_string(":TRIGger:EDGE:LEVel?")
print "Trigger edge level: %s" % qresult

do_command(":TRIGger:EDGE:SLOPe POSitive")
qresult = do_query_string(":TRIGger:EDGE:SLOPe?")
print "Trigger edge slope: %s" % qresult

# Save oscilloscope setup.


sSetup = do_query_string(":SYSTem:SETup?")
sSetup = get_definite_length_block_data(sSetup)

f = open("setup.stp", "wb")
f.write(sSetup)
f.close()
print "Setup bytes saved: %d" % len(sSetup)

# Change oscilloscope settings with individual commands:

# Set vertical scale and offset.


do_command(":CHANnel1:SCALe 0.05")
qresult = do_query_values(":CHANnel1:SCALe?")[0]
print "Channel 1 vertical scale: %f" % qresult

do_command(":CHANnel1:OFFSet -1.5")
qresult = do_query_values(":CHANnel1:OFFSet?")[0]
print "Channel 1 offset: %f" % qresult

# Set horizontal scale and offset.


do_command(":TIMebase:SCALe 0.0002")

1248 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

qresult = do_query_string(":TIMebase:SCALe?")
print "Timebase scale: %s" % qresult

do_command(":TIMebase:POSition 0.0")
qresult = do_query_string(":TIMebase:POSition?")
print "Timebase position: %s" % qresult

# Set the acquisition type.


do_command(":ACQuire:TYPE NORMal")
qresult = do_query_string(":ACQuire:TYPE?")
print "Acquire type: %s" % qresult

# Or, set up oscilloscope by loading a previously saved setup.


sSetup = ""
f = open("setup.stp", "rb")
sSetup = f.read()
f.close()
do_command(":SYSTem:SETup #8%08d%s" % (len(sSetup), sSetup), hide_param
s=True)
print "Setup bytes restored: %d" % len(sSetup)

# Capture an acquisition using :DIGitize.


do_command(":DIGitize CHANnel1")

# =========================================================
# Analyze:
# =========================================================
def analyze():

# Make measurements.
# --------------------------------------------------------
do_command(":MEASure:SOURce CHANnel1")
qresult = do_query_string(":MEASure:SOURce?")
print "Measure source: %s" % qresult

do_command(":MEASure:FREQuency")
qresult = do_query_string(":MEASure:FREQuency?")
print "Measured frequency on channel 1: %s" % qresult

do_command(":MEASure:VAMPlitude")
qresult = do_query_string(":MEASure:VAMPlitude?")
print "Measured vertical amplitude on channel 1: %s" % qresult

# Download the screen image.


# --------------------------------------------------------
do_command(":HARDcopy:INKSaver OFF")

sDisplay = do_query_string(":DISPlay:DATA? PNG, COLor")


sDisplay = get_definite_length_block_data(sDisplay)

# Save display data values to file.


f = open("screen_image.png", "wb")
f.write(sDisplay)
f.close()
print "Screen image written to screen_image.png."

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1249


40 Programming Examples

# Download waveform data.


# --------------------------------------------------------

# Set the waveform points mode.


do_command(":WAVeform:POINts:MODE RAW")
qresult = do_query_string(":WAVeform:POINts:MODE?")
print "Waveform points mode: %s" % qresult

# Get the number of waveform points available.


do_command(":WAVeform:POINts 10240")
qresult = do_query_string(":WAVeform:POINts?")
print "Waveform points available: %s" % qresult

# Set the waveform source.


do_command(":WAVeform:SOURce CHANnel1")
qresult = do_query_string(":WAVeform:SOURce?")
print "Waveform source: %s" % qresult

# Choose the format of the data returned:


do_command(":WAVeform:FORMat BYTE")
print "Waveform format: %s" % do_query_string(":WAVeform:FORMat?")

# Display the waveform settings from preamble:


wav_form_dict = {
0 : "BYTE",
1 : "WORD",
4 : "ASCii",
}
acq_type_dict = {
0 : "NORMal",
1 : "PEAK",
2 : "AVERage",
3 : "HRESolution",
}

preamble_string = do_query_string(":WAVeform:PREamble?")
(
wav_form, acq_type, wfmpts, avgcnt, x_increment, x_origin,
x_reference, y_increment, y_origin, y_reference
) = string.split(preamble_string, ",")

print "Waveform format: %s" % wav_form_dict[int(wav_form)]


print "Acquire type: %s" % acq_type_dict[int(acq_type)]
print "Waveform points desired: %s" % wfmpts
print "Waveform average count: %s" % avgcnt
print "Waveform X increment: %s" % x_increment
print "Waveform X origin: %s" % x_origin
print "Waveform X reference: %s" % x_reference # Always 0.
print "Waveform Y increment: %s" % y_increment
print "Waveform Y origin: %s" % y_origin
print "Waveform Y reference: %s" % y_reference

# Get numeric values for later calculations.


x_increment = do_query_values(":WAVeform:XINCrement?")[0]
x_origin = do_query_values(":WAVeform:XORigin?")[0]
y_increment = do_query_values(":WAVeform:YINCrement?")[0]
y_origin = do_query_values(":WAVeform:YORigin?")[0]

1250 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

y_reference = do_query_values(":WAVeform:YREFerence?")[0]

# Get the waveform data.


sData = do_query_string(":WAVeform:DATA?")
sData = get_definite_length_block_data(sData)

# Unpack unsigned byte data.


values = struct.unpack("%dB" % len(sData), sData)
print "Number of data values: %d" % len(values)

# Save waveform data values to CSV file.


f = open("waveform_data.csv", "w")

for i in xrange(0, len(values) - 1):


time_val = x_origin + (i * x_increment)
voltage = ((values[i] - y_reference) * y_increment) + y_origin
f.write("%E, %f\n" % (time_val, voltage))

f.close()
print "Waveform format BYTE data written to waveform_data.csv."

# =========================================================
# Send a command and check for errors:
# =========================================================
def do_command(command, hide_params=False):

if hide_params:
(header, data) = string.split(command, " ", 1)
if debug:
print "\nCmd = '%s'" % header
else:
if debug:
print "\nCmd = '%s'" % command

InfiniiVision.write("%s\n" % command)

if hide_params:
check_instrument_errors(header)
else:
check_instrument_errors(command)

# =========================================================
# Send a query, check for errors, return string:
# =========================================================
def do_query_string(query):
if debug:
print "Qys = '%s'" % query
result = InfiniiVision.ask("%s\n" % query)
check_instrument_errors(query)
return result

# =========================================================
# Send a query, check for errors, return values:
# =========================================================

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1251


40 Programming Examples

def do_query_values(query):
if debug:
print "Qyv = '%s'" % query
results = InfiniiVision.ask_for_values("%s\n" % query)
check_instrument_errors(query)
return results

# =========================================================
# Check for instrument errors:
# =========================================================
def check_instrument_errors(command):

while True:
error_string = InfiniiVision.ask(":SYSTem:ERRor?\n")
if error_string: # If there is an error string value.

if error_string.find("+0,", 0, 3) == -1: # Not "No error".

print "ERROR: %s, command: '%s'" % (error_string, command)


print "Exited because of error."
sys.exit(1)

else: # "No error"


break

else: # :SYSTem:ERRor? should always return string.


print "ERROR: :SYSTem:ERRor? returned nothing, command: '%s'" % comma
nd
print "Exited because of error."
sys.exit(1)

# =========================================================
# Returns data from definite-length block.
# =========================================================
def get_definite_length_block_data(sBlock):

# First character should be "#".


pound = sBlock[0:1]
if pound != "#":
print "PROBLEM: Invalid binary block format, pound char is '%s'." % po
und
print "Exited because of problem."
sys.exit(1)

# Second character is number of following digits for length value.


digits = sBlock[1:2]

# Get the data out of the block and return it.


sData = sBlock[int(digits) + 2:]

return sData

# =========================================================
# Main program:

1252 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

# =========================================================

InfiniiVision = visa.instrument("TCPIP0::130.29.70.139::inst0::INSTR")
InfiniiVision.timeout = 15
InfiniiVision.term_chars = ""
InfiniiVision.clear()

# Initialize the oscilloscope, capture data, and analyze.


initialize()
capture()
analyze()

print "End of program."

VISA Example in Python (PyVISA 1.6 and newer)


You can use the Python programming language with the PyVISA package to
control Keysight Infiniium Series oscilloscopes.
The Python language and PyVISA package can be downloaded from the web at
http://www.python.org/ and http://pyvisa.readthedocs.org/, respectively.
To run this example with Python and PyVISA:
1 Cut-and-paste the code that follows into a file named "example.py".
2 Edit the program to use the VISA address of your oscilloscope.
3 If "python.exe" can be found via your PATH environment variable, open a
Command Prompt window; then, change to the folder that contains the
"example.py" file, and enter:
python example.py

# *********************************************************
# This program illustrates a few commonly-used programming
# features of your Keysight oscilloscope.
# *********************************************************

# Import modules.
# ---------------------------------------------------------
import visa
import string
import struct
import sys

# Global variables (booleans: 0 = False, 1 = True).


# ---------------------------------------------------------
debug = 0

# =========================================================
# Initialize:
# =========================================================
def initialize():

# Get and display the device's *IDN? string.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1253


40 Programming Examples

idn_string = do_query_string("*IDN?")
print "Identification string: '%s'" % idn_string

# Clear status and load the default setup.


do_command("*CLS")
do_command("*RST")

# =========================================================
# Capture:
# =========================================================
def capture():

# Use auto-scale to automatically set up oscilloscope.


print "Autoscale."
do_command(":AUToscale")

# Set trigger mode.


do_command(":TRIGger:MODE EDGE")
qresult = do_query_string(":TRIGger:MODE?")
print "Trigger mode: %s" % qresult

# Set EDGE trigger parameters.


do_command(":TRIGger:EDGE:SOURce CHANnel1")
qresult = do_query_string(":TRIGger:EDGE:SOURce?")
print "Trigger edge source: %s" % qresult

do_command(":TRIGger:EDGE:LEVel 1.5")
qresult = do_query_string(":TRIGger:EDGE:LEVel?")
print "Trigger edge level: %s" % qresult

do_command(":TRIGger:EDGE:SLOPe POSitive")
qresult = do_query_string(":TRIGger:EDGE:SLOPe?")
print "Trigger edge slope: %s" % qresult

# Save oscilloscope setup.


sSetup = do_query_ieee_block(":SYSTem:SETup?")

f = open("setup.stp", "wb")
f.write(sSetup)
f.close()
print "Setup bytes saved: %d" % len(sSetup)

# Change oscilloscope settings with individual commands:

# Set vertical scale and offset.


do_command(":CHANnel1:SCALe 0.05")
qresult = do_query_string(":CHANnel1:SCALe?")
print "Channel 1 vertical scale: %s" % qresult

do_command(":CHANnel1:OFFSet -1.5")
qresult = do_query_string(":CHANnel1:OFFSet?")
print "Channel 1 offset: %s" % qresult

# Set horizontal scale and offset.


do_command(":TIMebase:SCALe 0.0002")
qresult = do_query_string(":TIMebase:SCALe?")

1254 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

print "Timebase scale: %s" % qresult

do_command(":TIMebase:POSition 0.0")
qresult = do_query_string(":TIMebase:POSition?")
print "Timebase position: %s" % qresult

# Set the acquisition type.


do_command(":ACQuire:TYPE NORMal")
qresult = do_query_string(":ACQuire:TYPE?")
print "Acquire type: %s" % qresult

# Or, set up oscilloscope by loading a previously saved setup.


sSetup = ""
f = open("setup.stp", "rb")
sSetup = f.read()
f.close()
do_command_ieee_block(":SYSTem:SETup", sSetup)
print "Setup bytes restored: %d" % len(sSetup)

# Capture an acquisition using :DIGitize.


do_command(":DIGitize CHANnel1")

# =========================================================
# Analyze:
# =========================================================
def analyze():

# Make measurements.
# --------------------------------------------------------
do_command(":MEASure:SOURce CHANnel1")
qresult = do_query_string(":MEASure:SOURce?")
print "Measure source: %s" % qresult

do_command(":MEASure:FREQuency")
qresult = do_query_string(":MEASure:FREQuency?")
print "Measured frequency on channel 1: %s" % qresult

do_command(":MEASure:VAMPlitude")
qresult = do_query_string(":MEASure:VAMPlitude?")
print "Measured vertical amplitude on channel 1: %s" % qresult

# Download the screen image.


# --------------------------------------------------------
do_command(":HARDcopy:INKSaver OFF")

sDisplay = do_query_ieee_block(":DISPlay:DATA? PNG, COLor")

# Save display data values to file.


f = open("screen_image.png", "wb")
f.write(sDisplay)
f.close()
print "Screen image written to screen_image.png."

# Download waveform data.


# --------------------------------------------------------

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1255


40 Programming Examples

# Set the waveform points mode.


do_command(":WAVeform:POINts:MODE RAW")
qresult = do_query_string(":WAVeform:POINts:MODE?")
print "Waveform points mode: %s" % qresult

# Get the number of waveform points available.


do_command(":WAVeform:POINts 10240")
qresult = do_query_string(":WAVeform:POINts?")
print "Waveform points available: %s" % qresult

# Set the waveform source.


do_command(":WAVeform:SOURce CHANnel1")
qresult = do_query_string(":WAVeform:SOURce?")
print "Waveform source: %s" % qresult

# Choose the format of the data returned:


do_command(":WAVeform:FORMat BYTE")
print "Waveform format: %s" % do_query_string(":WAVeform:FORMat?")

# Display the waveform settings from preamble:


wav_form_dict = {
0 : "BYTE",
1 : "WORD",
4 : "ASCii",
}
acq_type_dict = {
0 : "NORMal",
1 : "PEAK",
2 : "AVERage",
3 : "HRESolution",
}

preamble_string = do_query_string(":WAVeform:PREamble?")
(
wav_form, acq_type, wfmpts, avgcnt, x_increment, x_origin,
x_reference, y_increment, y_origin, y_reference
) = string.split(preamble_string, ",")

print "Waveform format: %s" % wav_form_dict[int(wav_form)]


print "Acquire type: %s" % acq_type_dict[int(acq_type)]
print "Waveform points desired: %s" % wfmpts
print "Waveform average count: %s" % avgcnt
print "Waveform X increment: %s" % x_increment
print "Waveform X origin: %s" % x_origin
print "Waveform X reference: %s" % x_reference # Always 0.
print "Waveform Y increment: %s" % y_increment
print "Waveform Y origin: %s" % y_origin
print "Waveform Y reference: %s" % y_reference

# Get numeric values for later calculations.


x_increment = do_query_number(":WAVeform:XINCrement?")
x_origin = do_query_number(":WAVeform:XORigin?")
y_increment = do_query_number(":WAVeform:YINCrement?")
y_origin = do_query_number(":WAVeform:YORigin?")
y_reference = do_query_number(":WAVeform:YREFerence?")

# Get the waveform data.

1256 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

sData = do_query_ieee_block(":WAVeform:DATA?")

# Unpack unsigned byte data.


values = struct.unpack("%dB" % len(sData), sData)
print "Number of data values: %d" % len(values)

# Save waveform data values to CSV file.


f = open("waveform_data.csv", "w")

for i in xrange(0, len(values) - 1):


time_val = x_origin + (i * x_increment)
voltage = ((values[i] - y_reference) * y_increment) + y_origin
f.write("%E, %f\n" % (time_val, voltage))

f.close()
print "Waveform format BYTE data written to waveform_data.csv."

# =========================================================
# Send a command and check for errors:
# =========================================================
def do_command(command, hide_params=False):

if hide_params:
(header, data) = string.split(command, " ", 1)
if debug:
print "\nCmd = '%s'" % header
else:
if debug:
print "\nCmd = '%s'" % command

InfiniiVision.write("%s" % command)

if hide_params:
check_instrument_errors(header)
else:
check_instrument_errors(command)

# =========================================================
# Send a command and binary values and check for errors:
# =========================================================
def do_command_ieee_block(command, values):
if debug:
print "Cmb = '%s'" % command
InfiniiVision.write_binary_values("%s " % command, values, datatype='c'
)
check_instrument_errors(command)

# =========================================================
# Send a query, check for errors, return string:
# =========================================================
def do_query_string(query):
if debug:
print "Qys = '%s'" % query
result = InfiniiVision.query("%s" % query)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1257


40 Programming Examples

check_instrument_errors(query)
return result

# =========================================================
# Send a query, check for errors, return floating-point value:
# =========================================================
def do_query_number(query):
if debug:
print "Qyn = '%s'" % query
results = InfiniiVision.query("%s" % query)
check_instrument_errors(query)
return float(results)

# =========================================================
# Send a query, check for errors, return binary values:
# =========================================================
def do_query_ieee_block(query):
if debug:
print "Qys = '%s'" % query
result = InfiniiVision.query_binary_values("%s" % query, datatype='s')
check_instrument_errors(query)
return result[0]

# =========================================================
# Check for instrument errors:
# =========================================================
def check_instrument_errors(command):

while True:
error_string = InfiniiVision.query(":SYSTem:ERRor?")
if error_string: # If there is an error string value.

if error_string.find("+0,", 0, 3) == -1: # Not "No error".

print "ERROR: %s, command: '%s'" % (error_string, command)


print "Exited because of error."
sys.exit(1)

else: # "No error"


break

else: # :SYSTem:ERRor? should always return string.


print "ERROR: :SYSTem:ERRor? returned nothing, command: '%s'" % comma
nd
print "Exited because of error."
sys.exit(1)

# =========================================================
# Main program:
# =========================================================

rm = visa.ResourceManager()
InfiniiVision= rm.open_resource("TCPIP0::130.29.70.139::inst0::INSTR")

1258 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

InfiniiVision.timeout = 15000
InfiniiVision.clear()

# Initialize the oscilloscope, capture data, and analyze.


initialize()
capture()
analyze()

print "End of program."

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1259


40 Programming Examples

VISA.NET Examples
These programming examples show how to use the VISA.NET drivers that come
with Keysight IO Libraries Suite.
• "VISA.NET Example in C#" on page 1260
• "VISA.NET Example in Visual Basic .NET" on page 1266
• "VISA.NET Example in IronPython" on page 1273

VISA.NET Example in C#
To compile and run this example in Microsoft Visual Studio 2013:
1 Open Visual Studio.
2 Choose FILE > New > Project....
3 In the New Project dialog box, select .NET Framework 4.5.2.
4 Create a new Visual C#, Console Application project.
5 Cut-and-paste the code that follows into the C# source file.
6 Edit the program to use the VISA address of your oscilloscope.
7 Add a reference to the VISA.NET driver:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Add Reference....
c In the Reference Manager dialog box, under Assemblies, select Extensions.
d In the "Targeting: .NET Framework 4.5.2" list, select the Ivi.Visa Assembly
check box; then, click OK.
8 Build and run the program.

For more information, see the VISA.NET Help that comes with Keysight IO
Libraries Suite.
/*
* Keysight VISA.NET Example in C#
* -------------------------------------------------------------------
* This program illustrates a few commonly used programming
* features of your Keysight InfiniiVision oscilloscope.
* -------------------------------------------------------------------
*/

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

using Ivi.Visa;
using Ivi.Visa.FormattedIO;

1260 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

namespace Example
{
class Program
{

static void Main(string[] args)


{
// Change this variable to the address of your instrument
string VISA_ADDRESS = "TCPIP0::141.121.230.6::inst0::INSTR";

// Create a connection (session) to the instrument


IMessageBasedSession session;
try
{
session = GlobalResourceManager.Open(VISA_ADDRESS) as
IMessageBasedSession;
}
catch (NativeVisaException visaException)
{
Console.WriteLine("Couldn't connect.");
Console.WriteLine("Error is:\r\n{0}\r\n", visaException);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
return;
}

// Create a formatted I/O object which will help us format the


// data we want to send/receive to/from the instrument
MessageBasedFormattedIO myScope =
new MessageBasedFormattedIO(session);

// For Serial and TCP/IP socket connections enable the read


// Termination Character, or read's will timeout
if (session.ResourceName.Contains("ASRL") ||
session.ResourceName.Contains("SOCKET"))
session.TerminationCharacterEnabled = true;

session.TimeoutMilliseconds = 20000;

// Initialize - start from a known state.


// ==============================================================
string strResults;
FileStream fStream;

// Get and display the device's *IDN? string.


myScope.WriteLine("*IDN?");
strResults = myScope.ReadLine();
Console.WriteLine("*IDN? result is: {0}", strResults);

// Clear status and load the default setup.


myScope.WriteLine("*CLS");
myScope.WriteLine("*RST");

// Capture data.
// ==============================================================

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1261


40 Programming Examples

// Use auto-scale to automatically configure oscilloscope.


myScope.WriteLine(":AUToscale");

// Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.WriteLine(":TRIGger:MODE EDGE");
myScope.WriteLine(":TRIGger:MODE?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger mode: {0}", strResults);

// Set EDGE trigger parameters.


myScope.WriteLine(":TRIGger:EDGE:SOURce CHANnel1");
myScope.WriteLine(":TRIGger:EDGE:SOURce?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger edge source: {0}", strResults);

myScope.WriteLine(":TRIGger:EDGE:LEVel 1.5");
myScope.WriteLine(":TRIGger:EDGE:LEVel?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger edge level: {0}", strResults);

myScope.WriteLine(":TRIGger:EDGE:SLOPe POSitive");
myScope.WriteLine(":TRIGger:EDGE:SLOPe?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger edge slope: {0}", strResults);

// Save oscilloscope configuration.


byte[] ResultsArray; // Results array.
int nLength; // Number of bytes returned from instrument.
string strPath;

// Query and read setup string.


myScope.WriteLine(":SYSTem:SETup?");
ResultsArray = myScope.ReadLineBinaryBlockOfByte();
nLength = ResultsArray.Length;

// Write setup string to file.


strPath = "c:\\scope\\config\\setup.stp";
fStream = File.Open(strPath, FileMode.Create);
fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Setup bytes saved: {0}", nLength);

// Change settings with individual commands:

// Set vertical scale and offset.


myScope.WriteLine(":CHANnel1:SCALe 0.05");
myScope.WriteLine(":CHANnel1:SCALe?");
strResults = myScope.ReadLine();
Console.WriteLine("Channel 1 vertical scale: {0}", strResults);

myScope.WriteLine(":CHANnel1:OFFSet -1.5");
myScope.WriteLine(":CHANnel1:OFFSet?");
strResults = myScope.ReadLine();
Console.WriteLine("Channel 1 vertical offset: {0}", strResults);

// Set horizontal scale and offset.


myScope.WriteLine(":TIMebase:SCALe 0.0002");

1262 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

myScope.WriteLine(":TIMebase:SCALe?");
strResults = myScope.ReadLine();
Console.WriteLine("Timebase scale: {0}", strResults);

myScope.WriteLine(":TIMebase:POSition 0.0");
myScope.WriteLine(":TIMebase:POSition?");
strResults = myScope.ReadLine();
Console.WriteLine("Timebase position: {0}", strResults);

// Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution


).
myScope.WriteLine(":ACQuire:TYPE NORMal");
myScope.WriteLine(":ACQuire:TYPE?");
strResults = myScope.ReadLine();
Console.WriteLine("Acquire type: {0}", strResults);

// Or, configure by loading a previously saved setup.


byte[] DataArray;
int nBytesWritten;

// Read setup string from file.


strPath = "c:\\scope\\config\\setup.stp";
DataArray = File.ReadAllBytes(strPath);
nBytesWritten = DataArray.Length;

// Restore setup string.


myScope.Write(":SYSTem:SETup ");
myScope.WriteBinary(DataArray);
myScope.WriteLine("");
Console.WriteLine("Setup bytes restored: {0}", nBytesWritten);

// Capture an acquisition using :DIGitize.


myScope.WriteLine(":DIGitize CHANnel1");

// Analyze the captured waveform.


// ==============================================================

// Make a couple of measurements.


// -----------------------------------------------------------
myScope.WriteLine(":MEASure:SOURce CHANnel1");
myScope.WriteLine(":MEASure:SOURce?");
strResults = myScope.ReadLine();
Console.WriteLine("Measure source: {0}", strResults);

double fResult;
myScope.WriteLine(":MEASure:FREQuency");
myScope.WriteLine(":MEASure:FREQuency?");
fResult = myScope.ReadLineDouble();
Console.WriteLine("Frequency: {0:F4} kHz", fResult / 1000);

myScope.WriteLine(":MEASure:VAMPlitude");
myScope.WriteLine(":MEASure:VAMPlitude?");
fResult = myScope.ReadLineDouble();
Console.WriteLine("Vertical amplitude: {0:F2} V", fResult);

// Download the screen image.


// -----------------------------------------------------------

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1263


40 Programming Examples

myScope.WriteLine(":HARDcopy:INKSaver OFF");

// Get the screen data.


myScope.WriteLine(":DISPlay:DATA? PNG, COLor");
ResultsArray = myScope.ReadLineBinaryBlockOfByte();
nLength = ResultsArray.Length;

// Store the screen data to a file.


strPath = "c:\\scope\\data\\screen.png";
fStream = File.Open(strPath, FileMode.Create);
fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Screen image ({0} bytes) written to {1}",
nLength, strPath);

// Download waveform data.


// -----------------------------------------------------------

// Set the waveform points mode.


myScope.WriteLine(":WAVeform:POINts:MODE RAW");
myScope.WriteLine(":WAVeform:POINts:MODE?");
strResults = myScope.ReadLine();
Console.WriteLine("Waveform points mode: {0}", strResults);

// Get the number of waveform points available.


myScope.WriteLine(":WAVeform:POINts?");
strResults = myScope.ReadLine();
Console.WriteLine("Waveform points available: {0}", strResults);

// Set the waveform source.


myScope.WriteLine(":WAVeform:SOURce CHANnel1");
myScope.WriteLine(":WAVeform:SOURce?");
strResults = myScope.ReadLine();
Console.WriteLine("Waveform source: {0}", strResults);

// Choose the format of the data returned (WORD, BYTE, ASCII):


myScope.WriteLine(":WAVeform:FORMat BYTE");
myScope.WriteLine(":WAVeform:FORMat?");
strResults = myScope.ReadLine();
Console.WriteLine("Waveform format: {0}", strResults);

// Display the waveform settings:


double[] fResultsArray;
myScope.WriteLine(":WAVeform:PREamble?");
fResultsArray = myScope.ReadLineListOfDouble();

double fFormat = fResultsArray[0];


if (fFormat == 0.0)
{
Console.WriteLine("Waveform format: BYTE");
}
else if (fFormat == 1.0)
{
Console.WriteLine("Waveform format: WORD");
}
else if (fFormat == 2.0)
{

1264 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Console.WriteLine("Waveform format: ASCii");


}

double fType = fResultsArray[1];


if (fType == 0.0)
{
Console.WriteLine("Acquire type: NORMal");
}
else if (fType == 1.0)
{
Console.WriteLine("Acquire type: PEAK");
}
else if (fType == 2.0)
{
Console.WriteLine("Acquire type: AVERage");
}
else if (fType == 3.0)
{
Console.WriteLine("Acquire type: HRESolution");
}

double fPoints = fResultsArray[2];


Console.WriteLine("Waveform points: {0:e}", fPoints);

double fCount = fResultsArray[3];


Console.WriteLine("Waveform average count: {0:e}", fCount);

double fXincrement = fResultsArray[4];


Console.WriteLine("Waveform X increment: {0:e}", fXincrement);

double fXorigin = fResultsArray[5];


Console.WriteLine("Waveform X origin: {0:e}", fXorigin);

double fXreference = fResultsArray[6];


Console.WriteLine("Waveform X reference: {0:e}", fXreference);

double fYincrement = fResultsArray[7];


Console.WriteLine("Waveform Y increment: {0:e}", fYincrement);

double fYorigin = fResultsArray[8];


Console.WriteLine("Waveform Y origin: {0:e}", fYorigin);

double fYreference = fResultsArray[9];


Console.WriteLine("Waveform Y reference: {0:e}", fYreference);

// Read waveform data.


myScope.WriteLine(":WAVeform:DATA?");
ResultsArray = myScope.ReadLineBinaryBlockOfByte();
nLength = ResultsArray.Length;
Console.WriteLine("Number of data values: {0}", nLength);

// Set up output file:


strPath = "c:\\scope\\data\\waveform_data.csv";
if (File.Exists(strPath)) File.Delete(strPath);

// Open file for output.


StreamWriter writer = File.CreateText(strPath);

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1265


40 Programming Examples

// Output waveform data in CSV format.


for (int i = 0; i < nLength - 1; i++)
writer.WriteLine("{0:f9}, {1:f6}",
fXorigin + ((float)i * fXincrement),
(((float)ResultsArray[i] - fYreference)
* fYincrement) + fYorigin);

// Close output file.


writer.Close();
Console.WriteLine("Waveform format BYTE data written to {0}",
strPath);

// Close the connection to the instrument


// --------------------------------------------------------------
session.Dispose();

Console.WriteLine("Press any key to exit...");


Console.ReadKey();

}
}
}

VISA.NET Example in Visual Basic .NET


To compile and run this example in Microsoft Visual Studio 2013:
1 Open Visual Studio.
2 Choose FILE > New > Project....
3 In the New Project dialog box, select .NET Framework 4.5.2.
4 Create a new Visual Basic, Console Application project.
5 Cut-and-paste the code that follows into the Visual Basic .NET source file.
6 Edit the program to use the VISA address of your oscilloscope.
7 Add a reference to the VISA.NET 3.0 driver:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Add Reference....
c In the Add Reference dialog, select the Browse tab, and navigate to the
ScpiNetDrivers folder.
• Windows XP: C:\Documents and Settings\All Users\Agilent\Command
Expert\ScpiNetDrivers
• Windows 7: C:\ProgramData\Agilent\Command Expert\ScpiNetDrivers
d Select the .dll file for your oscilloscope, for example
AgInfiniiVision2000X_01_20.dll; then, click OK.
e Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment and choose

1266 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Properties; then, select "InfiniiVision.ScpiNetInstrumentApp" as the Startup


object.
8 Add a reference to the VISA.NET driver:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Add Reference....
c In the Reference Manager dialog box, under Assemblies, select Extensions.
d In the "Targeting: .NET Framework 4.5.2" list, select the Ivi.Visa Assembly
check box; then, click OK.
9 Specify the Startup object:
a Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b Choose Properties.
c In the Properties dialog box, under Application, select the Startup object: field
and choose Sub Main.
d Save your change and close the Properties dialog box.
10 Build and run the program.

For more information, see the VISA.NET driver help that comes with Keysight
Command Expert.
'
' Keysight VISA.NET Example in VB.NET
' -------------------------------------------------------------------
' This program illustrates a few commonly used programming
' features of your Keysight InfiniiVision oscilloscope.
' -------------------------------------------------------------------

Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Text

Imports Ivi.Visa
Imports Ivi.Visa.FormattedIO

Namespace Example
Class Program

Public Shared Sub Main(args As String())


' Change this variable to the address of your instrument
Dim VISA_ADDRESS As String = "TCPIP0::141.121.230.6::inst0::INSTR"

' Create a connection (session) to the instrument


Dim session As IMessageBasedSession
Try
session = TryCast(GlobalResourceManager.Open(VISA_ADDRESS), _
IMessageBasedSession)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1267


40 Programming Examples

Catch visaException As NativeVisaException


Console.WriteLine("Couldn't connect.")
Console.WriteLine("Error is:" & vbCr & vbLf & "{0}" _
& vbCr & vbLf, visaException)
Console.WriteLine("Press any key to exit...")
Console.ReadKey()
Return
End Try

' Create a formatted I/O object which will help us format the
' data we want to send/receive to/from the instrument
Dim myScope As New MessageBasedFormattedIO(session)

' For Serial and TCP/IP socket connections enable the read
' Termination Character, or read's will timeout
If session.ResourceName.Contains("ASRL") OrElse _
session.ResourceName.Contains("SOCKET") Then
session.TerminationCharacterEnabled = True
End If

session.TimeoutMilliseconds = 20000

' Initialize - start from a known state.


' ==============================================================
Dim strResults As String
Dim fStream As FileStream

' Get and display the device's *IDN? string.


myScope.WriteLine("*IDN?")
strResults = myScope.ReadLine()
Console.WriteLine("*IDN? result is: {0}", strResults)

' Clear status and load the default setup.


myScope.WriteLine("*CLS")
myScope.WriteLine("*RST")

' Capture data.


' ==============================================================
' Use auto-scale to automatically configure oscilloscope.
myScope.WriteLine(":AUToscale")

' Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.WriteLine(":TRIGger:MODE EDGE")
myScope.WriteLine(":TRIGger:MODE?")
strResults = myScope.ReadLine()
Console.WriteLine("Trigger mode: {0}", strResults)

' Set EDGE trigger parameters.


myScope.WriteLine(":TRIGger:EDGE:SOURce CHANnel1")
myScope.WriteLine(":TRIGger:EDGE:SOURce?")
strResults = myScope.ReadLine()
Console.WriteLine("Trigger edge source: {0}", strResults)

myScope.WriteLine(":TRIGger:EDGE:LEVel 1.5")
myScope.WriteLine(":TRIGger:EDGE:LEVel?")
strResults = myScope.ReadLine()
Console.WriteLine("Trigger edge level: {0}", strResults)

1268 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

myScope.WriteLine(":TRIGger:EDGE:SLOPe POSitive")
myScope.WriteLine(":TRIGger:EDGE:SLOPe?")
strResults = myScope.ReadLine()
Console.WriteLine("Trigger edge slope: {0}", strResults)

' Save oscilloscope configuration.


Dim ResultsArray As Byte()
' Results array.
Dim nLength As Integer
' Number of bytes returned from instrument.
Dim strPath As String

' Query and read setup string.


myScope.WriteLine(":SYSTem:SETup?")
ResultsArray = myScope.ReadLineBinaryBlockOfByte()
nLength = ResultsArray.Length

' Write setup string to file.


strPath = "c:\scope\config\setup.stp"
fStream = File.Open(strPath, FileMode.Create)
fStream.Write(ResultsArray, 0, nLength)
fStream.Close()
Console.WriteLine("Setup bytes saved: {0}", nLength)

' Change settings with individual commands:

' Set vertical scale and offset.


myScope.WriteLine(":CHANnel1:SCALe 0.05")
myScope.WriteLine(":CHANnel1:SCALe?")
strResults = myScope.ReadLine()
Console.WriteLine("Channel 1 vertical scale: {0}", strResults)

myScope.WriteLine(":CHANnel1:OFFSet -1.5")
myScope.WriteLine(":CHANnel1:OFFSet?")
strResults = myScope.ReadLine()
Console.WriteLine("Channel 1 vertical offset: {0}", strResults)

' Set horizontal scale and offset.


myScope.WriteLine(":TIMebase:SCALe 0.0002")
myScope.WriteLine(":TIMebase:SCALe?")
strResults = myScope.ReadLine()
Console.WriteLine("Timebase scale: {0}", strResults)

myScope.WriteLine(":TIMebase:POSition 0.0")
myScope.WriteLine(":TIMebase:POSition?")
strResults = myScope.ReadLine()
Console.WriteLine("Timebase position: {0}", strResults)

' Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution)


.
myScope.WriteLine(":ACQuire:TYPE NORMal")
myScope.WriteLine(":ACQuire:TYPE?")
strResults = myScope.ReadLine()
Console.WriteLine("Acquire type: {0}", strResults)

' Or, configure by loading a previously saved setup.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1269


40 Programming Examples

Dim DataArray As Byte()


Dim nBytesWritten As Integer

' Read setup string from file.


strPath = "c:\scope\config\setup.stp"
DataArray = File.ReadAllBytes(strPath)
nBytesWritten = DataArray.Length

' Restore setup string.


myScope.Write(":SYSTem:SETup ")
myScope.WriteBinary(DataArray)
myScope.WriteLine("")
Console.WriteLine("Setup bytes restored: {0}", nBytesWritten)

' Capture an acquisition using :DIGitize.


myScope.WriteLine(":DIGitize CHANnel1")

' Analyze the captured waveform.


' ==============================================================

' Make a couple of measurements.


' -----------------------------------------------------------
myScope.WriteLine(":MEASure:SOURce CHANnel1")
myScope.WriteLine(":MEASure:SOURce?")
strResults = myScope.ReadLine()
Console.WriteLine("Measure source: {0}", strResults)

Dim fResult As Double


myScope.WriteLine(":MEASure:FREQuency")
myScope.WriteLine(":MEASure:FREQuency?")
fResult = myScope.ReadLineDouble()
Console.WriteLine("Frequency: {0:F4} kHz", fResult / 1000)

myScope.WriteLine(":MEASure:VAMPlitude")
myScope.WriteLine(":MEASure:VAMPlitude?")
fResult = myScope.ReadLineDouble()
Console.WriteLine("Vertical amplitude: {0:F2} V", fResult)

' Download the screen image.


' -----------------------------------------------------------
myScope.WriteLine(":HARDcopy:INKSaver OFF")

' Get the screen data.


myScope.WriteLine(":DISPlay:DATA? PNG, COLor")
ResultsArray = myScope.ReadLineBinaryBlockOfByte()
nLength = ResultsArray.Length

' Store the screen data to a file.


strPath = "c:\scope\data\screen.png"
fStream = File.Open(strPath, FileMode.Create)
fStream.Write(ResultsArray, 0, nLength)
fStream.Close()
Console.WriteLine("Screen image ({0} bytes) written to {1}", _
nLength, strPath)

' Download waveform data.


' -----------------------------------------------------------

1270 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

' Set the waveform points mode.


myScope.WriteLine(":WAVeform:POINts:MODE RAW")
myScope.WriteLine(":WAVeform:POINts:MODE?")
strResults = myScope.ReadLine()
Console.WriteLine("Waveform points mode: {0}", strResults)

' Get the number of waveform points available.


myScope.WriteLine(":WAVeform:POINts?")
strResults = myScope.ReadLine()
Console.WriteLine("Waveform points available: {0}", strResults)

' Set the waveform source.


myScope.WriteLine(":WAVeform:SOURce CHANnel1")
myScope.WriteLine(":WAVeform:SOURce?")
strResults = myScope.ReadLine()
Console.WriteLine("Waveform source: {0}", strResults)

' Choose the format of the data returned (WORD, BYTE, ASCII):
myScope.WriteLine(":WAVeform:FORMat BYTE")
myScope.WriteLine(":WAVeform:FORMat?")
strResults = myScope.ReadLine()
Console.WriteLine("Waveform format: {0}", strResults)

' Display the waveform settings:


Dim fResultsArray As Double()
myScope.WriteLine(":WAVeform:PREamble?")
fResultsArray = myScope.ReadLineListOfDouble()

Dim fFormat As Double = fResultsArray(0)


If fFormat = 0.0 Then
Console.WriteLine("Waveform format: BYTE")
ElseIf fFormat = 1.0 Then
Console.WriteLine("Waveform format: WORD")
ElseIf fFormat = 2.0 Then
Console.WriteLine("Waveform format: ASCii")
End If

Dim fType As Double = fResultsArray(1)


If fType = 0.0 Then
Console.WriteLine("Acquire type: NORMal")
ElseIf fType = 1.0 Then
Console.WriteLine("Acquire type: PEAK")
ElseIf fType = 2.0 Then
Console.WriteLine("Acquire type: AVERage")
ElseIf fType = 3.0 Then
Console.WriteLine("Acquire type: HRESolution")
End If

Dim fPoints As Double = fResultsArray(2)


Console.WriteLine("Waveform points: {0:e}", fPoints)

Dim fCount As Double = fResultsArray(3)


Console.WriteLine("Waveform average count: {0:e}", fCount)

Dim fXincrement As Double = fResultsArray(4)


Console.WriteLine("Waveform X increment: {0:e}", fXincrement)

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1271


40 Programming Examples

Dim fXorigin As Double = fResultsArray(5)


Console.WriteLine("Waveform X origin: {0:e}", fXorigin)

Dim fXreference As Double = fResultsArray(6)


Console.WriteLine("Waveform X reference: {0:e}", fXreference)

Dim fYincrement As Double = fResultsArray(7)


Console.WriteLine("Waveform Y increment: {0:e}", fYincrement)

Dim fYorigin As Double = fResultsArray(8)


Console.WriteLine("Waveform Y origin: {0:e}", fYorigin)

Dim fYreference As Double = fResultsArray(9)


Console.WriteLine("Waveform Y reference: {0:e}", fYreference)

' Read waveform data.


myScope.WriteLine(":WAVeform:DATA?")
ResultsArray = myScope.ReadLineBinaryBlockOfByte()
nLength = ResultsArray.Length
Console.WriteLine("Number of data values: {0}", nLength)

' Set up output file:


strPath = "c:\scope\data\waveform_data.csv"
If File.Exists(strPath) Then
File.Delete(strPath)
End If

' Open file for output.


Dim writer As StreamWriter = File.CreateText(strPath)

' Output waveform data in CSV format.


For i As Integer = 0 To nLength - 2
writer.WriteLine("{0:f9}, {1:f6}", _
fXorigin + (CSng(i) * fXincrement), _
((CSng(ResultsArray(i)) - fYreference) _
* fYincrement) + fYorigin)
Next

' Close output file.


writer.Close()
Console.WriteLine("Waveform format BYTE data written to {0}", _
strPath)

' Close the connection to the instrument


' --------------------------------------------------------------
session.Dispose()

Console.WriteLine("Press any key to exit...")


Console.ReadKey()

End Sub
End Class
End Namespace

1272 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

VISA.NET Example in IronPython


You can also control Keysight oscilloscopes using the VISA.NET library and Python
programming language on the .NET platform using:
• IronPython (http://ironpython.net/) which is an implementation of the Python
programming language running under .NET.
To run this example with IronPython:
1 Cut-and-paste the code that follows into a file named "example.py".
2 Edit the program to use the address of your oscilloscope.
3 If the IronPython "ipy.exe" can be found via your PATH environment variable,
open a Command Prompt window; then, change to the folder that contains the
"example.py" file, and enter:
ipy example.py

#
# Keysight VISA.NET Example in IronPython
# *********************************************************
# This program illustrates a few commonly used programming
# features of your Keysight InfiniiVision oscilloscope.
# *********************************************************

# Import Python modules.


# ---------------------------------------------------------
import sys
sys.path.append("C:\Python27\Lib") # Python Standard Library.
import string

# Import .NET modules.


# ---------------------------------------------------------
from System import *
from System.IO import *
from System.Text import *
from System.Runtime.InteropServices import *
import clr
clr.AddReference("Ivi.Visa")
from Ivi.Visa import *
from Ivi.Visa.FormattedIO import *

# =========================================================
# Initialize:
# =========================================================
def initialize():

# Get and display the device's *IDN? string.


myScope.WriteLine("*IDN?")
idn_string = myScope.ReadLine()
print "Identification string '%s'" % idn_string

# Clear status and load the default setup.


myScope.WriteLine("*CLS")
myScope.WriteLine("*RST")

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1273


40 Programming Examples

# =========================================================
# Capture:
# =========================================================
def capture():

# Use auto-scale to automatically set up oscilloscope.


print "Autoscale."
myScope.WriteLine(":AUToscale")

# Set trigger mode.


myScope.WriteLine(":TRIGger:MODE EDGE")
myScope.WriteLine(":TRIGger:MODE?")
qresult = myScope.ReadLine()
print "Trigger mode: %s" % qresult

# Set EDGE trigger parameters.


myScope.WriteLine(":TRIGger:EDGE:SOURce CHANnel1")
myScope.WriteLine(":TRIGger:EDGE:SOURce?")
qresult = myScope.ReadLine()
print "Trigger edge source: %s" % qresult

myScope.WriteLine(":TRIGger:EDGE:LEVel 1.5")
myScope.WriteLine(":TRIGger:EDGE:LEVel?")
qresult = myScope.ReadLine()
print "Trigger edge level: %s" % qresult

myScope.WriteLine(":TRIGger:EDGE:SLOPe POSitive")
myScope.WriteLine(":TRIGger:EDGE:SLOPe?")
qresult = myScope.ReadLine()
print "Trigger edge slope: %s" % qresult

# Save oscilloscope setup to file.


myScope.WriteLine(":SYSTem:SETup?")
setup_bytes = myScope.ReadLineBinaryBlockOfByte()
File.WriteAllBytes("setup.stp", setup_bytes)
print "Setup bytes saved: %d" % len(setup_bytes)

# Change settings with individual commands:

# Set vertical scale and offset.


myScope.WriteLine(":CHANnel1:SCALe 0.05")
myScope.WriteLine(":CHANnel1:SCALe?")
qresult = myScope.ReadLine()
print "Channel 1 vertical scale: %s" % qresult

myScope.WriteLine(":CHANnel1:OFFSet -1.5")
myScope.WriteLine(":CHANnel1:OFFSet?")
qresult = myScope.ReadLine()
print "Channel 1 offset: %s" % qresult

# Set horizontal scale and offset.


myScope.WriteLine(":TIMebase:SCALe 0.0002")
myScope.WriteLine(":TIMebase:SCALe?")
qresult = myScope.ReadLine()
print "Timebase scale: %s" % qresult

1274 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

myScope.WriteLine(":TIMebase:POSition 0.0")
myScope.WriteLine(":TIMebase:POSition?")
qresult = myScope.ReadLine()
print "Timebase position: %s" % qresult

# Set the acquisition type.


myScope.WriteLine(":ACQuire:TYPE NORMal")
myScope.WriteLine(":ACQuire:TYPE?")
qresult = myScope.ReadLine()
print "Acquire type: %s" % qresult

# Or, configure by loading a previously saved setup.

# Read setup string from file.


setup_bytes = File.ReadAllBytes("setup.stp")

# Restore setup string.


myScope.Write(":SYSTem:SETup ")
write_binary = myScope.WriteBinary.Overloads[Array[Byte]]
write_binary(setup_bytes)
myScope.WriteLine("")
print "Setup bytes restored: %d" % len(setup_bytes)

# Capture an acquisition using :DIGitize.


myScope.WriteLine(":DIGitize CHANnel1")

# =========================================================
# Analyze:
# =========================================================
def analyze():

# Make measurements.
# --------------------------------------------------------
myScope.WriteLine(":MEASure:SOURce CHANnel1")
myScope.WriteLine(":MEASure:SOURce?")
qresult = myScope.ReadLine()
print "Measure source: %s" % qresult

myScope.WriteLine(":MEASure:FREQuency")
myScope.WriteLine(":MEASure:FREQuency?")
qresult = myScope.ReadLineDouble()
print "Measured frequency on channel 1: %f" % qresult

myScope.WriteLine(":MEASure:VAMPlitude")
myScope.WriteLine(":MEASure:VAMPlitude?")
qresult = myScope.ReadLineDouble()
print "Measured vertical amplitude on channel 1: %f" % qresult

# Download the screen image.


# --------------------------------------------------------
myScope.WriteLine(":HARDcopy:INKSaver OFF")

# Get the screen data.


myScope.WriteLine(":DISPlay:DATA? PNG, COLor")
image_bytes = myScope.ReadLineBinaryBlockOfByte()

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1275


40 Programming Examples

nLength = len(image_bytes)
fStream = File.Open("screen_image.png", FileMode.Create)
fStream.Write(image_bytes, 0, nLength)
fStream.Close()
print "Screen image written to screen_image.png."

# Download waveform data.


# --------------------------------------------------------

# Set the waveform points mode.


myScope.WriteLine(":WAVeform:POINts:MODE RAW")
myScope.WriteLine(":WAVeform:POINts:MODE?")
qresult = myScope.ReadLine()
print "Waveform points mode: %s" % qresult

# Get the number of waveform points available.


myScope.WriteLine(":WAVeform:POINts?")
qresult = myScope.ReadLine()
print "Waveform points available: %s" % qresult

# Set the waveform source.


myScope.WriteLine(":WAVeform:SOURce CHANnel1")
myScope.WriteLine(":WAVeform:SOURce?")
qresult = myScope.ReadLine()
print "Waveform source: %s" % qresult

# Choose the format of the data returned:


myScope.WriteLine(":WAVeform:FORMat BYTE")
myScope.WriteLine(":WAVeform:FORMat?")
qresult = myScope.ReadLine()
print "Waveform format: %s" % qresult

# Display the waveform settings from preamble:


wav_form_dict = {
0 : "BYTE",
1 : "WORD",
4 : "ASCii",
}
acq_type_dict = {
0 : "NORMal",
1 : "PEAK",
2 : "AVERage",
3 : "HRESolution",
}

myScope.WriteLine(":WAVeform:PREamble?")
(
wav_form, acq_type, wfmpts, avgcnt, x_increment, x_origin,
x_reference, y_increment, y_origin, y_reference
) = string.split(myScope.ReadLine(), ",")

print "Waveform format: %s" % wav_form_dict[int(wav_form)]


print "Acquire type: %s" % acq_type_dict[int(acq_type)]
print "Waveform points desired: %s" % wfmpts
print "Waveform average count: %s" % avgcnt
print "Waveform X increment: %s" % x_increment
print "Waveform X origin: %s" % x_origin

1276 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

print "Waveform X reference: %s" % x_reference # Always 0.


print "Waveform Y increment: %s" % y_increment
print "Waveform Y origin: %s" % y_origin
print "Waveform Y reference: %s" % y_reference

# Get numeric values for later calculations.


myScope.WriteLine(":WAVeform:XINCrement?")
x_increment = myScope.ReadLineDouble()
myScope.WriteLine(":WAVeform:XORigin?")
x_origin = myScope.ReadLineDouble()
myScope.WriteLine(":WAVeform:YINCrement?")
y_increment = myScope.ReadLineDouble()
myScope.WriteLine(":WAVeform:YORigin?")
y_origin = myScope.ReadLineDouble()
myScope.WriteLine(":WAVeform:YREFerence?")
y_reference = myScope.ReadLineDouble()

# Get the waveform data.


myScope.WriteLine(":WAVeform:DATA?")
data_bytes = myScope.ReadLineBinaryBlockOfByte()
nLength = len(data_bytes)
print "Number of data values: %d" % nLength

# Open file for output.


strPath = "waveform_data.csv"
writer = File.CreateText(strPath)

# Output waveform data in CSV format.


for i in xrange(0, nLength - 1):
time_val = x_origin + i * x_increment
voltage = (data_bytes[i] - y_reference) * y_increment + y_origin
writer.WriteLine("%E, %f" % (time_val, voltage))

# Close output file.


writer.Close()
print "Waveform format BYTE data written to %s." % strPath

# =========================================================
# Main program:
# =========================================================
addr = "TCPIP0::141.121.230.6::inst0::INSTR"
session = GlobalResourceManager.Open(addr)
session.TimeoutMilliseconds = 20000
myScope = MessageBasedFormattedIO(session)

# Initialize the oscilloscope, capture data, and analyze.


initialize()
capture()
analyze()

# Close the connection to the instrument


session.Dispose()
print "End of program."

# Wait for a key press before exiting.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1277


40 Programming Examples

print "Press any key to exit..."


Console.ReadKey(True)

1278 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

SICL Examples
• "SICL Example in C" on page 1279
• "SICL Example in Visual Basic" on page 1288

SICL Example in C
To compile and run this example in Microsoft Visual Studio 2008:
1 Open Visual Studio.
2 Create a new Visual C++, Win32, Win32 Console Application project.
3 In the Win32 Application Wizard, click Next >. Then, check Empty project, and
click Finish.
4 Cut-and-paste the code that follows into a file named "example.c" in the
project directory.
5 In Visual Studio 2008, right-click the Source Files folder, choose Add > Add
Existing Item..., select the example.c file, and click Add.
6 Edit the program to use the SICL address of your oscilloscope.
7 Choose Project > Properties.... In the Property Pages dialog, update these project
settings:
a Under Configuration Properties, Linker, Input, add "sicl32.lib" to the
Additional Dependencies field.
b Under Configuration Properties, C/C++, Code Generation, select
Multi-threaded DLL for the Runtime Library field.
c Click OK to close the Property Pages dialog.
8 Add the include files and library files search paths:
a Choose Tools > Options....
b In the Options dialog, select VC++ Directories under Projects and Solutions.
c Show directories for Include files, and add the include directory (for example,
Program Files\Agilent\IO Libraries Suite\include).
d Show directories for Library files, and add the library files directory (for
example, Program Files\Agilent\IO Libraries Suite\lib).
e Click OK to close the Options dialog.
9 Build and run the program.
/*
* Keysight SICL Example in C
* ------------------------------------------------------------------
* This program illustrates a few commonly-used programming
* features of your Keysight oscilloscope.
*/

#include <stdio.h> /* For printf(). */

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1279


40 Programming Examples

#include <string.h> /* For strcpy(), strcat(). */


#include <time.h> /* For clock(). */
#include <sicl.h> /* Keysight SICL routines. */

#define SICL_ADDRESS "usb0[2391::6054::US50210029::0]"


#define TIMEOUT 5000
#define IEEEBLOCK_SPACE 100000

/* Function prototypes */
void initialize(void); /* Initialize to known state. */
void capture(void); /* Capture the waveform. */
void analyze(void); /* Analyze the captured waveform. */

void do_command(char *command); /* Send command. */


int do_command_ieeeblock(char *command); /* Command w/IEEE block. */
void do_query_string(char *query); /* Query for string. */
void do_query_number(char *query); /* Query for number. */
void do_query_numbers(char *query); /* Query for numbers. */
int do_query_ieeeblock(char *query); /* Query for IEEE block. */
void check_instrument_errors(); /* Check for inst errors. */

/* Global variables */
INST id; /* Device session ID. */
char str_result[256] = {0}; /* Result from do_query_string(). */
double num_result; /* Result from do_query_number(). */
unsigned char ieeeblock_data[IEEEBLOCK_SPACE]; /* Result from
do_query_ieeeblock(). */
double dbl_results[10]; /* Result from do_query_numbers(). */

/* Main Program
* --------------------------------------------------------------- */
void main(void)
{
/* Install a default SICL error handler that logs an error message
* and exits. On Windows 98SE or Windows Me, view messages with
* the SICL Message Viewer. For Windows 2000 or XP, use the Event
* Viewer.
*/
ionerror(I_ERROR_EXIT);

/* Open a device session using the SICL_ADDRESS */


id = iopen(SICL_ADDRESS);

if (id == 0)
{
printf ("Oscilloscope iopen failed!\n");
}
else
{
printf ("Oscilloscope session opened!\n");
}

/* Initialize - start from a known state. */


initialize();

/* Capture data. */
capture();

1280 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

/* Analyze the captured waveform. */


analyze();

/* Close the device session to the instrument. */


iclose(id);
printf ("Program execution is complete...\n");

/* For WIN16 programs, call _siclcleanup before exiting to release


* resources allocated by SICL for this application. This call is
* a no-op for WIN32 programs.
*/
_siclcleanup();
}

/* Initialize the oscilloscope to a known state.


* --------------------------------------------------------------- */
void initialize (void)
{
/* Set the I/O timeout value for this session to 5 seconds. */
itimeout(id, TIMEOUT);

/* Clear the interface. */


iclear(id);

/* Get and display the device's *IDN? string. */


do_query_string("*IDN?");
printf("Oscilloscope *IDN? string: %s\n", str_result);

/* Clear status and load the default setup. */


do_command("*CLS");
do_command("*RST");
}

/* Capture the waveform.


* --------------------------------------------------------------- */
void capture (void)
{
int num_bytes;
FILE *fp;

/* Use auto-scale to automatically configure oscilloscope.


* ------------------------------------------------------------- */
do_command(":AUToscale");

/* Set trigger mode (EDGE, PULSe, PATTern, etc., and input source. */
do_command(":TRIGger:MODE EDGE");
do_query_string(":TRIGger:MODE?");
printf("Trigger mode: %s\n", str_result);

/* Set EDGE trigger parameters. */


do_command(":TRIGger:EDGE:SOURce CHANnel1");
do_query_string(":TRIGger:EDGE:SOURce?");
printf("Trigger edge source: %s\n", str_result);

do_command(":TRIGger:EDGE:LEVel 1.5");
do_query_string(":TRIGger:EDGE:LEVel?");

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1281


40 Programming Examples

printf("Trigger edge level: %s\n", str_result);

do_command(":TRIGger:EDGE:SLOPe POSitive");
do_query_string(":TRIGger:EDGE:SLOPe?");
printf("Trigger edge slope: %s\n", str_result);

/* Save oscilloscope configuration.


* ------------------------------------------------------------- */

/* Read system setup. */


num_bytes = do_query_ieeeblock(":SYSTem:SETup?");
printf("Read setup string query (%d bytes).\n", num_bytes);

/* Write setup string to file. */


fp = fopen ("c:\\scope\\config\\setup.stp", "wb");
num_bytes = fwrite(ieeeblock_data, sizeof(unsigned char), num_bytes,
fp);
fclose (fp);
printf("Wrote setup string (%d bytes) to ", num_bytes);
printf("c:\\scope\\config\\setup.stp.\n");

/* Change settings with individual commands:


* ------------------------------------------------------------- */

/* Set vertical scale and offset. */


do_command(":CHANnel1:SCALe 0.05");
do_query_string(":CHANnel1:SCALe?");
printf("Channel 1 vertical scale: %s\n", str_result);

do_command(":CHANnel1:OFFSet -1.5");
do_query_string(":CHANnel1:OFFSet?");
printf("Channel 1 offset: %s\n", str_result);

/* Set horizontal scale and position. */


do_command(":TIMebase:SCALe 0.0002");
do_query_string(":TIMebase:SCALe?");
printf("Timebase scale: %s\n", str_result);

do_command(":TIMebase:POSition 0.0");
do_query_string(":TIMebase:POSition?");
printf("Timebase position: %s\n", str_result);

/* Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution). *


/
do_command(":ACQuire:TYPE NORMal");
do_query_string(":ACQuire:TYPE?");
printf("Acquire type: %s\n", str_result);

/* Or, configure by loading a previously saved setup.


* ------------------------------------------------------------- */

/* Read setup string from file. */


fp = fopen ("c:\\scope\\config\\setup.stp", "rb");
num_bytes = fread (ieeeblock_data, sizeof(unsigned char),
IEEEBLOCK_SPACE, fp);
fclose (fp);
printf("Read setup string (%d bytes) from file ", num_bytes);

1282 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

printf("c:\\scope\\config\\setup.stp.\n");

/* Restore setup string. */


num_bytes = do_command_ieeeblock(":SYSTem:SETup", num_bytes);
printf("Restored setup string (%d bytes).\n", num_bytes);

/* Capture an acquisition using :DIGitize.


* ------------------------------------------------------------- */
do_command(":DIGitize CHANnel1");
}

/* Analyze the captured waveform.


* --------------------------------------------------------------- */
void analyze (void)
{
double wav_format;
double acq_type;
double wav_points;
double avg_count;
double x_increment;
double x_origin;
double x_reference;
double y_increment;
double y_origin;
double y_reference;

FILE *fp;
int num_bytes; /* Number of bytes returned from instrument. */
int i;

/* Make a couple of measurements.


* ------------------------------------------------------------- */
do_command(":MEASure:SOURce CHANnel1");
do_query_string(":MEASure:SOURce?");
printf("Measure source: %s\n", str_result);

do_command(":MEASure:FREQuency");
do_query_number(":MEASure:FREQuency?");
printf("Frequency: %.4f kHz\n", num_result / 1000);

do_command(":MEASure:VAMPlitude");
do_query_number(":MEASure:VAMPlitude?");
printf("Vertical amplitude: %.2f V\n", num_result);

/* Download the screen image.


* ------------------------------------------------------------- */
do_command(":HARDcopy:INKSaver OFF");

/* Read screen image. */


num_bytes = do_query_ieeeblock(":DISPlay:DATA? PNG, COLor");
printf("Screen image bytes: %d\n", num_bytes);

/* Write screen image bytes to file. */


fp = fopen ("c:\\scope\\data\\screen.png", "wb");
num_bytes = fwrite(ieeeblock_data, sizeof(unsigned char), num_bytes,
fp);
fclose (fp);

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1283


40 Programming Examples

printf("Wrote screen image (%d bytes) to ", num_bytes);


printf("c:\\scope\\data\\screen.png.\n");

/* Download waveform data.


* ------------------------------------------------------------- */

/* Set the waveform points mode. */


do_command(":WAVeform:POINts:MODE RAW");
do_query_string(":WAVeform:POINts:MODE?");
printf("Waveform points mode: %s\n", str_result);

/* Get the number of waveform points available. */


do_command(":WAVeform:POINts 10240");
do_query_string(":WAVeform:POINts?");
printf("Waveform points available: %s\n", str_result);

/* Set the waveform source. */


do_command(":WAVeform:SOURce CHANnel1");
do_query_string(":WAVeform:SOURce?");
printf("Waveform source: %s\n", str_result);

/* Choose the format of the data returned (WORD, BYTE, ASCII): */


do_command(":WAVeform:FORMat BYTE");
do_query_string(":WAVeform:FORMat?");
printf("Waveform format: %s\n", str_result);

/* Display the waveform settings: */


do_query_numbers(":WAVeform:PREamble?");

wav_format = dbl_results[0];
if (wav_format == 0.0)
{
printf("Waveform format: BYTE\n");
}
else if (wav_format == 1.0)
{
printf("Waveform format: WORD\n");
}
else if (wav_format == 2.0)
{
printf("Waveform format: ASCii\n");
}

acq_type = dbl_results[1];
if (acq_type == 0.0)
{
printf("Acquire type: NORMal\n");
}
else if (acq_type == 1.0)
{
printf("Acquire type: PEAK\n");
}
else if (acq_type == 2.0)
{
printf("Acquire type: AVERage\n");
}
else if (acq_type == 3.0)

1284 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

{
printf("Acquire type: HRESolution\n");
}

wav_points = dbl_results[2];
printf("Waveform points: %e\n", wav_points);

avg_count = dbl_results[3];
printf("Waveform average count: %e\n", avg_count);

x_increment = dbl_results[4];
printf("Waveform X increment: %e\n", x_increment);

x_origin = dbl_results[5];
printf("Waveform X origin: %e\n", x_origin);

x_reference = dbl_results[6];
printf("Waveform X reference: %e\n", x_reference);

y_increment = dbl_results[7];
printf("Waveform Y increment: %e\n", y_increment);

y_origin = dbl_results[8];
printf("Waveform Y origin: %e\n", y_origin);

y_reference = dbl_results[9];
printf("Waveform Y reference: %e\n", y_reference);

/* Read waveform data. */


num_bytes = do_query_ieeeblock(":WAVeform:DATA?");
printf("Number of data values: %d\n", num_bytes);

/* Open file for output. */


fp = fopen("c:\\scope\\data\\waveform_data.csv", "wb");

/* Output waveform data in CSV format. */


for (i = 0; i < num_bytes - 1; i++)
{
/* Write time value, voltage value. */
fprintf(fp, "%9f, %6f\n",
x_origin + ((float)i * x_increment),
(((float)ieeeblock_data[i] - y_reference) * y_increment)
+ y_origin);
}

/* Close output file. */


fclose(fp);
printf("Waveform format BYTE data written to ");
printf("c:\\scope\\data\\waveform_data.csv.\n");
}

/* Send a command to the instrument.


* --------------------------------------------------------------- */
void do_command(command)
char *command;
{
char message[80];

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1285


40 Programming Examples

strcpy(message, command);
strcat(message, "\n");
iprintf(id, message);

check_instrument_errors();
}

/* Command with IEEE definite-length block.


* --------------------------------------------------------------- */
int do_command_ieeeblock(command, num_bytes)
char *command;
int num_bytes;
{
char message[80];
int data_length;

strcpy(message, command);
strcat(message, " #8%08d");
iprintf(id, message, num_bytes);
ifwrite(id, ieeeblock_data, num_bytes, 1, &data_length);

check_instrument_errors();

return(data_length);
}

/* Query for a string result.


* --------------------------------------------------------------- */
void do_query_string(query)
char *query;
{
char message[80];

strcpy(message, query);
strcat(message, "\n");
iprintf(id, message);

iscanf(id, "%t\n", str_result);

check_instrument_errors();
}

/* Query for a number result.


* --------------------------------------------------------------- */
void do_query_number(query)
char *query;
{
char message[80];

strcpy(message, query);
strcat(message, "\n");
iprintf(id, message);

iscanf(id, "%lf", &num_result);

check_instrument_errors();

1286 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

/* Query for numbers result.


* --------------------------------------------------------------- */
void do_query_numbers(query)
char *query;
{
char message[80];

strcpy(message, query);
strcat(message, "\n");
iprintf(id, message);

iscanf(id, "%,10lf\n", dbl_results);

check_instrument_errors();
}

/* Query for an IEEE definite-length block result.


* --------------------------------------------------------------- */
int do_query_ieeeblock(query)
char *query;
{
char message[80];
int data_length;

strcpy(message, query);
strcat(message, "\n");
iprintf(id, message);

data_length = IEEEBLOCK_SPACE;
iscanf(id, "%#b", &data_length, ieeeblock_data);

if (data_length == IEEEBLOCK_SPACE )
{
printf("IEEE block buffer full: ");
printf("May not have received all data.\n");
}

check_instrument_errors();

return(data_length);
}

/* Check for instrument errors.


* --------------------------------------------------------------- */
void check_instrument_errors()
{
char str_err_val[256] = {0};
char str_out[800] = "";

ipromptf(id, ":SYSTem:ERRor?\n", "%t", str_err_val);


while(strncmp(str_err_val, "+0,No error", 3) != 0 )
{
strcat(str_out, ", ");
strcat(str_out, str_err_val);
ipromptf(id, ":SYSTem:ERRor?\n", "%t", str_err_val);

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1287


40 Programming Examples

if (strcmp(str_out, "") != 0)
{
printf("INST Error%s\n", str_out);
iflush(id, I_BUF_READ | I_BUF_WRITE);
}
}

SICL Example in Visual Basic


To run this example in Visual Basic for Applications:
1 Start the application that provides Visual Basic for Applications (for example,
Microsoft Excel).
2 Press ALT+F11 to launch the Visual Basic editor.
3 Add the sicl32.bas file to your project:
a Choose File > Import File....
b Navigate to the header file, sicl32.bas (installed with Keysight IO Libraries
Suite and found in the Program Files\Agilent\IO Libraries Suite\include
directory), select it, and click Open.
4 Choose Insert > Module.
5 Cut-and-paste the code that follows into the editor.
6 Edit the program to use the SICL address of your oscilloscope, and save the
changes.
7 Run the program.
'
' Keysight SICL Example in Visual Basic
' -------------------------------------------------------------------
' This program illustrates a few commonly-used programming
' features of your Keysight oscilloscope.
' -------------------------------------------------------------------

Option Explicit

Public id As Integer ' Session to instrument.

' Declare variables to hold numeric values returned by


' ivscanf/ifread.
Public dblQueryResult As Double
Public Const ByteArraySize = 5000000
Public retCount As Long
Public byteArray(ByteArraySize) As Byte

' Declare fixed length string variable to hold string value returned
' by ivscanf.
Public strQueryResult As String * 200

' For Sleep subroutine.

1288 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'
' Main Program
' -------------------------------------------------------------------

Sub Main()

On Error GoTo ErrorHandler

' Open a device session using the SICL_ADDRESS.


id = iopen("usb0[2391::6054::US50210029::0]")
Call itimeout(id, 5000)

' Initialize - start from a known state.


Initialize

' Capture data.


Capture

' Analyze the captured waveform.


Analyze

' Close the vi session and the resource manager session.


Call iclose(id)

Exit Sub

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

'
' Initialize the oscilloscope to a known state.
' -------------------------------------------------------------------

Private Sub Initialize()

On Error GoTo ErrorHandler

' Clear the interface.


Call iclear(id)

' Get and display the device's *IDN? string.


strQueryResult = DoQueryString("*IDN?")
MsgBox "Result is: " + RTrim(strQueryResult), vbOKOnly, "*IDN? Result"

' Clear status and load the default setup.


DoCommand "*CLS"
DoCommand "*RST"

Exit Sub

ErrorHandler:

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1289


40 Programming Examples

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

'
' Capture the waveform.
' -------------------------------------------------------------------

Private Sub Capture()

On Error GoTo ErrorHandler

' Use auto-scale to automatically configure oscilloscope.


' -----------------------------------------------------------------
DoCommand ":AUToscale"

' Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
DoCommand ":TRIGger:MODE EDGE"
Debug.Print "Trigger mode: " + _
DoQueryString(":TRIGger:MODE?")

' Set EDGE trigger parameters.


DoCommand ":TRIGger:EDGE:SOURce CHANnel1"
Debug.Print "Trigger edge source: " + _
DoQueryString(":TRIGger:EDGE:SOURce?")

DoCommand ":TRIGger:EDGE:LEVel 1.5"


Debug.Print "Trigger edge level: " + _
DoQueryString(":TRIGger:EDGE:LEVel?")

DoCommand ":TRIGger:EDGE:SLOPe POSitive"


Debug.Print "Trigger edge slope: " + _
DoQueryString(":TRIGger:EDGE:SLOPe?")

' Save oscilloscope configuration.


' -----------------------------------------------------------------
Dim lngSetupStringSize As Long
lngSetupStringSize = DoQueryIEEEBlock_Bytes(":SYSTem:SETup?")
Debug.Print "Setup bytes saved: " + CStr(lngSetupStringSize)

' Output setup string to a file:


Dim strPath As String
strPath = "c:\scope\config\setup.dat"
If Len(Dir(strPath)) Then
Kill strPath ' Remove file if it exists.
End If

' Open file for output.


Dim hFile As Long
hFile = FreeFile
Open strPath For Binary Access Write Lock Write As hFile
Dim lngI As Long
For lngI = 0 To lngSetupStringSize - 1
Put hFile, , byteArray(lngI) ' Write data.
Next lngI

1290 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Close hFile ' Close file.

' Change settings with individual commands:


' -----------------------------------------------------------------

' Set vertical scale and offset.


DoCommand ":CHANnel1:SCALe 0.05"
Debug.Print "Channel 1 vertical scale: " + _
DoQueryString(":CHANnel1:SCALe?")

DoCommand ":CHANnel1:OFFSet -1.5"


Debug.Print "Channel 1 vertical offset: " + _
DoQueryString(":CHANnel1:OFFSet?")

' Set horizontal scale and position.


DoCommand ":TIMebase:SCALe 0.0002"
Debug.Print "Timebase scale: " + _
DoQueryString(":TIMebase:SCALe?")

DoCommand ":TIMebase:POSition 0.0"


Debug.Print "Timebase position: " + _
DoQueryString(":TIMebase:POSition?")

' Set the acquisition type (NORMal, PEAK, AVERage, or HRESolution).


DoCommand ":ACQuire:TYPE NORMal"
Debug.Print "Acquire type: " + _
DoQueryString(":ACQuire:TYPE?")

' Or, configure by loading a previously saved setup.


' -----------------------------------------------------------------
strPath = "c:\scope\config\setup.dat"
Open strPath For Binary Access Read As hFile ' Open file for input.
Dim lngSetupFileSize As Long
lngSetupFileSize = LOF(hFile) ' Length of file.
Get hFile, , byteArray ' Read data.
Close hFile ' Close file.
' Write setup string back to oscilloscope using ":SYSTem:SETup"
' command:
Dim lngRestored As Long
lngRestored = DoCommandIEEEBlock(":SYSTem:SETup", lngSetupFileSize)
Debug.Print "Setup bytes restored: " + CStr(lngRestored)

' Capture an acquisition using :DIGitize.


' -----------------------------------------------------------------
DoCommand ":DIGitize CHANnel1"

Exit Sub

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

'
' Analyze the captured waveform.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1291


40 Programming Examples

' -------------------------------------------------------------------

Private Sub Analyze()

On Error GoTo ErrorHandler

' Make a couple of measurements.


' -----------------------------------------------------------------
DoCommand ":MEASure:SOURce CHANnel1"
Debug.Print "Measure source: " + _
DoQueryString(":MEASure:SOURce?")

DoCommand ":MEASure:FREQuency"
dblQueryResult = DoQueryNumber(":MEASure:FREQuency?")
MsgBox "Frequency:" + vbCrLf + _
FormatNumber(dblQueryResult / 1000, 4) + " kHz"

DoCommand ":MEASure:VAMPlitude"
dblQueryResult = DoQueryNumber(":MEASure:VAMPlitude?")
MsgBox "Vertical amplitude:" + vbCrLf + _
FormatNumber(dblQueryResult, 4) + " V"

' Download the screen image.


' -----------------------------------------------------------------
DoCommand ":HARDcopy:INKSaver OFF"

' Get screen image.


Dim lngBlockSize As Long
lngBlockSize = DoQueryIEEEBlock_Bytes(":DISPlay:DATA? PNG, COLor")
Debug.Print "Screen image bytes: " + CStr(lngBlockSize)

' Save screen image to a file:


Dim strPath As String
strPath = "c:\scope\data\screen.png"
If Len(Dir(strPath)) Then
Kill strPath ' Remove file if it exists.
End If
Dim hFile As Long
hFile = FreeFile
Open strPath For Binary Access Write Lock Write As hFile
Dim lngI As Long
' Skip past header.
For lngI = CInt(Chr(byteArray(1))) + 2 To lngBlockSize - 1
Put hFile, , byteArray(lngI) ' Write data.
Next lngI
Close hFile ' Close file.
MsgBox "Screen image written to " + strPath

' Download waveform data.


' -----------------------------------------------------------------

' Set the waveform points mode.


DoCommand ":WAVeform:POINts:MODE RAW"
Debug.Print "Waveform points mode: " + _
DoQueryString(":WAVeform:POINts:MODE?")

' Get the number of waveform points available.

1292 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

DoCommand ":WAVeform:POINts 10240"


Debug.Print "Waveform points available: " + _
DoQueryString(":WAVeform:POINts?")

' Set the waveform source.


DoCommand ":WAVeform:SOURce CHANnel1"
Debug.Print "Waveform source: " + _
DoQueryString(":WAVeform:SOURce?")

' Choose the format of the data returned (WORD, BYTE, ASCII):
DoCommand ":WAVeform:FORMat BYTE"
Debug.Print "Waveform format: " + _
DoQueryString(":WAVeform:FORMat?")

' Display the waveform settings:


Dim Preamble() As Double
Dim intFormat As Integer
Dim intType As Integer
Dim lngPoints As Long
Dim lngCount As Long
Dim dblXIncrement As Double
Dim dblXOrigin As Double
Dim lngXReference As Long
Dim sngYIncrement As Single
Dim sngYOrigin As Single
Dim lngYReference As Long

Preamble() = DoQueryNumbers(":WAVeform:PREamble?")

intFormat = Preamble(0)
intType = Preamble(1)
lngPoints = Preamble(2)
lngCount = Preamble(3)
dblXIncrement = Preamble(4)
dblXOrigin = Preamble(5)
lngXReference = Preamble(6)
sngYIncrement = Preamble(7)
sngYOrigin = Preamble(8)
lngYReference = Preamble(9)

If intFormat = 0 Then
Debug.Print "Waveform format: BYTE"
ElseIf intFormat = 1 Then
Debug.Print "Waveform format: WORD"
ElseIf intFormat = 2 Then
Debug.Print "Waveform format: ASCii"
End If

If intType = 0 Then
Debug.Print "Acquisition type: NORMal"
ElseIf intType = 1 Then
Debug.Print "Acquisition type: PEAK"
ElseIf intType = 2 Then
Debug.Print "Acquisition type: AVERage"
ElseIf intType = 3 Then
Debug.Print "Acquisition type: HRESolution"
End If

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1293


40 Programming Examples

Debug.Print "Waveform points: " + _


FormatNumber(lngPoints, 0)

Debug.Print "Waveform average count: " + _


FormatNumber(lngCount, 0)

Debug.Print "Waveform X increment: " + _


Format(dblXIncrement, "Scientific")

Debug.Print "Waveform X origin: " + _


Format(dblXOrigin, "Scientific")

Debug.Print "Waveform X reference: " + _


FormatNumber(lngXReference, 0)

Debug.Print "Waveform Y increment: " + _


Format(sngYIncrement, "Scientific")

Debug.Print "Waveform Y origin: " + _


FormatNumber(sngYOrigin, 0)

Debug.Print "Waveform Y reference: " + _


FormatNumber(lngYReference, 0)

' Get the waveform data


Dim lngNumBytes As Long
lngNumBytes = DoQueryIEEEBlock_Bytes(":WAVeform:DATA?")
Debug.Print "Number of data values: " + _
CStr(lngNumBytes - CInt(Chr(byteArray(1))) - 2)

' Set up output file:


strPath = "c:\scope\data\waveform_data.csv"

' Open file for output.


Open strPath For Output Access Write Lock Write As hFile

' Output waveform data in CSV format.


Dim lngDataValue As Long

' Skip past header.


For lngI = CInt(Chr(byteArray(1))) + 2 To lngNumBytes - 2
lngDataValue = CLng(byteArray(lngI))

' Write time value, voltage value.


Print #hFile, _
FormatNumber(dblXOrigin + (lngI * dblXIncrement), 9) + _
", " + _
FormatNumber(((lngDataValue - lngYReference) * _
sngYIncrement) + sngYOrigin)

Next lngI

' Close output file.


Close hFile ' Close file.
MsgBox "Waveform format BYTE data written to " + _
"c:\scope\data\waveform_data.csv."

1294 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

Exit Sub

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

Private Sub DoCommand(command As String)

On Error GoTo ErrorHandler

Call ivprintf(id, command + vbLf)

CheckInstrumentErrors

Exit Sub

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

Private Function DoCommandIEEEBlock(command As String, _


lngBlockSize As Long)

On Error GoTo ErrorHandler

' Send command part.


Call ivprintf(id, command + " ")

' Write definite-length block bytes.


Call ifwrite(id, byteArray(), lngBlockSize, vbNull, retCount)

' retCount is now actual number of bytes written.


DoCommandIEEEBlock = retCount

CheckInstrumentErrors

Exit Function

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Function

Private Function DoQueryString(query As String) As String

Dim actual As Long

On Error GoTo ErrorHandler

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1295


40 Programming Examples

Dim strResult As String * 200

Call ivprintf(id, query + vbLf)


Call ivscanf(id, "%200t", strResult)
DoQueryString = strResult

CheckInstrumentErrors

Exit Function

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Function

Private Function DoQueryNumber(query As String) As Double

On Error GoTo ErrorHandler

Dim dblResult As Double

Call ivprintf(id, query + vbLf)


Call ivscanf(id, "%lf" + vbLf, dblResult)
DoQueryNumber = dblResult

CheckInstrumentErrors

Exit Function

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Function

Private Function DoQueryNumbers(query As String) As Double()

On Error GoTo ErrorHandler

Dim dblResults(10) As Double

Call ivprintf(id, query + vbLf)


Call ivscanf(id, "%,10lf" + vbLf, dblResults)
DoQueryNumbers = dblResults

CheckInstrumentErrors

Exit Function

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

1296 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

End Function

Private Function DoQueryIEEEBlock_Bytes(query As String) As Long

On Error GoTo ErrorHandler

' Send query.


Call ivprintf(id, query + vbLf)

' Read definite-length block bytes.


Sleep 2000 ' Delay before reading data.
Call ifread(id, byteArray(), ByteArraySize, vbNull, retCount)

' Get number of block length digits.


Dim intLengthDigits As Integer
intLengthDigits = CInt(Chr(byteArray(1)))

' Get block length from those digits.


Dim strBlockLength As String
strBlockLength = ""
Dim i As Integer
For i = 2 To intLengthDigits + 1
strBlockLength = strBlockLength + Chr(byteArray(i))
Next

' Return number of bytes in block plus header.


DoQueryIEEEBlock_Bytes = CLng(strBlockLength) + intLengthDigits + 2

CheckInstrumentErrors

Exit Function

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Function

Private Sub CheckInstrumentErrors()

On Error GoTo ErrorHandler

Dim strErrVal As String * 200


Dim strOut As String

Call ivprintf(id, ":SYSTem:ERRor?" + vbLf) ' Query any errors data.


Call ivscanf(id, "%200t", strErrVal) ' Read: Errnum,"Error String".
While Val(strErrVal) <> 0 ' End if find: +0,"No Error".
strOut = strOut + "INST Error: " + strErrVal
Call ivprintf(id, ":SYSTem:ERRor?" + vbLf) ' Request error message
.
Call ivscanf(id, "%200t", strErrVal) ' Read error message.
Wend

If Not strOut = "" Then

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1297


40 Programming Examples

MsgBox strOut, vbExclamation, "INST Error Messages"


Call iflush(id, I_BUF_READ Or I_BUF_WRITE)

End If

Exit Sub

ErrorHandler:

MsgBox "*** Error : " + Error, vbExclamation


End

End Sub

1298 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Programming Examples 40

SCPI.NET Examples
You can also program the oscilloscope using the SCPI.NET drivers that come with
Keysight's free Command Expert software.
While you can write code manually using the SCPI.NET drivers, you can also use
the Command Expert software to:
• Connect to instruments and control them interactively using SCPI command
sets.
• Quickly prototype and test command sequences.
• Generate C#, VB.NET, or C/C++ code for command sequences.
• Find, download, and install SCPI command sets.
• Browse command trees, search for commands, and view command
descriptions.
The Command Expert suite also comes with Add-ons for easy instrument control
and measurement data retrieval in NI LabVIEW, Microsoft Excel, Keysight VEE, and
Keysight SystemVue.
To download the Keysight Command Expert software, see:
http://www.keysight.com/find/commandexpert
For more on programming with the SCPI.NET drivers, see "Using SCPI.NET
Drivers" in the help that comes with Keysight Command Expert.

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1299


40 Programming Examples

1300 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index
Symbols all (snapshot) measurement, 422 ARINC 429 base, 653
ALL segments waveform save option, 641 ARINC 429 demo signal, 292
AM demo signal, 290 ARINC 429 signal speed, 660
+9.9E+37, infinity representation, 1171 AM depth, waveform generator ARINC 429 signal type, 658
+9.9E+37, measurement error, 421 modulation, 1040 ARINC 429 source, 659
AM modulation type, waveform ARINC 429 trigger data pattern, 662, 823
generator, 1050 ARINC 429 trigger label, 661, 665, 821
Numerics amplitude, vertical, 434, 472 ARINC 429 trigger SDI pattern, 663, 824
amplitude, waveform generator, 1056 ARINC 429 trigger SSM pattern, 664, 825
0 (zero) values in waveform data, 993 analog channel coupling, 272 ARINC 429 trigger type, 666, 822
1 (one) values in waveform data, 993 analog channel display, 273 ARINC 429 word and error counters,
7000B Series oscilloscopes, command analog channel impedance, 274 reset, 655
differences from, 51 analog channel input, 1081 ARINC 429 word format, 657
82350B GPIB interface, 6 analog channel inversion, 275 Arm Event Register (AER), 198, 213, 215,
analog channel labels, 276, 316 1146
analog channel offset, 277 arming edge slope, Edge Then Edge
A analog channel protection lock, 880 trigger, 916
analog channel range, 284 arming edge source, Edge Then Edge
A429 SEARch commands, 820 analog channel scale, 285 trigger, 917
A429 serial bus commands, 650 analog channel source for glitch, 941 arrange waveforms, 1084
absolute math function, 357 analog channel units, 286 ASCII format, 995
absolute value math function, 336 analog channels only oscilloscopes, 6 ASCII format for data transfer, 988
AC coupling, trigger edge, 928 analog probe attenuation, 278 ASCII string, quoted, 164
AC input coupling for specified analog probe head type, 279 ASCiixy waveform data format, 638
channel, 272 analog probe sensing, 1082 assign channel names, 276
AC RMS measured on waveform, 438, 479 analog probe skew, 281, 1080 attenuation factor (external trigger)
accumulate activity, 197 analyzing captured data, 65 probe, 329
ACQuire commands, 233 angle brackets, 164 attenuation for oscilloscope probe, 278
acquire data, 205, 245 annotate channels, 276 audio channel, I2S trigger, 716
acquire mode on autoscale, 201 annotation background, display, 308 AUT option for probe sense, 1082, 1086
acquire reset conditions, 182, 877 annotation color, display, 309 Auto Range capability for DVM, 320
acquire sample rate, 244 annotation text, display, 310 auto set up, trigger level, 909
ACQuire subsystem, 69 annotation, display, 307 auto setup (ARINC 429), 652
acquired data points, 238 apparent power, 489, 579 auto setup for M1553 trigger, 750
acquisition count, 236 apply network printer connection auto setup for power analysis signals, 581
acquisition mode, 233, 237, 1010 settings, 376 auto trigger sweep mode, 903
acquisition type, 233, 245 arbitrary waveform generator output, 1036 automask create, 511
acquisition types, 985 arbitrary waveform, byte order, 1023 automask source, 512
active edges, 197 arbitrary waveform, capturing from other automask units, 513
active printer, 370 sources, 1031 automatic measurements constants, 278
activity logic levels, 197 arbitrary waveform, clear, 1028 automatic probe type detection, 1082,
activity on digital channels, 197 arbitrary waveform, download DAC 1086
add function, 1005 values, 1029 autoscale, 199
add math function, 336, 357 arbitrary waveform, download floating-point autoscale acquire mode, 201
add math function as g(t) source, 350 values, 1024 autoscale channels, 202
address field size, IIC serial decode, 726 arbitrary waveform, interpolation, 1030 AUToscale command, 68
address of network printer, 375 arbitrary waveform, points, 1027 autoset for FLEXray event trigger, 697
address, IIC trigger pattern, 729 arbitrary waveform, recall, 615 autosetup for FLEXray decode, 687
Addresses softkey, 58 arbitrary waveform, save, 624 average value measurement, 435, 473
AER (Arm Event Register), 198, 213, 215, area for hardcopy print, 369 Average, power modulation analysis, 569
1146 area for saved image, 1117 averaging acquisition type, 234, 987
ALB waveform data format, 38 area measurement, 423, 433 averaging, synchronizing with, 1160
alignment, I2S trigger, 707 ARINC 429 auto setup, 652 Ax + B math function, 336, 357

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1301


Index

B C, VISA library example, 1207 channel threshold, 1079


C#, VISA COM example, 1183 channel vernier, 287
C#, VISA example, 1226 channel, stop displaying, 204
bandwidth filter limits, 270, 328 C#, VISA.NET example, 1260 CHANnel<n> commands, 267, 269
bandwidth filter limits to 20 MHz, 271 CAL PROTECT button, 262 channels to autoscale, 202
bar chart of current harmonics results, 556 CAL PROTECT switch, 258 channels, how autoscale affects, 199
base 10 exponential math function, 337, calculating preshoot of waveform, 452 characters to display, 873
357 calculating the waveform overshoot, 446 chart logic bus state math function, 337,
base value measurement, 436, 474 calibrate, 259, 260, 262, 266 357
base, ARINC 429, 653 CALibrate commands, 257 chart logic bus state, clock edge, 339
base, I2S serial decode, 708 calibrate date, 259 chart logic bus state, clock source, 338
base, MIL-STD-1553 serial decode, 751 calibrate introduction, 258 chart logic bus timing math function, 337,
base, UART trigger, 787 calibrate label, 260 357
basic instrument functions, 169 calibrate output, 261 chart logic bus, units, 342
baud rate, 676, 739, 776 calibrate start, 263 chart logic bus, value for data = 0, 341
begin acquisition, 205, 225, 227 calibrate status, 264 chart logic bus, value for data
BHARris window for minimal spectral calibrate switch, 262 increment, 340
leakage, 347 calibrate temperature, 265 classes of input signals, 347
binary block data, 164, 312, 888, 993 calibrate time, 266 classifications, command, 1164
BINary waveform data format, 638 CAN acknowledge, 675 clear, 311
bind levels for masks, 532 CAN and LIN demo signal, 292 clear bus command, 252
bit order, 777 CAN baud rate, 676 clear cumulative edge variables, 1077
bit order, SPI decode, 758 CAN demo signal, 292 clear markers, 426, 1095
bit rate measurement, 424 CAN frame counters, reset, 672 clear measurement, 426, 1095
bit selection command, bus, 249 CAN SEARch commands, 826 clear message queue, 171
bit weights, 174 CAN serial bus commands, 668 Clear method, 67
bitmap display, 312 CAN serial search, data, 828 clear reference waveforms, 1063
bits in Service Request Enable CAN serial search, data length, 829 clear screen, 1085
Register, 187 CAN serial search, ID, 830 clear status, 171
bits in Standard Event Status Enable CAN serial search, ID mode, 831 clear waveform area, 306
Register, 172 CAN serial search, mode, 827 clipped high waveform data value, 993
bits in Status Byte Register, 189 CAN signal definition, 677 clipped low waveform data value, 993
bits selection command, bus, 250 CAN source, 678 clock, 727, 759, 762
blank, 204 CAN trigger, 679, 682 clock slope, I2S, 709
block data, 164, 177, 888 CAN trigger data pattern, 681 CLOCk source, I2S, 711
block response data, 72 CAN trigger ID pattern, 683 clock source, setup and hold trigger, 959
blocking synchronization, 1155 CAN trigger pattern id mode, 684 clock timeout, SPI, 760
blocking wait, 1154 CAN triggering, 645 clock with infrequent glitch demo
BMP format screen image data, 312 capture data, 205 signal, 291
braces, 163 capturing data, 64 CLS (Clear Status), 171
built-in measurements, 65 cardiac waveform generator output, 1035 CME (Command Error) status bit, 172, 174
burst data demo signal, 291 center frequency set, 336, 344 CMOS threshold voltage for digital
burst width measurement, 425 center of screen, 1018 channels, 303, 1079
burst, minimum time before next, 924 center reference, 896 CMOS trigger threshold voltage, 1121
bus bit selection command, 249 center screen, vertical value at, 356, 360 code, :ACQuire:COMPlete, 235
bus bits selection commands, 250 channel, 231, 276, 1077, 1079 code, :ACQuire:SEGMented, 241
bus clear command, 252 channel coupling, 272 code, :ACQuire:TYPE, 246
bus commands, 248 channel display, 273 code, :AUToscale, 200
BUS data format, 990 channel input impedance, 274 code, :CHANnel<n>:LABel, 276
bus display, 253 channel inversion, 275 code, :CHANnel<n>:PROBe, 278
bus label command, 254 channel label, 276, 1078 code, :CHANnel<n>:RANGe, 284
bus mask command, 255 channel labels, 315, 316 code, :DIGitize, 206
BUS<n> commands, 247 channel numbers, 1084 code, :DISPlay:DATA, 312
button disable, 875 channel overload, 283 code, :DISPlay:LABel, 315
button, calibration protect, 262 channel protection, 283 code, :DISPlay:ORDer, 1084
byte format for data transfer, 989, 995 channel reset conditions, 182, 877 code, :MEASure:PERiod, 460
BYTeorder, 991 channel selected to produce trigger, 941, code, :MEASure:RESults, 454
972 code, :MEASure:TEDGe, 469
channel signal type, 282 code, :MTESt, 507
C channel skew for oscilloscope probe, 281, code, :POD<n>:THReshold, 543
1080 code, :RUN/:STOP, 225
C, SICL library example, 1279 channel status, 228, 1084 code, :SYSTem:SETup, 888

1302 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

code, :TIMebase:DELay, 1120 common command headers, 1167 cursors track measurements, 459
code, :TIMebase:MODE, 893 common logarithm math function, 337 cursors, how autoscale affects, 199
code, :TIMebase:RANGe, 895 completion criteria for an acquisition, 235, cursors, X1, X2, Y1, Y2, 390
code, :TIMebase:REFerence, 896 236 cycle count base, FLEXray frame
code, :TRIGger:MODE, 912 compound command headers, 1167 trigger, 700
code, :TRIGger:SLOPe, 931 compound header, 1169 cycle count repetition, FLEXray frame
code, :TRIGger:SOURce, 932 computer control examples, 1173 trigger, 701
code, :VIEW and :BLANk, 231 conditions for external trigger, 327 cycle measured, 439, 442
code, :WAVeform, 1006 conditions, reset, 182, 877 cycle time, 449
code, :WAVeform:DATA, 993 conduction calculation method for switching cycles analyzed, number of, 582, 583
code, :WAVeform:POINts, 997 loss, 603
code, :WAVeform:PREamble, 1001 Config softkey, 58
code, :WAVeform:SEGMented, 241 configurations, oscilloscope, 177, 181, D
code, :WGEN:ARBitrary:DATA, 1024 185, 888
code, *RST, 184 Configure softkey, 58 D- source, 979
code, SICL library example in C, 1279 connect oscilloscope, 57 D+ source, 980
code, SICL library example in Visual connect sampled data points, 1083 data, 728, 730, 993
Basic, 1288 Connection Expert, 59 data (waveform) maximum length, 640
code, VISA COM library example in constants for making automatic data 2, 731
C#, 1183 measurements, 278 data acquisition types, 985
code, VISA COM library example in constants for scaling display factors, 278 data conversion, 987
Python, 1200 constants for setting trigger levels, 278 data format for transfer, 988
code, VISA COM library example in Visual controller initialization, 64 data output order, 991
Basic, 1174 copy display, 221 data pattern length, 682, 747
code, VISA COM library example in Visual copyright, 2 data pattern, ARINC 429 trigger, 662, 823
Basic .NET, 1192 core commands, 1164 data pattern, CAN trigger, 681
code, VISA library example in C, 1207 count, 992 data point index, 1015
code, VISA library example in C#, 1226 count values, 236 data points, 238
code, VISA library example in count, Edge Then Edge trigger, 919 data record, measurement, 998
Python, 1247, 1253 count, Nth edge of burst, 923 data record, raw acquisition, 998
code, VISA library example in Visual counter, 427 data required to fill time buckets, 235
Basic, 1216 coupling, 928 DATA source, I2S, 712
code, VISA library example in Visual Basic COUPling demo signal, 290 data source, setup and hold trigger, 960
.NET, 1237 coupling for channels, 272 data structures, status reporting, 1133
code, VISA.NET library example in create automask, 511 data, saving and recalling, 306
C#, 1260 crest factor, 491, 579 date, calibration, 259
code, VISA.NET library example in CSV (Comma Separated Values) waveform date, system, 871
IronPython, 1273 data format, 638 dB versus frequency, 336
code, VISA.NET library example in Visual cumulative edge activity, 1077 DC coupling for edge trigger, 928
Basic .NET, 1266 current harmonics analysis fail count, 557 DC input coupling for specified
colon, root commands prefixed by, 196 current harmonics analysis results, channel, 272
color palette for hardcopy, 381 save, 634 DC offset correction for integrate
color palette for image, 630 current harmonics analysis run count, 560 input, 353
Comma Separated Values (CSV) waveform current harmonics analysis, apply, 554 DC RMS measured on waveform, 438, 479
data format, 638 current harmonics results data, 555 DC waveform generator output, 1034
command classifications, 1164 current harmonics results display, 556 DDE (Device Dependent Error) status
command differences from 7000B Series current logic levels on digital bit, 172, 174
oscilloscopes, 51 channels, 197 decision chart, status reporting, 1151
command errors detected in Standard Event current oscilloscope configuration, 177, default conditions, 182, 877
Status, 174 181, 185, 888 define channel labels, 276
Command Expert, 1260, 1299 current probe, 286, 331 define glitch trigger, 939
command header, 1165 CURRent segment waveform save define logic thresholds, 1079
command headers, common, 1167 option, 641 define measurement, 429
command headers, compound, 1167 current source, 598 define measurement source, 460
command headers, simple, 1167 cursor mode, 391 define trigger, 940, 948, 949, 951
command strings, valid, 1165 cursor position, 392, 394, 396, 399, 403 defined as, 163
commands quick reference, 77 cursor readout, 1096, 1100, 1101 definite-length block query response, 72
commands sent over interface, 170 cursor reset conditions, 182, 877 definite-length block response data, 164
commands, more about, 1163 cursor source, 393, 395 delay measured to calculate phase, 450
commands, obsolete and cursor time, 1096, 1100, 1101 delay measurement, 429
discontinued, 1071 cursor units, X, 397, 398 delay measurements, 468
common (*) commands, 3, 167, 169 cursor units, Y, 404, 405 delay parameters for measurement, 431

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1303


Index

delay time, Edge Then Edge trigger, 918 display for channels, 273 edge slope, 931
DELay trigger commands, 915 display frequency span, 345 edge source, 932
delay, how autoscale affects, 199 display measurements, 420, 459 edge string for OR'ed edge trigger, 943
delayed time base, 893 display order, 1084 EDGE trigger commands, 927
delayed window horizontal scale, 901 display persistence, 317 edge triggering, 904
delete mask, 521 display reference, 894, 896 edges (activity) on digital channels, 197
delta time, 1096 display reference waveforms, 1064 edges in measurement, 429
delta voltage measurement, 1104 display reset conditions, 183, 878 efficiency, 492
delta X cursor, 390 display serial number, 226 efficiency power analysis, apply, 552
delta Y cursor, 390 display vectors, 318 elapsed time in mask test, 518
demo, 289 display wave position, 1084 ellipsis, 164
DEMO commands, 289 display, lister, 387 enable channel labels, 315
demo signal, 291 display, measurement statistics on/off, 463 enabling calibration, 262
demo signal function, 290 display, oscilloscope, 299, 317, 343, 541, enabling channel display, 273
demo signal phase angle, 294 873 enabling status register bits, 172, 186
demo signals output control, 295 display, serial decode bus, 648 end of string (EOS) terminator, 1166
deskew for power measurements, 551 displaying a baseline, 914 end of text (EOT) terminator, 1166
destination, remote command logging, 882 displaying unsynchronized signal, 914 end or identify (EOI), 1166
detecting probe types, 1082, 1086 divide math function, 336, 357 energy loss, 493
device-defined error queue clear, 171 DNS IP, 58 EOI (end or identify), 1166
DIFF source for function, 1087 domain, 58 EOS (end of string) terminator, 1166
differences from 7000B Series oscilloscope domain, network printer, 377 EOT (end of text) terminator, 1166
commands, 51 driver, printer, 1093 erase data, 311
differential probe heads, 279 DSO models, 6 erase measurements, 1095
differential signal type, 282 duplicate mnemonics, 1169 erase screen, 1085
differentiate math function, 336, 357, duration, 948, 949, 951 error counter (ARINC 429), 654
1005 duration for glitch trigger, 935, 936, 940 error counter (ARINC 429), reset, 655
digital channel commands, 298, 299, 300, duration of power analysis, 584, 585, 586, error frame count (CAN), 670
301, 303 587, 588, 589 error frame count (UART), 778
digital channel data, 989 duration qualifier, trigger, 948, 949 error messages, 874, 1123
digital channel labels, 316 duration triggering, 904 error number, 874
digital channel order, 1084 duty cycle measurement, 65, 420, 439, error queue, 874, 1143
digital channel source for glitch 442 error, measurement, 420
trigger, 941 Duty Cycle, power modulation ESB (Event Status Bit), 187, 189
digital channels, 6 analysis, 569 ESE (Standard Event Status Enable
digital channels, activity and logic levels DVM commands, 319 Register), 172, 1142
on, 197 DVM displayed value, 321 ESR (Standard Event Status Register), 174,
digital channels, groups of, 539, 541, 543 DVM enable/disable, 322 1141
digital pod, stop displaying, 204 DVM frequency value, 323 ETE demo signal, 291
digital reset conditions, 183, 878 DVM input source, 325 event status conditions occurred, 189
DIGital<d> commands, 297 DVM mode, 324 Event Status Enable Register (ESE), 172,
digitize channels, 205 1142
DIGitize command, 64, 69, 986 Event Status Register (ESR), 174, 230,
digits, 164 E 1141
disable front panel, 875 example code, :ACQuire:COMPlete, 235
disable function, 1088 EBURst trigger commands, 922 example code, :ACQuire:SEGMented, 241
disabling calibration, 262 ECL channel threshold, 1079 example code, :ACQuire:TYPE, 246
disabling channel display, 273 ECL threshold voltage for digital example code, :AUToscale, 200
disabling status register bits, 172, 186 channels, 303 example code, :CHANnel<n>:LABel, 276
discontinued and obsolete ECL trigger threshold voltage, 1121 example code, :CHANnel<n>:PROBe, 278
commands, 1071 edge activity, 1077 example code, :CHANnel<n>:RANGe, 284
display annotation, 307 edge counter, Edge Then Edge trigger, 919 example code, :DIGitize, 206
display annotation background, 308 edge counter, Nth edge of burst, 923 example code, :DISPlay:DATA, 312
display annotation color, 309 edge coupling, 928 example code, :DISPlay:LABel, 315
display annotation text, 310 edge fall time, 440 example code, :DISPlay:ORDer, 1084
display channel labels, 315 edge parameter for delay example code, :MEASure:PERiod, 460
display clear, 311 measurement, 431 example code, :MEASure:RESults, 454
DISPlay commands, 305 edge preshoot measured, 452 example code, :MEASure:TEDGe, 469
display commands introduction, 306 edge rise time, 457 example code, :MTESt, 507
display connect, 1083 EDGE SEARch commands, 800 example code, :POD<n>:THReshold, 543
display date, 871 edge search slope, 801 example code, :RUN/:STOP, 225
display factors scaling, 278 edge search source, 802 example code, :SYSTem:SETup, 888

1304 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

example code, :TIMebase:DELay, 1120 filename for hardcopy, 1090 frequency measurements with X
example code, :TIMebase:MODE, 893 filename for recall, 616, 1032 cursors, 397
example code, :TIMebase:RANGe, 895 filename for save, 625 frequency resolution, 347
example code, :TIMebase:REFerence, 896 filter for frequency reject, 930 frequency span of display, 345
example code, :TRIGger:MODE, 912 filter for high frequency reject, 907 frequency versus dB, 336
example code, :TRIGger:SLOPe, 931 filter for noise reject, 913 Frequency, power modulation analysis, 569
example code, :TRIGger:SOURce, 932 filter used to limit bandwidth, 271, 328 front panel mode, 914
example code, :VIEW and :BLANk, 231 filters to Fast Fourier Transforms, 347 front panel Single key, 227
example code, :WAVeform, 1006 filters, math, 337 front panel Stop key, 229
example code, :WAVeform:DATA, 993 fine horizontal adjustment (vernier), 898 front-panel lock, 875
example code, :WAVeform:POINts, 997 fine vertical adjustment (vernier), 287 FSK modulation type, waveform
example code, finish pending device operations, 178 generator, 1050
:WAVeform:PREamble, 1001 first point displayed, 1015 FSK rate, waveform generator
example code, FLATtop window for amplitude modulation, 1045
:WAVeform:SEGMented, 241 measurements, 347 full-scale horizontal time, 895, 900
example code, FLEXray autoset for event trigger, 697 full-scale vertical axis defined, 359
:WGEN:ARBitrary:DATA, 1024 FLEXray autosetup, 687 function, 231, 343, 344, 345, 347, 356,
example code, *RST, 184 FlexRay demo signal, 292 357, 359, 360, 361, 1087, 1088
example programs, 5, 1173 FlexRay frame counters, reset, 691 FUNCtion commands, 333
examples on the website, 1173 FLEXray SEARch commands, 832 function memory, 228
EXE (Execution Error) status bit, 172, 174 FlexRay serial search, cycle, 833 function turned on or off, 1088
execution error detected in Standard Event FlexRay serial search, data, 834 function, demo signal, 290
Status, 174 FlexRay serial search, data length, 835 function, first source input, 362
exponential fall waveform generator FlexRay serial search, frame, 836 function, second source input, 364
output, 1035 FlexRay serial search, mode, 837 function, waveform generator, 1033
exponential math function, 337, 357 FLEXray source, 694 functions, 1005
exponential notation, 163 FLEXray trigger, 695
exponential rise waveform generator FLEXray trigger commands, 685
output, 1035 FM burst demo signal, 290 G
extended video triggering license, 973 FM modulation type, waveform
external glitch trigger source, 941 generator, 1050 g(t) source, first input channel, 351
external range, 330 force trigger, 906 g(t) source, math operation, 350
external trigger, 327, 329, 932 format, 995, 1000 g(t) source, second input channel, 352
EXTernal trigger commands, 327 format (word), ARINC 429, 657 gain for Ax + B math operation, 354
EXTernal trigger level, 929 format for block data, 177 gateway IP, 58
external trigger probe attenuation format for generic video, 969, 973 gaussian pulse waveform generator
factor, 329 format for hardcopy, 1089 output, 1035
external trigger probe sensing, 1086 format for image, 628 general SBUS<n> commands, 647
EXTernal trigger source, 932 format for waveform data, 638 general SEARch commands, 796
external trigger units, 331 FormattedIO488 object, 67 general trigger commands, 905
formfeed for hardcopy, 368, 372 GENeric, 969, 973
formulas for data conversion, 987 generic video format, 969, 973
F frame, 763 Generic video trigger, edge number, 974
frame counters (CAN), error, 670 Generic video trigger, greater than sync
fail count, current harmonics analysis, 557 frame counters (CAN), overload, 671 pulse width time, 977
fail/pass status (overall) for current frame counters (CAN), reset, 672 Generic video trigger, horizontal sync
harmonics analysis, 562 frame counters (CAN), total, 673 control, 975
failed waveforms in mask test, 516 frame counters (FlexRay), null, 690, 692 Generic video trigger, horizontal sync pulse
failure, self test, 191 frame counters (FlexRay), reset, 691 time, 976
fall time measurement, 420, 440 frame counters (FlexRay), total, 693 glitch demo signal, 291
Fall Time, power modulation analysis, 569 frame counters (UART), error, 778 glitch duration, 940
falling edge count measurement, 443 frame counters (UART), reset, 779 glitch qualifier, 939
falling pulse count measurement, 444 frame counters (UART), Rx frames, 780 GLITch SEARch commands, 803
Fast Fourier Transform (FFT) frame counters (UART), Tx frames, 781 glitch search, greater than value, 804
functions, 336, 344, 345, 347, 1087 frame ID, FLEXray BSS event trigger, 698 glitch search, less than value, 805
FF values in waveform data, 993 frame ID, FLEXray frame trigger, 702 glitch search, polarity, 806
FFT (Fast Fourier Transform) functions, 336, frame type, FLEXray frame trigger, 703 glitch search, qualifier, 807
344, 345, 347, 1087 framing, 761 glitch search, range, 808
FFT (Fast Fourier Transform) frequency deviation, waveform generator FM glitch search, source, 809
operation, 357, 1005 modulation, 1042 glitch source, 941
FFT vertical units, 346 frequency measurement, 65, 420, 441 GLITch trigger commands, 933
fifty ohm impedance, disable setting, 880 glitch trigger duration, 935

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1305


Index

glitch trigger polarity, 938 I initial load current, transient response


glitch trigger source, 935 analysis, 610
GPIB interface, 57, 58 initialization, 64, 67
graticule area for hardcopy print, 369 I1080L50HZ, 969, 973 initialize, 182, 877
graticule colors, invert for hardcopy, 373, I1080L60HZ, 969, 973 initialize label list, 316
1092 I2C demo signal, 291 initiate acquisition, 205
graticule colors, invert for image, 629 I2S alignment, 707 inksaver, save image with, 629
grayscale palette for hardcopy, 381 I2S audio channel, 716 input coupling for channels, 272
grayscale palette for image, 630 I2S clock slope, 709 input for integrate, DC offset
grayscaling on hardcopy, 1091 I2S CLOCk source, 711 correction, 353
greater than qualifier, 939 I2S DATA source, 712 input impedance for channels, 274, 1081
greater than time, 935, 940, 948, 951 I2S demo signal, 292 input inversion for specified channel, 275
greater than value for glitch search, 804 I2S pattern data, 717 input power, 495
groups of digital channels, 539, 541, 543, I2S pattern format, 719 inrush current, 499
1079 I2S range, 720 inrush current analysis, 564, 565, 566
I2S receiver width, 710 inrush current expected, 590
I2S SEARch commands, 838 insert label, 276
H I2S serial bus commands, 704 installed options identified, 179
I2S serial decode base, 708 instruction header, 1165
I2S serial search, audio channel, 839 instrument number, 176
HANNing window for frequency I2S serial search, data, 841
resolution, 347 instrument options identified, 179
I2S serial search, format, 842 instrument requests service, 189
hardcopy, 221, 368 I2S serial search, mode, 840
HARDcopy commands, 367 instrument serial number, 226
I2S serial search, range, 843 instrument settings, 368
hardcopy factors, 371, 627 I2S transmit word size, 722
hardcopy filename, 1090 instrument status, 74
I2S trigger operator, 714 instrument type, 176
hardcopy format, 1089 I2S triggering, 645
hardcopy formfeed, 372 integrate DC offset correction, 353
I2S word select (WS) low, 723 integrate math function, 336, 357, 1005
hardcopy grayscale, 1091 I2S word select (WS) source, 713
hardcopy invert graticule colors, 373, INTegrate source for function, 1087
id mode, 684 intensity, waveform, 314
1092 ID pattern, CAN trigger, 683
hardcopy layout, 374 internal low-pass filter, 270, 271, 328
identification number, 176 introduction to :ACQuire commands, 233
hardcopy palette, 381 identification of options, 179
hardcopy print, area, 369 introduction to :BUS<n> commands, 248
identifier, LIN, 744 introduction to :CALibrate commands, 258
hardcopy printer driver, 1093 idle, 924
HARMonics demo signal, 290 introduction to :CHANnel<n>
idle until operation complete, 178 commands, 269
head type, probe, 279 IDN (Identification Number), 176
header, 1165 introduction to :DEMO commands, 289
IEC 61000-3-2 standard for current introduction to :DIGital<d>
high pass filter math function, 337 harmonics analysis, 561
high resolution acquisition type, 987 commands, 298
IEEE 488.2 standard, 169 introduction to :DISPlay commands, 306
high trigger level, 910 IIC address, 729
high-frequency reject filter, 907, 930 introduction to :EXTernal commands, 327
IIC clock, 727 introduction to :FUNCtion commands, 336
high-level voltage, waveform IIC data, 728, 730
generator, 1057 introduction to :HARDcopy
IIC data 2, 731 commands, 368
high-pass filter cutoff frequency, 348 IIC SEARch commands, 844
high-pass filter math function, 357 introduction to :LISTer commands, 385
IIC serial decode address field size, 726 introduction to :MARKer commands, 390
high-resolution acquisition type, 234 IIC serial search, address, 847
hold time, setup and hold trigger, 961 introduction to :MEASure commands, 420
IIC serial search, data, 848 introduction to :POD<n> commands, 539
hold until operation complete, 178 IIC serial search, data2, 849
holdoff time, 908 introduction to :RECall commands, 614
IIC serial search, mode, 845 introduction to :SAVE commands, 623
holes in waveform data, 993 IIC serial search, qualifier, 850
hop frequency, waveform generator FSK introduction to :SBUS commands, 645
IIC trigger commands, 724 introduction to :SYSTem commands, 870
modulation, 1044 IIC trigger qualifier, 732
horizontal adjustment, fine (vernier), 898 introduction to :TIMebase commands, 892
IIC trigger type, 733 introduction to :TRIGger commands, 903
horizontal position, 899 IIC triggering, 646
horizontal scale, 897, 901 introduction to :WAVeform
image format, 628 commands, 985
horizontal scaling, 1000 image invert graticule colors, 629
horizontal time, 895, 900, 1096 introduction to :WGEN commands, 1021
image memory, 228 introduction to :WMEMory<r>
Host ID of oscilloscope, 872 image palette, 630
Host name softkey, 58 commands, 1061
image, save, 626 introduction to common (*)
hostname, 58 image, save with inksaver, 629 commands, 169
impedance, 274 introduction to root (:) commands, 196
infinity representation, 1171

1306 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

invert graticule colors for hardcopy, 373, LIN SEARch commands, 851 M1553 trigger type, 755
1092 LIN serial decode bus parity bits, 737 magnify math function, 337, 357
invert graticule colors for image, 629 LIN serial search, data, 854 magnitude of occurrence, 470
inverted masks, bind levels, 532 LIN serial search, data format, 856 main sweep range, 899
inverting input for channels, 275 LIN serial search, data length, 855 main time base, 1120
IO library, referencing, 66 LIN serial search, frame ID, 852 main time base mode, 893
IP address, 58 LIN serial search, mode, 853 making measurements, 420
IronPython, VISA.NET example, 1273 LIN source, 740 MAN option for probe sense, 1082, 1086
LIN standard, 741 manual cursor mode, 391
LIN sync break, 742 MARKer commands, 389
K LIN trigger, 743, 747 marker mode, 399
LIN trigger commands, 735 marker position, 401
key disable, 875 LIN trigger definition, 1118 marker readout, 1100, 1101
key press detected in Standard Event Status LIN triggering, 646 marker set for voltage measurement, 1105,
Register, 174 line frequency setting for current harmonics 1106
Keysight Interactive IO application, 61 analysis, 558 marker sets start time, 1097
Keysight IO Control icon, 59 line glitch trigger source, 941 marker time, 1096
Keysight IO Libraries Suite, 6, 55, 66, 68 line number for TV trigger, 969 markers for delta voltage
Keysight IO Libraries Suite, installing, 56 line terminator, 163 measurement, 1104
knob disable, 875 LINE trigger level, 929 markers track measurements, 459
known state, 182, 877 LINE trigger source, 932 markers, command overview, 390
list of channel labels, 316 markers, mode, 391
LISTer commands, 385 markers, time at start, 1101
L lister display, 387 markers, time at stop, 1100
lister time reference, 388 markers, X delta, 396
label, 1078 ln (natural logarithm) math function, 357 markers, X1 position, 392
label command, bus, 254 ln math function, 337 markers, X1Y1 source, 393
label list, 276, 316 load utilization (CAN), 674 markers, X2 position, 394
label reference waveforms, 1065 local lockout, 875 markers, X2Y2 source, 395
label, ARINC 429 trigger, 661, 665, 821 lock, 875 markers, Y delta, 403
label, digital channel, 300 lock mask to signal, 523 markers, Y1 position, 399
labels, 276, 315, 316 lock, analog channel protection, 880 markers, Y2 position, 401
labels to store calibration information, 260 lockout message, 875 mask, 172, 186
labels, specifying, 306 log (common logarithm) math function, 357 mask command, bus, 255
LAN instrument, 60 log file name, remote command mask statistics, reset, 517
LAN interface, 57, 59 logging, 881, 884 mask test commands, 505
LAN Settings softkey, 58 log math function, 337 Mask Test Event Enable Register
landscape layout for hardcopy, 374 logic level activity, 1077 (MTEenable), 207
language for program examples, 63 long form, 1166 mask test event event register, 209
layout for hardcopy, 374 low frequency sine with glitch demo Mask Test Event Event Register
leakage into peak spectrum, 347 signal, 290 (:MTERegister[:EVENt]), 209, 1148
learn string, 177, 888 low pass filter math function, 337 mask test run mode, 524
least significant byte first, 991 low trigger level, 911 mask test termination conditions, 524
left reference, 896 lower threshold, 449 mask test, all channels, 510
legal values for channel offset, 277 lower threshold voltage for mask test, enable/disable, 522
legal values for frequency span, 345 measurement, 1094 mask, delete, 521
legal values for offset, 356, 360 lowercase characters in commands, 1165 mask, get as binary block data, 520
length for waveform data, 639 low-frequency reject filter, 930 mask, load from binary block data, 520
less than qualifier, 939 low-level voltage, waveform mask, lock to signal, 523
less than time, 936, 940, 949, 951 generator, 1058 mask, recall, 617
less than value for glitch search, 805 low-pass filter cutoff frequency, 349 mask, save, 631, 632
level for trigger voltage, 929, 937 low-pass filter math function, 357 masks, bind levels, 532
LF coupling, 928 low-pass filter used to limit master summary status bit, 189
license information, 179 bandwidth, 270, 271, 328 math filters, 337
limit bandwidth, 270 LRN (Learn Device Setup), 177 math function, stop displaying, 204
limits for line number, 969 lsbfirst, 991 math operators, 336
LIN acknowledge, 738 math transforms, 336
LIN baud rate, 739 math visualizations, 337
LIN demo signal, 292
M MAV (Message Available), 171, 187, 189
LIN identifier, 744 maximum duration, 936, 948, 949
LIN pattern data, 745 M1553 SEARch commands, 857 maximum position, 894
LIN pattern format, 748 M1553 trigger commands, 749 maximum range for zoomed window, 900

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1307


Index

maximum scale for zoomed window, 901 measurements, rising edge count, 448 modulation analysis source (voltage or
maximum vertical value measurement, 475 measurements, rising pulse count, 451 current), 568
maximum vertical value, time of, 483, measurements, show, 459 modulation analysis, type of, 569
1098 measurements, snapshot all, 422 modulation type, waveform
maximum waveform data length, 640 measurements, source channel, 460 generator, 1050
MEASure commands, 407 measurements, standard deviation, 458 MOSI data pattern width, 769
measure mask test failures, 525 measurements, start marker time, 1100 MOSI data pattern, SPI trigger, 768
measure overshoot, 446 measurements, stop marker time, 1101 MOSI data source, SPI trigger, 765, 1119
measure period, 449 measurements, thresholds, 1097 most significant byte first, 991
measure phase between channels, 450 measurements, time between start and stop move cursors, 1100, 1101
MEASure power commands, 485 markers, 1096 msbfirst, 991
measure preshoot, 452 measurements, time between trigger and MSG (Message), 187, 189
measure start voltage, 1105 edge, 468 MSO models, 6
measure stop voltage, 1106 measurements, time between trigger and MSS (Master Summary Status), 189
measure value at a specified time, 480 vertical value, 470 MTEenable (Mask Test Event Enable
measure value at top of waveform, 481 measurements, time between trigger and Register), 207
measurement error, 420 voltage level, 1102 MTERegister[:EVENt] (Mask Test Event Event
measurement record, 998 measurements, upper threshold Register), 209, 1148
measurement setup, 420, 460 value, 1103 MTESt commands, 505
measurement source, 460 measurements, vertical amplitude, 434, multi-channel waveform data, save, 633
measurement statistics results, 454 472 multiple commands, 1169
measurement statistics, display on/off, 463 measurements, vertical peak-to-peak, 437, multiple queries, 73
measurement trend math function, 337, 477 multiply math function, 336, 357, 1005
357 measurements, voltage difference, 1104 multiply math function as g(t) source, 350
measurement window, 482 memory setup, 185, 888
measurements, AC RMS, 438, 479 menu, system, 876
measurements, area, 423, 433 message available bit, 189 N
measurements, average value, 435, 473 message available bit clear, 171
measurements, base value, 436, 474 message displayed, 189 N2820A high sensitivity current probe, 38,
measurements, built-in, 65 message error, 1123 433, 434, 435, 436, 437, 438
measurements, burst width, 425 message queue, 1140 N8900A InfiniiView oscilloscope analysis
measurements, clear, 426, 1095 messages ready, 189 software, 633
measurements, command overview, 420 midpoint of thresholds, 449 name channels, 276
measurements, counter, 427 MIL-STD-1553 demo signal, 292 name list, 316
measurements, DC RMS, 438, 479 MIL-STD-1553 serial decode base, 751 natural logarithm math function, 337
measurements, definition setup, 429 MIL-STD-1553 serial search, data, 859 negative glitch trigger polarity, 938
measurements, delay, 431 MIL-STD-1553 serial search, mode, 858 negative pulse width, 445
measurements, duty cycle, 439 MIL-STD-1553 serial search, Remote negative pulse width measurement, 65
measurements, fall time, 440 Terminal Address, 860 negative pulse width, power modulation
measurements, falling edge count, 443 MIL-STD-1553, dual demo signal, 292 analysis, 569
measurements, falling pulse count, 444 minimum duration, 935, 948, 949, 951 negative slope, 759, 931
measurements, frequency, 441 minimum vertical value measurement, 476 negative slope, Nth edge in burst, 925
measurements, how autoscale affects, 199 minimum vertical value, time of, 484, 1099 negative TV trigger polarity, 971
measurements, lower threshold level, 1094 MISO data pattern width, 767 network domain password, 378
measurements, maximum vertical MISO data pattern, SPI trigger, 766 network domain user name, 380
value, 475 MISO data source, SPI trigger, 764 network printer address, 375
measurements, maximum vertical value, MISO data, SPI, 1009 network printer domain, 377
time of, 483, 1098 mixed-signal demo signals, 291 network printer slot, 379
measurements, minimum vertical mixed-signal oscilloscopes, 6 network printer, apply connection
value, 476 mnemonics, duplicate, 1169 settings, 376
measurements, minimum vertical value, mode, 391, 893, 970 new line (NL) terminator, 163, 1166
time of, 484, 1099 mode, serial decode, 649 new load current, transient response
measurements, negative duty cycle, 442 model number, 176 analysis, 611
measurements, overshoot, 446 models, oscilloscope, 3 NL (new line) terminator, 163, 1166
measurements, period, 449 modes for triggering, 912 noise floor, 604, 607
measurements, phase, 450 Modify softkey, 58 noise reject filter, 913
measurements, preshoot, 452 modulating signal frequency, waveform noise waveform generator output, 1034
measurements, pulse width, negative, 445 generator, 1041, 1043 noise, adding to waveform generator
measurements, pulse width, positive, 453 modulation (waveform generator), output, 1048
measurements, ratio of AC RMS enabling/disabling, 1049 noisy sine waveform demo signal, 290
values, 478 modulation analysis, 567 non-core commands, 1164
measurements, rise time, 457 non-interlaced GENeric mode, 973

1308 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

non-volatile memory, label list, 254, 300, OPT (Option Identification), 179 parametric measurements, 420
316 optional syntax terms, 163 parity, 783
normal acquisition type, 233, 986 options, 179 parity bits, LIN serial decode bus, 737
normal trigger sweep mode, 903 OR trigger commands, 942 parser, 196, 1169
notices, 2 order of digital channels on display, 1084 pass, self test, 191
NR1 number format, 163 order of output, 991 pass/fail status (overall) for current
NR3 number format, 163 oscilloscope connection, opening, 67 harmonics analysis, 562
Nth edge burst trigger source, 926 oscilloscope connection, verifying, 59 password, network domain, 378
Nth edge burst triggering, 904 oscilloscope external trigger, 327 path information, recall, 618
Nth edge in a burst idle, 924 oscilloscope models, 3 path information, save, 635
Nth edge in burst slope, 925 oscilloscope rate, 244 pattern, 729, 730, 731
Nth edge of burst counter, 923 oscilloscope, connecting, 57 pattern data, I2S, 717
Nth edge of Edge Then Edge trigger, 919 oscilloscope, initialization, 64 pattern data, LIN, 745
NTSC, 969, 973 oscilloscope, operation, 6 pattern duration, 935, 936, 948, 949
null frame count (FlexRay), 690 oscilloscope, program structure, 64 pattern for pattern trigger, 945
null offset, 604 oscilloscope, setting up, 57 pattern format, I2S, 719
NULL string, 873 oscilloscope, setup, 68 pattern format, LIN, 748
number format, 163 output control, demo signals, 295 pattern length, 682, 747
number of points, 238, 996, 998 output control, waveform generator, 1052 PATTern trigger commands, 944
number of time buckets, 996, 998 output load impedance, waveform pattern trigger format, 947
numeric variables, 72 generator, 1053 pattern trigger qualifier, 950
numeric variables, reading query results into output messages ready, 189 pattern triggering, 904
multiple, 74 output power, 498 pattern width, 767, 769
nwidth, 445 output queue, 178, 1139 peak current, 499
output queue clear, 171 peak data, 987
output ripple, 503 peak detect, 245
O output ripple analysis, 580 peak detect acquisition type, 234, 987
output sequence, 991 peak-to-peak vertical value
obsolete and discontinued overall pass/fail status for current harmonics measurement, 437, 477
commands, 1071 analysis, 562 pending operations, 178
obsolete commands, 1164 overlapped commands, 1172 percent of waveform overshoot, 446
occurrence reported by magnitude, 1102 overload, 283 percent thresholds, 429
offset, 337 Overload Event Enable Register (OVL), 217 period measured to calculate phase, 450
offset for Ax + B math operation, 355 Overload Event Register period measurement, 65, 420, 449
offset value for channel voltage, 277 (:OVLRegister), 1147 Period, power modulation analysis, 569
offset value for selected function, 356, 360 Overload Event Register (OVLR), 219 period, waveform generator, 1054
offset, waveform generator, 1059 overload frame count (CAN), 671 persistence, waveform, 306, 317
one values in waveform data, 993 overload protection, 217, 219 phase angle, 579
OPC (Operation Complete) command, 178 overshoot of waveform, 446 phase angle, demo signals, 294
OPC (Operation Complete) status bit, 172, overshoot percent for transient response phase measured between channels, 450
174 analysis, 591 phase measurements, 468
OPEE (Operation Status Enable overvoltage, 283 phase measurements with X cursors, 397
Register), 211 OVL (Overload Event Enable Register), 217 phase shifted demo signals, 290
Open method, 67 OVLR (Overload Event Register), 219 PNG format screen image data, 312
operating configuration, 177, 888 OVLR bit, 213, 215 pod, 539, 541, 542, 543, 1005, 1079
operating state, 185 OVLRegister (Overload Event POD commands, 539
operation complete, 178 Register), 1147 POD data format, 989
operation status condition register, 213 pod, stop displaying, 204
Operation Status Condition Register points, 238, 996, 998
(:OPERegister:CONDition), 213, 1145 P points in waveform data, 986
operation status conditions occurred, 189 polarity, 784, 971
Operation Status Enable Register P1080L24HZ, 969, 973 polarity for glitch search, 806
(OPEE), 211 P1080L25HZ, 969, 973 polarity for glitch trigger, 938
operation status event register, 215 P1080L50HZ, 969, 973 polarity, runt search, 811
Operation Status Event Register P1080L60HZ, 969, 973 polarity, runt trigger, 953
(:OPERegister[:EVENt]), 215, 1144 P480L60HZ, 969, 973 polling synchronization with timeout, 1156
operations for function, 357 P720L60HZ, 969, 973 polling wait, 1154
operators, math, 336 PAL, 969, 973 PON (Power On) status bit, 172, 174
OPERegister:CONDition (Operation Status palette for hardcopy, 381 portrait layout for hardcopy, 374
Condition Register), 213, 1145 palette for image, 630 position, 301, 394, 894, 899
OPERegister[:EVENt] (Operation Status PAL-M, 969, 973 position cursors, 1100, 1101
Event Register), 215, 1144 parameters for delay measurement, 431 position in zoomed view, 899

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1309


Index

position waveforms, 1084 program message terminator, 1166 range, 337, 900
positive glitch trigger polarity, 938 program structure, 64 range for channels, 284
positive pulse width, 453 programming examples, 5, 1173 range for duration trigger, 951
positive pulse width measurement, 65 protecting against calibration, 262 range for external trigger, 330
positive pulse width, power modulation protection, 217, 219, 283 range for full-scale vertical axis, 359
analysis, 569 protection lock, 880 range for glitch search, 808
positive slope, 759, 931 pulse waveform generator output, 1034 range for glitch trigger, 940
positive slope, Nth edge in burst, 925 pulse width, 445, 453 range for time base, 895
positive TV trigger polarity, 971 pulse width duration trigger, 935, 936, range of offset values, 277
positive width, 453 940 range qualifier, 939
power analysis, enabling, 553 pulse width measurement, 65, 420 range, I2S, 720
POWer commands, 545 pulse width trigger, 913 ranges, value, 164
Power Event Enable Register pulse width trigger level, 937 rate, 244
(PWRenable), 222 pulse width triggering, 904 ratio measurements with X cursors, 397
power event event register, 224 pulse width, waveform generator, 1037 ratio measurements with Y cursors, 404
Power Event Event Register pwidth, 453 ratio of AC RMS values measured between
(:PWRRegister[:EVENt]), 224, 1149 PWRenable (Power Event Enable channels, 478
power factor, 494, 579 Register), 222 Ratio, power modulation analysis, 569
power factor for IEC 61000-3-2 Standard PWRRegister[:EVENt] (Power Event Event raw acquisition record, 998
Class C, 559 Register), 224, 1149 RCL (Recall), 181
power loss, 500 Python, VISA COM example, 1200 Rds (dynamic ON resistance)
power phase angle, 488 Python, VISA example, 1247, 1253 waveform, 603
power quality analysis, 578 PyVISA 1.5 and older, 1247 Rds(on) value for conduction
power quality type, 579 PyVISA 1.6 and newer, 1253 calculation, 605
power supply rejection ratio (PSRR), 574, reactive power, 501, 579
575, 576, 577 read configuration, 177
preamble data, 1000 Q ReadIEEEBlock method, 67, 71, 73
preamble metadata, 985 ReadList method, 67, 71
predefined logic threshold, 1079 qualifier, 940 ReadNumber method, 67, 71
predefined threshold voltages, 1121 qualifier for glitch search, 807 readout, 1096
present working directory, recall qualifier, runt search, 812 ReadString method, 67, 71
operations, 618 qualifier, runt trigger, 954 real (actual) power, 579
present working directory, save qualifier, transition search, 816 real power, 502
operations, 635 qualifier, transition trigger, 964 real-time acquisition mode, 237
preset conditions, 877 qualifier, trigger duration, 948, 949 recall, 181, 614, 888
preshoot measured on waveform, 452 qualifier, trigger pattern, 950 recall arbitrary waveform, 615
previously stored configuration, 181 queries, multiple, 73 RECall commands, 613
print command, 221 query error detected in Standard Event recall filename, 616, 1032
print job, start, 383 Status, 174 recall mask, 617
print mask test failures, 526 query responses, block data, 72 recall path information, 618
print query, 1115 query responses, reading, 71 recall reference waveform, 620
printer driver for hardcopy, 1093 query results, reading into numeric recall setup, 619
printer, active, 370 variables, 72 recalling and saving data, 306
printing, 368 query results, reading into string receiver width, I2S, 710
printing in grayscale, 1091 variables, 72 RECTangular window for transient
probe, 929 query return values, 1171 signals, 347
probe attenuation affects channel voltage query setup, 368, 390, 420, 888 reference, 337, 896
range, 284 query subsystem, 248, 298 reference for time base, 1120
probe attenuation factor (external querying setup, 269 reference waveform save source, 642
trigger), 329 querying the subsystem, 904 reference waveform, recall, 620
probe attenuation factor for selected queues, clearing, 1150 reference waveform, save, 643
channel, 278 quick reference, commands, 77 reference waveforms, clear, 1063
probe head type, 279 quoted ASCII string, 164 reference waveforms, display, 1064
probe ID, 280 QYE (Query Error) status bit, 172, 174 reference waveforms, label, 1065
probe sense for oscilloscope, 1082, 1086 reference waveforms, save to, 1066
probe skew value, 281, 1080 reference waveforms, skew, 1067
process sigma, mask test run, 529 R reference waveforms, Y offset, 1068
program data, 1166 reference waveforms, Y range, 1069
program data syntax rules, 1168 ramp symmetry, waveform generator, 1038 reference waveforms, Y scale, 1070
program initialization, 64 ramp symmetry, waveform generator reference, lister, 388
program message, 67, 170 modulating signal, 1047 registers, 174, 181, 185, 198, 207, 209,
program message syntax, 1165 ramp waveform generator output, 1034 211, 213, 215, 217, 219, 222, 224

1310 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

registers, clearing, 1150 runt search polarity, 811 SEARch commands, GLITch, 803
reject filter, 930 runt search qualifier, 812 SEARch commands, I2S, 838
reject high frequency, 907 runt search source, 813 SEARch commands, IIC, 844
reject noise, 913 runt search, pulse time, 814 SEARch commands, LIN, 851
relative standard deviation, 467 RUNT trigger commands, 952 SEARch commands, M1553, 857
remote command logging, runt trigger polarity, 953 SEARch commands, RUNT, 810
enable/disable, 881, 885 runt trigger qualifier, 954 SEARch commands, SPI, 861
remote control examples, 1173 runt trigger source, 955 SEARch commands, TRANsition, 815
Remote Terminal Address (RTA), M1553 runt trigger time, 956 SEARch commands, UART, 865
trigger, 754 Rx frame count (UART), 780 search mode, 798
remove cursor information, 391 Rx source, 785 search state, 799
remove labels, 315 search, edge slope, 801
remove message from display, 873 search, edge source, 802
reorder channels, 199 S SECAM, 969, 973
repetitive acquisitions, 225 seconds per division, 897
report errors, 874 sample rate, 244 segmented waveform save option, 641
report transition, 468, 470 sampled data, 1083 segments, analyze, 239
reporting status, 1131 sampled data points, 993 segments, count of waveform, 1003
reporting the setup, 904 SAV (Save), 185 segments, setting number of memory, 240
request service, 189 save, 185, 623 segments, setting the index, 241
Request-for-OPC flag clear, 171 save arbitrary waveform, 624 segments, time tag, 1004
reset, 182 SAVE commands, 621 select measurement channel, 460
reset conditions, 182 save current harmonics analysis self-test, 191
reset defauts, waveform generator, 1055 results, 634 sensing a channel probe, 1082
reset mask statistics, 517 save filename, 625 sensing a external trigger probe, 1086
reset measurements, 311 save image, 626 sensitivity of oscilloscope input, 278
resolution of printed copy, 1091 save image with inksaver, 629 sequential commands, 1172
resource session object, 67 save mask, 631, 632 serial clock, 727, 762
ResourceManager object, 67 save mask test failures, 527 serial data, 728
restore configurations, 177, 181, 185, 888 save path information, 635 serial decode bus, 645
restore labels, 315 save reference waveform, 643 serial decode bus display, 648
restore setup, 181 save setup, 636 serial decode mode, 649
return values, query, 1171 save to reference waveform location, 1066 serial frame, 763
returning acquisition type, 245 save waveform data, 637 serial number, 226
returning number of data points, 238 saved image, area, 1117 service request, 189
RF burst demo signal, 290 saving and recalling data, 306 Service Request Enable Register
right reference, 896 SBUS A429 commands, 650 (SRE), 187, 1137
ringing pulse demo signal, 290 SBUS CAN commands, 668 set center frequency, 344
ripple (output) analysis, 580 SBUS commands, 645 set cursors, 1100, 1101
ripple, output, 503 SBUS I2S commands, 704 set date, 871
rise time measurement, 420 SBUS<n> commands, general, 647 set time, 890
rise time of positive edge, 457 scale, 361, 897, 901 set up oscilloscope, 57
Rise Time, power modulation analysis, 569 scale factors output on hardcopy, 371, 627 setting digital display, 299
rising edge count measurement, 448 scale for channels, 285 setting digital label, 254, 300
rising pulse count measurement, 451 scale units for channels, 286 setting digital position, 301
RMS - AC, power modulation analysis, 569 scale units for external trigger, 331 setting digital threshold, 303
RMS value measurement, 438, 479 scaling display factors, 278 setting display, 343
roll time base mode, 893 SCPI commands, 75 setting external trigger level, 327
root (:) commands, 193, 196 SCPI.NET examples, 1299 setting impedance for channels, 274
root level commands, 3 scratch measurements, 1095 setting inversion for channels, 275
RQL (Request Control) status bit, 172, 174 screen area for hardcopy print, 369 setting pod display, 541
RQS (Request Service), 189 screen area for saved image, 1117 setting pod size, 542
RS-232/UART triggering, 646 screen display of logged remote commands, setting pod threshold, 543
RST (Reset), 182 enable/disable, 883 settings, 181, 185
rules, tree traversal, 1169 screen image data, 312 settings, instrument, 368
rules, truncation, 1166 SDI pattern, ARINC 429 trigger, 663, 824 setup, 234, 248, 269, 298, 306, 368,
run, 190, 225 SEARch commands, 795 888
Run bit, 213, 215 SEARch commands, A429, 820 setup and hold trigger clock source, 959
run count, current harmonics analysis, 560 SEARch commands, CAN, 826 setup and hold trigger data source, 960
run mode, mask test, 524 SEARch commands, EDGE, 800 setup and hold trigger hold time, 961
running configuration, 185, 888 SEARch commands, FLEXray, 832 setup and hold trigger setup time, 962
RUNT SEARch commands, 810 SEARch commands, general, 796 setup and hold trigger slope, 958

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1311


Index

setup configuration, 181, 185, 888 source input for function, first, 362 start time marker, 1097
setup defaults, 182, 877 source input for function, second, 364 state memory, 185
setup memory, 181 source, arming edge, Edge Then Edge state of instrument, 177, 888
setup reported, 904 trigger, 917 statistics increment, 464
setup time, setup and hold trigger, 962 source, automask, 512 statistics reset, 466
setup, recall, 619 source, FLEXray, 694 statistics results, 454
setup, save, 636 source, mask test, 537 statistics, max count, 465
shape of modulation signal, waveform source, runt search, 813 statistics, relative standard deviation, 467
generator, 1046 source, runt trigger, 955 statistics, type of, 462
SHOLd trigger commands, 957 source, save reference waveform, 642 status, 188, 228, 230
short form, 5, 1166 source, transition trigger, 818, 966 Status Byte Register (STB), 186, 188, 189,
show channel labels, 315 source, trigger edge, Edge Then Edge 1135
show measurements, 420, 459 trigger, 921 status data structure clear, 171
SICL example in C, 1279 source, waveform, 1005 status registers, 74
SICL example in Visual Basic, 1288 span, 336 status reporting, 1131
SICL examples, 1279 span of frequency on display, 345 STB (Status Byte Register), 186, 188, 189,
sigma, mask test run, 529 specify measurement, 460 1135
signal speed, ARINC 429, 660 speed of ARINC 429 signal, 660 steady state output voltage expected, 595,
signal type, 282 SPI, 759 596, 597
signal type, ARINC 429, 658 SPI clock timeout, 760 step size for frequency span, 345
signed data, 988 SPI decode bit order, 758 stop, 205, 229
simple command headers, 1167 SPI decode word width, 771 stop acquisition, 229
sine cardinal waveform generator SPI demo signal, 292 stop cursor, 1101
output, 1035 SPI MISO data, 1009 stop displaying channel, 204
sine waveform demo signal, 290 SPI SEARch commands, 861 stop displaying math function, 204
sine waveform generator output, 1033 SPI serial search, data, 863 stop displaying pod, 204
single acquisition, 227 SPI serial search, data width, 864 stop on mask test failure, 528
single-ended probe heads, 279 SPI serial search, mode, 862 stop time, 940, 1101
single-ended signal type, 282 SPI trigger, 761, 767, 769 storage, 185
single-shot demo signal, 291 SPI trigger clock, 762 store instrument setup, 177, 185
single-shot DUT, synchronizing with, 1158 SPI trigger commands, 756 store setup, 185
size, 542 SPI trigger frame, 763 storing calibration information, 260
size, digital channels, 302 SPI trigger MISO data pattern, 766 string variables, 72
skew, 281, 1080 SPI trigger MOSI data pattern, 768 string variables, reading multiple query
skew reference waveform, 1067 SPI trigger type, 770 results into, 73
slew rate power analysis, 600 SPI trigger, MISO data source, 764 string variables, reading query results into
slope, 759, 931 SPI trigger, MOSI data source, 765, 1119 multiple, 73
slope (direction) of waveform, 1102 SPI triggering, 646 string, quoted ASCII, 164
slope not valid in TV trigger mode, 931 square math function, 336, 357 subnet mask, 58
slope parameter for delay square root math function, 336, 357 subsource, waveform source, 1009
measurement, 431 square wave duty cycle, waveform subsystem commands, 3, 1169
slope, arming edge, Edge Then Edge generator, 1039 subtract math function, 336, 357, 1005
trigger, 916 square waveform generator output, 1033 subtract math function as g(t) source, 350
slope, Nth edge in burst, 925 SRE (Service Request Enable sweep mode, trigger, 903, 914
slope, setup and hold trigger, 958 Register), 187, 1137 sweep speed set to fast to measure fall
slope, transition search, 817 SRQ (Service Request interrupt), 207, 211, time, 440
slope, transition trigger, 965 222 sweep speed set to fast to measure rise
slope, trigger edge, Edge Then Edge SSM pattern, ARINC 429 trigger, 664, 825 time, 457
trigger, 920 standard deviation measured on switch disable, 875
slot, network printer, 379 waveform, 458 switching level, current, 604
smoothing acquisition type, 987 Standard Event Status Enable Register switching level, voltage, 607
snapshot all measurement, 422 (ESE), 172, 1142 switching loss per cycle, 490
software version, 176 Standard Event Status Register (ESR), 174, switching loss power analysis, 602
source, 460, 659, 678, 740 1141 sync break, LIN, 742
source (voltage or current) for slew rate standard for video, 973 sync frame count (FlexRay), 692
analysis, 601 standard, LIN, 741 syntax elements, 163
source channel, M1553, 752 start acquisition, 190, 205, 225, 227 syntax rules, program data, 1168
source for function, 1087 start and stop edges, 429 syntax, optional terms, 163
source for glitch search, 809 start cursor, 1100 syntax, program message, 1165
source for Nth edge burst trigger, 926 start measurement, 420 SYSTem commands, 869
source for trigger, 932 start print job, 383 system commands, 871, 873, 874, 875,
source for TV trigger, 972 start time, 940, 1100 888, 890

1312 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

system commands introduction, 870 time-ordered label list, 316 trigger occurred, 189
timeout, SPI clock, 760 TRIGger OR commands, 942
timing measurement, 420 TRIGger PATTern commands, 944
T title channels, 276 trigger pattern qualifier, 950
title, mask test, 538 trigger qualifier, UART, 791
table of current harmonics results, 556 tolerance, automask, 514, 515 trigger reset conditions, 183, 878
tdelta, 1096 top of waveform value measured, 481 TRIGger RUNT commands, 952
tedge, 468 total frame count (CAN), 673 TRIGger SHOLd commands, 957
telnet ports 5024 and 5025, 993 total frame count (FlexRay), 693 trigger SPI clock slope, 759
Telnet sockets, 75 total harmonics distortion (THD), 563 TRIGger SPI commands, 756
temporary message, 873 total waveforms in mask test, 519 trigger status bit, 230
TER (Trigger Event Register), 230, 1138 trace memory, 228 trigger sweep mode, 903
termination conditions, mask test, 524 track measurements, 459 TRIGger TV commands, 963, 968
test sigma, mask test run, 529 transfer instrument state, 177, 888 trigger type, ARINC 429, 666, 822
test, self, 191 transforms, math, 336 trigger type, SPI, 770
text, writing to display, 873 transient response, 504 trigger type, UART, 792
THD (total harmonics distortion), 563 transient response analysis, 608, 609, 612 TRIGger UART commands, 772
threshold, 303, 543, 1079, 1121 TRANsition SEARch commands, 815 TRIGger USB commands, 978
threshold voltage (lower) for transition search qualifier, 816 trigger, ARINC 429 source, 659
measurement, 1094 transition search slope, 817 trigger, CAN, 679
threshold voltage (upper) for transition search time, 819 trigger, CAN pattern data length, 682
measurement, 1103 transition trigger qualifier, 964 trigger, CAN pattern ID mode, 684
thresholds, 429, 1097 transition trigger slope, 965 trigger, CAN sample point, 675
thresholds used to measure period, 449 transition trigger source, 818, 966 trigger, CAN signal baudrate, 676
thresholds, how autoscale affects, 199 transition trigger time, 967 trigger, CAN signal definition, 677
time base, 893, 894, 895, 896, 897, transmit word size, I2S, 722 trigger, CAN source, 678
1120 transparent screen background, remote trigger, duration greater than, 948
time base commands introduction, 892 command logging, 886 trigger, duration less than, 949
time base reset conditions, 183, 878 tree traversal rules, 1169 trigger, duration range, 951
time base window, 899, 900, 901 trend measurement, 365 trigger, edge coupling, 928
time between points, 1096 TRG (Trigger), 187, 189, 190 trigger, edge level, 929
time buckets, 235, 236 TRIG OUT BNC, 261 trigger, edge reject, 930
time delay, 1120 trigger armed event register, 213, 215 trigger, edge slope, 931
time delay, Edge Then Edge trigger, 918 trigger burst, UART, 788 trigger, edge source, 932
time delta, 1096 trigger channel source, 941, 972 trigger, FLEXray, 695
time difference between data points, 1013 TRIGger commands, 903 trigger, FLEXray error, 696
time duration, 940, 948, 949, 951 TRIGger commands, general, 905 trigger, FLEXray event, 699
time holdoff for trigger, 908 trigger data, UART, 789 trigger, force a, 906
time interval, 468, 470, 1096 TRIGger DELay commands, 915 trigger, glitch greater than, 935
time interval between trigger and trigger duration, 948, 949 trigger, glitch less than, 936
occurrence, 1102 TRIGger EBURst commands, 922 trigger, glitch level, 937
time marker sets start time, 1097 TRIGger EDGE commands, 927 trigger, glitch polarity, 938
time measurements with X cursors, 397 trigger edge coupling, 928 trigger, glitch qualifier, 939
time per division, 895 trigger edge slope, 931 trigger, glitch range, 940
time record, 347 trigger edge slope, Edge Then Edge trigger, glitch source, 941
time reference, lister, 388 trigger, 920 trigger, high frequency reject filter, 907
time specified, 480 trigger edge source, Edge Then Edge trigger, holdoff, 908
time, calibration, 266 trigger, 921 trigger, I2S, 714
time, mask test run, 530 trigger event bit, 230 trigger, I2S alignment, 707
time, runt pulse search, 814 Trigger Event Register (TER), 1138 trigger, I2S audio channel, 716
time, runt trigger, 956 TRIGger FLEXray commands, 685 trigger, I2S clock slope, 709
time, start marker, 1100 TRIGger GLITch commands, 933 trigger, I2S CLOCksource, 711
time, stop marker, 1101 trigger holdoff, 908 trigger, I2S DATA source, 712
time, system, 890 trigger idle, UART, 790 trigger, I2S pattern data, 717
time, transition search, 819 TRIGger IIC commands, 724 trigger, I2S pattern format, 719
time, transition trigger, 967 trigger level auto set up, 909 trigger, I2S range, 720
time/div, how autoscale affects, 199 trigger level constants, 278 trigger, I2S receiver width, 710
time-at-max measurement, 1098 trigger level voltage, 929 trigger, I2S transmit word size, 722
time-at-min measurement, 1099 trigger level, high, 910 trigger, I2S word select (WS) low, 723
TIMebase commands, 891 trigger level, low, 911 trigger, I2S word select (WS) source, 713
timebase vernier, 898 TRIGger LIN commands, 735 trigger, IIC clock source, 727
TIMebase:MODE, 70 TRIGger M1553 commands, 749 trigger, IIC data source, 728

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1313


Index

trigger, IIC pattern address, 729 turn on/turn off time analysis, 570, 571, USB trigger, 982
trigger, IIC pattern data, 730 572, 573 USB trigger commands, 978
trigger, IIC pattern data 2, 731 turning channel display on and off, 273 USB triggering, 904
trigger, IIC qualifier, 732 turning off/on function calculation, 343 user defined channel labels, 276
trigger, IIC signal baudrate, 739 turning vectors on or off, 1083 user defined threshold, 1079
trigger, IIC type, 733 TV mode, 970, 1122 user event conditions occurred, 189
trigger, LIN, 743 TV trigger commands, 963, 968 user name, network domain, 380
trigger, LIN pattern data, 745 TV trigger line number setting, 969 User's Guide, 6
trigger, LIN pattern data length, 747 TV trigger mode, 972 user-defined threshold voltage for digital
trigger, LIN pattern format, 748 TV trigger polarity, 971 channels, 303
trigger, LIN sample point, 738 TV trigger standard setting, 973 user-defined trigger threshold, 1121
trigger, LIN signal definition, 1118 TV triggering, 904 USR (User Event bit), 187, 189
trigger, LIN source, 740 tvmode, 1122 utilization, CAN bus, 674
trigger, mode, 912 Tx data, UART, 1009
trigger, noise reject filter, 913 Tx frame count (UART), 781
trigger, Nth edge burst source, 926 Tx source, 786 V
trigger, Nth edge in burst slope, 925
trigger, Nth edge of burst count, 923 valid command strings, 1165
trigger, Nth edge of Edge Then Edge U valid pattern time, 948, 949
trigger, 919 value, 470
trigger, SPI clock slope, 759 UART base, 787 value measured at base of waveform, 436,
trigger, SPI clock source, 762 UART baud rate, 776 474
trigger, SPI clock timeout, 760 UART bit order, 777 value measured at specified time, 480
trigger, SPI frame source, 763 UART frame counters, reset, 779 value measured at top of waveform, 481
trigger, SPI framing, 761 UART parity, 783 value ranges, 164
trigger, SPI pattern MISO width, 767 UART polarity, 784 values required to fill time buckets, 236
trigger, SPI pattern MOSI width, 769 UART Rx source, 785 VBA, 66, 1174
trigger, sweep, 914 UART SEARch commands, 865 Vce(sat) value for conduction
trigger, threshold, 1121 UART serial search, data, 866 calculation, 606
trigger, TV line, 969 UART serial search, data qualifier, 868 vectors turned on or off, 1083
trigger, TV mode, 970, 1122 UART serial search, mode, 867 vectors, display, 318
trigger, TV polarity, 971 UART trigger burst, 788 vectors, turning on or off, 306
trigger, TV source, 972 UART trigger commands, 772 vernier, channel, 287
trigger, TV standard, 973 UART trigger data, 789 vernier, horizontal, 898
trigger, UART base, 787 UART trigger idle, 790 vertical adjustment, fine (vernier), 287
trigger, UART baudrate, 776 UART trigger qualifier, 791 vertical amplitude measurement, 434, 472
trigger, UART bit order, 777 UART trigger type, 792 vertical axis defined by RANGe, 359
trigger, UART parity, 783 UART Tx data, 1009 vertical axis range for channels, 284
trigger, UART polarity, 784 UART Tx source, 786 vertical offset for channels, 277
trigger, UART Rx source, 785 UART width, 793 vertical peak-to-peak measured on
trigger, UART Tx source, 786 UART/RS232 demo signal, 291 waveform, 437, 477
trigger, UART width, 793 UART/RS-232 triggering, 646 vertical scale, 285, 361
trigger, USB, 982 units (vertical) for FFT, 346 vertical scaling, 1000
trigger, USB D- source, 979 units per division, 285, 286, 331, 897 vertical threshold, 1079
trigger, USB D+ source, 980 units per division (vertical) for vertical units for FFT, 346
trigger, USB speed, 981 function, 285, 361 vertical value at center screen, 356, 360
truncation rules, 1166 units, automask, 513 vertical value maximum measured on
TST (Self Test), 191 units, X cursor, 397, 398 waveform, 475
tstart, 1100 units, Y cursor, 404, 405 vertical value measurements to calculate
tstop, 1101 unsigned data, 988 overshoot, 446
TTL threshold voltage for digital unsigned mode, 1011 vertical value minimum measured on
channels, 303, 1079 upper threshold, 449 waveform, 476
TTL trigger threshold voltage, 1121 upper threshold voltage for video line to trigger on, 969
turn function on or off, 1088 measurement, 1103 video standard selection, 973
turn off channel, 204 uppercase characters in commands, 1165 view, 231, 1012, 1084
turn off channel labels, 315 URQ (User Request) status bit, 172, 174 view turns function on or off, 1088
turn off digital pod, 204 USB (Device) interface, 57 VISA COM example in C#, 1183
turn off math function, 204 USB source, 979, 980 VISA COM example in Python, 1200
turn off time, 496, 573 USB speed, 981 VISA COM example in Visual Basic, 1174
turn on channel labels, 315 USB storage device, recalling files VISA COM example in Visual Basic
turn on channel number display, 1084 from, 614 .NET, 1192
turn on time, 497, 573 USB storage device, saving files to, 623 VISA example in C, 1207

1314 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide


Index

VISA example in C#, 1226 waveform generator output load word counter (ARINC 429), 656
VISA example in Python, 1247, 1253 impedance, 1053 word counter (ARINC 429), reset, 655
VISA example in Visual Basic, 1216 waveform generator period, 1054 word format, 995
VISA example in Visual Basic .NET, 1237 waveform generator pulse width, 1037 word format for data transfer, 988
VISA examples, 1174, 1207 waveform generator ramp symmetry, 1038 word format, ARINC 429, 657
VISA.NET example in C#, 1260 waveform generator reset defaults, 1055 word select (WS) low, I2S trigger, 723
VISA.NET example in IronPython, 1273 waveform generator square wave duty word select (WS) source, I2S, 713
VISA.NET example in Visual Basic cycle, 1039 word width, SPI decode, 771
.NET, 1266 waveform introduction, 985 write mode, remote command
VISA.NET examples, 1260 waveform maximum vertical value logging, 881, 887
Visual Basic .NET, VISA COM measured, 475 write text to display, 873
example, 1192 waveform minimum vertical value WriteIEEEBlock method, 67, 73
Visual Basic .NET, VISA example, 1237 measured, 476 WriteList method, 67
Visual Basic .NET, VISA.NET example, 1266 waveform must cross voltage level to be an WriteNumber method, 67
Visual Basic 6.0, 67 occurrence, 1102 WriteString method, 67
Visual Basic for Applications, 66, 1174 WAVeform parameters, 70
Visual Basic, SICL library example, 1288 waveform peak-to-peak vertical value
Visual Basic, VISA COM example, 1174 measured, 437, 477 X
Visual Basic, VISA example, 1216 waveform period, 449
visualizations, math, 337 waveform persistence, 306 X axis markers, 390
voltage crossing reported or not waveform RMS value measured, 438, 479 X cursor units, 397, 398
found, 1102 waveform save option for segments, 641 X delta, 396
voltage difference between data waveform source, 1005 X delta, mask scaling, 534
points, 1016 waveform source subsource, 1009 X1 and X2 cursor value difference, 396
voltage difference measured, 1104 waveform standard deviation value X1 cursor, 390, 392, 393
voltage level for active trigger, 929 measured, 458 X1, mask scaling, 533
voltage marker used to measure waveform vertical amplitude, 434, 472 X2 cursor, 390, 394, 395
waveform, 1105, 1106 waveform voltage measured at X-axis functions, 892
voltage offset value for channels, 277 marker, 1105, 1106 X-increment, 1013
voltage probe, 286, 331 waveform, byte order, 991 X-of-max measurement, 483
voltage ranges for channels, 284 waveform, count, 992 X-of-min measurement, 484
voltage ranges for external trigger, 330 waveform, data, 993 X-origin, 1014
voltage source, 599 waveform, format, 995 X-reference, 1015
voltage threshold, 429 waveform, points, 996, 998 X-Y mode, 892, 893
voltage, maximum expected input, 592, waveform, preamble, 1000
593, 594 waveform, type, 1010
waveform, unsigned, 1011 Y
waveform, view, 1012
W waveform, X increment, 1013 Y axis markers, 390
waveform, X origin, 1014 Y cursor units, 404, 405
WAI (Wait To Continue), 192 waveform, X reference, 1015 Y offset, reference waveform, 1068
wait, 192 waveform, Y increment, 1016 Y range, reference waveform, 1069
wait for operation complete, 178 waveform, Y origin, 1017 Y scale, reference waveform, 1070
Wait Trig bit, 213, 215 waveform, Y reference, 1018 Y1 and Y2 cursor value difference, 403
warranty, 2 WAVeform:FORMat, 70 Y1 cursor, 390, 393, 399, 403
waveform base value measured, 436, 474 waveforms, mask test run, 531 Y1, mask scaling, 535
WAVeform command, 65 Web control, 75 Y2 cursor, 390, 395, 401, 403
WAVeform commands, 983 website, examples on, 1173 Y2, mask scaling, 536
waveform data, 985 WGEN commands, 1019 Y-axis value, 1017
waveform data format, 638 WGEN trigger source, 932 Y-increment, 1016
waveform data length, 639 what's new, 33 Y-origin, 1017, 1018
waveform data length, maximum, 640 width, 793, 940 Y-reference, 1018
waveform data, save, 637 window, 899, 900, 901
waveform generator, 1021 window time, 895
waveform generator amplitude, 1056 window time base mode, 893 Z
waveform generator function, 1033 window, measurement, 482
waveform generator high-level windows, 347
windows as filters to Fast Fourier zero values in waveform data, 993
voltage, 1057 zoomed time base, 893
waveform generator low-level Transforms, 347
windows for Fast Fourier Transform zoomed time base measurement
voltage, 1058 window, 482
waveform generator offset, 1059 functions, 347
WMEMory commands, 1061 zoomed time base mode, how autoscale
waveform generator output control, 1052 affects, 199

Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide 1315


Index

zoomed window horizontal scale, 901

1316 Keysight InfiniiVision 3000 X-Series Oscilloscopes Programmer's Guide

You might also like