Commit f2f884fc authored by remi.clement's avatar remi.clement
Browse files

update

Showing with 125 additions and 15 deletions
+125 -15
"""
created on January 6, 2020.
Updates dec 2022.
Hardware: Licensed under CERN-OHL-S v2 or any later version
Software: Licensed under the GNU General Public License v3.0
confi.py is a parameter file for OhmPi that has been developed by
Rémi CLEMENT (INRAE), Vivien DUBOIS (INRAE), Hélène GUYARD (IGE), Nicolas FORQUET (INRAE), Yannick FARGIER (IFSTTAR)
Olivier KAUFMANN (UMONS), Arnaud WATLET (UMONS) and Guillaume BLANCHY (FNRS/ULiege).
"""
import logging import logging
from utils import get_platform from utils import get_platform
...@@ -29,12 +17,12 @@ OHMPI_CONFIG = { ...@@ -29,12 +17,12 @@ OHMPI_CONFIG = {
'R_shunt': 2, # Shunt resistance in Ohms 'R_shunt': 2, # Shunt resistance in Ohms
'Imax': 4800 / 50 / 2, # Maximum current 'Imax': 4800 / 50 / 2, # Maximum current
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'nb_samples': 2, # Max value 10 # was named integer before... 'nb_samples': 20, # Max value 10 # was named integer before...
'version': 2, # Is this still needed? 'version': 2, # Is this still needed?
'max_elec': 64, 'max_elec': 64,
'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES 'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES
'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE
'measurement board_version': 'mb.2023.0.0' 'board_version': 'mb.2023.0.0'
} # TODO: add a dictionary with INA models and associated gain values } # TODO: add a dictionary with INA models and associated gain values
# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS # SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS
......
R1:;11.5;R2:;200;10.843914613116045;494.1635181737724;45.57058366874879;6.843958861049231;2;18.664368822909914
R1:;11.5;R2:;200;11.166455379794701;566.040711691641;50.69117212574648;1.7422406689657066;2;18.670737393156926
R1:;11.5;R2:;200;11.142568723557565;505.6208990752891;45.37740907142066;1.6836451307717937;2;16.69921875
R1:;11.5;R2:;200;11.167331399620677;544.821314127018;48.787064217107776;1.6172368541520257;2;18.25587364565609
R1:;11.5;R2:;200;11.146490203501005;461.4086123233741;41.39496863133205;1.433637501144446;2;17.54676842864638
\ No newline at end of file
...@@ -384,7 +384,7 @@ class OhmPi(object): ...@@ -384,7 +384,7 @@ class OhmPi(object):
factor = factor_I factor = factor_I
if factor_I > factor_vmn: if factor_I > factor_vmn:
factor = factor_vmn factor = factor_vmn
vab = factor * volt * 0.95 vab = factor * volt * 0.9
if vab > tx_max: if vab > tx_max:
vab = tx_max vab = tx_max
......
This source diff could not be displayed because it is too large. You can view the blob instead.
test_modif.py 0 → 100644
from 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=True)
k.settings['injection_duration'] = 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()
R1=11.5 #sol
R2=200 # contact
out = k.run_measurement(quad=[1, 2, 3, 4], nb_stack=2, tx_volt=2, strategy='vmax', autogain=True)
print(k.sequence)
data = out['fulldata']
inan = ~np.isnan(data[:,0])
print(['R1:',R1,' ','R2:',R2,' ', out['R [ohm]'],out['Vmn [mV]'],out['I [mA]'],out['Ps [mV]'],out['nbStack'],out['Tx [V]']])
f=open(r'data_goog.txt','a+')
f.write("\n")
f.write('R1:'+';'+ str(R1)+';'+'R2:'+';'+str(R2)+';'+ str(out['R [ohm]'])+';' + str(out['Vmn [mV]'])+';' + str(out['I [mA]'])+';'+ str(out['Ps [mV]'])+';'+ str(out['nbStack'])+';'+ str(out['Tx [V]']))
f.close()
k.append_and_save('out_test_qualite.csv', out)
# out = k.run_measurement(quad=[1, 2, 3, 4], nb_stack=2, tx_volt=2, strategy='vmin', autogain=True)
#
# data = out['fulldata']
# inan = ~np.isnan(data[:,0])
# print(out['R [ohm]'])
# k.append_and_save('out_test_qualite.csv', out)
#
# out = k.run_measurement(quad=[1, 2, 3, 4], nb_stack=2, tx_volt=5, strategy='constant', autogain=True)
#
# data = out['fulldata']
# inan = ~np.isnan(data[:,0])
# print(out['R [ohm]'])
# k.append_and_save('out_test_qualite.csv', out)
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()
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