Commit 009d2209 authored by Forquet Nicolas's avatar Forquet Nicolas
Browse files

import à partir d'un fichier json (ohmpi_param.json) directement dans un dictionnaire

Showing with 28 additions and 20 deletions
+28 -20
import json
with open('ohmpi_param.json') as json_file:
pardict = json.load(json_file)
print(pardict.get("nb_electrodes"))
\ No newline at end of file
......@@ -17,6 +17,7 @@ import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import pandas as pd
import os.path
import json
"""
display start time
......@@ -25,23 +26,11 @@ current_time = datetime.now()
print(current_time.strftime("%Y-%m-%d %H:%M:%S"))
"""
measurement parameters
import parameters
"""
nb_electrodes = 32 # maximum number of electrodes on the resistivity meter
injection_duration = 0.5 # Current injection duration in second
nbr_meas= 1 # Number of times the quadripole sequence is repeated
sequence_delay= 30 # Delay in seconds between 2 sequences
stack= 1 # repetition of the current injection for each quadripole
"""
hardware parameters
"""
R_ref = 50 # reference resistance value in ohm
coef_p0 = 2.02 # slope for current conversion for ADS.P0, measurement in V/V
coef_p1 = 2.02 # slope for current conversion for ADS.P1, measurement in V/V
coef_p2 = 1 # slope for current conversion for ADS.P2, measurement in V/V
coef_p3 = 1 # slope for current conversion for ADS.P3, measurement in V/V
export_path = "~/measurement.csv"
with open('ohmpi_param.json') as json_file:
pardict = json.load(json_file)
"""
functions
......@@ -171,19 +160,19 @@ for i in pinList:
"""
Main loop
"""
N=read_quad("ABMN.txt",nb_electrodes) # load quadripole file
N=read_quad("ABMN.txt",pardict.get("nb_electrodes")) # load quadripole file
for g in range(0,nbr_meas): # for time-lapse monitoring
for g in range(0,pardict.get("nbr_meas")): # for time-lapse monitoring
for i in range(0,N.shape[0]): # loop over quadripoles
# call the switch_mux function to switch to the right electrodes
switch_mux(N[i,])
# run a measurement
current_measurement = run_measurement(stack, injection_duration, R_ref, coef_p0, coef_p1, N[i,])
current_measurement = run_measurement(pardict.get("stack"), pardict.get("injection_duration"), pardict.get("R_ref"), pardict.get("coef_p0"), pardict.get("coef_p1"), pardict.get("coef_p2"), pardict.get("coef_p3"), N[i,])
# save data and print in a text file
append_and_save(export_path, current_measurement)
append_and_save(pardict.get("export_path"), current_measurement)
# reset multiplexer channels
GPIO.output(12, GPIO.HIGH); GPIO.output(16, GPIO.HIGH); GPIO.output(20, GPIO.HIGH); GPIO.output(21, GPIO.HIGH); GPIO.output(26, GPIO.HIGH)
......@@ -191,4 +180,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(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)
\ No newline at end of file
time.sleep(pardict.get("sequence_delay")) #waiting next measurement (time-lapse)
\ No newline at end of file
{
"nb_electrodes": 32,
"injection_duration": 0.5,
"nbr_meas": 1,
"sequence_delay": 30,
"stack": 1,
"R_ref": 50,
"coef_p0": 2.02,
"coef_p1": 2.02,
"coef_p2": 1,
"coef_p3": 1,
"export_path": "~/measurement.csv"
}
\ 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