The following two example programs demonstrate methods that you can use to control the arbitrary/function generator through the General Purpose Interface Bus (GPIB). Example 1: Set up a waveform output Example 2: Waveform transfer and copy The example programs are written in Microsoft Visual Basic Version 6.0. The programs run on Windows PC equipped with TekVISA and a National Instruments GPIB board with the associated drivers. TekVISA is the Tektronix implementation of the VISA Application Programming Interface (API). TekVISA is industry-compliant software for writing interoperable instrument drivers in a variety of Application Development Environments (ADEs). The example programs assume that the GPIB system recognizes the PC (external controller) as GPIB0, and the address number of the instrument as 11. If you use an interface other than GPIB, change the resouce name of source code. Refer to TekVISA manual for details about resouce. 'Programming example 1 ' 'This is a sample program for setting the generator outputs. ' Private Sub Sample1_Click() ' 'Assign resource ' Tvc1.Descriptor = "GPIB0::11::INSTR" ' 'Initialize of device setting ' Tvc1.WriteString ("*RST") ' 'Set CH1 output parameters ' Tvc1.WriteString ("FUNCTION SIN") 'Set output waveform SIN Tvc1.WriteString ("FREQUENCY 10E3") 'Set frequency 10kHz Tvc1.WriteString ("VOLTAGE:AMPLITUDE 2.00") 'Set amplitude 2Vpp Tvc1.WriteString ("VOLTAGE:OFFSET 1.00") 'Set offset 1V Tvc1.WriteString ("PHASE:ADJUST 0DEG") 'Set phase 0degree ' 'Set CH2 output parameters ' Tvc1.WriteString ("SOURCE2:FUNCTION SIN") 'Set output waveform SIN Tvc1.WriteString ("SOURCE2:FREQUENCY 10E3") 'Set frequency 10kHz Tvc1.WriteString ("SOURCE2:VOLTAGE:AMPLITUDE 1.00") 'Set amplitude 1Vpp Tvc1.WriteString ("SOURCE2:VOLTAGE:OFFSET 0.00") 'Set offset 0V Tvc1.WriteString ("SOURCE2:PHASE:ADJUST 90DEG") 'Set phase 90degrees ' 'Save settings and output on ' Tvc1.WriteString ("*SAV 1") 'Save settings to Setup1 Tvc1.WriteString ("*RCL 1") 'Recall settings from Setup1 End Sub 'Programming example 2 ' 'This is a sample program for sending a arbitrary waveform to the generator's edit memory and copying contents of edit memory to user's waveform memory. ' Private Sub Sample2_Click() ' 'Assign resource ' Tvc1.Descriptor = "GPIB0::11::INSTR" ' 'Initialize of device setting ' Tvc1.WriteString ("*RST") ' 'Make arbitrary block data (2000 Points) ' Dim wave(4000) As Byte For i = 0 To 499 'Leading edge (500 Points) Data = i * Int(16382 / 500) 'Data range is from 0 to 16382 High = Int(Data / 256) 'AFG's Data Format is big endian Low = Data - (High * 256) wave(2 * i) = High wave(2 * i + 1) = Low Next i For i = 500 To 799 'Part of High Level (800 Points) Data = 16382 High = Int(Data / 256) Low = Data - (High * 256) wave(2 * i) = High wave(2 * i + 1) = Low Next i For i = 800 To 999 'Trailing Edge (200 Points) Data = (1000 - i) * Int(16382 / 200) High = Int(Data / 256) Low = Data - (High * 256) wave(2 * i) = High wave(2 * i + 1) = Low Next i For i = 1000 To 1999 'Part of Low Level (1000 Points) Data = 0 High = Int(Data / 256) Low = Data - (High * 256) wave(2 * i) = High wave(2 * i + 1) = Low Next i ' 'Transfer waveform ' Transfer arbitrary block data to edit memory ' Tvc1.SendEndEnabled = False Tvc1.WriteString ("TRACE:DATA EMEMORY,#44000") Tvc1.SendEndEnabled = True Tvc1.WriteByteArray (wave) ' 'Copy contents of edit memory to USER1 ' Tvc1.WriteString ("TRAC:COPY USER1,EMEM") ' 'Set CH1 output parameters ' Tvc1.WriteString ("FUNCTION USER1") 'Set output waveform USER1 Tvc1.WriteString ("FREQUENCY 8K") 'Set frequency 8kHz Tvc1.WriteString ("OUTPUT ON") 'Set CH1 output on End Sub