AFG-2005 follow up

26.05.2013 12:56

Here is some additional information about the GW Instek AFG-2005 function generator I reviewed earlier.

My first actual use of this instrument left a pretty bad impression. My father and I attempted to perform some tests on his home made short-wave transceiver and it failed badly. For some reason most commands we sent from the computer over the USB would either crash the AFG-2005 or produce very unpredictable results so we were not able to do anything useful with it. I'm still not sure what was the reason.

We used a somewhat longer USB cable (maybe 5 m) so one possibility was that data on the cable got corrupted. Considering that there was some high-powered RF hardware near by, I think that is not that far fetched. Linux kernel didn't show any complaints though which is weird. The other theory is that there was some incompatibility with the kernel that was running on the Ubuntu machine we were using. User space code was exactly the same that later ran fine at my place with AFG-2005 connected to my own computer.

Anyway, I published some Python code for controlling the AFG-2005 from a Linux computer. Currently it's pretty rudimentary, but takes care nicely of the specifics of the IEEE-488 implementation on this instrument.

To get it, run:

$ git clone

Example code to generate a 100 Hz square wave:

from gwinstek.afg import AFG2000

afg = AFG2000("/dev/ttyACM0")
afg.set_waveform(100, [-1.0, 1.0])

Some more notes regarding things I said in the previous post:

About synchronization issues with USBTMC: Apparently IEEE-488 specifies some special commands to deal with command concurrency and synchronization. This somewhat dated GPIB programming tutorial explains it nicely. AFG-2005 doesn't seem to support neither *WAI nor *OPC commands though.

Regarding error reporting, IEEE-488 specifies an error queue where errors are accumulated and can be read by the instrument controller using the SYSTEM:ERROR? query or cleared using the *CLS command. While the manual doesn't mention it explicitly, AFG-2005 does support this functionality. Python modules I published above use it to raise Python exceptions on command errors.

Posted by Tomaž | Categories: Code

Add a new comment

(No HTML tags allowed. Separate paragraphs with a blank line.)