The SPD series of power supplies feature remote programming capabilities and can be controlled via USB or LAN connection.
In this note, we will use Python and PyVISA to create a program that will connect to an SPD, enable the output, delay, and then disable the output.
There are two areas that differ from some other instrumentation:
- The SPD requires “\n” termination only. Additional characters will cause a failure.
NOTE: SPDs will make an audible “beep” if there is a remote communications error
- Delays, here using the Python “time.sleep” command, are helpful in sequencing and allow the instrument time to respond. 10-100 ms should do for most commands.
- Use single-action “Write” commands to send the string to the instrument, a set delay of 10-100 ms, and “Read” commands to retrieve data from the instrument. Bundled operation commands, like “Queries” that perform a Write-then-read operation without a delay may cause issues with programming.
- The SPD uses VXI-11 protocol for LAN. On some systems, it is helpful to use the VXI-11 format for the IP address:
Here is a zipped download Python PyVISA SPD Example
#Python 3.7 32 bit
import time # for sleep
rm = visa.ResourceManager()
instadd = ‘USB0::0x0483::0x7540::SPD3XGB4150080::INSTR’
inst = rm.open_resource(instadd)
inst.write_termination=’\n’ #Modify termination character
inst.read_termination=’\n’ #Modify termination character
#print (rm.list_resources()) #List USB resources
inst.write(‘OUTP CH1,ON’) #Turn on output
inst.write(‘OUTP CH1,OFF’) #Turn off output
inst.write(‘*IDN?’) #Write instrument and ask for identification string
qStr = inst.read() #Read instrument response
print (str(qStr)) #Print returned string
inst.close() #Close instrument VISA session
if __name__ == ‘__main__’: