Monday, May 11, 2020

GPIB - Agilent/HP 6621A

A new one for the "software" pile, using GPIB, Linux and Python.

In the past I placed some example on how to control the outputs of the Agilent/HP 6621A using the Arduino USB to GPIB converter, now, using a "proper" GPIB board to get the current delivered on the two outputs in graphical form and from the command line to set the same outputs.



The code output, along with the startup icon on the background, bellow; "1" is the current of output one and "2" is for output #2:

...not much going around at the time of the display.

Since the voltage will not change in most of the testings I do I didn't included the set voltage, anyhow I have an external meter better suited for easy reading than the LCD on the equipment. The meter also includes output jacks extended from the back of the PSU unit.

The panel meter used was a "conversion" of a 0 to 250VAC type to 0 to 25VDC in this post.

The Code to display the output current (every 1s):

=== code start gpsu.py

#!/usr/bin/python
import Tkinter as tk
import pyvisa
import time

rm = pyvisa.ResourceManager()
inst = rm.open_resource('GPIB0::1::INSTR')

counter = 0
def counter_label(label):
  def count():
    global counter
    counter += 1
    current1=inst.query("IOUT?1")
    current2=inst.query("IOUT?2")
    label.config(text="1:"+current1+"2:"+current2)
    label.after(1000, count)
  count()

root = tk.Tk()
root.title("Agilent 6621A - Iout")
label = tk.Label(root, fg="light green", bg ="dark green", font = "Helvetica 18 bold italic")
label.pack()
counter_label(label)
button = tk.Button(root, text=' EXIT ', width=45, command=root.destroy)
button.pack()
root.mainloop()

=== code end gpsu.py


If you need to set output on the PSU from command prompt you can use this one bellow (setoutput.py):

=== code start setoutput.py

#!/usr/bin/python
# sets output 1 or 2 from Agilent 6621A power supply via gpib
# needs pyvisa
import time
import pyvisa
import sys

rm = pyvisa.ResourceManager()
# gpib card 0 address 1, change to your instrument address
inst = rm.open_resource('GPIB0::1::INSTR')

if len(sys.argv) == 3:
 print("Setting: ")
 print "Output #",
 print sys.argv[1],
 print "to ",
 print sys.argv[2],
 print " V"

 if sys.argv[1] == "1": # setting output number 1
  inst.query("VSET1,"+sys.argv[2])
  print("..done!")

 if sys.argv[1] == "2": # setting output number 2
  inst.query("VSET2,"+sys.argv[2])
  print("..done!")


# number of args not given currectly
else:
 print("")
 print("Not enough arguments")
 print("")
 print("setoutput.py ")
 print("")
 print("ex: setoutput.py 1 5.00")

# voltage2=inst.query("VOUT?2")
# current1=inst.query("IOUT?1")
# current2=inst.query("IOUT?2")

=== code end setoutput.py

To get all (current and voltage) from the PSU use the following code (getoutput.py):

(previous screenshot showing the output 1 and 2 voltages being set and the collected the current values along with the current)

=== code start getoutput.py

#!/usr/bin/python
# sets output 1 or 2 from Agilent 6621A power supply via gpib
# needs pyvisa
import time
import pyvisa
import sys

rm = pyvisa.ResourceManager()
# gpib card 0 address 1, change to your instrument address
inst = rm.open_resource('GPIB0::1::INSTR')

if len(sys.argv) == 3:
 print("Setting: ")
 print "Output #",
 print sys.argv[1],
 print "to ",
 print sys.argv[2],
 print " V"

 if sys.argv[1] == "1": # setting output number 1
  inst.query("VSET1,"+sys.argv[2])
  print("..done!")

 if sys.argv[1] == "2": # setting output number 2
  inst.query("VSET2,"+sys.argv[2])
  print("..done!")


# number of args not given currectly
else:
 print("")
 print("Not enough arguments")
 print("")
 print("setoutput.py ")
 print("")
 print("ex: setoutput.py 1 5.00")

# voltage2=inst.query("VOUT?2")
# current1=inst.query("IOUT?1")
# current2=inst.query("IOUT?2")

=== code end getoutput.py


Hope you find it useful.

Have a nice day!






No comments: