Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
earik87 authored Aug 27, 2024
1 parent 518616d commit 072fed7
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 222 deletions.
243 changes: 119 additions & 124 deletions app/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Sensitivity</string>
</property>
</widget>
</item>
<!-- <item row="2" column="4"> -->
<!-- <widget class="QLabel" name="label_6"> -->
<!-- <property name="text"> -->
<!-- <string>Sensitivity</string> -->
<!-- </property> -->
<!-- </widget> -->
<!-- </item> -->
<item row="2" column="1">
<widget class="QSpinBox" name="nStepsize">
<property name="minimum">
Expand Down Expand Up @@ -264,11 +264,6 @@
</item>
<item row="0" column="5">
<widget class="QComboBox" name="ddTc">
<item>
<property name="text">
<string>100 s</string>
</property>
</item>
<item>
<property name="text">
<string>30 s</string>
Expand Down Expand Up @@ -331,118 +326,118 @@
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QComboBox" name="ddSens">
<property name="maxVisibleItems">
<number>20</number>
</property>
<item>
<property name="text">
<string>100 fA</string>
</property>
</item>
<item>
<property name="text">
<string>200 fA</string>
</property>
</item>
<item>
<property name="text">
<string>500 fA</string>
</property>
</item>
<item>
<property name="text">
<string>1 pA</string>
</property>
</item>
<item>
<property name="text">
<string>2 pA</string>
</property>
</item>
<item>
<property name="text">
<string>5 pA</string>
</property>
</item>
<item>
<property name="text">
<string>10 pA</string>
</property>
</item>
<item>
<property name="text">
<string>20 pA</string>
</property>
</item>
<item>
<property name="text">
<string>50 pA</string>
</property>
</item>
<item>
<property name="text">
<string>100 pA</string>
</property>
</item>
<item>
<property name="text">
<string>200 pA</string>
</property>
</item>
<item>
<property name="text">
<string>500 pA</string>
</property>
</item>
<item>
<property name="text">
<string>1 nA</string>
</property>
</item>
<item>
<property name="text">
<string>2 nA</string>
</property>
</item>
<item>
<property name="text">
<string>5 nA</string>
</property>
</item>
<item>
<property name="text">
<string>10 nA</string>
</property>
</item>
<item>
<property name="text">
<string>20 nA</string>
</property>
</item>
<item>
<property name="text">
<string>50 nA</string>
</property>
</item>
<item>
<property name="text">
<string>100 nA</string>
</property>
</item>
<item>
<property name="text">
<string>200 nA</string>
</property>
</item>
<item>
<property name="text">
<string>500 nA</string>
</property>
</item>
</widget>
</item>
<!-- <item row="2" column="5"> -->
<!-- <widget class="QComboBox" name="ddSens"> -->
<!-- <property name="maxVisibleItems"> -->
<!-- <number>20</number> -->
<!-- </property> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>100 fA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>200 fA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>500 fA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>1 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>2 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>5 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>10 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>20 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>50 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>100 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>200 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>500 pA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>1 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>2 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>5 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>10 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>20 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>50 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>100 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>200 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- <item> -->
<!-- <property name="text"> -->
<!-- <string>500 nA</string> -->
<!-- </property> -->
<!-- </item> -->
<!-- </widget> -->
<!-- </item> -->
<item row="5" column="5">
<widget class="QPushButton" name="btnUpdate">
<property name="text">
Expand Down
Binary file added app/instruments/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 26 additions & 4 deletions app/instruments/lockinAmplifier/sr830.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from time import sleep
from abc import ABC, abstractmethod
from pymeasure.instruments.srs import SR830 as RealSR830
from pymeasure.instruments.resources import list_resources
import pyvisa
from pyvisa.constants import StopBits, Parity

class LockinAmplifierBaseClass(ABC):
@abstractmethod
Expand Down Expand Up @@ -70,10 +72,30 @@ def __init__(self):
def openConnection(self, port, baudrate):
# Initialize visa resource manager
rm = pyvisa.ResourceManager()
# Open connection to the SR830 using USB to RS232
self.instrument = RealSR830(rm.open_resource(port, baud_rate=baudrate))
print('Real SR830 is connected')

print(rm.list_resources())
#To understand how this code works, read docs carefully!!!
#https://pyvisa.readthedocs.io/en/latest/introduction/communication.html#making-sure-the-instrument-understand-the-command
my_instrument = rm.open_resource('ASRL4::INSTR')
my_instrument.read_termination = '\r'
my_instrument.write_termination = '\n'
self.instrument = RealSR830(my_instrument)
#Ask id info.
print(my_instrument.query('*IDN?'))
#Ask time constant wıth low level query.
# print(my_instrument.query('OFLT?'))
#Get time constant.
print("Time constant is", self.instrument.time_constant)
new_tc = 0.3
print("Setting time constant to ", new_tc)
self.instrument.time_constant = new_tc
print("New time constant is", self.instrument.time_constant)


# print("Sensitivity is", self.instrument.sensitivity)
# my_instrument.query('SENS26')
# sleep(2)
# print("New Sensitivity is", self.instrument.sensitivity)

def measure(self) -> float:
if self.instrument is None:
raise ConnectionError("Instrument not connected.")
Expand Down
Binary file not shown.
Binary file not shown.
60 changes: 30 additions & 30 deletions app/instruments/nidaq/nidaq.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
from abc import ABC, abstractmethod
import random
from time import sleep
# from abc import ABC, abstractmethod
# import random
# from time import sleep

#For MacOS this import will fail, thats why it is in try/catch block to bypass.
try:
import nidaqmx
except Exception as e:
print(f"Unexpected error: {e}")
# For MacOS this import will fail, thats why it is in try/catch block to bypass.
# try:
# import nidaqmx
# except Exception as e:
# print(f"Unexpected error: {e}")

class NIDAQBaseClass(ABC):
@abstractmethod
def measure(self):
pass
# class NIDAQBaseClass(ABC):
# @abstractmethod
# def measure(self):
# pass

class NIDAQ(NIDAQBaseClass):
def measure(self):
try:
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai5")
data = task.read()
print(f"Acquired data: {data:f}")
return data
# class NIDAQ(NIDAQBaseClass):
# def measure(self):
# try:
# with nidaqmx.Task() as task:
# task.ai_channels.add_ai_voltage_chan("Dev1/ai5")
# data = task.read()
# print(f"Acquired data: {data:f}")
# return data

except Exception as e:
print(f"Unexpected error: {e}")
# except Exception as e:
# print(f"Unexpected error: {e}")

class NIDAQDemo(NIDAQBaseClass):
def measure(self):
lower_limit = 0
upper_limit = 10
random_number = random.uniform(lower_limit, upper_limit)
# class NIDAQDemo(NIDAQBaseClass):
# def measure(self):
# lower_limit = 0
# upper_limit = 10
# random_number = random.uniform(lower_limit, upper_limit)

sleep(0.00001)
print("Measurement is: ", random_number)
return random_number
# sleep(0.00001)
# print("Measurement is: ", random_number)
# return random_number
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 072fed7

Please sign in to comment.