Agilent T&M Toolkit 2.0 New Features: Waveform Data Type

One of the new data types in T&M Toolkit 2.0 for Visual Studio .NET 2003 is the Waveform data type.  It is a pretty simple type that encapsulates a simple time-domain waveform i.e. array of doubles for the y data and a startTime and sample interval (TimeBetweenPoints).  You can create one very simply like so:

Waveform w = new Waveform(new double[] {0.0, 1.0, 2.0}, 0.0, 1E-6);

You can also get one back from Toolkit’s FunctionWaveformGenerator type like so:

using Agilent.TMFramework;

FunctionWaveformGenerator fgen = new FunctionWaveformGenerator();
fgen.FunctionType = FunctionType.Square;
fgen.Amplitude = 5.0;
fgen.DCOffset = 2.5;
fgen.StopTime = 1E-3;
fgen.NumberOfPoints = 1000;
Waveform w = fgen.GenerateWaveform();

There is a cool accessory to the Waveform type we call wavefomr scaler objects which decode the preamble and scale the raw data for you.  These scaler objects implement the IWaveformData interface.  Waveform has one additional constructor that takes a reference to an object that implements IWaveformData.  Toolkit 2.0 ships with the following types that implement this interface:

  • Agilent5460XWaveformData
  • Agilent5461XWaveformData
  • Agilent5462XWaveformData
  • Agilent5464XWaveformData
  • Agilent548XXWaveformData

What’s cool about this is that you can now, using SCPI, get properly scaled waveforms out of Agilent oscilloscopes very easily.  For example:

using Agilent.TMFramework;
using Agilent.TMFramework.DataVisualization;
using Agilent.TMFramework.InstrumentIO;
using Agilent.TMFramework.InstrumentIO.InstrumentSupport;

using (DirectIO scope = new DirectIO("GPIB0::7::INSTR"))
    // Setup scope waveform acquisition
    scope.WriteLine("ACQUIRE:TYPE NORM");
    scope.WriteLine("ACQUIRE:COMPLETE 100");
    scope.WriteLine("WAVEFORM:SOURCE CHAN1");
    scope.WriteLine("WAVEFORM:FORMAT BYTE");
    scope.WriteLine("WAVEFORM:POINTS 1000");
    scope.WriteLine(":DIGITIZE CHAN1");

    // Grab the preamble info
    string preamble = scope.Read();

    //Get unscaled (raw) waveform data
    Byte[] rawdata = scope.ReadIeeeBlockAsByteArray();

    // Create a waveform data scaler object
    Agilent5460XWaveformData waveformData =
        new Agilent5460XWaveformData(rawdata, preamble);

    // Create waveform and plot it.
    Waveform w = new Waveform(waveformData);

The nice thing about using IWaveformData is that other folks can write scaler objects for other Agilent scopes.

This entry was posted in Agilent T&M Toolkit. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s