Commit 510430bc authored by remi.clement@inrae.fr's avatar remi.clement@inrae.fr
Browse files

fix rs_check with dph5005

Showing with 303 additions and 166 deletions
+303 -166
......@@ -3,8 +3,8 @@ from paho.mqtt.client import MQTTv31
# OhmPi configuration
OHMPI_CONFIG = {
'id': '0001', # Unique identifier of the OhmPi board (string)
'R_shunt': 2, # Shunt resistance in Ohms
'Imax': 4800/50/2, # Maximum current
'R_shunt': 1, # Shunt resistance in Ohms
'Imax': 4800/50/1, # Maximum current
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'coef_p3': 2.50, # slope for current conversion for ADS.P3, measurement in V/V
'offset_p2': 0,
......@@ -12,7 +12,7 @@ OHMPI_CONFIG = {
'integer': 2, # Max value 10 # TODO: Explain what this is...
'version': 2,
'max_elec': 64,
'board_address': {'A': 0x70, 'B': 0x71, 'M': 0x72, 'N': 0x73} # def. {'A': 0x76, 'B': 0x71, 'M': 0x74, 'N': 0x70}
'board_address': {'A': 0x72, 'B': 0x73, 'M': 0x70, 'N': 0x71} # def. {'A': 0x76, 'B': 0x71, 'M': 0x74, 'N': 0x70}
#'board_address': {'A': 0x76, 'B': 0x71, 'M': 0x74, 'N': 0x70} # def. {'A': 0x76, 'B': 0x71, 'M': 0x74, 'N': 0x70}
}
......@@ -80,4 +80,4 @@ MQTT_CONTROL_CONFIG = {
'transport': 'tcp',
'client_id': f'ohmpi_sn_{OHMPI_CONFIG["id"]}',
'cmd_topic': f'cmd_ohmpi_sn_{OHMPI_CONFIG["id"]}'
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -2,23 +2,64 @@ from ohmpi import OhmPi
import matplotlib.pyplot as plt
import numpy as np
k = OhmPi(idps=True)
k.rs_check()
a = np.arange(13) + 1
b = a + 3
m = a + 1
n = a + 2
seq = np.c_[a, b, m, n]
x = []
for i in range(1):
out = k.run_measurement(injection_duration=0.5, nb_stack=1, tx_volt=0, autogain=True, best_tx_injtime=0.2)
x.append(out['R [ohm]'])
k = OhmPi(idps=True)
k.pardict['injection_duration'] = 0.5
k.pardict['nb_stack'] = 1
k.pardict['tx_volt'] = 0
k.pardict['nbr_meas'] = 1
#k.sequence = seq
#k.reset_mux()
#k.switch_mux_on([4, 7, 5, 6])
#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(5):
out = k.run_measurement(injection_duration=0.5, nb_stack=5, strategy='vmin', tx_volt=5, autogain=True)
#x.append(out['R [ohm]'])
k.append_and_save('out.csv', out)
data = out['fulldata']
inan = ~np.isnan(data[:,0])
if True:
plt.plot(data[inan,2], data[inan,0], '.-', label='current [mA]')
plt.plot(data[inan,2], data[inan,1], '.-', label='voltage [mV]')
plt.legend()
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:
......
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
fnames = sorted(os.listdir('data'))
df = pd.read_csv('out.csv', engine='python')
df
ct = df.columns[df.columns.str.match('t\d+')]
ci = df.columns[df.columns.str.match('i\d+')]
cu = df.columns[df.columns.str.match('u\d+')]
fig, axs = plt.subplots(2, 1, sharex=True)
for i in range(df.shape[0]):
print(i)
data = np.c_[df.loc[i, ct], df.loc[i, ci], df.loc[i, cu]].astype(float)
inan = ~(np.isnan(data).any(1))
label = ', '.join(df.loc[i, ['A', 'B', 'M', 'N']].astype(str).to_list())
ax = axs[0]
ax.plot(data[inan,0], data[inan,1], '.-', label=label)
ax.set_ylabel('Current AB [mA]')
ax.legend()
ax = axs[1]
ax.plot(data[inan,0], data[inan,2], '.-', label=label)
ax.set_ylabel('Voltage MN [mV]')
ax.set_xlabel('Time [s]')
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