I have old Hewlet Packard 33120A function generator (it should be the same type as Agilent 33120A) and I would like to control it with MCU (ATMega). The generator has RS232 and use SCPI commands.

I made simple RS232 to TTL converter with MAX232, just with RX and TX lines. According to User's guide (chapter 4, section DTR/DSR Handshake Protocol) I tied the DSR to logic TRUE (negative voltage) and DTR is not connected. This configuration should disabled hardware handshake.

Now, I can connect converter to MCU or to computer. For my first experiment I used computer and this Python script:

import serial, sys, time

if __name__ == '__main__':
        if len(sys.argv) < 2:
                print 'Usage: %s <serial_port>' % sys.argv[0]

        s = serial.Serial(port=sys.argv[1], baudrate=2400, bytesize=8, parity='N', stopbits=2, timeout=None, xonxoff=0, rtscts=0)

        s.write('APPL:SIN 30E+3, 0.1\n')


This works without any problem. The generator set its output to 30kHz as expected. The problem is, when I try to read some response from generator. For example, this should return device name:

        print s.realine()

I am pretty sure the response is stored in generator's output buffer but no data are actually transmitted.

Is there any command to trigger transmitting data from buffer? Or do I need enable hardware handshake?

Is there anyone who has this generator? Do you use it with RS232 and SCPI?

  • \$\begingroup\$ I can't answer this question but i'm interested in the answers so you've got my up-vote \$\endgroup\$
    – Andy aka
    Commented Mar 20, 2013 at 22:23
  • \$\begingroup\$ How do you know it's not transmitting? You don't have any code there to read it. Have you tried a terminal program or a serial port monitor? Or an oscilloscope? \$\endgroup\$ Commented Mar 21, 2013 at 4:43
  • \$\begingroup\$ I have Saleae logic analyzer conected to RX/TX pins and in Python script, there is s.readline() function (I edited my question, thank you). \$\endgroup\$
    – vasco
    Commented Mar 21, 2013 at 6:43
  • \$\begingroup\$ Possibly a related question: stackoverflow.com/questions/1093598/… \$\endgroup\$ Commented Mar 29, 2013 at 20:56
  • \$\begingroup\$ On your computer, Turn off serial buffering, and set the serial buffer size to zero. Is the readline blocking indefinitely? (it should be from what you have described) \$\endgroup\$
    – david
    Commented Apr 23, 2013 at 8:42

2 Answers 2


The easiest way to debug SCPI over RS-232 is to use a terminal program with your existing serial interface. Just type the command and see what comes back. The terminal allows you to fairly easily fiddlle with baud rate, handshaking, echo and termination characters without relying on some unknown serial communication library in between (what you type is what you send, what is received is what is shown).

*IDN? doesn't need any special trigger or prompt for response. If the command is supported (according to the manual, it is), if the termination character is correct (which it appears to be, since your previous Python work had some success) and if the handshaking is correct, the instrument should respond immediately with the identification string.

Once you figure out exactly what the instrument expects and returns, you can then craft your Python script with ease.

  • 1
    \$\begingroup\$ Useful info for me mister guruman +1. Whatever happened to the OP? \$\endgroup\$
    – Andy aka
    Commented Oct 11, 2013 at 15:30

It's later but...

Try to tie DSR to positive voltage. My 33120A only responds if I do that in place of tied to negative voltage.

I use RealTerm with an FTDI USB-RS232 converter, and attaching CTS (PC) to DSR (33120a) but managing (and holding) the voltage of CTS through RealTerm during the communications (There is an option to do that in the program).



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.