AnsweredAssumed Answered

Agilent 33500A/33500B function gen Binary ARB example program

Question asked by lhornburg Employee on Aug 30, 2012
Latest reply on Jan 17, 2018 by toru
C#:

/****************************************************************************

* EXAMPLE DESCRIPTION:

*  Binary_Arb is a sample program that demonstrates how to send binary waveforms to the Agilent function generators
*  Waveforms over 64Kpoints must be sent using binary

*     Sample Rate:     400000 Samples/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.

******************************************************************************

* BUILDING THIS EXAMPLE:

* This sample program is intended to be used with Microsoft Visual C# 2005, 
* or later, and the VISA COM library.

* Sample program execution requires the VISA COM library as a prerequisite,
* which is installed by the Agilent IO Libraries Suite.
* Sample program uses VISA COM 3.0 Type Library as a reference to the 
* VISA COM library:

* $(VXIPNPPATH)\VisaCom\Primary Interop Assemblies\Ivi.Visa.Interop.dll

******************************************************************************
*
* Copyright © 2012 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.
*
*******************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
//Add VISA COM library reference.
using Ivi.Visa.Interop;

namespace Binary_Arb
{
    class Program
    {
        const string noErrString = "+0,\"No error\"\n";

        static void Main(string[] args)
        {
            try
            {
                BinaryArb();
            }
            catch (Exception oExp)
            {
                Console.WriteLine(oExp.Message);
            }

            Console.WriteLine("Press [Enter] to exit");
            Console.ReadKey();

        }
        public static void BinaryArb()
        {

            const int NUM_DATA_POINTS = 100000;
            float[] z = new float[NUM_DATA_POINTS];

            string instAddress = "TCPIP0::156.140.113.206::inst0::INSTR";
            ResourceManagerClass oRm = new ResourceManagerClass();
            FormattedIO488Class oFio = new FormattedIO488Class();

            //Open session for instrument.
            oFio.IO = (IMessage)oRm.Open(instAddress, AccessMode.NO_LOCK, 2000, "");
            oFio.IO.Timeout = 10000;

            //Query Idendity string and report.
            oFio.WriteString("*IDN?", true);
            string strResult = oFio.ReadString();

            Console.WriteLine("Instrument Identity String: " + strResult);

            //Clear and reset instrument
            oFio.WriteString("*CLS;*RST;*OPC?", true);
            oFio.ReadString();

            //Clear volatile memory
            oFio.WriteString("SOURce1:DATA:VOLatile:CLEar", true);

            //Create simple ramp waveform
            for (int i = 0; i < NUM_DATA_POINTS; i++)
                z[i] = (i - 1) / (float)NUM_DATA_POINTS;

            // swap the endian format
            oFio.WriteString("FORM:BORD NORM", true);

            //Downloading 
            Console.WriteLine("Downloading Waveform...");

            oFio.WriteIEEEBlock("SOURce1:DATA:ARBitrary testarb, ", z, true);

            // wait for the operation to complete before moving on
            oFio.WriteString("*WAI", true);

            Console.WriteLine("Download Complete", true);

            //Set desired configuration
            oFio.WriteString("SOURce1:FUNCtion:ARBitrary testarb", true); // set current arb waveform to defined arb pulse
            oFio.WriteString("SOURce1:FUNCtion ARB", true); // turn on arb function
            oFio.WriteString("SOURCE1:FUNCtion:ARB:SRATe 400000", true); // set sample rate
            oFio.WriteString("SOURCE1:VOLT 2", true); // set max waveform amplitude to 2 Vpp
            oFio.WriteString("SOURCE1:VOLT:OFFSET 0", true); // set offset to 0 V
            oFio.WriteString("OUTPUT1:LOAD 50", true); // set output load to 50 ohms

            //Enable Output
            oFio.WriteString("OUTPUT1 ON", true); // turn on channel 1 output

            //Read Error/s
            oFio.WriteString("SYSTEM:ERROR?", true);
            strResult = oFio.ReadString();

            if (strResult == noErrString)
            {
                Console.WriteLine("Output set without any error\n");
            }
            else
            {
                Console.WriteLine("Error reported: " + strResult);
            }

        }        
    }
}  

Attachments

Outcomes