first commit

This commit is contained in:
David Rice
2025-11-27 14:45:20 +00:00
commit 85b0a9f5c8
12 changed files with 1063 additions and 0 deletions

BIN
EPFBLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# Introduction
Application to control/run tests with SPD3303X-E PSU via USB

1
TEST FILES/1.csv Normal file
View File

@@ -0,0 +1 @@
1,500,28,30,18,2,28,30,12,2,30,30,12,2,30,30,24,2,30,2,16,2,28,2,24,2,12,2,30,2,12,2,24,30
1 1 500 28 30 18 2 28 30 12 2 30 30 12 2 30 30 24 2 30 2 16 2 28 2 24 2 12 2 30 2 12 2 24 30

Binary file not shown.

BIN
arriveico.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
arrivelogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
gray-led.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
green-led.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

471
psu_control_test_app.py Normal file
View File

@@ -0,0 +1,471 @@
#!/user/bin/env python3
"""
SPD3303X-E CONTROL APPLICATION - PSU_CONTROl_TEST_APP.PY
- ENTRY POINT OF APPLICATION
VERSION: 1.0
AUTHOR: D. RICE 19/11/2025
© 2025 ARRIVE
"""
# Imports
import numpy as np
from PySide6.QtCore import (QTimer)
from PySide6.QtWidgets import (QApplication, QMainWindow, QFileDialog)
import pyvisa
import time
import sys
import csv
from ui_mainwindow import Ui_MainWindow
# Global variables
test_state_flag = False
chan1_state_flag = False
chan2_state_flag = False
setup_del = 0.2 # Setup delay in seconds
meas_del = 0.05 # Measure delay in seconds
file_name = ""
test_data = list()
test_time_counter = 0
test_state = 0
test_length = 0
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):
def __init__(self):
global SPD
global setup_del
# Initialise main window
super(MainWindow, self).__init__()
# Finish main window initial setup
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
# Set up timer prototype
self.counter = 0
# Hold process reference.
self.p = None
# Add file browser button action
#self.ui.filebrowseButton.setCheckable(True)
#self.ui.filebrowseButton.clicked.connect(self.file_browse_button_press)
# Add test button action
#self.ui.testButton.setCheckable(True)
#self.ui.testButton.clicked.connect(self.test_button_press)
# Add channel button action
self.ui.chan1Button.setEnabled(True)
self.ui.chan1Button.setCheckable(True)
self.ui.chan1Button.clicked.connect(self.chan1_button_press)
self.ui.chan2Button.setEnabled(True)
self.ui.chan2Button.setCheckable(True)
self.ui.chan2Button.clicked.connect(self.chan2_button_press)
# Enable voltage/current entry
self.ui.chan1_v_lab.setEnabled(True)
self.ui.chan1_i_lab.setEnabled(True)
self.ui.chan2_v_lab.setEnabled(True)
self.ui.chan2_i_lab.setEnabled(True)
# Setup LEDs - show black/gray initially
self.ui.chan1_blk.setHidden(False)
self.ui.chan1_grn.setHidden(True)
self.ui.chan1_red.setHidden(True)
self.ui.chan2_blk.setHidden(False)
self.ui.chan2_grn.setHidden(True)
self.ui.chan2_red.setHidden(True)
#self.ui.test_blk.setHidden(False)
#self.ui.test_grn.setHidden(True)
#self.ui.test_red.setHidden(True)
# Setup QT timers
self.chan1timer = QTimer()
self.chan1timer.setInterval(200)
self.chan1timer.timeout.connect(self.chan1_timer)
self.chan2timer = QTimer()
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.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
time.sleep(setup_del)
SPD.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
time.sleep(setup_del)
SPD.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
def file_browse_button_press (self):
global file_name
fname=QFileDialog.getOpenFileName(self, 'Open file', 'C:\\Users\\david.rice\\Documents\\Python\\DRIVER CONSOLE TEST\\TEST FILES', 'CSV UTF-8 (*.csv)')
file_name = fname[0]
self.ui.tfp_val.setText(fname[0])
def test_button_press (self):
global test_state_flag
global SPD
global file_name
global test_data
global test_time_counter
global test_state
global test_length
global test_time_target
global repeat_state
global repeat_length
self.ui.testButton.toggle()
test_time_target = 0
if test_state_flag == False:
test_state_flag = True
if file_name != "":
self.ui.testButton.setText("STOP TEST")
self.testledtimer.start()
# Enable power supply output source
self.ui.chan1Button.setEnabled(False)
self.ui.v_lab.setEnabled(False)
self.ui.i_lab.setEnabled(False)
SPD.write('OUTP CH1,ON') # Enable supply output
# Read test file contents
with open(file_name, newline='') as csvfile:
test_data_l = list(csv.reader(csvfile))
test_data = test_data_l[0]
test_length = len(test_data) - 2
repeat_state = 0
repeat_length_str = test_data[1]
repeat_length = int(repeat_length_str)
test_time_counter = 0
test_state = 1
self.testtimer.start()
else:
test_state_flag = False
self.testtimer.stop()
self.ui.testButton.setText("RUN TEST")
self.testledtimer.stop()
self.ui.test_blk.setHidden(False)
self.ui.test_grn.setHidden(True)
self.ui.test_red.setHidden(True)
self.ui.chan1Button.setEnabled(True)
self.ui.v_lab.setEnabled(True)
self.ui.i_lab.setEnabled(True)
self.ui.it_val.setText("0.00")
self.ui.vt_val.setText("0.00")
self.ui.vt_val.setText("00.0")
# Disable power supply output source
#SPD.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
self.ui.chan1_v_lab.setEnabled(False)
self.ui.chan1_i_lab.setEnabled(False)
voltage = self.ui.chan1_v_val.text()
current = self.ui.chan1_i_val.text()
self.ui.chan1_blk.setHidden(True)
self.ui.chan1_grn.setHidden(False)
self.ui.chan1_red.setHidden(True)
SPD.write('CH1:VOLT ' + voltage) #Send power supply source voltage
time.sleep(setup_del)
SPD.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
# Enable timer to get data
self.chan1timer.start()
else:
chan1_state_flag = False
self.ui.chan1_v_lab.setEnabled(True)
self.ui.chan1_i_lab.setEnabled(True)
self.ui.chan1_blk.setHidden(False)
self.ui.chan1_grn.setHidden(True)
self.ui.chan1_red.setHidden(True)
# Disable power supply output source
SPD.write('OUTP CH1,OFF') # Disable supply output
# Disable timer
self.chan1timer.stop()
self.ui.chan1_mv_val.setText("0.00")
self.ui.chan1_mi_val.setText("0.00")
self.ui.chan1_mp_val.setText("0.00")
def chan2_button_press (self):
global chan2_state_flag
global setup_del
global SPD
if chan2_state_flag == False:
chan2_state_flag = True
self.ui.chan2_v_lab.setEnabled(False)
self.ui.chan2_i_lab.setEnabled(False)
voltage = self.ui.chan2_v_val.text()
current = self.ui.chan2_i_val.text()
self.ui.chan2_blk.setHidden(True)
self.ui.chan2_grn.setHidden(False)
self.ui.chan2_red.setHidden(True)
SPD.write('CH2:VOLT ' + voltage) #Send power supply source voltage
time.sleep(setup_del)
SPD.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
# Enable timer to get data
self.chan2timer.start()
else:
chan2_state_flag = False
self.ui.chan2_v_lab.setEnabled(True)
self.ui.chan2_i_lab.setEnabled(True)
self.ui.chan2_blk.setHidden(False)
self.ui.chan2_grn.setHidden(True)
self.ui.chan2_red.setHidden(True)
# Disable power supply output source
SPD.write('OUTP CH2,OFF') # Disable supply output
# Disable timer
self.chan2timer.stop()
self.ui.chan2_mv_val.setText("0.00")
self.ui.chan2_mi_val.setText("0.00")
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")
time.sleep(meas_del)
voltage = SPD.read()
SPD.write("MEAS:CURR? CH1")
time.sleep(meas_del)
current = SPD.read()
SPD.write("MEAS:POWE? CH1")
time.sleep(meas_del)
power = SPD.read()
self.ui.chan1_mv_val.setText(voltage)
self.ui.chan1_mi_val.setText(current)
self.ui.chan1_mp_val.setText(power)
QApplication.processEvents()
def chan2_timer (self):
global SPD
global meas_del
# get voltage/current/power
SPD.write("MEAS:VOLT? CH2")
time.sleep(meas_del)
voltage = SPD.read()
SPD.write("MEAS:CURR? CH2")
time.sleep(meas_del)
current = SPD.read()
SPD.write("MEAS:POWE? CH2")
time.sleep(meas_del)
power = SPD.read()
self.ui.chan2_mv_val.setText(voltage)
self.ui.chan2_mi_val.setText(current)
self.ui.chan2_mp_val.setText(power)
QApplication.processEvents()
def test_led_timer (self):
self.counter += 1
# Toggle light blue/dark blue LED for 'load_cell_zero' test
if self.counter == 1:
self.ui.test_red.setHidden(False)
self.ui.test_blk.setHidden(True)
else:
self.ui.test_blk.setHidden(False)
self.ui.test_red.setHidden(True)
self.counter = 0
QApplication.processEvents()
def test_timer (self):
global test_time_counter
global test_time_target
global test_state
global test_data
global test_length
global test_state_flag
global psu_state_flag
global repeat_state
global repeat_length
if repeat_state <= repeat_length:
if test_state <= test_length:
if test_time_counter >= test_time_target:
test_state = test_state + 1
print ("TEST STATE: " + str(test_state) + " | TEST LENGTH:" + str(test_length))
print ("REPEAT STATE: " + str(repeat_state) + " | REPEAT LENGTH: " + str(repeat_length))
if test_state % 2 == 0:
if test_state < test_length + 1:
voltage_set = test_data[test_state]
test_time_target = 0
SPD.write('CH1:VOLT ' + voltage_set) # Send power supply source voltage
current_t = self.ui.i_val.text()
self.ui.it_val.setText(current_t)
self.ui.vt_val.setText(voltage_set)
self.ui.tt_val.setText("00.0")
print ("VOLTAGE: " + voltage_set + " | CURRENT: " + current_t)
test_time_counter = 0
else:
time_set = test_data[test_state]
ts_f = float(time_set)
test_time_target = int(ts_f * 10)
if ts_f < 10:
self.ui.tt_val.setText("0" + time_set + ".0")
else:
self.ui.tt_val.setText(time_set + ".0")
else:
test_time_counter = test_time_counter + 1
time_now = test_time_target - test_time_counter
t_div = time_now / 10
t_mod = t_div % 1
int_t_modmult = int (t_mod * 10)
int_t_div = int(t_div)
if int_t_div < 10:
self.ui.tt_val.setText("0" + str(int_t_div) + "." + str(int_t_modmult))
else:
self.ui.tt_val.setText(str(int_t_div) + "." + str(int_t_modmult))
else:
repeat_state = repeat_state + 1
test_state = 1
test_time_counter = 0
else:
test_state_flag = False
self.testtimer.stop()
self.ui.testButton.setText("RUN TEST")
self.testledtimer.stop()
self.ui.test_blk.setHidden(False)
self.ui.test_grn.setHidden(True)
self.ui.test_red.setHidden(True)
self.ui.psuButton.setEnabled(True)
psu_state_flag = False
self.ui.psuButton.setText("PSU ON")
self.ui.v_lab.setEnabled(True)
self.ui.i_lab.setEnabled(True)
self.ui.it_val.setText("0.00")
self.ui.vt_val.setText("0.00")
# Disable power supply output source
#SPD.write('OUTP CH1,OFF') # Disable supply output
QApplication.processEvents()
# Run main
if __name__ == '__main__':
# Send debug information
print("SPD3303X-E CONTROL/TEST APPLICATION")
print("------------------------------------")
print("PROGRAM STARTED...")
# Launch main window
app = QApplication(sys.argv)
app.setStyle('Fusion')
window = MainWindow()
window.show()
app.exec()
# Exit app
print("EXITING APPLICATION...")
sys.exit()

BIN
red-led.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

442
ui_mainwindow.py Normal file
View File

@@ -0,0 +1,442 @@
# -*- coding: utf-8 -*-
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():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(1280, 800)
palette = QPalette()
brush = QBrush(QColor(255, 255, 255, 255))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
brush1 = QBrush(QColor(53, 53, 53, 255))
brush1.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Button, brush1)
palette.setBrush(QPalette.Active, QPalette.Light, brush)
brush2 = QBrush(QColor(202, 202, 202, 255))
brush2.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Midlight, brush2)
brush3 = QBrush(QColor(35, 35, 35, 255))
brush3.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Dark, brush3)
brush4 = QBrush(QColor(184, 184, 184, 255))
brush4.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Mid, brush4)
palette.setBrush(QPalette.Active, QPalette.Text, brush)
brush5 = QBrush(QColor(255, 0, 0, 255))
brush5.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.BrightText, brush5)
palette.setBrush(QPalette.Active, QPalette.ButtonText, brush)
brush6 = QBrush(QColor(42, 42, 42, 255))
brush6.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Base, brush6)
palette.setBrush(QPalette.Active, QPalette.Window, brush1)
brush7 = QBrush(QColor(20, 20, 20, 255))
brush7.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Shadow, brush7)
brush8 = QBrush(QColor(164, 0, 0, 255))
brush8.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Highlight, brush8)
palette.setBrush(QPalette.Active, QPalette.HighlightedText, brush)
palette.setBrush(QPalette.Active, QPalette.Link, brush8)
brush9 = QBrush(QColor(255, 0, 255, 255))
brush9.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.LinkVisited, brush9)
brush10 = QBrush(QColor(66, 66, 66, 255))
brush10.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush10)
brush11 = QBrush(QColor(0, 0, 0, 255))
brush11.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.NoRole, brush11)
palette.setBrush(QPalette.Active, QPalette.ToolTipBase, brush)
palette.setBrush(QPalette.Active, QPalette.ToolTipText, brush)
brush12 = QBrush(QColor(0, 0, 0, 128))
brush12.setStyle(Qt.SolidPattern)
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
palette.setBrush(QPalette.Active, QPalette.PlaceholderText, brush12)
#endif
palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
brush13 = QBrush(QColor(239, 239, 239, 255))
brush13.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Button, brush1)
palette.setBrush(QPalette.Inactive, QPalette.Light, brush)
palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush2)
brush14 = QBrush(QColor(159, 159, 159, 255))
brush14.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Dark, brush3)
palette.setBrush(QPalette.Inactive, QPalette.Mid, brush4)
palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush5)
palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
palette.setBrush(QPalette.Inactive, QPalette.Base, brush6)
palette.setBrush(QPalette.Inactive, QPalette.Window, brush1)
brush15 = QBrush(QColor(118, 118, 118, 255))
brush15.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush7)
brush16 = QBrush(QColor(48, 140, 198, 255))
brush16.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Highlight, brush8)
palette.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush)
brush17 = QBrush(QColor(0, 0, 255, 255))
brush17.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Link, brush8)
palette.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush9)
brush18 = QBrush(QColor(247, 247, 247, 255))
brush18.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10)
brush19 = QBrush(QColor(0, 0, 0, 255))
brush19.setStyle(Qt.NoBrush)
palette.setBrush(QPalette.Inactive, QPalette.NoRole, brush11)
brush20 = QBrush(QColor(255, 255, 220, 255))
brush20.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.ToolTipBase, brush)
palette.setBrush(QPalette.Inactive, QPalette.ToolTipText, brush)
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
palette.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush12)
#endif
palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
palette.setBrush(QPalette.Disabled, QPalette.Button, brush1)
palette.setBrush(QPalette.Disabled, QPalette.Light, brush)
palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush2)
palette.setBrush(QPalette.Disabled, QPalette.Dark, brush3)
palette.setBrush(QPalette.Disabled, QPalette.Mid, brush4)
palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush5)
brush21 = QBrush(QColor(127, 127, 127, 255))
brush21.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
palette.setBrush(QPalette.Disabled, QPalette.Base, brush6)
palette.setBrush(QPalette.Disabled, QPalette.Window, brush1)
brush22 = QBrush(QColor(177, 177, 177, 255))
brush22.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush7)
brush23 = QBrush(QColor(145, 145, 145, 255))
brush23.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Disabled, QPalette.Highlight, brush8)
palette.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush)
palette.setBrush(QPalette.Disabled, QPalette.Link, brush8)
palette.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush9)
palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10)
brush24 = QBrush(QColor(0, 0, 0, 255))
brush24.setStyle(Qt.NoBrush)
palette.setBrush(QPalette.Disabled, QPalette.NoRole, brush11)
palette.setBrush(QPalette.Disabled, QPalette.ToolTipBase, brush)
palette.setBrush(QPalette.Disabled, QPalette.ToolTipText, brush)
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
palette.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush12)
#endif
MainWindow.setPalette(palette)
MainWindow.setToolButtonStyle(Qt.ToolButtonIconOnly)
MainWindow.setAnimated(True)
MainWindow.setDocumentMode(False)
MainWindow.setWindowIcon(QIcon('/home/david-rice/Python/spd3303x-e-control-testarriveico.png'))
fontmain = QFont()
fontmain.setFamilies([u"Verdana"])
fontmain.setPointSize(10)
fontmain.setBold(True)
MainWindow.setFont(fontmain)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.header = QLabel(self.centralwidget)
self.header.setObjectName(u"header")
self.header.setGeometry(QRect(25, 25, 1030, 50))
font = QFont()
font.setFamilies([u"Verdana"])
font.setPointSize(16)
font.setBold(True)
self.header.setFont(font)
self.header.setAlignment(Qt.AlignCenter)
self.FBLogo = QLabel(self.centralwidget)
self.FBLogo.setObjectName(u"FBLogo")
self.FBLogo.setGeometry(QRect(1055, 25, 200, 50))
self.FBLogo.setFocusPolicy(Qt.NoFocus)
self.FBLogo.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/arrivelogo.png"))
self.FBLogo.setScaledContents(True)
self.channel1 = QFrame(self.centralwidget)
self.channel1.setObjectName(u"channel1")
self.channel1.setGeometry(QRect(25, 100, 1230, 90))
self.channel1.setFrameShape(QFrame.StyledPanel)
self.channel1.setFrameShadow(QFrame.Raised)
self.channel1_lab = QLabel(self.channel1)
self.channel1_lab.setObjectName(u"channel1_lab")
self.channel1_lab.setGeometry(QRect(25, 5, 1175, 20))
self.channel1_lab.setAlignment(Qt.AlignLeft)
self.chan1Button = QPushButton(self.channel1)
self.chan1Button.setObjectName(u"chan1Button")
self.chan1Button.setGeometry(QRect(25, 30, 200, 30))
self.chan1_red = QLabel(self.channel1)
self.chan1_red.setObjectName(u"chan1_red")
self.chan1_red.setGeometry(QRect(250, 30, 30, 30))
self.chan1_red.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/red-led.png"))
self.chan1_red.setScaledContents(True)
self.chan1_grn = QLabel(self.channel1)
self.chan1_grn.setObjectName(u"chan1_grn")
self.chan1_grn.setGeometry(QRect(250, 30, 30, 30))
self.chan1_grn.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/green-led.png"))
self.chan1_grn.setScaledContents(True)
self.chan1_blk = QLabel(self.channel1)
self.chan1_blk.setObjectName(u"chan1_blk")
self.chan1_blk.setGeometry(QRect(250, 30, 30, 30))
self.chan1_blk.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/gray-led.png"))
self.chan1_blk.setScaledContents(True)
self.chan1_v_lab = QLabel(self.channel1)
self.chan1_v_lab.setObjectName(u"chan1_v_lab")
self.chan1_v_lab.setGeometry(QRect(305, 5, 100, 30))
self.chan1_v_lab.setAlignment(Qt.AlignCenter)
self.chan1_v_val = QLineEdit(self.channel1)
self.chan1_v_val.setObjectName(u"chan1_v_val")
self.chan1_v_val.setGeometry(QRect(305, 30, 100, 30))
self.chan1_v_val.setAlignment(Qt.AlignCenter)
self.chan1_i_lab = QLabel(self.channel1)
self.chan1_i_lab.setObjectName(u"chan1_i_lab")
self.chan1_i_lab.setGeometry(QRect(430, 5, 100, 30))
self.chan1_i_lab.setAlignment(Qt.AlignCenter)
self.chan1_i_val = QLineEdit(self.channel1)
self.chan1_i_val.setObjectName(u"chan1_i_val")
self.chan1_i_val.setGeometry(QRect(430, 30, 100, 30))
self.chan1_i_val.setAlignment(Qt.AlignCenter)
self.chan1_mv_lab = QLabel(self.channel1)
self.chan1_mv_lab.setObjectName(u"chan1_mv_lab")
self.chan1_mv_lab.setGeometry(QRect(555, 5, 200, 30))
self.chan1_mv_lab.setAlignment(Qt.AlignCenter)
self.chan1_mv_val = QLineEdit(self.channel1)
self.chan1_mv_val.setObjectName(u"chan1_mv_val")
self.chan1_mv_val.setGeometry(QRect(555, 30, 200, 30))
self.chan1_mv_val.setAlignment(Qt.AlignCenter)
self.chan1_mi_lab = QLabel(self.channel1)
self.chan1_mi_lab.setObjectName(u"chan1_mi_lab")
self.chan1_mi_lab.setGeometry(QRect(780, 5, 200, 30))
self.chan1_mi_lab.setAlignment(Qt.AlignCenter)
self.chan1_mi_val = QLineEdit(self.channel1)
self.chan1_mi_val.setObjectName(u"chan1_mi_val")
self.chan1_mi_val.setGeometry(QRect(780, 30, 200, 30))
self.chan1_mi_val.setAlignment(Qt.AlignCenter)
self.chan1_mp_lab = QLabel(self.channel1)
self.chan1_mp_lab.setObjectName(u"chan1_mi_lab")
self.chan1_mp_lab.setGeometry(QRect(1005, 5, 200, 30))
self.chan1_mp_lab.setAlignment(Qt.AlignCenter)
self.chan1_mp_val = QLineEdit(self.channel1)
self.chan1_mp_val.setObjectName(u"chan1_mp_val")
self.chan1_mp_val.setGeometry(QRect(1005, 30, 200, 30))
self.chan1_mp_val.setAlignment(Qt.AlignCenter)
self.channel2 = QFrame(self.centralwidget)
self.channel2.setObjectName(u"channel2")
self.channel2.setGeometry(QRect(25, 215, 1230, 90))
self.channel2.setFrameShape(QFrame.StyledPanel)
self.channel2.setFrameShadow(QFrame.Raised)
self.channel2_lab = QLabel(self.channel2)
self.channel2_lab.setObjectName(u"channel2_lab")
self.channel2_lab.setGeometry(QRect(25, 5, 1175, 20))
self.channel2_lab.setAlignment(Qt.AlignLeft)
self.chan2Button = QPushButton(self.channel2)
self.chan2Button.setObjectName(u"chan2Button")
self.chan2Button.setGeometry(QRect(25, 30, 200, 30))
self.chan2_red = QLabel(self.channel2)
self.chan2_red.setObjectName(u"chan2_red")
self.chan2_red.setGeometry(QRect(250, 30, 30, 30))
self.chan2_red.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/red-led.png"))
self.chan2_red.setScaledContents(True)
self.chan2_grn = QLabel(self.channel2)
self.chan2_grn.setObjectName(u"chan2_grn")
self.chan2_grn.setGeometry(QRect(250, 30, 30, 30))
self.chan2_grn.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/green-led.png"))
self.chan2_grn.setScaledContents(True)
self.chan2_blk = QLabel(self.channel2)
self.chan2_blk.setObjectName(u"chan2_blk")
self.chan2_blk.setGeometry(QRect(250, 30, 30, 30))
self.chan2_blk.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/gray-led.png"))
self.chan2_blk.setScaledContents(True)
self.chan2_v_lab = QLabel(self.channel2)
self.chan2_v_lab.setObjectName(u"chan2_v_lab")
self.chan2_v_lab.setGeometry(QRect(305, 5, 100, 30))
self.chan2_v_lab.setAlignment(Qt.AlignCenter)
self.chan2_v_val = QLineEdit(self.channel2)
self.chan2_v_val.setObjectName(u"chan2_v_val")
self.chan2_v_val.setGeometry(QRect(305, 30, 100, 30))
self.chan2_v_val.setAlignment(Qt.AlignCenter)
self.chan2_i_lab = QLabel(self.channel2)
self.chan2_i_lab.setObjectName(u"chan2_i_lab")
self.chan2_i_lab.setGeometry(QRect(430, 5, 100, 30))
self.chan2_i_lab.setAlignment(Qt.AlignCenter)
self.chan2_i_val = QLineEdit(self.channel2)
self.chan2_i_val.setObjectName(u"chan2_i_val")
self.chan2_i_val.setGeometry(QRect(430, 30, 100, 30))
self.chan2_i_val.setAlignment(Qt.AlignCenter)
self.chan2_mv_lab = QLabel(self.channel2)
self.chan2_mv_lab.setObjectName(u"chan2_mv_lab")
self.chan2_mv_lab.setGeometry(QRect(555, 5, 200, 30))
self.chan2_mv_lab.setAlignment(Qt.AlignCenter)
self.chan2_mv_val = QLineEdit(self.channel2)
self.chan2_mv_val.setObjectName(u"chan2_mv_val")
self.chan2_mv_val.setGeometry(QRect(555, 30, 200, 30))
self.chan2_mv_val.setAlignment(Qt.AlignCenter)
self.chan2_mi_lab = QLabel(self.channel2)
self.chan2_mi_lab.setObjectName(u"chan2_mi_lab")
self.chan2_mi_lab.setGeometry(QRect(780, 5, 200, 30))
self.chan2_mi_lab.setAlignment(Qt.AlignCenter)
self.chan2_mi_val = QLineEdit(self.channel2)
self.chan2_mi_val.setObjectName(u"chan2_mi_val")
self.chan2_mi_val.setGeometry(QRect(780, 30, 200, 30))
self.chan2_mi_val.setAlignment(Qt.AlignCenter)
self.chan2_mp_lab = QLabel(self.channel2)
self.chan2_mp_lab.setObjectName(u"chan2_mi_lab")
self.chan2_mp_lab.setGeometry(QRect(1005, 5, 200, 30))
self.chan2_mp_lab.setAlignment(Qt.AlignCenter)
self.chan2_mp_val = QLineEdit(self.channel2)
self.chan2_mp_val.setObjectName(u"chan2_mp_val")
self.chan2_mp_val.setGeometry(QRect(1005, 30, 200, 30))
self.chan2_mp_val.setAlignment(Qt.AlignCenter)
#self.tfp_lab = QLabel(self.centralwidget)
#self.tfp_lab.setObjectName(u"tfp_lab")
#self.tfp_lab.setGeometry(QRect(25, 300, 950, 30))
#self.tfp_lab.setAlignment(Qt.AlignCenter)
#self.tfp_val = QLabel(self.centralwidget)
#self.tfp_val.setObjectName(u"tfp_val")
#self.tfp_val.setGeometry(QRect(25, 325, 950, 30))
#self.tfp_val.setFrameShape(QFrame.StyledPanel)
#self.tfp_val.setLineWidth(5)
#self.tfp_val.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignVCenter)
#self.filebrowseButton = QPushButton(self.centralwidget)
#self.filebrowseButton.setObjectName(u"filebrowseButton")
#self.filebrowseButton.setGeometry(QRect(1000, 325, 200, 30))
#self.testButton = QPushButton(self.centralwidget)
#self.testButton.setObjectName(u"testrunButton")
#self.testButton.setGeometry(QRect(25, 400, 150, 30))
#self.test_lab = QLabel(self.centralwidget)
#self.test_lab.setObjectName(u"test_lab")
#self.test_lab.setGeometry(QRect(225, 375, 150, 20))
#self.test_lab.setAlignment(Qt.AlignCenter)
#self.test_red = QLabel(self.centralwidget)
#self.test_red.setObjectName(u"test_red")
#self.test_red.setGeometry(QRect(285, 400, 30, 30))
#self.test_red.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/red-led.png"))
#self.test_red.setScaledContents(True)
#self.test_grn = QLabel(self.centralwidget)
#self.test_grn.setObjectName(u"test_grn")
#self.test_grn.setGeometry(QRect(285, 400, 30, 30))
#self.test_grn.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/green-led.png"))
#self.test_grn.setScaledContents(True)
#self.test_blk = QLabel(self.centralwidget)
#self.test_blk.setObjectName(u"test_blk")
#self.test_blk.setGeometry(QRect(285, 400, 30, 30))
#self.test_blk.setPixmap(QPixmap(u"/home/david-rice/Python/spd3303x-e-control-test/gray-led.png"))
#self.test_blk.setScaledContents(True)
#self.v_lab = QLabel(self.centralwidget)
#self.v_lab.setObjectName(u"v_lab")
#self.v_lab.setGeometry(QRect(1025, 175, 100, 30))
#self.v_lab.setAlignment(Qt.AlignCenter)
#self.v_val = QLineEdit(self.centralwidget)
#self.v_val.setObjectName(u"v_val")
#self.v_val.setGeometry(QRect(1025, 200, 100, 30))
#self.v_val.setAlignment(Qt.AlignCenter)
#self.i_lab = QLabel(self.centralwidget)
#self.i_lab.setObjectName(u"i_lab")
#self.i_lab.setGeometry(QRect(1150, 175, 100, 30))
#self.i_lab.setAlignment(Qt.AlignCenter)
#self.i_val = QLineEdit(self.centralwidget)
#self.i_val.setObjectName(u"i_val")
#self.i_val.setGeometry(QRect(1150, 200, 100, 30))
#self.i_val.setAlignment(Qt.AlignCenter)
#self.vt_lab = QLabel(self.centralwidget)
#self.vt_lab.setObjectName(u"vt_lab")
#self.vt_lab.setGeometry(QRect(400, 375, 100, 30))
#self.vt_lab.setAlignment(Qt.AlignCenter)
#self.vt_val = QLineEdit(self.centralwidget)
#self.vt_val.setObjectName(u"vt_val")
#self.vt_val.setGeometry(QRect(400, 400, 100, 30))
#self.vt_val.setAlignment(Qt.AlignCenter)
#self.it_lab = QLabel(self.centralwidget)
#self.it_lab.setObjectName(u"it_lab")
#self.it_lab.setGeometry(QRect(550, 375, 100, 30))
#self.it_lab.setAlignment(Qt.AlignCenter)
#self.it_val = QLineEdit(self.centralwidget)
#self.it_val.setObjectName(u"it_val")
#self.it_val.setGeometry(QRect(550, 400, 100, 30))
#self.it_val.setAlignment(Qt.AlignCenter)
#self.tt_lab = QLabel(self.centralwidget)
#self.tt_lab.setObjectName(u"tt_lab")
#self.tt_lab.setGeometry(QRect(700, 375, 100, 30))
#self.tt_lab.setAlignment(Qt.AlignCenter)
#self.tt_val = QLineEdit(self.centralwidget)
#self.tt_val.setObjectName(u"tt_val")
#self.tt_val.setGeometry(QRect(700, 400, 100, 30))
#self.tt_val.setAlignment(Qt.AlignCenter)
MainWindow.setCentralWidget(self.centralwidget)
self.header.raise_()
self.FBLogo.raise_()
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"SPD3303X-E CONTROL/TEST APPLICATION V1.0",
None))
self.header.setText(QCoreApplication.translate("MainWindow", u"SPD3303X-E CONTROL/TEST APPLICATION", None))
self.FBLogo.setText("")
self.channel1_lab.setText(QCoreApplication.translate("MainWindow", u"CHANNEL #1", None))
self.chan1Button.setText(QCoreApplication.translate("MainWindow", u"ON/OFF", None))
self.chan1_blk.setText("")
self.chan1_red.setText("")
self.chan1_grn.setText("")
self.chan1_v_lab.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE (V)", None))
self.chan1_v_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan1_i_lab.setText(QCoreApplication.translate("MainWindow", u"CURRENT (A)", None))
self.chan1_i_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan1_mv_lab.setText(QCoreApplication.translate("MainWindow", u"MEASURED VOLTAGE (V)", None))
self.chan1_mv_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan1_mi_lab.setText(QCoreApplication.translate("MainWindow", u"MEASURED CURRENT (A)", None))
self.chan1_mi_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan1_mp_lab.setText(QCoreApplication.translate("MainWindow", u"MEASURED POWER (W)", None))
self.chan1_mp_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.channel2_lab.setText(QCoreApplication.translate("MainWindow", u"CHANNEL #2", None))
self.chan2Button.setText(QCoreApplication.translate("MainWindow", u"ON/OFF", None))
self.chan2_blk.setText("")
self.chan2_red.setText("")
self.chan2_grn.setText("")
self.chan2_v_lab.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE (V)", None))
self.chan2_v_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan2_i_lab.setText(QCoreApplication.translate("MainWindow", u"CURRENT (A)", None))
self.chan2_i_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan2_mv_lab.setText(QCoreApplication.translate("MainWindow", u"MEASURED VOLTAGE (V)", None))
self.chan2_mv_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan2_mi_lab.setText(QCoreApplication.translate("MainWindow", u"MEASURED CURRENT (A)", None))
self.chan2_mi_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
self.chan2_mp_lab.setText(QCoreApplication.translate("MainWindow", u"MEASURED POWER (W)", None))
self.chan2_mp_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
#self.tfp_lab.setText(QCoreApplication.translate("MainWindow", u"TEST FILE PATH", None))
#self.tfp_val.setText("")
#self.filebrowseButton.setText(QCoreApplication.translate("MainWindow", u"BROWSE", None))
#self.testButton.setText(QCoreApplication.translate("MainWindow", u"RUN TEST", None))
#self.test_lab.setText(QCoreApplication.translate("MainWindow", u"TEST STATUS", None))
#self.test_blk.setText("")
#self.test_red.setText("")
#self.test_grn.setText("")
#self.v_lab.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE (V)", None))
#self.v_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
#self.i_lab.setText(QCoreApplication.translate("MainWindow", u"CURRENT (A)", None))
#self.i_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
#self.vt_lab.setText(QCoreApplication.translate("MainWindow", u"VOLTAGE (V)", None))
#self.vt_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
#self.it_lab.setText(QCoreApplication.translate("MainWindow", u"CURRENT (A)", None))
#self.it_val.setText(QCoreApplication.translate("MainWindow", u"0.00", None))
#self.tt_lab.setText(QCoreApplication.translate("MainWindow", u"TIME (S)", None))
#self.tt_val.setText(QCoreApplication.translate("MainWindow", u"00.0", None))
# retranslateUi

147
way_6x_supercap_test_app.py Normal file
View File

@@ -0,0 +1,147 @@
#!/user/bin/env python3
"""
WAY 6X Supercap Test App - way_6x_supercap_test_app.py
- ENTRY POINT OF APPLICATION
VERSION: 1.0
AUTHOR: D. RICE 20/06/2024
© 2024 FLOWBIRD TRANSPORT
"""
# Imports
import pyvisa
import time
from threading import Timer
import sys
from datetime import datetime
# Global variables
setup_del = 0.2 # Setup delay in seconds
meas_del = 0.05 # Measure delay in seconds
psu_on_trigger_flag = False
psu_off_trigger_flag = False
psu_on_trigger_target = 30
psu_off_trigger_target = 10
psu_toggle_flag = False
psu_voltage = 28.0
psu_current = 3.0
VISA_ADDRESS = "TCPIP::10.120.41.36::INSTR"
rm = pyvisa.ResourceManager()
SPD = rm.open_resource(
VISA_ADDRESS,
write_termination='\n',
read_termination='\n'
)
def main():
global SPD
global setup_del
global psu_on_trigger_flag
global psu_off_trigger_flag
global psu_on_trigger_target
global psu_off_trigger_target
global psu_toggle_flag
global psu_voltage
global psu_current
SPD.write('CH1:VOLT ' + str(psu_voltage)) # Send power supply source voltage
time.sleep(setup_del)
SPD.write('CH1:CURR ' + str(psu_current)) # Send power supply current limit
time.sleep(setup_del)
SPD.write('CH2:VOLT ' + str(psu_voltage)) # Send power supply source voltage
time.sleep(setup_del)
SPD.write('CH2:CURR ' + str(psu_current)) # Send power supply current limit
time.sleep(setup_del)
# Enable power supply output source
SPD.write('OUTP CH1,ON') # Enable supply output
time.sleep(setup_del)
SPD.write('OUTP CH2,ON') # Enable supply output
time.sleep(setup_del)
# Setup timer
psu_toggle_flag = False
test_timer = Timer(psu_on_trigger_target, test_timer_routine)
test_timer.daemon = True
test_timer.start()
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print ("TIME STAMP: " + current_time + " EVENT: PSU ON | CHANNEL #1 V (V) = " + str(psu_voltage) + " | CHANNEL #1 I (A) = " + str(psu_current) + " | CHANNEL #2 V (V) = " + str(psu_voltage) + " | CHANNEL #2 I (A) = " + str(psu_current))
while True:
if psu_on_trigger_flag == True:
psu_on_trigger_flag = False
test_timer = Timer(psu_on_trigger_target, test_timer_routine)
test_timer.daemon = True
test_timer.start()
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print ("TIME STAMP: " + current_time + " EVENT: PSU ON | CHANNEL #1 V (V) = " + str(psu_voltage) + " | CHANNEL #1 I (A) = " + str(psu_current) + " | CHANNEL #2 V (V) = " + str(psu_voltage) + " | CHANNEL #2 I (A) = " + str(psu_current))
SPD.write('CH1:VOLT ' + str(psu_voltage)) # Send power supply source voltage
time.sleep(setup_del)
SPD.write('CH1:CURR ' + str(psu_current)) # Send power supply current limit
time.sleep(setup_del)
SPD.write('CH2:VOLT ' + str(psu_voltage)) # Send power supply source voltage
time.sleep(setup_del)
SPD.write('CH2:CURR ' + str(psu_current)) # Send power supply current limit
time.sleep(setup_del)
# Enable power supply output source
SPD.write('OUTP CH1,ON') # Enable supply output
time.sleep(setup_del)
SPD.write('OUTP CH2,ON') # Enable supply output
time.sleep(setup_del)
if psu_off_trigger_flag == True:
psu_off_trigger_flag = False
test_timer = Timer(psu_off_trigger_target, test_timer_routine)
test_timer.daemon = True
test_timer.start()
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print ("TIME STAMP: " + current_time + " EVENT: PSU OFF | CHANNEL #1 V (V) = 0.0 | CHANNEL #1 I (A) = 0.0 | CHANNEL #2 V (V) = 0.0 | CHANNEL #2 I (A) = 0.0")
SPD.write('CH1:VOLT ' + '0.0') # Send power supply source voltage
time.sleep(setup_del)
SPD.write('CH1:CURR ' + '0.0') # Send power supply current limit
time.sleep(setup_del)
SPD.write('CH2:VOLT ' + '0.0') # Send power supply source voltage
time.sleep(setup_del)
SPD.write('CH2:CURR ' + '0.0') # Send power supply current limit
time.sleep(setup_del)
# Disbale power supply output source
SPD.write('OUTP CH1,OFF') # Disable supply output
time.sleep(setup_del)
SPD.write('OUTP CH2,OFF') # Disable supply output
time.sleep(setup_del)
def test_timer_routine():
global psu_on_trigger_flag
global psu_off_trigger_flag
global psu_toggle_flag
if psu_toggle_flag == False:
psu_toggle_flag = True
psu_off_trigger_flag = True
else:
psu_toggle_flag = False
psu_on_trigger_flag = True
# Run main
if __name__ == "__main__":
try:
main()
except (KeyboardInterrupt, SystemExit):
sys.exit()