@@ -0,0 +1,1343 @@
+#!/usr/bin/env python%0A%0A# RS-232 serial support for Agilent 33120A 15MHz Arbitrary Waveform Generator%0A# Be careful about the line endings. Handles SCPI commands and see manual%0A# http://www.home.agilent.com/upload/cmc_upload/All/6C0633120A_USERSGUIDE_ENGLISH.pdf%0A# or look for it on the Internet Archive%0A%0Aimport serial%0Afrom time import sleep%0Aimport random%0A%0A# Values set on unit manually (but these are standard settings%0Aser = serial.Serial('/dev/ttyUSB1',baudrate=9600, bytesize=8, stopbits=1, %5C%0A    parity=serial.PARITY_NONE, timeout=3)%0A%0Aser.open()%0Aprint ser%0A%0ADEBUG = 0%0A%0Adef sendCmd(command):%0A    if DEBUG:%0A        print %22%25s%22 %25(command).strip()%0A    # line ending is essential!%0A    ser.write(%22%25s%5Cn%22 %25(command))%0A%0A# Do a few random frequency changes%0Atry:%0A    # enable remote mode%0A    sendCmd(%22system:remote%22)%0A    n = 0%0A    while n %3C 5:%0A        sendCmd(%22*cls%22)%0A        sendCmd(%22func:shape ramp%22)%0A        freq = int(random.random() * 100)%0A        print %22Set frequency: %25d kHz%22 %25(freq)%0A        sendCmd(%22freq %25d.0E+3%22 %25(freq))%0A        # needs delay before functuon shape can be queried%0A        sleep(0.5)%0A        sendCmd(%22function:shape?%22)%0A        line = ser.readline().strip()%0A        print %22Shape: %25s%22 %25 (line)%0A        n += 1%0A        sleep(2)%0Aexcept (KeyboardInterrupt):%0A    # Exit with Control-C%0A    pass%0Aexcept:%0A    raise%0Afinally:%0A    ser.close()%0A

add RS-232 support for Agilent 33120A 15MHz arbitraty waveform generator