## Rigol DG1022 Arbitrary Waveform Function Generator

 The DG1022 is a function generator that I was able to test recently. It is quite cheap (390 USD in the USA), has two outputs for standard wave forms (sine, square, ramp, pulse and noise) and also supports arbitrary wave forms. It has a USB interface and can be controlled via Python easily (see below).

### Specifications

I found a shorter list of specifications on rigolna.com and more detailed list on rigol.com. If you need even more information, you have to download the full specifications PDF (scroll down to the section references).

### Software

The DG1022 comes with a Windows software for waveform editing called “UltraWave”. It enables you to 'draw' arbitrary waveforms by hand.

### USB Device Port

When you plug the DS1022 in on an Ubuntu Linux 12.04 machine, lsusb reveals the following vendor and device id:

Bus 008 Device 003: ID 1ab1:0588 Rigol Technologies DS1000 SERIES

The following log information is being reported using dmesg when you plug the DG1022 in:

[1265.720121] usb 8-2: new full-speed USB device number 2 using uhci_hcd
[1265.915865] usbcore: registered new interface driver usbtmc
[1260.448380] usb 8-2: USB disconnect, device number 2


The fact that the device implements the usbtmc interface makes me believe, you can use it in the same way as described for the Rigol oscilloscope DS1052E in this blog post by mahto.

##### More on the usbtmc Linux driver

USBTMC stands for USB Test & Measurement Class. USBTMC is a protocol built on top of USB that allows GPIB-like communication with USB devices. From the user's point of view, the USB device behaves just like a GPIB device. For example, you can use VISA Write to send the *IDN? query and use VISA Read to get the response. The USBTMC protocol supports service request, triggers and other GPIB specific operations.
USBTMC allows instrument manufacturers to upgrade the physical layer from GPIB to USB while maintaining software compatibility with existing software, such as instrument drivers and any application that uses VISA.

##### First Interaction via Python

update 2015-08:

Support for the function generator is included in my software PyOscilloskop.

After having had a look at all the web sites above I was curious to test if the Python code for the Linux driver usbtmc actually worked on Linux. So I took the usbtmc.py from sbrinkmann / PyOscilloskop and drafted a class similar to the rigolScope.py: rigolFG.py (FG for function generator). The source can be found in the gist #2597049: Controlling the Rigol DG1022 with Python on Linux (using the usbtmc driver) – Proof of Concept on Github.

When I ran this code in Python:

import rigolFG
fg = rigolFG.RigolFunctionGenerator()


it first complained about /dev/usbtmc0 not being readable:

OSError: [Errno 13] Permission denied: '/dev/usbtmc0' .

After allowing anyone on the system to read and write to the device file using sudo chmod 777 /dev/usbtmc0 and running the Python command again, it printed the following identification code for the DG1022:

RIGOL TECHNOLOGIES,DG1022 ,DG1D140704301,,00.03.00.08.00.02.08


Nice! It's just a proof of concept but it is nice to know that it would actually work if I would need to be able to control it with a computer some day.

The further commands needed to communicate with the DG1022 can be found in Rigol's programming guide (see below).