AnsweredAssumed Answered

Agilent 33500A/33500B function gen Sine Burst with Sync example program

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

'****************************************************************************
    '    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
' ****************************************************************************

' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'* Sine Burst With Sync is a sample program that demonstrate the synchronization of two 33522A instruments.
' * A BUS trigger on the first starts an infinite burst of one waveform and an EXTernal trigger
' * on the 2nd instrument starts a second infinite burst of a different waveform. The first instrument is
' * configured to fire an output trigger from its EXT TRIG IN/OUT rear connection when its burst starts.
' * The EXT TRIG IN/OUT output from the first instrument is connected with a signal cable to the EXT TRIG IN/OUT
' * on the second instrument. In this way, the second burst starts at the same time the first instrument burst
' * starts. For tight synchronization, the 10MHz output of the first instrument should also be connected to the
' * 10 MHz input connector of the second instrument.
'
'Instrument 1 Configuration, Channel 1:
'Wave Shape: Sine
'Frequency:  1000 Hz
'Amplitude:  2 Volt Peak to Peak
'Offset:     0 Volt
'Load Impedence: 50 Ohm
'Channel 1 Output: Enabled
'
'Instrument 2 Configuration, Channel 1:
'Wave Shape: Ramp
'Frequency:  2 KHz
'Amplitude:  1 Volt Peak to Peak
'Offset:     1 Volt
'Load Impedence: 50 Ohm
'Channel 1 Output: Enabled
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Private Sub Command1_Click()
    
    Dim io_mgr As VisaComLib.ResourceManager
    Dim mfIo1 As VisaComLib.FormattedIO488
    Dim mfIo2 As VisaComLib.FormattedIO488
    
    
    Set io_mgr = New AgilentRMLib.SRMCls
    Set mfIo1 = New FormattedIO488
    Set mfIo2 = New FormattedIO488
    
    Set mfIo1.IO = io_mgr.Open(Text1.Text, NO_LOCK, 2000, "")
    Set mfIo2.IO = io_mgr.Open(Text2.Text, NO_LOCK, 2000, "")
    
    On Error GoTo MyError
    
    ' Clear and reset instruments
    With mfIo1
         .WriteString "*CLS"
         .WriteString "*RST"
       
    End With
    
    With mfIo2
    
         .WriteString "*CLS"
         .WriteString "*RST"
       
    End With
    
    Sleep 2000
         
    With mfIo1
    
            ' Set up instrument 1
            ' Send commands to set channel 1 on instrument 1 to desired configuration
            .WriteString "SOURCE1:FUNCTION SIN"
            .WriteString "SOURCE1:FREQUENCY 1000"
            .WriteString "SOURCE1:VOLT:UNIT VPP"
            .WriteString "SOURCE1:VOLT 2"
            .WriteString "SOURCE1:VOLT:OFFSET 0"
            .WriteString "OUTPUT1:LOAD 50"

            ' Set trig mode to BUS for instrument 1
            .WriteString "TRIGGER1:SOURCE BUS"

            ' Set up and turn on infinite cycle burst with infinite cycle output
            ' This burst will start on instrument 1 when instrument receives a BUS trigger (*TRG)
            .WriteString "SOURCE1:BURST:NCYCLES INF"
            .WriteString "SOURCE1:BURST:MODE TRIG"
            .WriteString "SOURCE1:BURST:STATE ON"

            ' Set up the output trigger on instrument to output a positive pulse when its burst starts
            .WriteString "OUTPUT:TRIGGER ON"
            .WriteString "OUTPUT:TRIGGER:SLOPE POSITIVE"
            .WriteString "OUTPUT:TRIGGER:SOURCE CH1"

            ' turn off continuous init as we're just using one trigger to start burst
            .WriteString "INITIATE1:CONTINUOUS OFF"
            ' and arm instrument 1 with INIT so it is now waiting for BUS trigger to start burst
            .WriteString "INITIATE1"
        
    End With
    
    With mfIo2
    
            ' Set up instrument 2
            ' Send commands to set channel 1 on instrument 2 to desired configuration
            .WriteString "SOURCE1:FUNCTION RAMP"
            .WriteString "SOURCE1:FREQUENCY 2000"
            .WriteString "SOURCE1:VOLT:UNIT VPP"
            .WriteString "SOURCE1:VOLT 1"
            .WriteString "SOURCE1:VOLT:OFFSET 1"
            .WriteString "OUTPUT1:LOAD 50"

            ' Set trig mode to EXT for instrument 2
            .WriteString "TRIGGER1:SOURCE EXT"
            ' Set slope of rear external trigger to positive edge
            .WriteString "TRIGGER1:SLOPE POSITIVE"

            ' Set up and turn on infinite cycle burst with infinite cycle output
            ' This burst will start on instrument 2 when instrument receives a
            ' positive TTL pulse (EXT trigger) on its rear EXT TRIG IN port
            .WriteString "SOURCE1:BURST:NCYCLES INF"
            .WriteString "SOURCE1:BURST:MODE TRIG"
            .WriteString "SOURCE1:BURST:STATE ON"
            ' turn off continuous init as we're just using one trigger to start burst
            .WriteString "INITiate1:CONTinuous OFF"
            ' and arm instrument 2 with INIT so it is now waiting for EXT trigger to start burst
            .WriteString "INITiate1"
                
    End With
    
    With mfIo1
                    
            'Enable channel 1 output on instrument 1
            .WriteString "OUTPUT1 ON"
    End With
    
    With mfIo2
            'Enable channel 1 output on instrument 2
            .WriteString "OUTPUT1 ON"
            
    End With
    
    Sleep 2000
    
    With mfIo1
                    
            'Start burst on channel 1 with BUS trigger
            .WriteString "*TRG"
            
    End With
    
    On Error GoTo MyError

    mfIo1.IO.Close
    mfIo2.IO.Close
        
    Text3.Text = "Output set on both instruments"
  
Exit Sub
 
    
MyError:
    
    Text3 = Err.Description
    Resume Next
   
End Sub

Private Sub Form_Load()

    Text3.Text = ""
    
End Sub

Outcomes