Commit 56659566 authored by Clement Remi's avatar Clement Remi
Browse files

Update ohmpi.py, updating RScheck function

Showing with 50 additions and 16 deletions
+50 -16
...@@ -509,6 +509,7 @@ class OhmPi(object): ...@@ -509,6 +509,7 @@ class OhmPi(object):
def rs_check(self): def rs_check(self):
"""Check contact resistance. """Check contact resistance.
""" """
# create custom sequence where MN == AB # create custom sequence where MN == AB
nelec = self.sequence.max() # number of elec used in the sequence nelec = self.sequence.max() # number of elec used in the sequence
quads = np.vstack([ quads = np.vstack([
...@@ -517,25 +518,58 @@ class OhmPi(object): ...@@ -517,25 +518,58 @@ class OhmPi(object):
np.arange(nelec - 1) + 1, np.arange(nelec - 1) + 1,
np.arange(nelec - 1) + 2 np.arange(nelec - 1) + 2
]).T ]).T
# create backup TODO not good for i in range(0, quads.shape[0]):
export_path = self.pardict['export_path'].copy() quad = quads[i, :] # quadrupole
sequence = self.sequence.copy() self.reset_mux()
self.switch_mux_on(quad)
# assign new value pin0 = self.mcp.get_pin(0)
self.pardict['export_path'] = export_path.replace('.csv', '_rs.csv') pin0.direction = Direction.OUTPUT
self.sequence = quads pin1 = self.mcp.get_pin(1)
pin1.direction = Direction.OUTPUT
pin0.value = False
pin1.value = False
print(quad)
# call the switch_mux function to switch to the right electrodes
self.ads_current = ads.ADS1115(self.i2c, gain=2/3, data_rate=860, address=0x48)
# ADS1115 for voltage measurement (MN)
self.ads_voltage = ads.ADS1115(self.i2c, gain=2/3, data_rate=860, address=0x49)
pin1.value = True
pin0.value = False
time.sleep(0.2)
A=AnalogIn(self.ads_current,ads.P0).voltage/(50 * self.r_shunt)
B=-AnalogIn(self.ads_voltage,ads.P0,ads.P1).voltage*2.5
R=B/A
#print(B)
#print(A)
print(abs(round(R/1000,1)),"Kohm")
self.switch_mux_off(quad)
pin0.value = False
pin1.value = False
# run the RS check
self.log_exec('RS check (check contact resistance)', level='debug')
self.measure()
# restore # # create backup TODO not good
self.pardict['export_path'] = export_path # export_path = self.pardict['export_path']
self.sequence = sequence # sequence = self.sequence.copy()
#
# TODO if interrupted, we would need to restore the values # # assign new value
# TODO or we offer the possiblity in 'run_measurement' to have rs_check each time? # self.pardict['export_path'] = export_path.replace('.csv', '_rs.csv')
# self.sequence = quads
# print(self.sequence)
#
# # run the RS check
# self.log_exec('RS check (check contact resistance)', level='debug')
# self.measure()
#
# # restore
# self.pardict['export_path'] = export_path
# self.sequence = sequence
#
# # TODO if interrupted, we would need to restore the values
# # TODO or we offer the possiblity in 'run_measurement' to have rs_check each time?
@staticmethod @staticmethod
def append_and_save(fname, last_measurement): def append_and_save(fname, last_measurement):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment