diff --git a/__pycache__/ui_mainwindow.cpython-312.pyc b/__pycache__/ui_mainwindow.cpython-312.pyc index e9234e4..e662570 100644 Binary files a/__pycache__/ui_mainwindow.cpython-312.pyc and b/__pycache__/ui_mainwindow.cpython-312.pyc differ diff --git a/psu_control_test_app.py b/psu_control_test_app.py index d630d3b..104fea9 100644 --- a/psu_control_test_app.py +++ b/psu_control_test_app.py @@ -13,7 +13,7 @@ AUTHOR: D. RICE 19/11/2025 import numpy as np from PySide6.QtCore import (QTimer) from PySide6.QtWidgets import (QApplication, QMainWindow, QFileDialog) -import pyvisa +import vxi11 import time import sys import csv @@ -35,22 +35,11 @@ test_time_target = 0 repeat_state = 0 repeat_length = 0 -VISA_ADDRESS = "TCPIP::192.168.45.3::INSTR" - -rm = pyvisa.ResourceManager() -devices = rm.list_resources() -print (devices) - -SPD = rm.open_resource( - VISA_ADDRESS, - write_termination='\n', - read_termination='\n' -) - # Main window class class MainWindow(QMainWindow): + instr = vxi11.Instrument("192.168.45.3") + def __init__(self): - global SPD global setup_del # Initialise main window @@ -107,30 +96,28 @@ class MainWindow(QMainWindow): self.chan2timer.setInterval(200) self.chan2timer.timeout.connect(self.chan2_timer) - #self.testledtimer = QTimer() - #self.testledtimer.setInterval(500) - #self.testledtimer.timeout.connect(self.test_led_timer) + self.testledtimer = QTimer() + self.testledtimer.setInterval(500) + self.testledtimer.timeout.connect(self.test_led_timer) - #self.testtimer = QTimer() - #self.testtimer.setInterval(100) - #self.testtimer.timeout.connect(self.test_timer) + self.testtimer = QTimer() + self.testtimer.setInterval(100) + self.testtimer.timeout.connect(self.test_timer) # Configure Power Supplys - #SPD.write_termination='\n' - #SPD.read_termination='\n' - SPD.write('CH1:VOLT ' + str(0.0)) # Send power supply source voltage + self.instr.write('CH1:VOLT ' + str(0.0)) # Send power supply source voltage time.sleep(setup_del) - SPD.write('CH1:CURR ' + str(1.0)) # Send power supply current limit + self.instr.write('CH1:CURR ' + str(1.0)) # Send power supply current limit time.sleep(setup_del) - SPD.write('CH2:VOLT ' + str(0.0)) # Send power supply source voltage + self.instr.write('CH2:VOLT ' + str(0.0)) # Send power supply source voltage time.sleep(setup_del) - SPD.write('CH2:CURR ' + str(1.0)) # Send power supply current limit + self.instr.write('CH2:CURR ' + str(1.0)) # Send power supply current limit time.sleep(setup_del) # Disable power supply output source - SPD.write('OUTP CH1,OFF') # Enable supply output - SPD.write('OUTP CH2,OFF') # Enable supply output + self.instr.write('OUTP CH1,OFF') # Enable supply output + self.instr.write('OUTP CH2,OFF') # Enable supply output def file_browse_button_press (self): global file_name @@ -141,7 +128,6 @@ class MainWindow(QMainWindow): def test_button_press (self): global test_state_flag - global SPD global file_name global test_data global test_time_counter @@ -166,7 +152,7 @@ class MainWindow(QMainWindow): self.ui.v_lab.setEnabled(False) self.ui.i_lab.setEnabled(False) - SPD.write('OUTP CH1,ON') # Enable supply output + self.instr.write('OUTP CH1,ON') # Enable supply output # Read test file contents with open(file_name, newline='') as csvfile: @@ -203,12 +189,11 @@ class MainWindow(QMainWindow): self.ui.vt_val.setText("00.0") # Disable power supply output source - #SPD.write('OUTP CH1,OFF') # Disable supply output + self.instr.write('OUTP CH1,OFF') # Disable supply output def chan1_button_press (self): global chan1_state_flag global setup_del - global SPD if chan1_state_flag == False: chan1_state_flag = True @@ -222,13 +207,13 @@ class MainWindow(QMainWindow): self.ui.chan1_grn.setHidden(False) self.ui.chan1_red.setHidden(True) - SPD.write('CH1:VOLT ' + voltage) #Send power supply source voltage + self.instr.write('CH1:VOLT ' + voltage) #Send power supply source voltage time.sleep(setup_del) - SPD.write('CH1:CURR ' + current) #Send power supply current limit + self.instr.write('CH1:CURR ' + current) #Send power supply current limit time.sleep(setup_del) # Enable power supply output source - SPD.write('OUTP CH1,ON') # Enable supply output + self.instr.write('OUTP CH1,ON') # Enable supply output # Enable timer to get data self.chan1timer.start() @@ -243,7 +228,7 @@ class MainWindow(QMainWindow): self.ui.chan1_red.setHidden(True) # Disable power supply output source - SPD.write('OUTP CH1,OFF') # Disable supply output + self.instr.write('OUTP CH1,OFF') # Disable supply output # Disable timer self.chan1timer.stop() @@ -255,7 +240,6 @@ class MainWindow(QMainWindow): def chan2_button_press (self): global chan2_state_flag global setup_del - global SPD if chan2_state_flag == False: chan2_state_flag = True @@ -269,13 +253,13 @@ class MainWindow(QMainWindow): self.ui.chan2_grn.setHidden(False) self.ui.chan2_red.setHidden(True) - SPD.write('CH2:VOLT ' + voltage) #Send power supply source voltage + self.instr.write('CH2:VOLT ' + voltage) #Send power supply source voltage time.sleep(setup_del) - SPD.write('CH2:CURR ' + current) #Send power supply current limit + self.instr.write('CH2:CURR ' + current) #Send power supply current limit time.sleep(setup_del) # Enable power supply output source - SPD.write('OUTP CH2,ON') # Enable supply output + self.instr.write('OUTP CH2,ON') # Enable supply output # Enable timer to get data self.chan2timer.start() @@ -290,7 +274,7 @@ class MainWindow(QMainWindow): self.ui.chan2_red.setHidden(True) # Disable power supply output source - SPD.write('OUTP CH2,OFF') # Disable supply output + self.instr.write('OUTP CH2,OFF') # Disable supply output # Disable timer self.chan2timer.stop() @@ -300,19 +284,18 @@ class MainWindow(QMainWindow): self.ui.chan2_mp_val.setText("0.00") def chan1_timer (self): - global SPD global meas_del # get voltage/current/power - SPD.write("MEAS:VOLT? CH1") + self.instr.write("MEAS:VOLT? CH1") time.sleep(meas_del) - voltage = SPD.read() - SPD.write("MEAS:CURR? CH1") + voltage = self.instr.read() + self.instr.write("MEAS:CURR? CH1") time.sleep(meas_del) - current = SPD.read() - SPD.write("MEAS:POWE? CH1") + current = self.instr.read() + self.instr.write("MEAS:POWE? CH1") time.sleep(meas_del) - power = SPD.read() + power = self.instr.read() self.ui.chan1_mv_val.setText(voltage) self.ui.chan1_mi_val.setText(current) @@ -322,19 +305,18 @@ class MainWindow(QMainWindow): def chan2_timer (self): - global SPD global meas_del # get voltage/current/power - SPD.write("MEAS:VOLT? CH2") + self.instr.write("MEAS:VOLT? CH2") time.sleep(meas_del) - voltage = SPD.read() - SPD.write("MEAS:CURR? CH2") + voltage = self.instr.read() + self.instr.write("MEAS:CURR? CH2") time.sleep(meas_del) - current = SPD.read() - SPD.write("MEAS:POWE? CH2") + current = self.instr.read() + self.instr.write("MEAS:POWE? CH2") time.sleep(meas_del) - power = SPD.read() + power = self.instr.read() self.ui.chan2_mv_val.setText(voltage) self.ui.chan2_mi_val.setText(current) @@ -382,7 +364,7 @@ class MainWindow(QMainWindow): test_time_target = 0 - SPD.write('CH1:VOLT ' + voltage_set) # Send power supply source voltage + self.instr.write('CH1:VOLT ' + voltage_set) # Send power supply source voltage current_t = self.ui.i_val.text() @@ -446,7 +428,7 @@ class MainWindow(QMainWindow): self.ui.vt_val.setText("0.00") # Disable power supply output source - #SPD.write('OUTP CH1,OFF') # Disable supply output + self.instr.write('OUTP CH1,OFF') # Disable supply output QApplication.processEvents() diff --git a/ui_mainwindow.py b/ui_mainwindow.py index 6fc5b9d..200b765 100644 --- a/ui_mainwindow.py +++ b/ui_mainwindow.py @@ -4,9 +4,6 @@ from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect, Qt) from PySide6.QtGui import (QBrush, QColor, QFont, QIcon, QPalette, QPixmap) from PySide6.QtWidgets import (QLabel, QPushButton, QWidget, QFrame, QLineEdit) -import pyqtgraph as pg -from pyqtgraph.Qt import QtGui - class Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName():