PyVISA Rigol DL3021 via LXI (TCP SCPI) example
First install using
sudo pip install pyvisa pyvisa-py
The following example will connec to a LXI-enabled (license required!!!) DL3021 at IP address 192.168.178.31
import pyvisa
import time
rm = pyvisa.ResourceManager()
inst = rm.open_resource("TCPIP0::192.168.178.112::INSTR")
# Query if instrument is present
# Prints e.g. "RIGOL TECHNOLOGIES,DL3021,DL3A204800938,00.01.05.00.01"
print(inst.query("*IDN?"))
# Set to constant resistance mode
inst.write(":SOURCE:FUNCTION RESISTANCE")
# Set to 3 Ohms
inst.write(":SOURCE:RESISTANCE:LEVEL:IMMEDIATE 3.0")
# Enable electronic load
inst.write(":SOURCE:INPUT:STATE On")
# Wait for value to stabilize
time.sleep(2)
# Measure!
print("Voltage: ", inst.query(":MEASURE:VOLTAGE?").strip())
print("Current: ", inst.query(":MEASURE:CURRENT?").strip())
print("Power: ", inst.query(":MEASURE:POWER?").strip())
This will print, for example:
RIGOL TECHNOLOGIES,DL3021,DL3A204800938,00.01.05.00.01
Voltage: 2.885810
Current: 0.961862
Power: 2.775752
with some power supply attached of course.