Nothing fancy, here, just a way of getting a Linux python graphical interface for the output value of the HP5316B frequency counter on the GPIB interface.
Bellow example of code output/"display". Basic use will be video insertion during troubleshooting/recording and/or automated measurement.
The HP5316B frequency counter during testing of the Si5351 GPS disciplined oscillator with a NEO7M module from this post.
The icon on the desktop along with other projects for GPIB or serial interface data collection:
The ICS 4896 GPIB to serial converter (right icon) was describe on the previous post. The other ones to follow.
The Python code:
==== code start fcounter.py
import Tkinter as tk
import pyvisa
import time
rm = pyvisa.ResourceManager()
inst = rm.open_resource('GPIB0::3::INSTR')
counter = 0
def counter_label(label):
def count():
global counter
counter += 1
inst.write("FN1")
result=inst.read_bytes(19, break_on_termchar='\r\n')
result=result[2:] # renove the first 2 characters
result=float(result)
label.config(text=str(result)+" hz")
label.after(2000, count)
count()
root = tk.Tk()
root.title(" HP 5316B counter ")
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(
==== end code fcounter.py
You will need to set the GPIB address for your instrument on the following line:
inst = rm.open_resource('GPIB0::3::INSTR')
In my case it's address "3".
If you are using Linux Mint the desktop icon/launcher code this bellow. You need do adapt to your specific directories.
==== launcher
[Desktop Entry]
Name=HP5316B
Exec=python /home/rmartins/soft/fcounter/fcounter.py
Comment=
Terminal=false
Icon=/home/rmartins/soft/fcounter/th.jpeg
Type=Application
==== end launcher
Have a great day!
Bellow example of code output/"display". Basic use will be video insertion during troubleshooting/recording and/or automated measurement.
The HP5316B frequency counter during testing of the Si5351 GPS disciplined oscillator with a NEO7M module from this post.
The icon on the desktop along with other projects for GPIB or serial interface data collection:
The ICS 4896 GPIB to serial converter (right icon) was describe on the previous post. The other ones to follow.
The Python code:
==== code start fcounter.py
import Tkinter as tk
import pyvisa
import time
rm = pyvisa.ResourceManager()
inst = rm.open_resource('GPIB0::3::INSTR')
counter = 0
def counter_label(label):
def count():
global counter
counter += 1
inst.write("FN1")
result=inst.read_bytes(19, break_on_termchar='\r\n')
result=result[2:] # renove the first 2 characters
result=float(result)
label.config(text=str(result)+" hz")
label.after(2000, count)
count()
root = tk.Tk()
root.title(" HP 5316B counter ")
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(
==== end code fcounter.py
You will need to set the GPIB address for your instrument on the following line:
inst = rm.open_resource('GPIB0::3::INSTR')
In my case it's address "3".
If you are using Linux Mint the desktop icon/launcher code this bellow. You need do adapt to your specific directories.
==== launcher
[Desktop Entry]
Name=HP5316B
Exec=python /home/rmartins/soft/fcounter/fcounter.py
Comment=
Terminal=false
Icon=/home/rmartins/soft/fcounter/th.jpeg
Type=Application
==== end launcher
Have a great day!
No comments:
Post a Comment