Interfacing Rigol DG 4102 Waveform Generator via LXI

A few days ago I got my brand new arbitrary waveform generator from RIGOL.

It's a DG4102 with 100MHz bandwidth:

DG4102 Waveform Generator

DG4102 Waveform Generator

The DG4102 is a high end two channel function / arbitrary waveform generator with 100 MHz bandwidth, 500 MSa/s and 16 kpts memory. As I already own a RIGOL DS1052E scope, which I am very comfortable with, the generator from the same manufacturer was my very first choice.

As I am mainly a software developer, I was interested in interfacing the machine via the provided LXI interface. Fortunately National Instruments provides the VISA development library for this purpose. With LXi we are able to communicate with the device via the VXI-11 protocol, which allows it to completely remote control the device. Rigol provides the full programming manual for the generator at the link above.

So yesterday I fired up my Visual Studio and after a few creative hours I came up with this:

lxicontrol_small

The current version supports just basic control as setting a few wavfroms, controlling frequency, offset and phase. Maybe I'll provide a test version soon.

Basically the communication with an LXI capable instrument is very simple. Just download the VISA library from the link above and install it. After that, create a new Visual Studio solution and add a reference to the following libraries:

  • NationalInstruments.Common
  • NationalInstruments.Common.Native
  • NationalInstruments.VisaNS

After that you are able to open a session to a device with:

MessageBasedSession session = (MessageBasedSession) 
    ResourceManager.GetLocalManager().Open(Address);

Where Address is the connection string to the device. I case of a ethernet device it might be:

TCPIP0::192.168.178.25::INSTR

The same schema applies for USB devices. I will describe thiss issue in a different post.

Writing data and executing queries is as simple as a walk in the park. For example if we would query the current output frequency for channel 1 we write:

var response = session.Query(":SOURce1:FREQuency?");
Console.Writeln(response);

If we would like to set the current frequency for channel two to 1MHz then it is

session.Write(":SOURce2:FREQuency 1000000");

Note that the response values are in exponential format. Thus if the frequency queried is 1MHz the response would be 1.0000000+E06 for example.

In the next article I'll show you how to control your scope with VISA. After that we have all the tools we need to perform automatic circuit testing. Isn't that cool?