I have a Rigol DL3021 programmable load. I'd like to control it as part of an automated test setup, over SCPI from a Linux box.

Their programming manual assumes you're on a Windows machine and wants their software to be installed as a prerequisite. Luckily there's an open source VISA implementation called pyvisa which I've had success with over USB. I'm able to detect the device and send it commands. On a side note it seems a bit finicky, but I am new to SCPI and it is perhaps my fault.

Regardless, if I could, I'd like to control it directly over RS232 with SCPI commands. I am ok with writing a small SCPI wrapper driver and giving up whatever nice abstractions VISA provides me in doing this. I have a RS232 to USB FTDI cable which is known working.

When I write SCPI commands to the serial device, though, nothing happens and I receive no response. I have checked the baud, parity, stop bits, control, many times and am confident they match. I see nothing in the manual about needing to explicitly enable RS232 communication on the device.

As an extra datapoint, pyvisa documentation says it should pick up the device over the RS232 adapter, but it doesn't. I'm unsure what to make of this, I have no way to talk to it with the RS232.

This might be where I'm a bit lost, as I'm unclear if there's some handshaking or other magic that needs to be done to start communication with the load. I am working under the assumption that I can send it SCPI commands directly over the RS232 connection, but perhaps I've oversimplified this.

How do I connect to an instrument and check the serial connection?

  • \$\begingroup\$ What pyvisa backend are you using? What resource string are you using to open a handle to the instrument? Are you properly terminating your commands? Page 10 of the manual says you need to terminate your commands with a carriage return and a newline character. Post an example script sending a "*IDN?" query using pyvisa. \$\endgroup\$ – Shamtam Jun 26 at 23:22
  • \$\begingroup\$ I believe its PyVISA-py. This is the last part of my question, I still need a resource string to open a handle even over RS232?? In the instrument's menu it gives me a resource string in the USB settings but in the RS232 settings it only has serial setup params. I had assumed I could just send SCPI to it over the RS232 connection without needing a resource string. I am properly terminating them with \r\n per the manual, and just using pyserial's serial.write() and serial.read() methods. This has worked for me with other (non-SCPI) instruments. \$\endgroup\$ – brenzo Jun 27 at 0:21
  • \$\begingroup\$ Looks like you can just use the COM port directly as the resource string (see here), e.g. i = rm.open_resource('COM2'). Alternatively, I'm used to using a string like ASRL1::INSTR for e.g. COM1. \$\endgroup\$ – Shamtam Jun 27 at 12:21

You won't need to, make sure that the settings match these enter image description here

It sounds like you've gotten that far. The next problem is finding the right end of line characters, which are not described in the document but usually are used. With serial, the command interpreter on the instrument need to know where the end of a command is. This is usually done with the newline or carriage return characters

The best way I've found to trouble shoot instruments with serial ports is to use realterm Set the port (make sure it's the right one), the baud, and the stop and databits. Then open the port (port tab) Then send an *IDN? command (send tab) and you should see something come back, if you don't then try checking the LF then send again, if if that doesn't work then try the CR or try both. You should see something come back.

If none of that worked then you might not have the right serial cable, they come in straight and crossover versions. enter image description here

You can also turn on the display to see all characters coming back, this helps to understand how your software needs to interpret the serial stream coming back. (you would also need to use a serial package with python and maybe parse the serial stream)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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