Sunday, August 23, 2020

GPIB - Rohde & Schwarz URY / URV5 Millivoltmeter

 Having the URY millivoltmeter decided to code a small utility to collect data via GPIB using Linux. As far as I know the URY is functionally the same as the URV5 being the URY a version for a specific marked, this software was tested only on the URY with Linux GPIB and Python.

The meter:



The probe used for testing:


The graphical output along with the launcher icon:


The code for the above software:

===
import Tkinter as tk
import pyvisa
import time
# read power from channel A of the R&S URY millivoltmeter
rm = pyvisa.ResourceManager()
inst = rm.open_resource('GPIB0::12::INSTR')

counter = 0
def counter_label(label):
  def count():
    global counter
    counter += 1
    inst.write("IA,U1,KA0,F3,PA,F3,X1")
    result=inst.read_bytes(21, break_on_termchar='\r\n')
    result=result[9:] # remove the first 9 characters
    label.config(text=str(result)+" dBm")
    label.after(1000, count)
  count()

root = tk.Tk()
root.title("   R&S URY channel A  ")
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=35, command=root.destroy)
button.pack()
root.mainloop()
===

A screenshot in case formatting on blogger changes the code:



Made also a utility to get data via command line, could be handy for scripted collection. To get the values from channel B instead of A the code is only different on the instrument query string. The query is also only for dbm output, if you need any other unit or parameters do change the inst.write string.

Code for channel A:

copy/past version bellow:

===
#!/usr/bin/python
# get the power of channel A on R&S URY milivoltmeter

import pyvisa
rm = pyvisa.ResourceManager()

inst = rm.open_resource('GPIB0::12::INSTR')
inst.read_termination = '\n'
inst.write_termination = '\n'
inst.timeout = 5000

try:
  inst.write("IA,U1,KA0,F3,PA,F3,X1")
  exception = 1
  result=inst.read_bytes(20, break_on_termchar='\r\n')
  print(result)
except: exception = 2

if exception == 2:
 print("ERROR")
 exit()

===

Output example:

The query string for channel B:

In case no probe inserted you will get the "URY PB NO PROBE" message

Usage example along with code and diff for channel B:



Hope it helps.

Have a nice day!


 

 


No comments: