Commit d068572f authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Improves test_ohmpi_card_3_15.py

Showing with 16 additions and 2 deletions
+16 -2
...@@ -257,7 +257,7 @@ class Rx(RxAbstract): ...@@ -257,7 +257,7 @@ class Rx(RxAbstract):
gain_0 = _gain_auto(AnalogIn(self._ads_voltage, ads.P0)) gain_0 = _gain_auto(AnalogIn(self._ads_voltage, ads.P0))
gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2)) gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2))
gain = np.min([gain_0, gain_2]) 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 self.adc_gain = gain
@property @property
......
...@@ -226,7 +226,7 @@ class Rx(RxAbstract): ...@@ -226,7 +226,7 @@ class Rx(RxAbstract):
gain_0 = _gain_auto(AnalogIn(self._ads_voltage, ads.P0)) gain_0 = _gain_auto(AnalogIn(self._ads_voltage, ads.P0))
gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2)) gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2))
gain = np.min([gain_0, gain_2]) 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 self.adc_gain = gain
@property @property
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
from OhmPi.hardware.ohmpi_card_3_15 import Tx from OhmPi.hardware.ohmpi_card_3_15 import Tx
from OhmPi.hardware.ohmpi_card_3_15 import Rx from OhmPi.hardware.ohmpi_card_3_15 import Rx
from OhmPi.logging_setup import create_stdout_logger from OhmPi.logging_setup import create_stdout_logger
import numpy as np
exec_logger = create_stdout_logger(name='exec') exec_logger = create_stdout_logger(name='exec')
soh_logger = create_stdout_logger(name='soh') soh_logger = create_stdout_logger(name='soh')
...@@ -14,3 +15,16 @@ rx = Rx(exec_logger= exec_logger, soh_logger= soh_logger) ...@@ -14,3 +15,16 @@ rx = Rx(exec_logger= exec_logger, soh_logger= soh_logger)
print(f'TX current: {tx.current:.3f} mA') print(f'TX current: {tx.current:.3f} mA')
print(f'RX voltage: {rx.voltage:.3f} mV') 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} %')
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