Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ coverage.xml
# Sphinx documentation
docs/_build/

captures
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ Rigol DP83X GUI. This is a simple graphing GUI based on Colin O'Flynn's and kudl
To use this you'll need to install:

* Ultra Sigma from Rigol [OPTIONAL: Can also just copy/paste the address from the DP83X (DP831,DP832) display]
* Python 3.x with pyside6 PyQt5 pyqtgraph pyvisa-py install as follows
* Python 3.x
* pip install pyside6
* pip install PyQt5
* pip install pyqtgraph
* pip install pyvisa-py
* pip install pyvisa-py [On Linux you can skip this and use /dev/usbtmc*]
* pip install matplotlib

Once your system is running, just run dpgui.py via your installed Python. Supply the address string (open Ultra Sigma, make sure it finds your Power Supply, and copy-paste address string from that, OR just look in the 'utilities' menu, OR point your browser to its IP address).
Expand All @@ -23,6 +22,8 @@ Will look something like

If the address copied from the DP83X (DP831,DP832) display doesn't work, install Ultra Sigma to confirm it is detected there. If Ultra Sigma didn't see the power supply something else is up...

On Linux, run `ls -alh /dev/usbtmc*`, check if you have access and use the device filename directly

Bugs
=======

Expand Down
31 changes: 26 additions & 5 deletions dp83xgui/dp83x.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
# pip install pyvisa-py
import pyvisa as visa
import os

#Insert your serial number here / confirm via Ultra Sigma GUI
# examples "TCPIP0::192.168.1.60::INSTR"
# "USB0::0x1AB1::0x0E11::DPXXXXXXXXXXX::INSTR"

CONNECTSTRING = "TCPIP0::172.16.0.125::INSTR"
#CONNECTSTRING = "TCPIP0::192.168.1.60::INSTR"

# Implementation using char devices
# e.g. Linux USBTMC kernel driver or RS-232
class CharDevInst():
def __init__(self, path):
self.fd = os.open(path, os.O_RDWR)

def write(self, cmd):
os.write(self.fd, cmd.encode("ascii"))

def query(self, cmd):
self.write(cmd)
return os.read(self.fd, 4096).decode("ascii")

class DP83X(object):
def __init__(self):
pass

def conn(self, constr):
"""Attempt to connect to instrument"""
try:
rm = visa.ResourceManager()
self.inst = rm.open_resource(constr)
except visa.VisaIOError:
print("\n\n\nFailed to connect to",constr,"\n\n\n")
# /dev/usbtmc0, maybe TTY for RS-232
if constr.startswith('/'):
self.inst = CharDevInst(constr)
else:
import pyvisa as visa
rm = visa.ResourceManager()
self.inst = rm.open_resource(constr)
except Exception as err:
print("Failed to connect to ", constr, ": ", err)
raise err

def identify(self):
"""Return identify string which has serial number"""
Expand All @@ -34,6 +54,7 @@ def readings(self, channel="CH1"):
return dr

def dis(self):
self.inst.write(":SYSTEM:LOCAL")
del self.inst

def applyVoltage(self,channel, voltage):
Expand Down
45 changes: 32 additions & 13 deletions dp83xgui/dpgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#
# Python 3.10.0
# pip install pyside6
# pip install PyQt5
# pip install pyqtgraph
# pip install pyvisa-py
# pip install matplotlib
Expand All @@ -32,8 +31,8 @@
from PySide6.QtCore import *
from PySide6.QtGui import *

from PyQt5.QtWidgets import * #QApplication, QWidget, QMainWindow, QPushButton, QMessageBox, QBoxLayout
from PyQt5 import QtCore, QtGui
from PySide6.QtWidgets import * #QApplication, QWidget, QMainWindow, QPushButton, QMessageBox, QBoxLayout
from PySide6 import QtCore, QtGui

try:
import pyqtgraph as pg
Expand Down Expand Up @@ -145,7 +144,11 @@ class DP83XGUI(QMainWindow):
def __init__(self):
super(DP83XGUI, self).__init__()
self.setWindowIcon(QtGui.QIcon('frog1.bmp'))
wid = QWidget()
root = QWidget()
mainLayout = QVBoxLayout()
scroll = QScrollArea()
scroll.setWidgetResizable(True)
self.container = QWidget()
layout = QVBoxLayout()
self.drawDone = False

Expand Down Expand Up @@ -201,9 +204,9 @@ def __init__(self):

self.channelSpecsDP83x = []

self.channelSpecsDP83x.append({'DP832A':{'maxV':30,'maxI':3},'DP831':{'maxV':8 ,'maxI':5}})
self.channelSpecsDP83x.append({'DP832A':{'maxV':30,'maxI':3},'DP831':{'maxV':30,'maxI':2}})
self.channelSpecsDP83x.append({'DP832A':{'maxV':5 ,'maxI':3},'DP831':{'maxV':30,'maxI':2}})
self.channelSpecsDP83x.append({'DP832A':{'maxV':30,'maxI':3},'DP832':{'maxV':30,'maxI':3},'DP831':{'maxV':8 ,'maxI':5}})
self.channelSpecsDP83x.append({'DP832A':{'maxV':30,'maxI':3},'DP832':{'maxV':30,'maxI':3},'DP831':{'maxV':30,'maxI':2}})
self.channelSpecsDP83x.append({'DP832A':{'maxV':5 ,'maxI':3},'DP832':{'maxV':5 ,'maxI':3},'DP831':{'maxV':30,'maxI':2}})
Copy link
Author

@dsseng dsseng May 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we could set these limits to higher values. On DP832 it's 32V for 1 and 2 and 5.3V for CH3


self.graphlist = []
self.graphsettings = []
Expand Down Expand Up @@ -242,14 +245,22 @@ def __init__(self):
self.absSinX = (sinX +1)/2
shiftedAbsSinX = (np.sin((2*np.pi*F)*((x+(3/4)*(self.numSamples))/self.numSamples) )+1)/2

wid.setLayout(layout)
self.container.setLayout(layout)
scroll.setWidget(self.container)
mainLayout.addWidget(scroll)
root.setLayout(mainLayout)

self.setCentralWidget(wid)
self.setCentralWidget(root)
self.setWindowTitle("DP83X GUI")

def closeEvent(self, event):
self.dis()
event.accept()

def addGraphs(self, graphnum):
layout = self.centralWidget().layout()
layout = self.container.layout()
gb = QGroupBox()
gb.setMinimumHeight(240)

self.gridLayoutChannel = QGridLayout()

Expand Down Expand Up @@ -511,7 +522,12 @@ def tryConnect(self):
QSettings().setValue('constring', constr)

self.inst = DP83X()
self.inst.conn(constr)
try:
self.inst.conn(constr)
except Exception as err:
self.statusBar().showMessage(str(err))
return

self.leModel.setText(self.inst.identify()["model"])

self.layoutcon.addWidget(self.loggingPushButton)
Expand Down Expand Up @@ -599,7 +615,7 @@ def setLogging(self):
#print(self.loggingPushButton.isChecked())

def logData(self):#,readings,graphnum):
path_to_log = "captures\\"
path_to_log = "captures/"
file_format = "csv"
try:
os.makedirs(path_to_log)
Expand Down Expand Up @@ -634,17 +650,20 @@ def updateSystTemperature(self):
self.temperatureWarningToggle = False
self.leTemp.setStyleSheet("QLineEdit"
"{"
"color: black;"
"background : pink;"
"}")
else:
self.temperatureWarningToggle = True
self.leTemp.setStyleSheet("QLineEdit"
"{"
"color: black;"
"background : white;"
"}")
else:
self.leTemp.setStyleSheet("QLineEdit"
"{"
"color: black;"
"background : lightgreen;"
"}")

Expand Down Expand Up @@ -708,4 +727,4 @@ def makeApplication():
window.show()

# Run the main Qt loop
sys.exit(app.exec_())
sys.exit(app.exec())
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyside6
pyqtgraph
pyvisa-py
matplotlib