The Frequency Agile program generates a signal with a single pattern consisting of three pulses. Each of the pulses use different Pulse Type definitions. The first pulse, CW1, is created using the Pulse Building application's trapezoidal definition. The second pulse, CW2, uses a custom I/Q format to describe the trapezoidal pulse type. The third pulse, CW3, uses a custom profile format to describe the pulse. This program example creates the signal generated in the Frequency Agile Example shown in the Examples section of this Help system and uses the same parameters. Review this example for a description and details on the settings and parameters used to generate the signal. The Frequency Agile program will:
Build a pattern of pulses
Use pattern parameter properties such as repeats, edge jitter, and so forth
Set the signal generator power level and frequency
Generate three pulses with different frequency offset values
Use the power scale function to scale the amplitude of the third pulse
Read I/Q and custom profile data from a text file
Each of the forms that make up this program example is discussed in the following sections:
Details on procedures and declarations include:
The Pulse Building form is the first form displayed when the program is run. The Connect to Instrument button on this form starts the Run System Configuration wizard. This wizard allows you to change or create a hardware configuration and select a GPIB or LAN (TCP/IP) connection for I/O instrument communication. You can also access the wizard from the
System menu. In addition to the Connect to Instrument button, the Pulse Building form has a Download and Play
command button that will generate a waveform, download the waveform, marker, and sequence files to the signal generator, and play the corrected waveform.
The Frequency Agile example uses file input to read data from text files. Select the Microsoft Scripting Runtime library from the Available References in your Visual Basic project. You must reference this library.
A check mark beside Enable Corrections on the Download menu indicates that corrections are applied to the signal. The corrections used are RF Flatness and Image Rejection. You must have an analyzer connected to the signal generator if you want to use corrections. To save the .pbp file in the directory where the Menu Driven Test program is run click the Save button
or select . This .pbp file consists of the Pulse and Pattern Library items along with all associated parameters.
You must have a spectrum or signal analyzer connected to the signal generator if you want to use corrections.
The following code listing is from the Pulse Building form's General section. Descriptions follow the code lines.
Option Explicit ' It is advised that Option Explicit be used to prevent spelling and declaration errors in the program.
Dim project As AgtPBProject ' Declare an object, project, as type AgtPBProject. All the functionality available in the Pulse Building GUI is available in the AgtPBProject object.
Dim cw1 As AgtPBPulse ' Declare an object of type AgtPBPulse object with the name cw1. This is the first pulse
Dim cw2 As AgtPBPulse ' Declare an object of type AgtPBPulse object with the name cw2.
Dim cw3 As AgtPBPulse ' Declare an object of type AgtPBPulse object with the name cw3.
Dim AgilePattern As AgtPBPattern ' Declare an object, AgilePattern, as type AgtPBPattern.
Dim AgileItem As AgtPBPatternItem' Declare an object AgileItem, as type AgtPBPatternitem for the Agile pattern. Each pattern item must be declared as an AgtPBPatternItem type.
Dim SpectrumAnalyzer As AgtPBSpectrumAnalyzer ' Declare an analyzer instrument object.
Dim SignalGenerator As AgtPBSignalGenerator ' Declare a signal generator instrument object.
Dim Settings As AgtPBSignalProperties ' Declare a signal generator properties object. Functions such as amplitude and frequency are set using the Settings object.
Dim IData() As Double ' Declare a dynamic array to hold I data values
Dim QData() As Double ' Declare a dynamic array to hold Q data values
Dim customProfile() As Double ' Declare a dynamic array to hold custom profile data
Dim dataType As String ' Declare a string variable to indicate data type; Custom profile or IQ data.
Dim SGConnected As Boolean ' Used to verify signal generator IO connection
Dim SAConnected As Boolean ' Used to verify analyzer IO connection
The following code listing is from the Pulse Building form'sForm_Load() event. Functions and code descriptions follow or precede the code statements.
Private Sub Form_Load()
On Error GoTo Error_Handler ' sets up an error trap to handle errors. If an error occurs in this procedure, the code execution jumps to the 'Error_Handler line label and a message describing the error is generated.
Set project = New AgtPBProject ' Creates a new project by instantiating an object of type AgtPBProject.
Exit Sub
Error_Handler:
MsgBox Err.Description
End Sub
The following code listing is from the Pulse Building form'scmdRun_Click() event. The program creates three pulses; CW1, CW2, and CW3. These three pulses are used to create a pattern named AgilePattern
Comments describing functions follow or precede code statements.Private Sub cmdRun_Click()
On Error GoTo ErrorHandler ' Sets up an error trap to handle errors. If an error occurs in this procedure, code execution 'jumps to the Error_Handler line label and a message describing the error is generated.
If Not SGConnected Then ' Check to see that the signal generator IO connection is valid
Call MsgBox("Connect Signal Generator", vbOKOnly)
frmMain.MousePointer = vbDefault
Exit Sub
End If
If Not SAConnected And chkCorrections.Value = 1 Then ' Check to see that the analyzer IO connection is valid
Call MsgBox("Connect Spectrum Analyzer", vbOKOnly)
frmMain.MousePointer = vbDefault
Exit Sub
End If
frmMain.MousePointer = vbHourglass ' Use an hourglass pointer to indicate the procedure is running.
cmdRun.Enabled = False ' Disable the Download and Play button until the process has finished
project.NewProject ("Frequency Agile Pulse.pbp") ' Create a new pbp project file
' Create the first pulse
Set cw1 = project.PulseLibrary.CreateNewPulse("CW1") ' Create a new pulse named cw1
cw1.PulseType = AgtPBPulseType_Trapezoidal ' Set the pulse type to Trapezoidal
' Set the rise time to 30 ns, the fall time to 30 ns, 100% to 100% to 940 ns, the width jitter type to
' Gaussian, and the jitter deviation to 100 ns
Call cw1.SetEnvelopeTrapezoidal(0.00000003, 0.00000003, 0.00000094, AgtPBJitterType_Gaussian, 0.0000001)
cw1.ModulationType = AgtPBModulationType_FMChirp ' Set the modulation type to FM Chirp
' The next code statement sets the chirp deviation to 5MHz, and the chirp direction to Ascending
Call cw1.SetModulationFMChirp(5000000, AgtPBFMChirpDeviationType_Ascending) '
dataType = "IQ" ' Variable to identify the IQ data text file
Call ReadDataASCIIFile(IData(), QData(), customProfile(), dataType) ' Read pulse data from a text file
' Create the second pulse
Set cw2 = project.PulseLibrary.CreateNewPulse("CW2") ' Create a new pulse called cw2
cw2.PulseType = AgtPBPulseType_CustomIQ ' Set the pulse type to Custom IQ
' The next code statement sets the sampling rate to 100 MHz, and uses the IQ data to create the CW2 IQ Profile pulse
Call cw2.SetCustomIQ(100000000, IData(), QData())
cw2.ModulationType = AgtPBModulationType_None ' Set the modulation type to none
' Create the third pulse
Set cw3 = project.PulseLibrary.CreateNewPulse("CW3") ' Create a new pulse named cw3
cw3.PulseType = AgtPBPulseType_CustomEnvelope ' Set the pulse type to custom profile
dataType = "Custom" ' Variable to identify the custom profile data text file
Call ReadDataASCIIFile(IData(), QData(), customProfile(), dataType) ' Read pulse data from a text file
' Set the sampling rate to 100 MHz, and use the customProfile data to create the CW3 Custom Profile pulse
Call cw3.SetEnvelopeCustom(100000000, customProfile())
cw3.ModulationType = AgtPBModulationType_FMChirp ' Set the modulation to FM Chirp
' The next code statement sets the chirp deviation to 5 MHz, and the chirp direction to Ascending
Call cw3.SetModulationFMChirp(5000000, AgtPBFMChirpDeviationType_Ascending)
' Create a Frequency Agile Pulse Pattern
Set AgilePattern = project.PatternLibrary.CreateNewPattern("Frequency Agile")
' Adding the trapezoidal pulse (CW1) as the first pattern item
Set AgileItem = AgilePattern.CreateNewItemAt(AgtPBPatternItemObjectType_Pulse, "CW1", 0)
' The following code statements set up the pattern item parameters
AgileItem.RepetitionIntervalSec = 0.000003 ' Repetition interval set for 3 us
AgileItem.NumberOfRepeats = 1 ' Number of repeats for the pattern item
AgileItem.EdgeJitterType = AgtPBJitterType_None ' No jitter type selected
AgileItem.JitterDeviationSec = 0 ' Jitter deviation set to 0
AgileItem.RelativePowerScaleDB = 0 ' Sets the power scale for the pattern to 0, the signal generator's RF power level
AgileItem.FrequencyOffsetHz = -10000000 ' Decrease the pattern item signal generator RF frequency 10 MHz
AgileItem.PhaseOffsetRad = 0 ' No pattern item phase shift (0 radians)
' Adding the custom I/Q pulse (CW2) as the second pattern item
Set AgileItem = AgilePattern.CreateNewItemAt(AgtPBPatternItemObjectType_Pulse, "CW2", 1)
' The following code statements set up the pattern item parameters
AgileItem.RepetitionIntervalSec = 0.000003 ' Repetition interval set for 3 us
AgileItem.NumberOfRepeats = 1 ' Number of repeats for the pattern item
AgileItem.EdgeJitterType = AgtPBJitterType_Gausian ' Edge Jitter Type set to Gaussian
AgileItem.JitterDeviationSec = 0 ' Jitter deviation set to 0
AgileItem.RelativePowerScaleDB = 0 ' Sets the power scale for the pattern to 0, the signal generator's RF power level
AgileItem.FrequencyOffsetHz = 0 ' No signal generator RF frequency offset
AgileItem.PhaseOffsetRad = 0 ' No pattern item phase shift (0 radians)
' Adding the custom envelope pulse (CW3) as the third pattern item
Set AgileItem = AgilePattern.CreateNewItemAt(AgtPBPatternItemObjectType_Pulse, "CW3", 2)
' The following code statements set up the pattern item parameters
AgileItem.RepetitionIntervalSec = 0.000003 ' Repetition interval set for 3 us
AgileItem.NumberOfRepeats = 1 ' Number of repeats for the pattern item
AgileItem.EdgeJitterType = AgtPBJitterType_None ' No jitter type selected
AgileItem.JitterDeviationSec = 0 ' Jitter deviation set to 0
AgileItem.RelativePowerScaleDB = -10 ' Sets the pattern item signal generator RF power level to -10 dBm
AgileItem.FrequencyOffsetHz = 10000000 ' Increases the signal generator's frequency 10 MHz
AgileItem.PhaseOffsetRad = 0 ' No pattern item phase shift (0 radians)
' Save the .pbp file to the PC
If chkSaveFile.Value = 1 Then
project.SaveProject
End If
' If no analyzer then corrections must be disabled.
If chkCorrections.Value = 0 Then
project.ImageRejectionCorrectionEnabled = False
project.RFFlatnessCorrectionEnabled = False
End If
project.DownloadAndPlayPattern ("Frequency Agile") ' Download and play the signal on the signal generator
Call MsgBox("Signal Downloaded to Signal Generator", vbOKOnly)
frmMain.MousePointer = vbDefault ' Use default mouse icon
cmdRun.Enabled = True ' Re-enable the Download and Play button; the process is finished
Exit Sub
ErrorHandler:
frmMain.MousePointer = vbDefault ' Mouse pointer returns to the arrow icon
cmdRun.Enabled = True ' Re-enable the Download and Play button because; an exception occurred
Call MsgBox(Err.Description, vbOKOnly) ' A message box with the error description is displayed.
End Sub
The following code listing is from the Pulse Building form'sReadDataASCIIFile() procedure. The procedure opens a text data file and reads the text data into a string array. The text files are in the following locations:
C:\Users\Public\Public Documents\Keysight\Pulse Building\Samples\VB6\Frequency Agile
C:\Documents and Settings\All Users\Keysight\Pulse Building\Samples\VB6\Frequency Agile
The IQ data file uses a tab delimited format to hold the I and Q data values describing the pulse. The custom profile data file uses single data values separated by end of line carriage returns to represent the amplitude values describing the pulse. The array data is passed back to the cmdRun() event procedure. Functions and code descriptions follow or precede the code statements.
Private Function ReadDataASCIIFile(IValues() As Double, QValues() As Double, customProfile() As Double, dataType As String)
Dim s As String ' Declare a string variable to hold each line of text data.
Dim i As Integer ' Counter variable..
Dim sArray() As String ' Declare a string array to hold the tab delimited text read from the file.
Dim fso As New FileSystemObject, textFile As File, ts As TextStream ' Declare a file object
On Error GoTo FileError ' Sets up an error trap to handle errors. If an error occurs in this procedure code execution jumps to the FileError line
' label and a message describing the error is generated.
' The following code opens the text data file; either the IQ or Custom Profile data
If dataType = "IQ" Then
Set textFile = fso.GetFile(App.Path & "\Freq Agile IQ.txt")
Else
Set textFile = fso.GetFile(App.Path & "\Freq Agile Custom Profile.txt")
End If
Set ts = textFile.OpenAsTextStream(ForReading) ' Declare a file handle
' The following code uses a loop to read in text data from the open file
Do While Not ts.AtEndOfStream
s = ts.ReadLine ' Read the current line of text data
If dataType = "IQ" Then ' Read IQ data from tab delimited text formated file
ReDim Preserve IValues(i) ' Re-dimension the I data array
ReDim Preserve QValues(i) ' Re-dimension the Q data array
sArray = Split(s, vbTab) ' Read the tab delimited data into sArray
IValues(i) = CDbl(sArray(0)) ' I data at counter is set to the previously read data
QValues(i) = CDbl(sArray(1)) ' Q data at counter is set to the previously read data
Else ' Read Custom Profile data
ReDim Preserve customProfile(i)
customProfile(i) = CDbl(s) ' Read the single data value into the customProfile array
End If
i = i + 1 ' Increment the loop counter
Loop
ts.Close ' Close the file handle
Exit Function
FileError:
MsgBox Err.Description
End Function
The Sensitivity Program Example describes the signal generator and spectrum/signal analyzer I/O connection forms. Refer to that section for details.