Commit 0ea5a1b9 authored by Forquet Nicolas's avatar Forquet Nicolas
Browse files

version testée sur l'ohmpi. Correction de bugs mineurs. Le code fonctionne et...

version testée sur l'ohmpi. Correction de bugs mineurs. Le code fonctionne et ferme les tickets #3 et #5
Showing with 15 additions and 16 deletions
+15 -16
...@@ -18,7 +18,7 @@ import sys ...@@ -18,7 +18,7 @@ import sys
import adafruit_ads1x15.ads1115 as ADS import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn from adafruit_ads1x15.analog_in import AnalogIn
import pandas as pd import pandas as pd
from pathlib import Path import os.path
""" """
display start time display start time
...@@ -30,14 +30,14 @@ print(current_time.strftime("%Y-%m-%d %H:%M:%S")) ...@@ -30,14 +30,14 @@ print(current_time.strftime("%Y-%m-%d %H:%M:%S"))
parameters parameters
""" """
nb_electrodes = 32 # maximum number of electrodes on the resistivity meter nb_electrodes = 32 # maximum number of electrodes on the resistivity meter
injection_duration = 5 # Current injection duration in second injection_duration = 0.5 # Current injection duration in second
nbr_meas= 900 # Number of times the quadripole sequence is repeated nbr_meas= 1 # Number of times the quadripole sequence is repeated
sequence_delay= 30 # Delay in seconds between 2 sequences sequence_delay= 30 # Delay in seconds between 2 sequences
stack= 1 # repetition of the current injection for each quadripole stack= 1 # repetition of the current injection for each quadripole
R_ref = 50 # reference resistance value in ohm R_ref = 50 # reference resistance value in ohm
coef_p0 = 2.02 # slope for current conversion for ADS.P0, measurement in ??? coef_p0 = 2.02 # slope for current conversion for ADS.P0, measurement in ???
coef_p1 = 2.02 # slope for current conversion for ADS.P1, measurement in ??? coef_p1 = 2.02 # slope for current conversion for ADS.P1, measurement in ???
export_path = "/home/..." export_path = "/home/pi/Desktop/ohmpy-develop/measurement.csv"
""" """
functions functions
...@@ -94,7 +94,7 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1): ...@@ -94,7 +94,7 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1):
GPIO.setup(7, GPIO.OUT) GPIO.setup(7, GPIO.OUT)
GPIO.setup(8, GPIO.OUT) GPIO.setup(8, GPIO.OUT)
# resistance measurement # resistance measurement
for n in range(0,3+2*nbr_stack-1) : for n in range(0,3+2*nb_stack-1) :
print("stack "+ str(n+1)) print("stack "+ str(n+1))
if (n % 2) == 0: if (n % 2) == 0:
GPIO.output(7, GPIO.HIGH) # polarité n°1 GPIO.output(7, GPIO.HIGH) # polarité n°1
...@@ -104,8 +104,8 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1): ...@@ -104,8 +104,8 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1):
print('negatif') print('negatif')
GPIO.output(8, GPIO.HIGH) # current injection GPIO.output(8, GPIO.HIGH) # current injection
time.sleep(injection_deltat) # delay depending on current injection duration time.sleep(injection_deltat) # delay depending on current injection duration
Ia1 = AnalogIn(ads,ADS.P0).voltage * coeffp0 # reading current value on ADS channel A0 Ia1 = AnalogIn(ads,ADS.P0).voltage * coefp0 # reading current value on ADS channel A0
Ib1 = AnalogIn(ads,ADS.P1).voltage * coeffp1 # reading current value on ADS channel A1 Ib1 = AnalogIn(ads,ADS.P1).voltage * coefp1 # reading current value on ADS channel A1
Vm1 = AnalogIn(ads,ADS.P2).voltage # reading voltage value on ADS channel A2 Vm1 = AnalogIn(ads,ADS.P2).voltage # reading voltage value on ADS channel A2
Vn1 = AnalogIn(ads,ADS.P3).voltage # reading voltage value on ADS channel A3 Vn1 = AnalogIn(ads,ADS.P3).voltage # reading voltage value on ADS channel A3
GPIO.output(8, GPIO.LOW)# stop current injection GPIO.output(8, GPIO.LOW)# stop current injection
...@@ -120,19 +120,19 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1): ...@@ -120,19 +120,19 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1):
sum_Ps=sum_Ps+Vmn1 sum_Ps=sum_Ps+Vmn1
# return averaged values # return averaged values
output = pd.DataFrame({ output = pd.DataFrame({
"time":datetime.now() "time":[datetime.now()],
"Vmn":sum_Vmn/(3+2*nb_stack-1), "Vmn":[sum_Vmn/(3+2*nb_stack-1)],
"I":sum_I/(3+2*nb_stack-1), "I":[sum_I/(3+2*nb_stack-1)],
"R":Vmn/I, "R":[sum_Vmn/(3+2*nb_stack-1)/(sum_I/(3+2*nb_stack-1))],
"Ps":sum_Ps/(3+2*nb_stack-1) "Ps":[sum_Ps/(3+2*nb_stack-1)],
"nbStack":nb_stack "nbStack":[nb_stack]
}) })
return output return output
# save data # save data
def append_and_save(path, last_measurement): def append_and_save(path, last_measurement):
if path.is_file(): if os.path.isfile(path):
# Load data file and append data to it # Load data file and append data to it
with open(path, 'a') as f: with open(path, 'a') as f:
last_measurement.to_csv(f, header=False) last_measurement.to_csv(f, header=False)
...@@ -178,5 +178,4 @@ for g in range(0,nbr_meas): # for time-lapse monitoring ...@@ -178,5 +178,4 @@ for g in range(0,nbr_meas): # for time-lapse monitoring
GPIO.output(6, GPIO.HIGH); GPIO.output(13, GPIO.HIGH); GPIO.output(4, GPIO.HIGH); GPIO.output(17, GPIO.HIGH); GPIO.output(27, GPIO.HIGH) GPIO.output(6, GPIO.HIGH); GPIO.output(13, GPIO.HIGH); GPIO.output(4, GPIO.HIGH); GPIO.output(17, GPIO.HIGH); GPIO.output(27, GPIO.HIGH)
GPIO.output(22, GPIO.HIGH); GPIO.output(10, GPIO.HIGH); GPIO.output(9, GPIO.HIGH); GPIO.output(11, GPIO.HIGH); GPIO.output(5, GPIO.HIGH) GPIO.output(22, GPIO.HIGH); GPIO.output(10, GPIO.HIGH); GPIO.output(9, GPIO.HIGH); GPIO.output(11, GPIO.HIGH); GPIO.output(5, GPIO.HIGH)
time.sleep(sequence_delay) #waiting next measurement (time-lapse) time.sleep(sequence_delay) #waiting next measurement (time-lapse)
\ No newline at end of file
\ No newline at end of file
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