Commit a8bf3904 authored by Clement Remi's avatar Clement Remi
Browse files

Correction of the continuous mode, for a good measurement.

No related merge requests found
Showing with 14 additions and 7 deletions
+14 -7
...@@ -33,6 +33,7 @@ try: ...@@ -33,6 +33,7 @@ try:
import adafruit_tca9548a # noqa import adafruit_tca9548a # noqa
import adafruit_ads1x15.ads1115 as ads # noqa import adafruit_ads1x15.ads1115 as ads # noqa
from adafruit_ads1x15.analog_in import AnalogIn # noqa from adafruit_ads1x15.analog_in import AnalogIn # noqa
from adafruit_ads1x15.ads1x15 import Mode
from adafruit_mcp230xx.mcp23008 import MCP23008 # noqa from adafruit_mcp230xx.mcp23008 import MCP23008 # noqa
from adafruit_mcp230xx.mcp23017 import MCP23017 # noqa from adafruit_mcp230xx.mcp23017 import MCP23017 # noqa
import digitalio # noqa import digitalio # noqa
...@@ -886,11 +887,13 @@ class OhmPi(object): ...@@ -886,11 +887,13 @@ class OhmPi(object):
polarity = 1 polarity = 1
Rab = None Rab = None
# first reset the gain to 2/3 before trying to find best gain (mode 0 is continuous) # first reset the gain to 2/3 before trying to find best gain
self.ads_current = ads.ADS1115(self.i2c, gain=2 / 3, data_rate=860, self.ads_current = ads.ADS1115(self.i2c, gain=2 / 3, data_rate=860,
address=self.ads_current_address, mode=0) address=self.ads_current_address)
self.ads_current.mode= Mode.CONTINUOUS
self.ads_voltage = ads.ADS1115(self.i2c, gain=2 / 3, data_rate=860, self.ads_voltage = ads.ADS1115(self.i2c, gain=2 / 3, data_rate=860,
address=self.ads_voltage_address, mode=0) address=self.ads_voltage_address)
self.ads_voltage.mode= Mode.CONTINUOUS
# turn on the power supply # turn on the power supply
start_delay = None start_delay = None
end_delay = None end_delay = None
...@@ -907,7 +910,8 @@ class OhmPi(object): ...@@ -907,7 +910,8 @@ class OhmPi(object):
if not out_of_range: # we found a Vab in the range so we measure if not out_of_range: # we found a Vab in the range so we measure
gain = 2 / 3 gain = 2 / 3
self.ads_voltage = ads.ADS1115(self.i2c, gain=gain, data_rate=860, self.ads_voltage = ads.ADS1115(self.i2c, gain=gain, data_rate=860,
address=self.ads_voltage_address, mode=0) address=self.ads_voltage_address)
self.ads_voltage.mode= Mode.CONTINUOUS
if autogain: if autogain:
# compute autogain # compute autogain
gain_voltage = [] gain_voltage = []
...@@ -950,7 +954,8 @@ class OhmPi(object): ...@@ -950,7 +954,8 @@ class OhmPi(object):
self.exec_logger.debug(f'Gain current: {gain_current:.3f}, gain voltage: {gain_voltage[0]:.3f}, ' self.exec_logger.debug(f'Gain current: {gain_current:.3f}, gain voltage: {gain_voltage[0]:.3f}, '
f'{gain_voltage[1]:.3f}') f'{gain_voltage[1]:.3f}')
self.ads_current = ads.ADS1115(self.i2c, gain=gain_current, data_rate=860, self.ads_current = ads.ADS1115(self.i2c, gain=gain_current, data_rate=860,
address=self.ads_current_address, mode=0) address=self.ads_current_address)
self.ads_current.mode= Mode.CONTINUOUS
self.pin0.value = False self.pin0.value = False
self.pin1.value = False self.pin1.value = False
...@@ -977,13 +982,15 @@ class OhmPi(object): ...@@ -977,13 +982,15 @@ class OhmPi(object):
self.pin1.value = False self.pin1.value = False
if autogain: # select gain computed on first half cycle if autogain: # select gain computed on first half cycle
self.ads_voltage = ads.ADS1115(self.i2c, gain=np.min(gain_voltage), data_rate=860, self.ads_voltage = ads.ADS1115(self.i2c, gain=np.min(gain_voltage), data_rate=860,
address=self.ads_voltage_address, mode=0) address=self.ads_voltage_address)
self.ads_current.mode= Mode.CONTINUOUS
else: else:
self.pin0.value = False self.pin0.value = False
self.pin1.value = True # current injection nr2 self.pin1.value = True # current injection nr2
if autogain: # select gain computed on first half cycle if autogain: # select gain computed on first half cycle
self.ads_voltage = ads.ADS1115(self.i2c, gain=np.min(gain_voltage),data_rate=860, self.ads_voltage = ads.ADS1115(self.i2c, gain=np.min(gain_voltage),data_rate=860,
address=self.ads_voltage_address, mode=0) address=self.ads_voltage_address)
self.ads_current.mode= Mode.CONTINUOUS
self.exec_logger.debug(f'Stack {n} {self.pin0.value} {self.pin1.value}') self.exec_logger.debug(f'Stack {n} {self.pin0.value} {self.pin1.value}')
if self.board_version == 'mb.2023.0.0': if self.board_version == 'mb.2023.0.0':
self.pin6.value = True # IHM current injection led on self.pin6.value = True # IHM current injection led on
......
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