Sensitivity Program Example

The Sensitivity Program example demonstrates using the Pulse Building API to create a signal that simulates an antenna scan. The Sensitivity example also shows how to create a pattern within a pattern. One pattern, called Doublet, consists of two pattern items both of which are pulses. The other pattern, Sensitivity, consists of ten pattern items and each of these pattern items is a Doublet pattern. This code example creates the signal generated in the Sensitivity Example shown in the Pulse Building Examples section of this Help document and uses the same parameters. Review this example for a description and details on the settings and parameters used to generate this signal. The Sensitivity program will:

Each of the forms that make up this program example are discussed in the following sections:

Details on procedures and declarations include:

Pulse Building Form

The Pulse Building form is the first form displayed when the program is run. The Connect command buttons on this form use the Signal Generator Connection and Spectrum Analyzer Connection forms to set up the signal generator and analyzer I/O interface. In addition to the Connect command buttons, 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.

There are two check boxes on the form: Apply Corrections and Save File. A check mark in the Apply Corrections check box indicates that corrections are applied to the signal. The corrections used are RF Flatness and Image Rejection. You must have a spectrum or signal analyzer connected to the signal generator if you want to use corrections. A check mark in the Save File check box will save the .pbp file in the directory where the Menu Driven Test program is run. 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 to use corrections.

General Section

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 BarkerA As AgtPBPulse ' Declare an object of type AgtPBPulse object with the name  BarkerA. This pulse will have the Barker Code modulation

Dim BarkerB As AgtPBPulse ' Declare an object of type AgtPBPulse object with the name  cw3. Second Barker Code modulated pulse.

Dim DoubletPattern As AgtPBPattern ' Instantiate a pattern, DoubletPattern as type AgtPBPattern. This is the first pattern.

Dim SensitivityPattern As AgtPBPattern' Declare an object, SensitivityPattern, as type AgtPBPattern.  

Dim DoubletItem As AgtPBPatternItem ' Instantiate a pattern item DoubletItem, as type AgtPBPatternItem for the DoubletPattern pattern. Each pattern item must be declared as an AgtPBPatternItem type.

Dim SensitivityItem As AgtPBPatternItem ' Declare an object SensitivityItem, as type AgtPBPatternItem for the Sensitivity 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. Amplitude and frequency settings for a pattern item are set using the Settings object. 

Dim SGConnected As Boolean ' Used to verify signal generator IO connection.

Dim SAConnected As Boolean ' Used to verify signal generator IO connection.

Form Load Event

The following code listing is from the Pulse Building form's Form_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 .pbp project by instantiating an object of type AgtPBProject.

Exit Sub

Error_Handler:

MsgBox Err.Description

End Sub

cmdRun Event

The following code listing is from the Pulse Building form'scmdRun_Click() event. The first part of the cmdRun click event creates two pulses modulated using Barker codes. 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, the code execution jumps to the ErrorHandler 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 the hourglass icon while running the function.

cmdRun.Enabled = False ' Disable the Download and Play button until the process has finished.

project.NewProject ("Sensitivity Program Example.pbp") ' Create a new pbp project file.

Dim indexItem as Integer ' Declare a counter variable.

Dim powerScale as Double ' Setup power scale variable.  

Set BarkerA = project.PulseLibrary.CreateNewPulse("BarkerA") ' BarkerA is instantiated as an AgtPBPulse type object.

BarkerA.PulseType = AgtPBPulseType_RaisedCosine ' Set the pulse type to raised cosine.

'The following code statement sets the pulse rise time to 100 ns, the fall time to 100 ns, 100% to 100% amplitude duration to 800 ns, the width jitter type to None, and the jitter deviation to 0 s

Call BarkerA.SetEnvelopeRaisedCosine(0.0000001, 0.0000001, 0.0000008, AgtPBJitterType_None, 0)

BarkerA.ModulationType = AgtPBModulationType_Barker ' Set Barker code as the modulation type.

BarkerA.SetModulationBarker (13) ' Use Barker code 13 for the pulse modulation.

' The following code statements create a second pulse identical to the BarkerA pulse, except for the modulation: Barker code # 7.

Set BarkerB = project.PulseLibrary.CreateNewPulse("BarkerB")

BarkerB.PulseType = AgtPBPulseType_RaisedCosine

Call BarkerB.SetEnvelopeRaisedCosine(0.0000001, 0.0000001, 0.0000008, AgtPBJitterType_None, 0)

BarkerB.ModulationType = AgtPBModulationType_Barker

BarkerB.SetModulationBarker (7)

' This next section of code creates the Doubletpattern using the two previously created pulses: BarkerA and BarkerB.

Set DoubletPattern = project.PatternLibrary.CreateNewPattern("Doublet") ' Instantiate a pattern object of type AgtPBPattern

' The following code statement sets the BarkerA pulse as the first pattern item by instantiating this item as type AgtPBPatternItem.

Set DoubletItem = DoubletPattern.CreateNewItemAt(AgtPBPatternItemObjectType_Pulse, "BarkerA", 1)

DoubletItem.RepetitionIntervalSec = 0.000005 ' The repetition interval for the item is set to 5 us. 

DoubletItem.NumberOfRepeats = 1 ' The pattern item repeats once.

' The following code statements set pattern item parameters. Refer to Columns in Pattern Details for more information.

DoubletItem.EdgeJitterType = AgtPBJitterType_None

DoubletItem.JitterDeviationSec = 0

DoubletItem.RelativePowerScaleDB = 0

DoubletItem.FrequencyOffsetHz = 0

DoubletItem.PhaseOffsetRad = 0

' The following code statement sets the BarkerB pulse as the second pattern item by instantiating this pattern item as type AgtPBPatternItem. This second pattern item is identical to the first item except for the phase offset and Barker Code modulation.

Set DoubletItem = DoubletPattern.CreateNewItemAt(AgtPBPatternItemObjectType_Pulse, "BarkerB", 2)

DoubletItem.RepetitionIntervalSec = 0.000045

DoubletItem.NumberOfRepeats = 1

DoubletItem.EdgeJitterType = AgtPBJitterType_None

DoubletItem.JitterDeviationSec = 0

DoubletItem.RelativePowerScaleDB = 0

DoubletItem.FrequencyOffsetHz = 0

DoubletItem.PhaseOffsetRad = 1.57 ' Set a 180 degree phase shift relative to the carrier frequency.

Creating a second pattern named Sensitivity consisting of Doublet pattern items.

Set SensitivityPattern = project.PatternLibrary.CreateNewPattern("Sensitivity") ' Instantiate a pattern object of type AgtPBPattern.

SensitivityPattern.Properties.AmplitudeDBm = -10 ' Set the signal generator output power level to -10 dBm.

The next section of code uses a loop to fill in the pattern item parameters for the Sensitivity pattern.

For indexItem = 0 To 9

Set SensitivityItem = SensitivityPattern.CreateNewItemAt(AgtPBPatternItemObjectType_Pattern, "Doublet", indexItem) ' The pattern item at the counter variable indexItem is instantiated as type AgtPBPatternItem. Each pattern item in the Sensitivity pattern is a Doublet pattern.

SensitivityItem.RepetitionIntervalSec = 0.00005 ' The repetition interval is set to 50 us.    

SensitivityItem.NumberOfRepeats = 1 ' Repeat pattern item once.    

SensitivityItem.EdgeJitterType = AgtPBJitterType_None ' No jitter applied to pattern item.    

SensitivityItem.JitterDeviationSec = 0 ' Deviation not applied.     

SensitivityItem.RelativePowerScaleDB = PowerScale ' Scale variable increments/decrements within the loop.    

SensitivityItem.FrequencyOffsetHz = 0 ' No frequency offset applied.    

SensitivityItem.PhaseOffsetRad = 0 ' No phase offset applied.    

If indexItem < 5 Then ' Decrease the power scale from 0 dB for the first 5 pattern items.    

powerScale = powerScale - 6        

Else    

powerScale = powerScale + 6 ' Increase the power scale for the last 5 items.        

End If    

Next ' indexItem end loop

If chkSaveFile.Value = 1 Then ' Save the .pbp file to the PC

project.SaveProject    

End If

If chkCorrections.Value = 0 Then ' If no analyzer then corrections must be disabled.

project.ImageRejectionCorrectionEnabled = False    

project.RFFlatnessCorrectionEnabled = False    

End If

' Uncomment the next line of code if you want to download the Doublet pattern.

'project.DownloadPattern ("Doublet") ' Download the Doublet pattern/signal to the signal generator's waveform memory.

project.DownloadAndPlayPattern ("Sensitivity") ' Download the Sensitivity pattern/signal to the signal generator and play it.

Call MsgBox("Signal Downloaded", vbOKOnly) ' Indicate completion of the program. 

frmMain.MousePointer = vbDefault ' Return the mouse pointer to the default arrow 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

Signal Generator and Spectrum Analyzer Connection Forms

The Connect to Instrument command button displays 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 ClosedSystem menu. Text boxes are used to specify the LAN TCP/IP address or GPIB information. The GPIB values shown in the form are default values and will need to be changed if your computer has several GPIB boards or the signal generator uses an address other than the default address shown. Refer to the installation guide for information on the GPIB or LAN interface. The installation guide is available at: http://www.keysight.com/find/signalstudio.

The OK command button, on the Signal Generator Connection form, sets a boolean value, okSelected, true indicating that the values entered in the Signal Generator Connection form are valid. The Cancel button in the Signal Generator Connection form sets the boolean value, okSelected, to false indicating that the values in the Signal Generator Connection form are not valid. Clicking either of these buttons hides the form and returns you to the Pulse Building form.

The values entered into the Signal Generator Connection form text boxes, if valid, are used to establish communication with the instruments over the selected interface: LAN or GPIB. The ConnectSG_Click event procedure in the Pulse Building form calls the .SignalGenerator.SetConnectionGPIB procedure for GPIB configuration or the SignalGenerator.SetConnectionTCPIP procedure for LAN configuration. These procedures verify that the instrument's I/O configuration, such as TCP/IP or GPIB addresses, are correct. If the communication is not established, the program executes the On Error GoTo statement and an error message is displayed.

The Connect command button for the Spectrum Analyzer Configuration displays the Spectrum Analyzer Connection form. This form performs the same functions as described for the Signal Generator Connection form.   

API Programming Overview

Frequency Agile Program Example

Complex Test Program Example

Executive Test Program Example