diff --git a/.dev/test.py b/.dev/test.py deleted file mode 100644 index f4946ed980f5fac2df8542470e22ee82b8d2c871..0000000000000000000000000000000000000000 --- a/.dev/test.py +++ /dev/null @@ -1,91 +0,0 @@ -from ohmpi.ohmpi import OhmPi -import matplotlib.pyplot as plt -import numpy as np - -a = np.arange(13) + 1 -b = a + 3 -m = a + 1 -n = a + 2 -seq = np.c_[a, b, m, n] - -k = OhmPi(idps=False) -k.settings['injection_duration'] = 1 -k.settings['nb_stack'] = 1 -k.settings['nbr_meas'] = 1 -k.sequence = seq -k.reset_mux() -k.switch_mux_on([1, 4, 2, 3]) -#k.switch_mux_on([12, 15, 13, 14]) -#k.measure(strategy='vmax') -#print('vab', k.compute_tx_volt(strategy='vmin')) -#k.rs_check() -out = k.run_measurement(quad=[3, 3, 3, 3], nb_stack=1, tx_volt=12, strategy='constant', autogain=True) -#k.reset_mux() -#k.rs_check(tx_volt=12) - -# x = [] -#for i in range(3): -# out = k.run_measurement(injection_duration=2, nb_stack=2, strategy='constant', tx_volt=5, autogain=False) - #x.append(out['R [ohm]']) - #k.append_and_save('out.csv', out) - -data = out['fulldata'] -inan = ~np.isnan(data[:,0]) - -if True: - fig, axs = plt.subplots(2, 1, sharex=True) - ax = axs[0] - ax.plot(data[inan,2], data[inan,0], 'r.-', label='current [mA]') - ax.set_ylabel('Current AB [mA]') - ax = axs[1] - ax.plot(data[inan,2], data[inan,1], '.-', label='voltage [mV]') - ax.set_ylabel('Voltage MN [mV]') - ax.set_xlabel('Time [s]') - plt.show() - -# fig,ax=plt.subplots() -# -# -# ax.plot(data[inan,2], data[inan,0], label='current [mA]', marker="o") -# ax2=ax.twinx() -# ax2.plot(data[inan,2], data[inan,1],'r.-' , label='current [mV]') -# ax2.set_ylabel('Voltage [mV]', color='r') -# ymin=-50 -# ymax=50 -# ymin1=-4500 -# ymax1= 4500 -# ax.set_ylim([ymin,ymax]) -# ax2.set_ylim([ymin1,ymax1]) -# -# plt.show() - - - -if False: - from numpy.fft import fft, ifft - - x = data[inan, 1][10:300] - t = np.linspace(0, len(x)*4, len(x)) - sr = 1/0.004 - - X = fft(x) - N = len(X) - n = np.arange(N) - T = N/sr - freq = n/T - - plt.figure(figsize = (12, 6)) - plt.subplot(121) - - plt.stem(freq, np.abs(X), 'b', \ - markerfmt=" ", basefmt="-b") - plt.xlabel('Freq (Hz)') - plt.ylabel('FFT Amplitude |X(freq)|') - #plt.xlim(0, 10) - - plt.subplot(122) - plt.plot(t, ifft(X), 'r') - plt.xlabel('Time (s)') - plt.ylabel('Amplitude') - plt.tight_layout() - plt.show() diff --git a/.dev/test_mb_2023_4_mux_2023.py b/.dev/test_mb_2023_4_mux_2023.py index 2841a90d1f53f85ed13e8abceb646b5129f441cf..045afb0425e434c0d1b1cf90c62483dbac8dc174 100644 --- a/.dev/test_mb_2023_4_mux_2023.py +++ b/.dev/test_mb_2023_4_mux_2023.py @@ -89,7 +89,7 @@ if within_ohmpi: k.reset_mux() # k.run_multiple_sequences(sequence_delay=20, nb_meas=3) k.run_sequence(injection_duration=0.2) - # k.rs_check(tx_volt=4) + # k.rs_check(vab=4) # k.test_mux(mux_id=None, activation_time=0.2) # k._hw.switch_mux([A, B, M, N], state='on') # k._hw.vab_square_wave(12.,1., cycles=2) diff --git a/.dev/test_mb_2024_3_mux_2024.py b/.dev/test_mb_2024_3_mux_2024.py index c71984694f0de520a8d0199f64578d379cdcdf9e..f34b996418e27c8c7bc0993c103ca7ee02cb76d6 100644 --- a/.dev/test_mb_2024_3_mux_2024.py +++ b/.dev/test_mb_2024_3_mux_2024.py @@ -92,7 +92,7 @@ if within_ohmpi: # A, B, M, N = (32, 29, 31, 30) k.reset_mux() k.load_sequence('sequences/ABMN2.txt') - k.run_sequence(tx_volt=50, injection_duration=1., nb_stack=2, duty_cycle=0.5) + k.run_sequence(vab=50, injection_duration=1., nb_stack=2, duty_cycle=0.5) print('using OhmPi') #d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5) # print(d) diff --git a/.dev/test_mb_2024_4_mux_2023.py b/.dev/test_mb_2024_4_mux_2023.py index d0700b5a241004a238865277e513f357ce1c8d2b..59a8fbbbcbab29029b2338a38f6678020ec5d5bb 100644 --- a/.dev/test_mb_2024_4_mux_2023.py +++ b/.dev/test_mb_2024_4_mux_2023.py @@ -98,7 +98,7 @@ if within_ohmpi: k._hw._plot_readings() # k.load_sequence('sequences/test_circuit_1423.txt') #k.load_sequence('sequences/wenner1-16.txt') - # k.run_sequence(tx_volt=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) + # k.run_sequence(vab=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) print('using OhmPi') #d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5) #print(d) diff --git a/.dev/test_mb_2024_4_mux_2023_dps5005.py b/.dev/test_mb_2024_4_mux_2023_dps5005.py index d2877b1424fb4d2b64a722d5e03406677762f159..3bbd899eba676bd7fcf43d0ea7cd9b9aab1a674a 100644 --- a/.dev/test_mb_2024_4_mux_2023_dps5005.py +++ b/.dev/test_mb_2024_4_mux_2023_dps5005.py @@ -77,14 +77,13 @@ if part_of_hardware_system: if within_ohmpi: from ohmpi.ohmpi import OhmPi # from ohmpi.plots import plot_exec_log - print('Starting test with OhmPi.') k = OhmPi() - # A, B, M, N = (32, 29, 31, 30) - # k.reset_mux() + k.reset_mux() # k.create_sequence(nelec=6, params=[('wenner', 1)], ireciprocal=True) - # print(k.sequence) - # k.run_sequence(cycles=1, tx_vold=5, cycle_duration=0.2) + # k.rs_check() + print(k.sequence) + k.run_sequence(cycles=1, vab=5, strategy='constant', injection_duration=1) # k.plot_last_fw() k.export(ftype='bert') # k.export(fnames=['data/measurements_20240226T180635.csv'], ftype='bert') @@ -99,6 +98,7 @@ if within_ohmpi: # k._hw._plot_readings() # A, B, M, N = (1, 4, 2, 3) # A, B, M, N = (5, 8, 6, 7) + # A, B, M, N = (32, 29, 31, 30) # k._hw.switch_mux([A, B, M, N], state='on') # k._hw.vab_square_wave(5., cycle_duration=0.500, cycles=2, duty_cycle=0.5) # k._hw.switch_mux([A, B, M, N], state='off') @@ -106,8 +106,8 @@ if within_ohmpi: # if k._hw.sp is None: # k._hw.sp = 0 # if not off-time, sp is None # k._hw._plot_readings() - # k.load_sequence('sequences/test_circuit_1423.txt') - # k.run_sequence(tx_volt=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) + k.load_sequence('sequences/wenner1-16.txt') + # k.run_sequence(vab=5, injection_duration=.2, nb_stack=1, duty_cycle=1) print('using OhmPi') #d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5) #print(d) diff --git a/.dev/test_mb_2024_4_mux_2024.py b/.dev/test_mb_2024_4_mux_2024.py index 48ff0f36c6113106d5ca3b0d2d4bbcd958c09297..39fd7d7606963deb49f9b1aa8199c8698dfca295 100644 --- a/.dev/test_mb_2024_4_mux_2024.py +++ b/.dev/test_mb_2024_4_mux_2024.py @@ -110,9 +110,9 @@ if within_ohmpi: # print(f'OhmPiHardware Resistance: {k._hw.last_rho :.2f} ohm, dev. {k._hw.last_dev:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV') # k._hw._plot_readings() # k.load_sequence('sequences/9991_GRAD_16_s1_a1.txt') - # k.run_sequence(tx_volt=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) + # k.run_sequence(vab=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) # print('using OhmPi') - d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5, tx_volt=42., strategy='vmax', vab_max=40., delay=0.01) + d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5, vab=42., strategy='vmax', vab_max=40., delay=0.01) print(d) k._hw._plot_readings() # print(f'OhmPiHardware: Resistance: {k._hw.last_resistance() :.2f} ohm, dev. {k._hw.last_dev():.2f} %, sp: {k._hw.sp:.2f} mV, rx bias: {k._hw.rx._bias:.2f} mV') diff --git a/.dev/test_mb_2024_4_mux_2024_4_mux_2023.py b/.dev/test_mb_2024_4_mux_2024_4_mux_2023.py index a53e8662aa5cd304a4a2ccb35b22911fc560ac78..1c4d03bcd29ab175a5a889bb5a7b6a44d93bca90 100644 --- a/.dev/test_mb_2024_4_mux_2024_4_mux_2023.py +++ b/.dev/test_mb_2024_4_mux_2024_4_mux_2023.py @@ -103,7 +103,7 @@ if within_ohmpi: # print(f'OhmPiHardware Resistance: {k._hw.last_rho :.2f} ohm, dev. {k._hw.last_dev:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV') # k._hw._plot_readings() # k.load_sequence('sequences/9991_GRAD_16_s1_a1.txt') - # k.run_sequence(tx_volt=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) + # k.run_sequence(vab=5, injection_duration=1., nb_stack=2, duty_cycle=0.5) print('using OhmPi') #d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5) # print(d) diff --git a/configs/config_default.py b/configs/config_default.py index 411cad0432beea238964192e620b155581d159bf..c83a4728edc861870d1ffd3e966d041a32e85860 100644 --- a/configs/config_default.py +++ b/configs/config_default.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023.py b/configs/config_mb_2023.py index 2ef5840f340365957675fa25ba53edc582dd971f..5443691112abbb38a8866765a8c2bec07830d839 100644 --- a/configs/config_mb_2023.py +++ b/configs/config_mb_2023.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__1_mux_2024_4roles.py b/configs/config_mb_2023__1_mux_2024_4roles.py index b1c64d6d170e0fcb348bcf752c6cae5f9f6216ba..319207eeb191ce493eb9cd9d5da24a4d975e71b2 100644 --- a/configs/config_mb_2023__1_mux_2024_4roles.py +++ b/configs/config_mb_2023__1_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__2_mux_2024_2roles.py b/configs/config_mb_2023__2_mux_2024_2roles.py index 6f14a8215b00aff7c3d5a783d08009cb623f6f8f..61be8588a8063da420f99a2dc1e36e9d2a3a145f 100644 --- a/configs/config_mb_2023__2_mux_2024_2roles.py +++ b/configs/config_mb_2023__2_mux_2024_2roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__2_mux_2024_4roles.py b/configs/config_mb_2023__2_mux_2024_4roles.py index 36cbbc41e1129c452b84e22a44b1578efec644e4..6449f86771aff945594c6b6da9ea58f97f4aa4c2 100644 --- a/configs/config_mb_2023__2_mux_2024_4roles.py +++ b/configs/config_mb_2023__2_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__3_mux_2024_4roles.py b/configs/config_mb_2023__3_mux_2024_4roles.py index 0edb73c153794cf03c3534ffca4736222d0ecda0..5039251734567eab686fd156e85deb9e3a3ab889 100644 --- a/configs/config_mb_2023__3_mux_2024_4roles.py +++ b/configs/config_mb_2023__3_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__4_mux_2023.py b/configs/config_mb_2023__4_mux_2023.py index 66e7ec87b7b246b6f3646c11e27c187b825fc60d..16b57777be236de6c15721bf17f2ea9f78a3595a 100644 --- a/configs/config_mb_2023__4_mux_2023.py +++ b/configs/config_mb_2023__4_mux_2023.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__4_mux_2024_2roles.py b/configs/config_mb_2023__4_mux_2024_2roles.py index 4735f2c7e256860d0ccb82133d4f5425516aba7b..7b13a70d838c631d1c144e5160febe056eec97bc 100644 --- a/configs/config_mb_2023__4_mux_2024_2roles.py +++ b/configs/config_mb_2023__4_mux_2024_2roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2023__4_mux_2024_4roles.py b/configs/config_mb_2023__4_mux_2024_4roles.py index 9b979829d86fee070d1b57bc79fae639f2a8d4eb..0b3da7543988c06fb568f8061a3c8796558971f3 100644 --- a/configs/config_mb_2023__4_mux_2024_4roles.py +++ b/configs/config_mb_2023__4_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2.py b/configs/config_mb_2024_0_2.py index de3c949ece8eeab1ea9673d9518ffec666816bf7..23c77aa7011712a1985e1de6f231b9001e37de74 100644 --- a/configs/config_mb_2024_0_2.py +++ b/configs/config_mb_2024_0_2.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__1_mux_2024_4roles.py b/configs/config_mb_2024_0_2__1_mux_2024_4roles.py index 4d0bf01738d56560e87ee36ec7983b485639a4c2..d337f4a61f7b9f7268602b1d78048557ccad0baa 100644 --- a/configs/config_mb_2024_0_2__1_mux_2024_4roles.py +++ b/configs/config_mb_2024_0_2__1_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__1_mux_2024_4roles_dps5005.py b/configs/config_mb_2024_0_2__1_mux_2024_4roles_dps5005.py index 42622a821798bbe02fe9c3e821c5e74bb87002e3..2c3e5b129f0c1b14dc720c6dff3dfb1e3b1ad539 100644 --- a/configs/config_mb_2024_0_2__1_mux_2024_4roles_dps5005.py +++ b/configs/config_mb_2024_0_2__1_mux_2024_4roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__2_mux_2024_2roles.py b/configs/config_mb_2024_0_2__2_mux_2024_2roles.py index a08d907948e39d187007cfb07fe6da7d61156aa2..8741734e3fec72f7d2aed27a567df686205006e9 100644 --- a/configs/config_mb_2024_0_2__2_mux_2024_2roles.py +++ b/configs/config_mb_2024_0_2__2_mux_2024_2roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__2_mux_2024_2roles_dps5005.py b/configs/config_mb_2024_0_2__2_mux_2024_2roles_dps5005.py index 93aaadb4fb49f16b8fc0bfb8681080a8861c9a65..66f0856b9c56fdf826a85c3bfbb949961ec8b6cf 100644 --- a/configs/config_mb_2024_0_2__2_mux_2024_2roles_dps5005.py +++ b/configs/config_mb_2024_0_2__2_mux_2024_2roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__2_mux_2024_4roles.py b/configs/config_mb_2024_0_2__2_mux_2024_4roles.py index 9b50b845e52b1824a4f4317a1ca6890b837c8feb..89317c1dad98489c1b01fd5c28ba4b6e70af1527 100644 --- a/configs/config_mb_2024_0_2__2_mux_2024_4roles.py +++ b/configs/config_mb_2024_0_2__2_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__2_mux_2024_4roles_dps5005.py b/configs/config_mb_2024_0_2__2_mux_2024_4roles_dps5005.py index 16dfee2b86b6477d9ad2695516fe03828d9f6fb7..5093dc7e841d7d532acf31216e135af0cae15bbd 100644 --- a/configs/config_mb_2024_0_2__2_mux_2024_4roles_dps5005.py +++ b/configs/config_mb_2024_0_2__2_mux_2024_4roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__3_mux_2024_4roles.py b/configs/config_mb_2024_0_2__3_mux_2024_4roles.py index 7e0f9467ebb9f7a52c73fbb8f9ecde308267aad2..b308ca84af7763855ec38c2e5fe8d001be501c9c 100644 --- a/configs/config_mb_2024_0_2__3_mux_2024_4roles.py +++ b/configs/config_mb_2024_0_2__3_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__3_mux_2024_4roles_dps5005.py b/configs/config_mb_2024_0_2__3_mux_2024_4roles_dps5005.py index 028900ed10a8eaff62ff9c5c53c0b0f9aa89fca4..b4a4bef95884be324cda063068cc0703d57dcc90 100644 --- a/configs/config_mb_2024_0_2__3_mux_2024_4roles_dps5005.py +++ b/configs/config_mb_2024_0_2__3_mux_2024_4roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2023.py b/configs/config_mb_2024_0_2__4_mux_2023.py index 6231883053d5a65898d32fc4e54ceadcfd2eb004..a85c8d37b68705fd33d5d7b93ae7f25d7fc18d97 100644 --- a/configs/config_mb_2024_0_2__4_mux_2023.py +++ b/configs/config_mb_2024_0_2__4_mux_2023.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2023__2_mux_2024_2roles_dps5005.py b/configs/config_mb_2024_0_2__4_mux_2023__2_mux_2024_2roles_dps5005.py index 4765b7110cc49a5ca596c0ae370f0a19806a1584..00a15870f613ec681f206eef75f5871c7ba6d916 100644 --- a/configs/config_mb_2024_0_2__4_mux_2023__2_mux_2024_2roles_dps5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2023__2_mux_2024_2roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2023_dps5005.py b/configs/config_mb_2024_0_2__4_mux_2023_dps5005.py index 57cd2686ed8f30c6445d53d2a56586e10896a052..30d13e906c6ef07f510dc908a2a8c706a3651d8a 100644 --- a/configs/config_mb_2024_0_2__4_mux_2023_dps5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2023_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2024_2roles.py b/configs/config_mb_2024_0_2__4_mux_2024_2roles.py index 84c3b009ca979e7b7d281188c5cb2473c518c07b..b4db08099664b279e16060b8a9daf27765e21b01 100644 --- a/configs/config_mb_2024_0_2__4_mux_2024_2roles.py +++ b/configs/config_mb_2024_0_2__4_mux_2024_2roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2024_2roles_dps5005.py b/configs/config_mb_2024_0_2__4_mux_2024_2roles_dps5005.py index 8ded3e1a5af38d3bf42c3bbe3cf40087166f5c4a..0d0d69ce5ae8fd53c5ee9d0fc2586e842a34d1cc 100644 --- a/configs/config_mb_2024_0_2__4_mux_2024_2roles_dps5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2024_2roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2024_4roles.py b/configs/config_mb_2024_0_2__4_mux_2024_4roles.py index 4710f01e68cecba8b7f6129d59d2486e4ff8f130..d3c1bb27232f4fb4842442efc86fd2b2e28df34c 100644 --- a/configs/config_mb_2024_0_2__4_mux_2024_4roles.py +++ b/configs/config_mb_2024_0_2__4_mux_2024_4roles.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__4_mux_2024_4roles_dps5005.py b/configs/config_mb_2024_0_2__4_mux_2024_4roles_dps5005.py index a8130966fae7a983855c5274197a54d1786e2360..0f17446e60eaea2677088991f0b8c7a25024519a 100644 --- a/configs/config_mb_2024_0_2__4_mux_2024_4roles_dps5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2024_4roles_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2__8_mux_2023_dps5005.py b/configs/config_mb_2024_0_2__8_mux_2023_dps5005.py index 3a7859ef01f729d3a1b3c9e306a0d6581b72f04b..815a38c90361b6dbe91d8bdef5a51527b9f535d8 100644 --- a/configs/config_mb_2024_0_2__8_mux_2023_dps5005.py +++ b/configs/config_mb_2024_0_2__8_mux_2023_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/configs/config_mb_2024_0_2_dps5005.py b/configs/config_mb_2024_0_2_dps5005.py index f4f7e4083bc3863deb67c03c86cca9314a59b286..5641b8ebfd6ffb6013a78d665c750aeb81fdf99f 100644 --- a/configs/config_mb_2024_0_2_dps5005.py +++ b/configs/config_mb_2024_0_2_dps5005.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/ohmpi/config.py b/ohmpi/config.py index 411cad0432beea238964192e620b155581d159bf..c83a4728edc861870d1ffd3e966d041a32e85860 100644 --- a/ohmpi/config.py +++ b/ohmpi/config.py @@ -13,7 +13,7 @@ logging_suffix = '' # OhmPi configuration OHMPI_CONFIG = { 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) - 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE + 'settings': 'settings/default.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } r_shunt = 2. diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 8142047b2a141a11408fcbaad85e7190c42a3c4f..8b46223b083e657cef68cc6662ad33e05164b0de 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -417,9 +417,9 @@ class OhmPiHardware: return new_vab - def compute_tx_volt(self, pulse_duration=0.1, strategy='vmax', tx_volt=5., vab_max=None, - iab_max=None, vmn_max=None, vmn_min=None, polarities=(1, -1), delay=0.05, - p_max=None, diff_vab_lim=2.5, n_steps=4): + def compute_vab(self, pulse_duration=0.1, strategy='vmax', vab=5., vab_max=None, + iab_max=None, vmn_max=None, vmn_min=None, polarities=(1, -1), delay=0.05, + p_max=None, diff_vab_lim=2.5, n_steps=4): # TODO: Optimise how to pass iab_max, vab_max, vmn_min # TODO: Update docstring """Estimates best Tx voltage based on different strategies. @@ -442,10 +442,10 @@ class OhmPiHardware: - vmax : compute Vab to reach a maximum Iab without exceeding vab_max - vmin : compute Vab to reach at least vmn_min - constant : apply given Vab - tx_volt : float, optional + vab : float, optional Voltage to apply for guessing the best voltage. 5 V applied by default. If strategy "constant" is chosen, constant voltage - to applied is "tx_volt". + to applied is "vab". vab_max : float, optional Maximum injection voltage to apply to tx (used by all strategies) vmn_min : float, optional @@ -460,14 +460,14 @@ class OhmPiHardware: rab : float Resistance between injection electrodes """ - tx_volt = np.abs(tx_volt) - vab_opt = tx_volt + vab_opt = np.abs(vab) if not self.tx.pwr.voltage_adjustable: vab_opt = self.tx.pwr.voltage else: - if strategy == 'full_constant': - return tx_volt + # TODO what is "full_constant"? maybe just a typo? + if strategy == 'full_constant' or strategy == 'constant': + return vab if vmn_max is None: vmn_max = self.rx._voltage_max / 1000. @@ -483,13 +483,13 @@ class OhmPiHardware: vab_max = np.abs(vab_max) vmn_min = np.abs(vmn_min) - # tx_volt = np.abs(tx_volt) + # Set gain at min self.rx.reset_gain() - # vab_opt = tx_volt - if tx_volt >= vab_max: + + if vab >= vab_max: strategy = 'constant' - vab = np.min([np.abs(tx_volt), vab_max]) + vab = np.min([np.abs(vab), vab_max]) if strategy == 'constant': vab_max = vab vab = vab * .9 @@ -522,12 +522,12 @@ class OhmPiHardware: while (k < n_steps) and (diff_vab > diff_vab_lim) and (vab_list[k] < vab_max): if k>0: self.exec_logger.event( - f'OhmPiHardware\t_compute_tx_volt_sleep\tbegin\t{datetime.datetime.utcnow()}') + f'OhmPiHardware\t_compute_vab_sleep\tbegin\t{datetime.datetime.utcnow()}') time.sleep( 0.2) # TODO: replace this by discharging DPS on resistor with relay on GPIO5 (at least for strategy vmin, # but might be useful in vmax when last vab too high...) self.exec_logger.event( - f'OhmPiHardware\t_compute_tx_volt_sleep\tend\t{datetime.datetime.utcnow()}') + f'OhmPiHardware\t_compute_vab_sleep\tend\t{datetime.datetime.utcnow()}') if strategy == 'vmax': vmn_min = vmn_max vabs = [] @@ -541,13 +541,13 @@ class OhmPiHardware: vabs.append(new_vab) # print(f'new_vab: {new_vab}, diff_vab: {diff_vab}\n') if diff_vab < diff_vab_lim: - self.exec_logger.debug('Compute_tx_volt stopped on vab increase too small') + self.exec_logger.debug('Compute_vab stopped on vab increase too small') k = k + 1 vab_list[k] = np.min(vabs) if self.tx.pwr.voltage_adjustable: self.tx.voltage = vab_list[k] if k > n_steps: - self.exec_logger.debug('Compute_tx_volt stopped on maximum number of steps reached') + self.exec_logger.debug('Compute_vab stopped on maximum number of steps reached') vab_opt = vab_list[k] # print(f'Selected Vab: {vab_opt:.2f}') # if switch_pwr_off: diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index b06a25efeb37720ffa3c60fe0feccee25eae92ad..ca9a3fe592b15bd3176ffcb3346c84d0a6ac3d92 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -58,7 +58,7 @@ class OhmPi(object): settings : dict, optional Dictionnary of parameters. Possible parameters with their default values: `{'injection_duration': 0.2, 'nb_meas': 1, 'sequence_delay': 1, - 'nb_stack': 1, 'sampling_interval': 2, 'tx_volt': 5, 'duty_cycle': 0.5, + 'nb_stack': 1, 'sampling_interval': 2, 'vab': 5, 'duty_cycle': 0.5, 'strategy': 'constant', 'export_path': None sequence : str, optional Path of the .csv or .txt file with A, B, M and N electrodes. @@ -520,12 +520,12 @@ class OhmPi(object): self._hw._plot_readings(save_fig=save_fig, filename=filename) def run_measurement(self, quad=None, nb_stack=None, injection_duration=None, duty_cycle=None, - autogain=True, strategy=None, tx_volt=None, best_tx_injtime=0.1, + autogain=True, strategy=None, tx_volt=None, vab=None, best_tx_injtime=0.1, cmd_id=None, vab_max=None, iab_max=None, vmn_max=None, vmn_min=None, **kwargs): # TODO: add sampling_interval -> impact on _hw.rx.sampling_rate (store the current value, # change the _hw.rx.sampling_rate, do the measurement, reset the sampling_rate to the previous value) # TODO: default value of tx_volt and other parameters set to None should be given in config.py and used - # in function definition + # in function definition -> (GB) default values are in self.settings. """Measures on a quadrupole and returns a dictionnary with the transfer resistance. Parameters @@ -541,15 +541,15 @@ class OhmPi(object): duty_cycle : float, optional Duty cycle (default=0.5) of injection square wave. strategy : str, optional, default: constant - Define injection strategy (if power is adjustable, otherwise constant tx_volt, generally 12V battery is used). + Define injection strategy (if power is adjustable, otherwise constant vab, generally 12V battery is used). Either: - vmax : compute Vab to reach a maximum Vmn_max and Iab without exceeding vab_max - vmin : compute Vab to reach at least Vmn_min - - constant : apply given Vab (tx_volt) but checks if expected readings not out-of-range - - full_constant: apply given Vab (tx_volt) with no out-of-range checks for optimising duration at the risk of out-of-range readings + - constant : apply given Vab but checks if expected readings not out-of-range + - full_constant: apply given Vab with no out-of-range checks for optimising duration at the risk of out-of-range readings Safety check (i.e. short voltage pulses) performed prior to injection to ensure injection within bounds defined in vab_max, iab_max, vmn_max or vmn_min. This can adapt Vab. - To bypass safety check before injection, tx_volt should be set equal to vab_max (not recpommanded) + To bypass safety check before injection, vab should be set equal to vab_max (not recpommanded) vab_max : str, optional Maximum injection voltage. Default value set by config or boards specs @@ -562,7 +562,9 @@ class OhmPi(object): vmn_min : Minimum Vmn desired (used in strategy vmin). Default value set by config or boards specs - tx_volt : float, optional # TODO: change tx_volt to Vab + tx_volt : float, optional # deprecated + For power adjustable only. If specified, voltage will be imposed. + vab : float, optional For power adjustable only. If specified, voltage will be imposed. cmd_id : str, optional Unique command identifier. @@ -587,6 +589,11 @@ class OhmPi(object): duty_cycle = self.settings['duty_cycle'] if tx_volt is None and 'tx_volt' in self.settings: tx_volt = self.settings['tx_volt'] + if vab is None and 'vab' in self.settings: + vab = self.settings['vab'] + if vab is None and tx_volt is not None: + warnings.warn('"tx_volt" argument is deprecated and will be removed in future version. Use "vab" instead to set the transmitter voltage in volts.', DeprecationWarning) + vab = tx_volt if strategy is None and 'strategy' in self.settings: strategy = self.settings['strategy'] if vab_max is None and 'vab_max' in self.settings: @@ -612,7 +619,7 @@ class OhmPi(object): switch_pwr_on.join() status = q.get() if status: - vab = self._hw.compute_tx_volt(tx_volt=tx_volt, strategy=strategy, vmn_max=vmn_max, vab_max=vab_max, + vab = self._hw.compute_vab(vab=vab, strategy=strategy, vmn_max=vmn_max, vab_max=vab_max, iab_max=iab_max, vmn_min=vmn_min) # time.sleep(0.5) # to wait for pwr discharge self._hw.vab_square_wave(vab, cycle_duration=injection_duration*2/duty_cycle, cycles=nb_stack, duty_cycle=duty_cycle) @@ -673,7 +680,7 @@ class OhmPi(object): # if strategy not constant, then switch dps off (button) in case following measurement within sequence # TODO: check if this is the right strategy to handle DPS pwr state on/off after measurement - if (strategy == 'vmax' or strategy == 'vmin') and vab - tx_volt > 5.: # if starting tx_volt was too far (> 5 V) from actual vab, then turn pwr off + if (strategy == 'vmax' or strategy == 'vmin') and vab - vab > 5.: # if starting vab was too far (> 5 V) from actual vab, then turn pwr off self._hw.tx.pwr.pwr_state = 'off' # Discharge DPS capa @@ -889,7 +896,7 @@ class OhmPi(object): # TODO: we could build a smarter RS-Check by selecting adjacent electrodes based on their locations and try to # isolate electrodes that are responsible for high resistances (ex: AB high, AC low, BC high # -> might be a problem at B (cf what we did with WofE) - def rs_check(self, tx_volt=5.0, cmd_id=None, couple=None): + def rs_check(self, vab=5, cmd_id=None, couple=None, tx_volt=None): # TODO: add a default value for rs-check in config.py import it in ohmpi.py and add it in rs_check definition """Checks contact resistances. Strategy: we just open A and B, measure the current and using vAB set or @@ -897,12 +904,20 @@ class OhmPi(object): Parameters ---------- - tx_volt : float + vab : float, optional Voltage of the injection. couple : array, for selecting a couple of electrode for checking resistance cmd_id : str, optional Unique command identifier. + tx_volt : float, optional DEPRECATED + Save as vab. """ + # check arguments + if tx_volt is not None: + warnings.warn('"tx_volt" is deprecated and will be removed in future version. Please use "vab" instead.', + DeprecationWarning) + vab = tx_volt + # check pwr is on, if not, let's turn it on switch_tx_pwr_off = False if self._hw.pwr_state == 'off': @@ -947,7 +962,7 @@ class OhmPi(object): for i in range(0, quads.shape[0]): quad = quads[i, :] # quadrupole self._hw.switch_mux(electrodes=list(quads[i, :2]), roles=['A', 'B'], state='on') - self._hw._vab_pulse(duration=0.2, vab=tx_volt) + self._hw._vab_pulse(duration=0.2, vab=vab) current = self._hw.readings[-1, 3] vab = self._hw.tx.pwr.voltage print(vab, current) @@ -1106,7 +1121,7 @@ class OhmPi(object): self.exec_logger.debug('Acquisition parameters updated: ' + str(self.settings)) self.status = 'idle (acquisition updated)' except Exception as e: # noqa - self.exec_logger.warning('Unable to update settings.') + self.exec_logger.warning('Unable to update settings. Error: ' + str(e)) self.status = 'idle (unable to update settings)' else: self.exec_logger.warning('Settings are missing...') diff --git a/settings/default.json b/settings/default.json index a0178639f1a9f15c93c2345546aabf3cba6f526f..d69f189e60ba297da69d245b02ecdfec0d62b386 100644 --- a/settings/default.json +++ b/settings/default.json @@ -4,7 +4,7 @@ "sequence_delay": 1, "nb_stack": 1, "sampling_interval": 2, - "tx_volt": 5, + "vab": 5, "duty_cycle": 0.5, "strategy": "constant", "fw_in_csv": true,