add equip

This commit is contained in:
nazarchuk.as 2022-11-21 12:39:13 +03:00
parent 90c2fdaf50
commit a69e2745c8
26 changed files with 176 additions and 101 deletions

View File

@ -141,29 +141,3 @@ class ChartWindow(AbstractWindow):
s4 = 'b = ' + str(round(self.parent.b*10**4)) + ' +- ' + \
str(round(self.parent.sigma_b*10**4)) + ', см^3/(В*с)'+'\n'+'\n'
return s0+s1+s2+s3+s4
# print('all ', -k/h, '+-', sigma[0]/h)
# plt.show()
# plt.figure(dpi=500, figsize=(8, 5))
# plt.figure(dpi=500, figsize=(8, 5))
# x = np.array(data['I'])
# y = np.array(data['k'])
# xlabel = 'I, мА'
# ylabel = 'K, мВ/Тл'
# caption_point = ''
# xerr = abs(x*1/100)
# yerr = data['sig_k']
# k, b, sigma = make_graffic(
# x, y, xlabel, ylabel, caption_point, xerr, yerr, b=0, koef=[1.1, 1.1])
# plt.savefig('K(I)')
# print('R_x ', k*h*10**6, '+-', sigma[0]*10**6*h)
# n = 1/(-k*h*e_e)*10**-21
# sigma_n = n*abs(sigma[0]/k)
# print('n = ', n, '+-', sigma_n)
# sig = 1/4.097*5/4/10**-3
# sig_sig = sig*((5*10**-5)**2+(1/100)**2)**0.5
# print('sigma = ', sig, '+-', sig_sig)
# b = -sig*k*h*10**4
# sig_b = b*((sig_sig/sig)**2+(sigma[0]/k)**2)**0.5
# print('b = ', b, '+-', sig_b)

View File

@ -26,7 +26,7 @@ class GraduationWindow(AbstractWindow):
self.setWindowTitle('Градуировка электромагнита')
self.parent = parent
self.volt = 0
self.volt = 1
# make csv file
self.parent.flow_dataname = 'Induction_data.csv'
@ -78,7 +78,7 @@ class GraduationWindow(AbstractWindow):
def enter_value(self):
self.lineEdit.setReadOnly(True)
self.no_data()
self.take_data()
self.lineEdit.clear()
self.lineEdit.setReadOnly(False)
@ -106,15 +106,14 @@ class GraduationWindow(AbstractWindow):
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
msg = 'MEASure:Current?\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
bytesToRead = self.parent.ser.inWaiting()
I_M = self.parent.ser.read(bytesToRead)
self.volt += 5
f_amp = open(self.parent.I_M_name, 'w')
f_amp.write('Measure:Current:DC?\n')
f_amp.close()
f_amp = open(self.parent.I_M_name, 'r')
I_M = '{:.9f}'.format(float(f_amp.read(15))*10**3)
f_amp.close()
self.save_data([b, self.volt, I_M, t])
def closeEvent(self, event):
pass
# msg = 'VOLTage '+str(0)+'\n'
# self.parent.ser.write(msg.encode('ascii'))
self.parent.close()

View File

@ -3,7 +3,8 @@ import sys
import serial
import csv
import time
from PyQt6.QtGui import QIcon
# from PyQt import KeepAspectRatioByExpanding
from PyQt6.QtGui import QIcon, QPalette, QImage, QBrush
from PyQt6.QtWidgets import (QApplication,
QLineEdit,
QPushButton,
@ -31,7 +32,7 @@ class Start:
self.app = QApplication.instance()
self.window = StartWindow(self)
# self.add_equip()
self.add_equip()
self.draw()
self.app.exec()
@ -62,7 +63,7 @@ class Start:
def add_equip(self):
self.ser = serial.Serial(
port='/dev/ttyUSB2',
port='/dev/ttyUSB0',
baudrate=9600,
timeout=1
)
@ -70,8 +71,38 @@ class Start:
msg = 'OUTput on\n'
self.ser.write(msg.encode('ascii'))
self.parent.amp_name= os.path.join('/dev', 'usbtmc1')
self.volt_name = os.path.join('/dev', 'usbtmc0')
for i in range(3):
l = 'usbtmc'+str(i)
file = os.path.join('/dev', l)
f = open(file, 'w')
f.write('*IDN?\n')
f.close()
f = open(file, 'r')
st = f.read(35)
# print(st)
f.close()
if st=='AKIP,AKIP-2101/2,NDM36GBD4R0065,3.0':
self.I_M_name = os.path.join('/dev', l)
if st=='AKIP,AKIP-2101/2,NDM36GBD4R0064,3.0':
self.amp_name = os.path.join('/dev', l)
if st=='Prist,V7-78/1,TW00023291,03.31-01-0':
self.volt_name = os.path.join('/dev', l)
def close(self):
msg = 'VOLTage '+str(0)+'\n'
self.ser.write(msg.encode('ascii'))
def __del__(self):
msg = 'OUTput off\n'
self.ser.write(msg.encode('ascii'))
class StartWindow(AbstractWindow):
@ -79,6 +110,14 @@ class StartWindow(AbstractWindow):
super().__init__()
self.setWindowTitle('Эффект Холла в полупроводниках')
# palette = QPalette()
# img = QImage('image.jpg')
# scaled = img.scaled(self.size(), KeepAspectRatioByExpanding)
# palette.setBrush(QPalette.Window, QBrush(scaled))
# self.setPalette(palette)
# self.setStyleSheet('.QWidget {background-image: url(style.jpg);}')
self.parent = parent
self.centralwidget = QWidget()
self.resize(1400, 800)
@ -163,6 +202,7 @@ class StartWindow(AbstractWindow):
start = Start()
# import time

View File

@ -35,7 +35,7 @@ class ThreadData(QtCore.QThread):
def run(self):
self.running = True
while self.running:
self.parent.no_data()
self.parent.take_data()
self.sleep(1)
@ -49,11 +49,11 @@ class MainWindow(AbstractWindow):
self.resize(1400, 800)
self.number_iteration = 1
self.start_time = 0
self.volt = 0
self.volt = 0.05
# make masthead
self.parent.dataname = 'data.csv'
heads = ['U_34,mV', 'I_M,mA', 'U_0,mV', 'I_0,mA', 'E, mV', 'N', 't,ms']
heads = ['U_34,mV', 'I_M,mA', 'U_0,mV', 'I_0,mA', 'N', 't,ms']
with open(os.path.join(self.parent.folder, self.parent.dataname), 'w') as file:
wr = csv.writer(file)
wr.writerow(heads)
@ -109,6 +109,7 @@ class MainWindow(AbstractWindow):
self.stop.setEnabled(True)
if self.start_time == 0:
self.start_time = round(time.time()*1000)
self.this_time = self.start_time
self.start.setEnabled(False)
self.new.setEnabled(True)
if not self.data_thread.running:
@ -122,7 +123,8 @@ class MainWindow(AbstractWindow):
def new_clicked(self):
self.number_iteration += 1
self.volt = 0
self.volt += 0.05
self.this_time = round(time.time()*1000)
if not self.data_thread.running:
self.data_thread.start()
self.start.setEnabled(False)
@ -137,13 +139,12 @@ class MainWindow(AbstractWindow):
current_time = round(time.time()*1000)
v = str((current_time-self.start_time)/60)
t = str(current_time-self.start_time)
if float(self.volt) <= 0.1:
if float(current_time-self.this_time) <= 1:
self.u_0 = v
a = str(float(v)/100)
I_M = v
self.save_data([v, I_M, self.u_0, a, self.volt,
self.save_data([v, I_M, self.u_0, a,
self.number_iteration, t])
self.volt = str(float(self.volt)+5)
if float(a) > 1:
self.stop_clicked()
@ -157,17 +158,23 @@ class MainWindow(AbstractWindow):
QTableWidgetItem(str(data[i])))
def take_data(self):
current_time = round(time.time()*1000)
t = str(current_time-self.start_time)
# measure voltage and current
msg = 'VOLTage '+str(self.volt)+'\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
msg = 'MEASure:Current?\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
bytesToRead = self.parent.ser.inWaiting()
I_M = self.parent.ser.read(bytesToRead)
self.volt += 5
f_amp = open(self.parent.I_M_name, 'w')
f_amp.write('Measure:Current:DC?\n')
f_amp.close()
f_amp = open(self.parent.I_M_name, 'r')
I_M = '{:.9f}'.format(float(f_amp.read(15))*10**3)
f_amp.close()
f_volt = open(self.parent.volt_name, 'w')
f_volt.write('Measure:Voltage:DC?\n')
@ -178,28 +185,25 @@ class MainWindow(AbstractWindow):
f_volt = open(self.parent.volt_name, 'r')
v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
if self.volt == 0:
if float(current_time-self.this_time) <= 100:
self.u_0 = v
f_amp = open(self.parent.amp_name, 'r')
a = '{:.9f}'.format(float(f_amp.read(15))*10**3)
print(a)
print((current_time-self.this_time) )
# protect of errors:
if a > 1:
if float(a) > 1:
self.stop_clicked()
f_volt.close()
f_amp.close()
current_time = round(time.time()*1000)
t = str(current_time-self.start_time)
self.save_data([v, I_M, self.u_0, a, self.volt,
self.number_iteration, t])
def closeEvent(self, event):
self.data_thread.running = False
# msg = 'VOLTage '+str(0)+'\n'
# self.parent.ser.write(msg.encode('ascii'))
self.parent.close()

View File

@ -13,6 +13,7 @@ from PyQt6.QtWidgets import (QPushButton,
QLineEdit
)
from Abstract_window import AbstractWindow
import time
class ResistanceWindow(AbstractWindow):
@ -72,7 +73,9 @@ class ResistanceWindow(AbstractWindow):
self.start.setEnabled(False)
current=10
voltage=15
# voltage, current = self.measure()
voltage, current = self.measure()
print(voltage*self.parent.l*self.parent.a)
print(current*self.parent.L)
self.parent.sigma = current*self.parent.L/(voltage*self.parent.l*self.parent.a)
self.parent.sigma_sigma = self.parent.sigma*((5*10**-5)**2+(0.0035/100)**2)**0.5
@ -81,6 +84,13 @@ class ResistanceWindow(AbstractWindow):
self.menu.setEnabled(True)
def measure(self):
msg = 'VOLTage '+str(1)+'\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
f_amp = open(self.parent.amp_name, 'w')
f_amp.write('Measure:Current:DC?\n')
f_amp.close()
@ -95,4 +105,8 @@ class ResistanceWindow(AbstractWindow):
f_volt = open(self.parent.volt_name, 'r')
v = '{:.9f}'.format(float(f_volt.read(15))*10**3)
f_volt.close()
return v, a
return float(v), float(a)
def closeEvent(self, event):
self.parent.close()

View File

@ -22,7 +22,7 @@ class SignWindow(AbstractWindow):
self.setWindowTitle('Определение знака носителей')
self.parent = parent
self.start = QPushButton('Старт')
self.start = QPushButton('Без поля')
self.start.clicked.connect(self.start_clicked)
self.start.setEnabled(True)
@ -30,6 +30,10 @@ class SignWindow(AbstractWindow):
self.menu.setEnabled(False)
self.menu.clicked.connect(self.menu_clicked)
self.field = QPushButton('С полем')
self.field.setEnabled(False)
self.field.clicked.connect(self.field_clicked)
self.with_field = QLabel('С полем: ', self)
self.without_field = QLabel('Без поля: ', self)
self.with_field_value = QLabel(self)
@ -41,11 +45,14 @@ class SignWindow(AbstractWindow):
self.grid_layout = QGridLayout(self.centralwidget)
self.grid_layout.addWidget(self.start, 0, 0, 1, -1)
self.grid_layout.addWidget(self.with_field, 1, 0)
self.grid_layout.addWidget(self.with_field_value, 1, 1)
self.grid_layout.addWidget(self.without_field, 2, 0)
self.grid_layout.addWidget(self.without_field_value, 2, 1)
self.grid_layout.addWidget(self.menu, 3, 0, 1, -1)
self.grid_layout.addWidget(self.without_field, 1, 0)
self.grid_layout.addWidget(self.without_field_value, 1, 1)
self.grid_layout.addWidget(self.field, 2, 0, 1, -1)
self.grid_layout.addWidget(self.with_field, 3, 0)
self.grid_layout.addWidget(self.with_field_value, 3, 1)
self.grid_layout.addWidget(self.menu, 4, 0, 1, -1)
def menu_clicked(self):
self.parent.number = 0
@ -53,17 +60,21 @@ class SignWindow(AbstractWindow):
def start_clicked(self):
self.start.setEnabled(False)
with_field=10
without_field=15
# without_field, with_field = self.get_values()
self.with_field_value.setText(str(with_field)+', mV')
without_field=10
without_field = self.measure()
self.without_field_value.setText(str(without_field)+', mV')
self.field.setEnabled(True)
def field_clicked(self):
with_field=90
with_field = self.measure()
self.with_field_value.setText(str(with_field)+', mV')
self.menu.setEnabled(True)
def measure(self, volt):
msg = 'VOLTage '+str(volt)+'\n'
self.parent.ser.write(msg.encode('ascii'))
time.sleep(1)
def measure(self):
f_volt = open(self.parent.volt_name, 'w')
f_volt.write('Measure:Voltage:DC?\n')
f_volt.close()
@ -72,12 +83,6 @@ class SignWindow(AbstractWindow):
f_volt.close()
return v
def get_values(self):
without_field = self.measure(0)
with_field = self.measure(10)
return without_field, with_field
def closeEvent(self, event):
pass
# msg = 'VOLTage '+str(0)+'\n'
# self.parent.ser.write(msg.encode('ascii'))
self.parent.close()

BIN
Automation/amb/Chart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -0,0 +1,4 @@
"B,mTl","E,mV","I_M,mA","t,ms"
6,2,-0.000005930,987
9,2,-0.000005930,5491
80,2,-0.000007116,9717
1 B,mTl E,mV I_M,mA t,ms
2 6 2 -0.000005930 987
3 9 2 -0.000005930 5491
4 80 2 -0.000007116 9717

22
Automation/amb/data.csv Normal file
View File

@ -0,0 +1,22 @@
"U_34,mV","I_M,mA","U_0,mV","I_0,mA",N,"t,ms"
-73.519321600,-0.000008006,-73.519321600,-0.000001773,0.5,1,0
-50.542880000,-0.000006227,-73.519321600,-0.000001773,0.5,1,5895
-74.628313600,-0.000005337,-73.519321600,-0.000002660,0.5,1,11791
-95.008281600,-0.000007709,-73.519321600,-0.000000886,0.5,1,17686
74.878502400,-0.000006523,-73.519321600,0.000001478,0.5,1,23601
-73.745145600,-0.000006523,-73.519321600,-0.000000591,0.5,1,29477
-87.920339200,-0.000006523,-87.920339200,-0.000001478,1.0,2,35352
-109.612584000,-0.000007709,-87.920339200,-0.000000886,1.0,2,41234
5.936342400,-0.000006523,-87.920339200,-0.000001773,1.0,2,47120
-57.207961600,-0.000005337,-87.920339200,-0.000003251,1.0,2,52983
-76.537747200,-0.000008302,-87.920339200,-0.000002069,1.0,2,58862
-90.498227200,-0.000007116,-87.920339200,-0.000003251,1.0,2,64742
-111.545984000,-0.000006523,-87.920339200,0.000000296,1.0,2,70645
-119.853240000,-0.000005634,-87.920339200,-0.000002955,1.0,2,76544
-4.587542720,-0.000006523,-87.920339200,-0.000001182,1.0,2,82435
-41.981990400,-0.000008599,-87.920339200,-0.000000886,1.0,2,88317
-72.026790400,-0.000006523,-87.920339200,-0.000002660,1.0,2,94201
-85.128089600,-0.000008006,-87.920339200,-0.000002364,1.0,2,100086
-103.383784000,-0.000006227,-87.920339200,-0.000000886,1.0,2,105950
-71.152601600,-0.000005634,-87.920339200,0.000000296,1.0,2,111836
-28.428736000,-0.000005040,-87.920339200,-0.000001182,1.0,2,117755
Can't render this file because it has a wrong number of fields in line 2.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

View File

@ -1,6 +0,0 @@
"B,mTl","E,mV","I_M,mA","t,ms"
1,17.983333333333334,8.991666666666667,1079
2,26.666666666666668,13.333333333333334,1600
3,34.583333333333336,17.291666666666668,2075
4,46.71666666666667,23.358333333333334,2803
5,55.5,27.75,3330
1 B,mTl E,mV I_M,mA t,ms
2 1 17.983333333333334 8.991666666666667 1079
3 2 26.666666666666668 13.333333333333334 1600
4 3 34.583333333333336 17.291666666666668 2075
5 4 46.71666666666667 23.358333333333334 2803
6 5 55.5 27.75 3330

View File

@ -1,5 +0,0 @@
"U_34,mV","I_M,mA","U_0,mV","I_0,mA","E, mV",N,"t,ms"
0.016666666666666666,0.016666666666666666,0.016666666666666666,0.00016666666666666666,0,1,1
16.683333333333334,16.683333333333334,0.016666666666666666,0.16683333333333333,5.0,1,1001
33.36666666666667,33.36666666666667,0.016666666666666666,0.33366666666666667,10.0,1,2002
50.06666666666667,50.06666666666667,0.016666666666666666,0.5006666666666667,15.0,1,3004
1 U_34,mV I_M,mA U_0,mV I_0,mA E, mV N t,ms
2 0.016666666666666666 0.016666666666666666 0.016666666666666666 0.00016666666666666666 0 1 1
3 16.683333333333334 16.683333333333334 0.016666666666666666 0.16683333333333333 5.0 1 1001
4 33.36666666666667 33.36666666666667 0.016666666666666666 0.33366666666666667 10.0 1 2002
5 50.06666666666667 50.06666666666667 0.016666666666666666 0.5006666666666667 15.0 1 3004

BIN
Automation/style.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -0,0 +1,4 @@
"B,mTl","E,mV","I_M,mA","t,ms"
1,1,-0.000005634,18629
2,1,-0.000003854,26851
3,1,-0.000007413,33225
1 B,mTl E,mV I_M,mA t,ms
2 1 1 -0.000005634 18629
3 2 1 -0.000003854 26851
4 3 1 -0.000007413 33225

View File

@ -0,0 +1,16 @@
"U_34,mV","I_M,mA","U_0,mV","I_0,mA",N,"t,ms"
-72.884595200,-0.000006820,-72.884595200,0.000000887,0.05,1,1
-68.160128000,-0.000005337,-72.884595200,0.000000887,0.05,1,5876
-90.281459200,-0.000007116,-72.884595200,0.000000000,0.05,1,12321
-71.586988800,-0.000008895,-72.884595200,-0.000002069,0.05,1,18208
-52.679334400,-0.000006227,-72.884595200,-0.000001478,0.05,1,24108
-80.186566400,-0.000005337,-72.884595200,-0.000001182,0.05,1,30002
-103.811368000,-0.000008006,-72.884595200,-0.000000295,0.05,1,35888
-4.395862080,-0.000007413,-72.884595200,0.000000591,0.05,1,41786
-69.878086400,-0.000007116,-69.878086400,-0.000000295,0.1,2,47677
-84.720902400,-0.000006820,-69.878086400,0.000000296,0.1,2,53572
-111.114152000,-0.000007709,-69.878086400,-0.000001478,0.1,2,59440
17.748641600,-0.000005634,-69.878086400,-0.000002069,0.1,2,65334
-66.228012800,-0.000005930,-69.878086400,-0.000001478,0.1,2,71208
-82.980300800,-0.000006227,-69.878086400,0.000000296,0.1,2,77089
-101.450720000,-0.000005634,-69.878086400,-0.000000886,0.1,2,82978
Can't render this file because it has a wrong number of fields in line 2.

3
Automation/й/data.csv Normal file
View File

@ -0,0 +1,3 @@
"U_34,mV","I_M,mA","U_0,mV","I_0,mA",N,"t,ms"
1.855950880,-0.000003854,1.855950880,0.000000000,0.05,1,0
-68.804281600,-0.000004151,1.855950880,-0.000004729,0.05,1,5868
Can't render this file because it has a wrong number of fields in line 2.

View File

@ -0,0 +1 @@
"B,mTl","E,mV","I_M,mA","t,ms"
1 B,mTl E,mV I_M,mA t,ms