From d068572fa975ac87f2d8339dd0c112558af63d81 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Sat, 15 Apr 2023 13:56:04 +0200
Subject: [PATCH] Improves test_ohmpi_card_3_15.py

---
 hardware/mb_2024_rev_0_0.py |  2 +-
 hardware/ohmpi_card_3_15.py |  2 +-
 test_ohmpi_card_3_15.py     | 14 ++++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/hardware/mb_2024_rev_0_0.py b/hardware/mb_2024_rev_0_0.py
index 4493a3f3..2b382d41 100644
--- a/hardware/mb_2024_rev_0_0.py
+++ b/hardware/mb_2024_rev_0_0.py
@@ -257,7 +257,7 @@ class Rx(RxAbstract):
         gain_0 = _gain_auto(AnalogIn(self._ads_voltage, ads.P0))
         gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2))
         gain = np.min([gain_0, gain_2])
-        self.exec_logger.debug(f'Setting TX ADC gain automatically to {gain}')
+        self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}')
         self.adc_gain = gain
 
     @property
diff --git a/hardware/ohmpi_card_3_15.py b/hardware/ohmpi_card_3_15.py
index 5ac3c287..2d82b8ac 100644
--- a/hardware/ohmpi_card_3_15.py
+++ b/hardware/ohmpi_card_3_15.py
@@ -226,7 +226,7 @@ class Rx(RxAbstract):
         gain_0 = _gain_auto(AnalogIn(self._ads_voltage, ads.P0))
         gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2))
         gain = np.min([gain_0, gain_2])
-        self.exec_logger.debug(f'Setting TX ADC gain automatically to {gain}')
+        self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}')
         self.adc_gain = gain
 
     @property
diff --git a/test_ohmpi_card_3_15.py b/test_ohmpi_card_3_15.py
index 7c8a3978..bbceaad4 100644
--- a/test_ohmpi_card_3_15.py
+++ b/test_ohmpi_card_3_15.py
@@ -3,6 +3,7 @@
 from OhmPi.hardware.ohmpi_card_3_15 import Tx
 from OhmPi.hardware.ohmpi_card_3_15 import Rx
 from OhmPi.logging_setup import create_stdout_logger
+import numpy as np
 
 exec_logger = create_stdout_logger(name='exec')
 soh_logger = create_stdout_logger(name='soh')
@@ -14,3 +15,16 @@ rx = Rx(exec_logger= exec_logger, soh_logger= soh_logger)
 
 print(f'TX current: {tx.current:.3f} mA')
 print(f'RX voltage: {rx.voltage:.3f} mV')
+
+tx.polarity = 1
+tx.inject(state='on')
+tx.adc_gain_auto()
+rx.adc_gain_auto()
+r = []
+for i in range(30):
+    r.append(rx.voltage/tx.current)
+    print(f'Resistance: {r[-1]:.3f}')
+r = np.array(r)
+print(f'Mean resistance: {np.mean(r):.3f} Ohms')
+print(f'Resistance std: {np.std(r):.3f} Ohms')
+print(f'Dev. {100. * np.std(r)/np.mean(r):.1} %')
-- 
GitLab