My trusty U1732B meter is old with no ESR button, follow me down this rabbit hole.
lets try and leverage AI to make a remote display,
(me)
Question: I am writing a program to calculate the esr of a capacitor
using a U1732B lcr meter.
I believe the sum is 1 over the reactance * Dissipation factor, but
don’t quote me on that!. Here is my code so far.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(120, 40, 113, 24))
self.lineEdit.setObjectName("lineEdit")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(50, 10, 271, 21))
font = QtGui.QFont()
font.setPointSize(20)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(16, 40, 91, 20))
self.label_2.setObjectName("label_2")
self.comboBox = QtWidgets.QComboBox(Dialog)
self.comboBox.setGeometry(QtCore.QRect(240, 40, 72, 24))
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(20, 70, 71, 16))
self.label_3.setObjectName("label_3")
self.lineEdit_2 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(120, 70, 113, 24))
self.lineEdit_2.setObjectName("lineEdit_2")
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(140, 180, 80, 24))
self.pushButton.setObjectName("pushButton")
self.pushButton.toggle()
self.pushButton.clicked.connect(lambda: self.whichbtn(self.pushButton))
self.pushButton.clicked.connect(self.btnstate)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)
def btnstate(self):
if self.pushButton.isChecked():
print("button pressed")
self.lineEdit_2.setText("Button Pressed")
else:
print("button released")
mytemp = self.lineEdit.text()
myresult = int(mytemp) / 1000000
self.lineEdit_2.setText(str(myresult))
def whichbtn(self, b):
print("clicked button is " + b.text())
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Rich\'s ESR Calculator"))
self.label_2.setText(_translate("Dialog", "Capacitor Value"))
self.comboBox.setCurrentText(_translate("Dialog", "Micro"))
self.comboBox.setItemText(0, _translate("Dialog", "Micro"))
self.comboBox.setItemText(1, _translate("Dialog", "Pico"))
self.comboBox.setItemText(2, _translate("Dialog", "Nano"))
self.label_3.setText(_translate("Dialog", "Converted"))
self.pushButton.setText(_translate("Dialog", "Calculate"))
def accept(self):
print("Hello")
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
Can you finish it for me please?
You’re off to a good start with the GUI. To complete your ESR calculator, you’ll want to:
Accept inputs for capacitance (C), frequency (f), and dissipation factor (D). Calculate reactance (Xc) using the formula: Xc=12πfC Xc=2πfC1 Calculate ESR using: ESR=Xc×D ESR=Xc×DHere’s a modified version of your code that does this: