AnsweredAssumed Answered

Agilent 33500A/33500B function gen Arb Sequence example program

Question asked by lhornburg Employee on Aug 30, 2012
Latest reply on Aug 30, 2012 by lhornburg

    '    Copyright © 2010 Agilent Technologies Inc. All rights
    '    reserved.
    ' You have a royalty-free right to use, modify, reproduce and distribute
    ' the Sample Application Files (and/or any modified version) in any way
    ' you find useful, provided that you agree that Agilent has no
    ' warranty,  obligations or liability for any Sample Application Files.
    ' Agilent Technologies provides programming examples for illustration only,
    ' This sample program assumes that you are familiar with the programming
    ' language being demonstrated and the tools used to create and debug
    ' procedures. Agilent support engineers can help explain the
    ' functionality of Agilent software components and associated
    ' commands, but they will not modify these samples to provide added
    ' functionality or construct procedures to meet your specific needs.

    'This sample program is intended to use with Microsoft Visual studio 6.0
    'and Agilent Visa Object library.
    'Sample program execution requires VISA library installation as pre requisites.
    'Add below libraries in project reference in Project\reference menu prior to execution of sample 'program:
    'VISA COM 3.0 Type Library, Location: \VisaCom\GlobMgr.dll
    'VISA COM 488.2 Formatted I/O 1.0, Location: \VisaCom\BasFrmIO.dll
    'VISA COM Resource Manager 1.0, Location: \bin\AgtRM.dll
' ****************************************************************************

' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
' Arb Sequence is a sample program that demonstrates how to define an Arb Sequence which consists
' of one or more different arb segments and play back the same using the following configuration:
'    Wave Shape: Arb Sequence
'    Frequency:  40 KSa/Sec
'    Amplitude:  2 Volt Peak to Peak
'    Offset:     0 Volt
'    Output Impedance:   50 Ohm
'    Channel1 Output: Enabled
'Caution: All un-saved data present in volatile memory will be erased.
'Save information before proceeding to this example program.
' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Private Sub Command1_Click()

    Dim io_mgr As VisaComLib.ResourceManager
    Dim mFio As VisaComLib.FormattedIO488
    Set io_mgr = New AgilentRMLib.SRMCls
    Set mFio = New FormattedIO488
    Set mFio.IO = io_mgr.Open(Text1.Text, NO_LOCK, 2000, "")
    Dim Waveform() As String
    Dim I As Integer
    Dim DataStr As String
    ReDim Waveform(1 To 4000)
    Dim strSeqDescriptor As String
    Dim strHeader As String
    Dim strCommand As String
    On Error GoTo MyError

    'Compute waveform
    Text2.Text = ""
    With mFio
        'Clear and reset instrument
        .WriteString "*CLS"
        .WriteString "*RST"
        Sleep 1000
        Call WaitForOPC(mFio)
         '    * Clearing Volatile memory.
         '    * Cautions: All un-saved data present in volatile memory will be erased.
         '    * Save information before proceeding to this example program.
        .WriteString "DATA:VOLatile:CLEar"
    End With
    'Loading arb files into waveform memory.
    With mFio
        .WriteString "MMEM:LOAD:DATA ""INT:\BUILTIN\SINC.ARB"""
        Call WaitForOPC(mFio)
        Call WaitForOPC(mFio)
        Call WaitForOPC(mFio)
    End With
    'Build a sequence descriptor string consisting of arb waveform segments.
    strSeqDescriptor = """mySequence"""
    strSeqDescriptor = strSeqDescriptor & "," + """INT:\BUILTIN\SINC.ARB"",""5"",""once"",""maintain"",""12"""
    strSeqDescriptor = strSeqDescriptor & "," + """INT:\BUILTIN\CARDIAC.ARB"",""5"",""repeat"",""highAtStart"",""35"""
    strSeqDescriptor = strSeqDescriptor & "," + """INT:\BUILTIN\HAVERSINE.ARB"",""0"",""once"",""lowAtStart"",""10"""
    strSeqDescriptor = strSeqDescriptor & "," + """INT:\BUILTIN\SINC.ARB"",""0"",""once"",""highAtStartGoLow"",""7"""
    'Calculate the header of sequence command.
    strHeader = "#" & CStr(Len(CStr(Len(strSeqDescriptor)))) & CStr(Len(strSeqDescriptor))
    'Append the header information and sequence descriptor.
    strCommand = "DATA:SEQ " & strHeader & strSeqDescriptor
    With mFio
        'Send Command to set the desired configuration
        .WriteString strCommand
        Call WaitForOPC(mFio)
        .WriteString "SOURce1:FUNCtion ARB"
     .WriteString "SOURce1:FUNCtion:ARBitrary mySequence"
        .WriteString "SOURCE1:VOLT 2"
        .WriteString "SOURCE1:VOLT:OFFSET 0"
        .WriteString "OUTPUT1:LOAD 50"
        .WriteString "SOURCE1:FUNCtion:ARB:SRATe 40000"
        'Enable output.
        .WriteString "OUTPUT1 ON"
        Sleep 1000
    End With
    Text2.SelText = "Arbitrary Wave Sequence generated on Channel1" & vbCrLf
Exit Sub

    Text2 = Err.Description
    Resume Next
End Sub

Private Sub Form_Load()

    Text2.Text = ""
End Sub

Private Function WaitForOPC(mFio As VisaComLib.FormattedIO488)
        Dim strResult As String
        With mFio
            .WriteString "*OPC?"
            strResult = .ReadString()
        End With
        If (InStr(strResult, "1") > 0) Then
            Exit Do
        End If
End Function