diff --git a/11-development-file.py b/11-development-file.py new file mode 100644 index 0000000000000000000000000000000000000000..42bf496bd4ae1660a695090c8d7b29d337fbadfc --- /dev/null +++ b/11-development-file.py @@ -0,0 +1,6 @@ +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 diff --git a/ohmpi.py b/ohmpi.py index f485b66570597b2e7bbbb3a78f044265cb75ba04..109d897a3462fed5b63b9e975a904901fec54981 100644 --- a/ohmpi.py +++ b/ohmpi.py @@ -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 diff --git a/ohmpi_param.json b/ohmpi_param.json new file mode 100644 index 0000000000000000000000000000000000000000..32eb1907bb31c3fbbb71954c66b0611b2b9ac011 --- /dev/null +++ b/ohmpi_param.json @@ -0,0 +1,13 @@ +{ + "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