SPD programming tips

December 26, 2018

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.

Here is a zipped download  Python PyVISA SPD Example

**

#Dependencies:
#Python 3.7 32 bit
#PyVisa 1.7

import visa
import time # for sleep
import binascii

def main():

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
time.sleep(0.04) #Wait
inst.write(‘OUTP CH1,ON’) #Turn on output
time.sleep(2) #Wait
inst.write(‘OUTP CH1,OFF’) #Turn off output
time.sleep(2) #Wait
inst.write(‘*IDN?’) #Write instrument and ask for identification string
#print (“here”)
time.sleep(1) #Wait
qStr = inst.read() #Read instrument response
print (str(qStr)) #Print returned string
inst.close() #Close instrument VISA session

if __name__ == ‘__main__’:

main()