diff --git a/ohmpi/hardware_components/abstract_hardware_components.py b/ohmpi/hardware_components/abstract_hardware_components.py index 60999509e7b93dd1f91ac2f6e66cc44d3fd6537c..bb7d3ae82452a014738f58200a35080ce34fecc7 100644 --- a/ohmpi/hardware_components/abstract_hardware_components.py +++ b/ohmpi/hardware_components/abstract_hardware_components.py @@ -375,6 +375,8 @@ class TxAbstract(ABC): self.exec_logger.debug(f'Voltage pulse of {polarity * self.pwr.voltage:.3f} V for {length:.3f} s') self.inject(polarity=polarity, injection_duration=length) + def switch_pwr(self): + self.exec_logger.debug(f'Power source cannot be switched on or off on {self.model}') class RxAbstract(ABC): def __init__(self, **kwargs): diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py index 5ace4148597d7b9cd5deb324566abf894e7ff432..801b143ef19c0e404e195cdf2813589a3974790a 100644 --- a/ohmpi/hardware_components/mb_2024_0_2.py +++ b/ohmpi/hardware_components/mb_2024_0_2.py @@ -6,6 +6,7 @@ from adafruit_mcp230xx.mcp23008 import MCP23008 # noqa from digitalio import Direction # noqa from busio import I2C # noqa import os +import time from ohmpi.utils import enforce_specs from ohmpi.hardware_components.mb_2023_0_X import Tx as Tx_mb_2023 from ohmpi.hardware_components.mb_2023_0_X import Rx as Rx_mb_2023 @@ -82,6 +83,13 @@ class Tx(Tx_mb_2023): self.pin6 = self.mcp_board.get_pin(6) self.pin6.direction = Direction.OUTPUT self.pin6.value = False + self.pin2 = self.mcp_board.get_pin(2) # dsp - + self.pin2.direction = Direction.OUTPUT + self.pin2.value = False + self.pin3 = self.mcp_board.get_pin(3) # dsp - + self.pin3.direction = Direction.OUTPUT + self.pin3.value = False + if not subclass_init: self.exec_logger.event(f'{self.model}\ttx_init\tend\t{datetime.datetime.utcnow()}') @@ -91,6 +99,25 @@ class Tx(Tx_mb_2023): Tx_mb_2023.inject(self, polarity=polarity, injection_duration=injection_duration) self.pin6.value = False + def switch_pwr(self,state='off', latency=4.): + """Switches pwr on or off. + + Parameters + ---------- + state : str + 'on', 'off' + """ + if state == 'on': + self.pin2.value = True + self.pin3.value = True + self.exec_logger.debug(f'Switching DPS on') + time.sleep(latency) # from pwr specs + elif state == 'off': + self.pin2.value = False + self.pin3.value = False + self.exec_logger.debug(f'Switching DPS off') + + class Rx(Rx_mb_2023): def __init__(self, **kwargs): if 'model' not in kwargs.keys():