Skip to content

Commit

Permalink
Trigger bug in combined instrument mode. Probably the
Browse files Browse the repository at this point in the history
generator should be open before the SCP
  • Loading branch information
zoran-grujic committed Jul 17, 2023
1 parent b70048b commit be038ae
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 21 deletions.
24 changes: 20 additions & 4 deletions app.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ class MyUi(Ui_MainWindow):

self.dialogs = list()

self.gen = arbGenerator()
self.scp = oscilloscope()
print(self.scp.scp_list_sn)
gen_sn = self.scp.scp_list_sn[0]
print(f"Selected generator SN: {gen_sn}")
self.gen = arbGenerator(gen_sn)


self.threadpool = QThreadPool()
self.theWorkerBlocks = Worker(self.getBlocks) # Any other args, kwargs are passed to the run function
Expand Down Expand Up @@ -134,6 +138,8 @@ class MyUi(Ui_MainWindow):
self.comboBox_FilterType.currentIndexChanged.connect(self.fitUISet)
self.radioButton_FITSource_CH1.clicked.connect(self.fitUISet)
self.radioButton_FITSource_CH2.clicked.connect(self.fitUISet)
self.radioButton_FITSource_CH3.clicked.connect(self.fitUISet)
self.radioButton_FITSource_CH4.clicked.connect(self.fitUISet)
self.pushButton_Set_FIT_init.clicked.connect(self.copyFITtoInit)
self.pushButton_SelectFolder.clicked.connect(self.selectFolder)
self.lineEdit_FolderName.setText(os.getcwd()+"\\data\\")
Expand Down Expand Up @@ -294,14 +300,20 @@ class MyUi(Ui_MainWindow):
if self.radioButton_PrStabSourceCH1.isChecked():
pos = 0
else:
pos = 1
if self.radioButton_PrStabSourceCH2.isChecked():
pos = 1
else:
if self.radioButton_PrStabSourceCH3.isChecked():
pos = 2
else:
pos = 3

try:
signalData = self.SCPData[pos]
except:
return
probeValue = np.mean(signalData[-3000:-100])
self.label_ActualProbeValue.setText(f"{probeValue:0.3f} V")
self.label_ActualProbeValue.setText(f"{probeValue:0.6f} V")

if self.checkBox_ActivateEOMstab.isChecked():
error = self.doubleSpinBox_setProbeValue.value() -probeValue
Expand Down Expand Up @@ -621,8 +633,12 @@ class MyUi(Ui_MainWindow):

if self.radioButton_FITSource_CH1.isChecked():
self.dataFIT = self.dataSCPtoFITtab[0]
else:
if self.radioButton_FITSource_CH2.isChecked():
self.dataFIT = self.dataSCPtoFITtab[1]
if self.radioButton_FITSource_CH3.isChecked():
self.dataFIT = self.dataSCPtoFITtab[2]
if self.radioButton_FITSource_CH4.isChecked():
self.dataFIT = self.dataSCPtoFITtab[3]
totalTime_ms = float(self.doubleSpinBox_FITStop_ms.value())
t = np.linspace(0, totalTime_ms, len(self.dataFIT), endpoint=False)

Expand Down
42 changes: 35 additions & 7 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@ def setupUi(self, MainWindow):
self.radioButton_FITSource_CH2.setObjectName("radioButton_FITSource_CH2")
self.horizontalLayout_4.addWidget(self.radioButton_FITSource_CH2)
self.verticalLayout_11.addLayout(self.horizontalLayout_4)
self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
self.horizontalLayout_12.setObjectName("horizontalLayout_12")
self.radioButton_FITSource_CH3 = QtWidgets.QRadioButton(self.groupBox_8)
self.radioButton_FITSource_CH3.setObjectName("radioButton_FITSource_CH3")
self.horizontalLayout_12.addWidget(self.radioButton_FITSource_CH3)
self.radioButton_FITSource_CH4 = QtWidgets.QRadioButton(self.groupBox_8)
self.radioButton_FITSource_CH4.setObjectName("radioButton_FITSource_CH4")
self.horizontalLayout_12.addWidget(self.radioButton_FITSource_CH4)
self.verticalLayout_11.addLayout(self.horizontalLayout_12)
self.gridLayout_12 = QtWidgets.QGridLayout()
self.gridLayout_12.setObjectName("gridLayout_12")
self.doubleSpinBox_FIT_B = QtWidgets.QDoubleSpinBox(self.groupBox_8)
Expand Down Expand Up @@ -541,9 +550,10 @@ def setupUi(self, MainWindow):
self.plainTextEdit_FITResults.setObjectName("plainTextEdit_FITResults")
self.verticalLayout_14.addWidget(self.plainTextEdit_FITResults)
self.gridLayout_FITRES.addWidget(self.groupBox_FIT_Results, 0, 0, 1, 1)
self.pushButton = QtWidgets.QPushButton(self.tab_FIT)
self.pushButton.setObjectName("pushButton")
self.gridLayout_FITRES.addWidget(self.pushButton, 1, 1, 1, 1)
self.pushButton_FIT_Realtime = QtWidgets.QPushButton(self.tab_FIT)
self.pushButton_FIT_Realtime.setCheckable(True)
self.pushButton_FIT_Realtime.setObjectName("pushButton_FIT_Realtime")
self.gridLayout_FITRES.addWidget(self.pushButton_FIT_Realtime, 1, 1, 1, 1)
self.groupBox_10 = QtWidgets.QGroupBox(self.tab_FIT)
self.groupBox_10.setObjectName("groupBox_10")
self.verticalLayout_13 = QtWidgets.QVBoxLayout(self.groupBox_10)
Expand Down Expand Up @@ -757,6 +767,18 @@ def setupUi(self, MainWindow):
self.radioButton_PrStabSourceCH2.setFont(font)
self.radioButton_PrStabSourceCH2.setObjectName("radioButton_PrStabSourceCH2")
self.horizontalLayout_9.addWidget(self.radioButton_PrStabSourceCH2)
self.radioButton_PrStabSourceCH3 = QtWidgets.QRadioButton(self.groupBox_5)
font = QtGui.QFont()
font.setPointSize(10)
self.radioButton_PrStabSourceCH3.setFont(font)
self.radioButton_PrStabSourceCH3.setObjectName("radioButton_PrStabSourceCH3")
self.horizontalLayout_9.addWidget(self.radioButton_PrStabSourceCH3)
self.radioButton_PrStabSourceCH4 = QtWidgets.QRadioButton(self.groupBox_5)
font = QtGui.QFont()
font.setPointSize(10)
self.radioButton_PrStabSourceCH4.setFont(font)
self.radioButton_PrStabSourceCH4.setObjectName("radioButton_PrStabSourceCH4")
self.horizontalLayout_9.addWidget(self.radioButton_PrStabSourceCH4)
self.horizontalLayout_8.addWidget(self.groupBox_5)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_8.addItem(spacerItem3)
Expand All @@ -771,11 +793,11 @@ def setupUi(self, MainWindow):
self.gridLayout_17.setObjectName("gridLayout_17")
self.doubleSpinBox_setBiasValue = QtWidgets.QDoubleSpinBox(self.groupBox_9)
self.doubleSpinBox_setBiasValue.setMinimumSize(QtCore.QSize(200, 0))
self.doubleSpinBox_setBiasValue.setDecimals(3)
self.doubleSpinBox_setBiasValue.setDecimals(8)
self.doubleSpinBox_setBiasValue.setMinimum(-10.0)
self.doubleSpinBox_setBiasValue.setMaximum(10.0)
self.doubleSpinBox_setBiasValue.setSingleStep(0.01)
self.doubleSpinBox_setBiasValue.setProperty("value", -1.0)
self.doubleSpinBox_setBiasValue.setProperty("value", -1.5)
self.doubleSpinBox_setBiasValue.setObjectName("doubleSpinBox_setBiasValue")
self.gridLayout_17.addWidget(self.doubleSpinBox_setBiasValue, 1, 1, 1, 1)
self.label_32 = QtWidgets.QLabel(self.groupBox_9)
Expand All @@ -787,7 +809,7 @@ def setupUi(self, MainWindow):
self.gridLayout_17.addWidget(self.label_ActualProbeValue, 0, 2, 1, 1)
self.doubleSpinBox_setProbeValue = QtWidgets.QDoubleSpinBox(self.groupBox_9)
self.doubleSpinBox_setProbeValue.setMinimumSize(QtCore.QSize(200, 0))
self.doubleSpinBox_setProbeValue.setDecimals(3)
self.doubleSpinBox_setProbeValue.setDecimals(8)
self.doubleSpinBox_setProbeValue.setSingleStep(0.01)
self.doubleSpinBox_setProbeValue.setProperty("value", 0.55)
self.doubleSpinBox_setProbeValue.setObjectName("doubleSpinBox_setProbeValue")
Expand Down Expand Up @@ -853,6 +875,7 @@ def setupUi(self, MainWindow):
self.label_36.setObjectName("label_36")
self.gridLayout_20.addWidget(self.label_36, 1, 0, 1, 1)
self.checkBox_useTolerance = QtWidgets.QCheckBox(self.groupBox_11)
self.checkBox_useTolerance.setChecked(False)
self.checkBox_useTolerance.setObjectName("checkBox_useTolerance")
self.gridLayout_20.addWidget(self.checkBox_useTolerance, 1, 2, 1, 1)
self.horizontalLayout_10.addLayout(self.gridLayout_20)
Expand Down Expand Up @@ -995,6 +1018,8 @@ def retranslateUi(self, MainWindow):
self.label_27.setText(_translate("MainWindow", "Fit src:"))
self.radioButton_FITSource_CH1.setText(_translate("MainWindow", "CH1"))
self.radioButton_FITSource_CH2.setText(_translate("MainWindow", "CH2"))
self.radioButton_FITSource_CH3.setText(_translate("MainWindow", "CH3"))
self.radioButton_FITSource_CH4.setText(_translate("MainWindow", "CH4"))
self.doubleSpinBox_FIT_f0.setSuffix(_translate("MainWindow", " Hz"))
self.label_21.setText(_translate("MainWindow", "B:"))
self.label_20.setText(_translate("MainWindow", "f0:"))
Expand All @@ -1008,7 +1033,8 @@ def retranslateUi(self, MainWindow):
self.plainTextEdit_FITResults.setPlainText(_translate("MainWindow", "Some text here\n"
"\n"
"f: 2568.258"))
self.pushButton.setText(_translate("MainWindow", "Not implemented"))
self.pushButton_FIT_Realtime.setToolTip(_translate("MainWindow", "Not implemented"))
self.pushButton_FIT_Realtime.setText(_translate("MainWindow", "Fit contineously"))
self.groupBox_10.setTitle(_translate("MainWindow", "FFT + FIT sensitivity"))
self.plainTextEdit_SensitivityFFT.setPlainText(_translate("MainWindow", "Some text here\n"
"\n"
Expand Down Expand Up @@ -1075,6 +1101,8 @@ def retranslateUi(self, MainWindow):
self.groupBox_5.setTitle(_translate("MainWindow", "Select Input"))
self.radioButton_PrStabSourceCH1.setText(_translate("MainWindow", "CH1"))
self.radioButton_PrStabSourceCH2.setText(_translate("MainWindow", "CH2"))
self.radioButton_PrStabSourceCH3.setText(_translate("MainWindow", "CH3"))
self.radioButton_PrStabSourceCH4.setText(_translate("MainWindow", "CH4"))
self.groupBox_9.setTitle(_translate("MainWindow", "Set point"))
self.doubleSpinBox_setBiasValue.setToolTip(_translate("MainWindow", "Set bias voltage here!"))
self.doubleSpinBox_setBiasValue.setSuffix(_translate("MainWindow", "V"))
Expand Down
63 changes: 57 additions & 6 deletions gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_data">
<attribute name="title">
Expand Down Expand Up @@ -1107,6 +1107,24 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QRadioButton" name="radioButton_FITSource_CH3">
<property name="text">
<string>CH3</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_FITSource_CH4">
<property name="text">
<string>CH4</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_12">
<item row="2" column="1">
Expand Down Expand Up @@ -1269,10 +1287,16 @@ f: 2568.258</string>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<widget class="QPushButton" name="pushButton_FIT_Realtime">
<property name="toolTip">
<string>Not implemented</string>
</property>
<property name="text">
<string>Fit contineously</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
Expand Down Expand Up @@ -1819,6 +1843,30 @@ f: 2568.258</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_PrStabSourceCH3">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>CH3</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_PrStabSourceCH4">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>CH4</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1862,7 +1910,7 @@ f: 2568.258</string>
<string>V</string>
</property>
<property name="decimals">
<number>3</number>
<number>8</number>
</property>
<property name="minimum">
<double>-10.000000000000000</double>
Expand All @@ -1874,7 +1922,7 @@ f: 2568.258</string>
<double>0.010000000000000</double>
</property>
<property name="value">
<double>-1.000000000000000</double>
<double>-1.500000000000000</double>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1910,7 +1958,7 @@ f: 2568.258</string>
<string>V</string>
</property>
<property name="decimals">
<number>3</number>
<number>8</number>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
Expand Down Expand Up @@ -2116,6 +2164,9 @@ f: 2568.258</string>
<property name="text">
<string>Use tolerance?</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
Expand Down
22 changes: 20 additions & 2 deletions tiepieArb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@

class arbGenerator:

def __init__(self):
def __init__(self, sn=None):
# Search for devices:
libtiepie.device_list.update()

# Try to open a generator with arbitrary support:
self.gen = None
for item in libtiepie.device_list:

if item.can_open(libtiepie.DEVICETYPE_GENERATOR):
self.gen = item.open_generator()
if sn is None:
self.gen = item.open_generator()
else:
if sn == item.serial_number:
self.gen = item.open_generator()

if self.gen.signal_types & libtiepie.ST_ARBITRARY:
break
else:
self.gen = None
if self.gen is None:
print("No generator detected! Connect the USB device!")
else:
#get S/N
print(item)

def arbLoad(self, arb, amplitude=1, frequency=10, offset=0.0):
if self.gen is None:
Expand Down Expand Up @@ -74,3 +83,12 @@ def stop(self):
self.gen.output_on = False
print("Generator STOP")


if __name__.endswith('__main__'):
gen = arbGenerator()
print(gen.gen.__dict__.keys())
print(gen.gen._trigger_outputs)
for t in gen.gen._trigger_outputs:
print(t.name)

#print(gen.gen.IDKIND_SERIALNUMBER)
17 changes: 15 additions & 2 deletions tiepieSCP.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ class oscilloscope:
}
trigger_name = "Generator new period"
channels = 0
scp_list_sn =[]

def __init__(self):
# Search for devices:
libtiepie.device_list.update()

# Try to open an oscilloscope with block measurement support:
self.scp = None
self.scp_list_sn=[]
for item in libtiepie.device_list:
print(item.name)
print(item.serial_number)
if "Handyscope HS5" == item.name.split("-")[0]:
self.scp_list_sn.append(item.serial_number)

scps = []
for item in libtiepie.device_list:
if item.can_open(libtiepie.DEVICETYPE_OSCILLOSCOPE):
Expand Down Expand Up @@ -61,6 +69,8 @@ def __init__(self):
self.channels = self.scp._channels._get_count()
print(f"We have {self.channels} channels.")



def set(self,
mode="block",
sample_frequency=1e6,
Expand Down Expand Up @@ -208,7 +218,7 @@ def set_trigger(self):

try:
# Locate trigger input:
trName = "HS5(33708).Generator new period"
tr_sn = self.scp_list_sn[0] # First SN available
"""
print("Triggers: ")
for trigger_input in self.scp.trigger_inputs:
Expand All @@ -217,8 +227,11 @@ def set_trigger(self):
print(trigger_input.name.split(".")[-1])
"""
for trigger_input in self.scp.trigger_inputs:
#print(trigger_input.name)
if trigger_input.name.split(".")[-1] == self.trigger_name:
break
if str(tr_sn) in trigger_input.name.split(".")[-1]:
break

"""
trigger_input = self.scp.trigger_inputs.get_by_id(
libtiepie.TIID_GENERATOR_NEW_PERIOD) # or TIID_GENERATOR_START or TIID_GENERATOR_STOP
Expand Down

0 comments on commit be038ae

Please sign in to comment.