Skip to content

interface.py

test_plans.fixtur-ctrl-func-test.hardware_utils.interface

Interface Module for the FixturCtrl Functional Test Fixture

logger = logging.getLogger(__name__) module-attribute

get_fixture_config

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
16
17
18
19
20
21
def get_fixture_config(slot_id="DEV", config_file="config.yml"):
    config_obj = get_config_from_file(
        f3ts_config=config_file,
        slot_id=slot_id,
    )
    return config_obj.fixture_settings

get_test_fixture

return the test fixture

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
24
25
26
def get_test_fixture(fixture_config):
    """return the test fixture"""
    return FixtureInterface(fixture_config)

Delays

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
29
30
31
32
33
34
35
36
class Delays:
    def __init__(self, config):
        """Initialize delays from custom fixture configuration settings"""
        self.CMD = float(config.user_vars["CMD_DELAY"])
        self.PWR = float(config.user_vars["PWR_DELAY"])
        self.USB_LOAD = float(config.user_vars["USB_LOAD_DELAY"])
        self.USB_SERIAL = float(config.user_vars["USB_SERIAL_DELAY"])
        self.BOOT = float(config.user_vars["BOOT_TIMEOUT"])

__init__

Initialize delays from custom fixture configuration settings

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
30
31
32
33
34
35
36
def __init__(self, config):
    """Initialize delays from custom fixture configuration settings"""
    self.CMD = float(config.user_vars["CMD_DELAY"])
    self.PWR = float(config.user_vars["PWR_DELAY"])
    self.USB_LOAD = float(config.user_vars["USB_LOAD_DELAY"])
    self.USB_SERIAL = float(config.user_vars["USB_SERIAL_DELAY"])
    self.BOOT = float(config.user_vars["BOOT_TIMEOUT"])

CMD = float(config.user_vars['CMD_DELAY']) instance-attribute

PWR = float(config.user_vars['PWR_DELAY']) instance-attribute

USB_LOAD = float(config.user_vars['USB_LOAD_DELAY']) instance-attribute

USB_SERIAL = float(config.user_vars['USB_SERIAL_DELAY']) instance-attribute

BOOT = float(config.user_vars['BOOT_TIMEOUT']) instance-attribute

ArduinoCLI

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class ArduinoCLI:
    def __init__(self, port="/dev/ACM0"):
        self.port = port

    def compile(
        self,
        sketch_dir: str = "dependencies/fixturfab-fixture-controller",
        sketch: str = "fixturfab-fixture-controller.ino",
        fqbn: str = "rp2040:rp2040:rpipico",
    ) -> str:
        """Compile the Arduino Sketch

        Compile arduino sketch from arduino's CLI and return command output

        Parameters:
            sketch_dir: current working directory with sketch to compile
            sketch: name of sketch
            fqbn: full qualified board name (ex/ arduino:avr:nano)

        Returns:
            command output of compile command
        """
        command = ["arduino-cli", "compile", sketch, "--fqbn", fqbn]
        print(command)

        output = subprocess.check_output(command, cwd=sketch_dir).decode("utf-8")
        print(output)
        return output

    def upload(
        self,
        sketch_dir: str = "dependencies/fixturfab-fixture-controller",
        sketch: str = "fixturfab-fixture-controller.ino",
        fqbn: str = "rp2040:rp2040:rpipico",
    ) -> str:
        """Compile the Arduino Sketch

        Compile arduino sketch from arduino's CLI and return command output

        Parameters:
            sketch_dir: current working directory with sketch to compile
            sketch: name of sketch
            fqbn: full qualified board name (ex/ arduino:avr:nano)

        Returns:
            command output of compile command
        """
        command = ["arduino-cli", "upload", sketch, "-p", self.port, "--fqbn", fqbn]
        print(command)

        output = subprocess.check_output(command, cwd=sketch_dir).decode("utf-8")
        print(output)
        return output

__init__

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
40
41
def __init__(self, port="/dev/ACM0"):
    self.port = port

port = port instance-attribute

compile

Compile the Arduino Sketch

Compile arduino sketch from arduino's CLI and return command output

Parameters: sketch_dir: current working directory with sketch to compile sketch: name of sketch fqbn: full qualified board name (ex/ arduino:avr:nano)

Returns: command output of compile command

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def compile(
    self,
    sketch_dir: str = "dependencies/fixturfab-fixture-controller",
    sketch: str = "fixturfab-fixture-controller.ino",
    fqbn: str = "rp2040:rp2040:rpipico",
) -> str:
    """Compile the Arduino Sketch

    Compile arduino sketch from arduino's CLI and return command output

    Parameters:
        sketch_dir: current working directory with sketch to compile
        sketch: name of sketch
        fqbn: full qualified board name (ex/ arduino:avr:nano)

    Returns:
        command output of compile command
    """
    command = ["arduino-cli", "compile", sketch, "--fqbn", fqbn]
    print(command)

    output = subprocess.check_output(command, cwd=sketch_dir).decode("utf-8")
    print(output)
    return output

upload

Compile the Arduino Sketch

Compile arduino sketch from arduino's CLI and return command output

Parameters: sketch_dir: current working directory with sketch to compile sketch: name of sketch fqbn: full qualified board name (ex/ arduino:avr:nano)

Returns: command output of compile command

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def upload(
    self,
    sketch_dir: str = "dependencies/fixturfab-fixture-controller",
    sketch: str = "fixturfab-fixture-controller.ino",
    fqbn: str = "rp2040:rp2040:rpipico",
) -> str:
    """Compile the Arduino Sketch

    Compile arduino sketch from arduino's CLI and return command output

    Parameters:
        sketch_dir: current working directory with sketch to compile
        sketch: name of sketch
        fqbn: full qualified board name (ex/ arduino:avr:nano)

    Returns:
        command output of compile command
    """
    command = ["arduino-cli", "upload", sketch, "-p", self.port, "--fqbn", fqbn]
    print(command)

    output = subprocess.check_output(command, cwd=sketch_dir).decode("utf-8")
    print(output)
    return output

FixtureInterface

Bases: object

Interface to the FixturCtrl Test Fixture.

This class provides an interface to the FixturCtrl Test Fixture. It is responsible for communicating with the instrumentation, DUT, and hardware used within the FixturCtrl Functional Test Fixture.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
class FixtureInterface(object):
    """Interface to the FixturCtrl Test Fixture.

    This class provides an interface to the FixturCtrl Test Fixture. It is
    responsible for communicating with the instrumentation, DUT, and hardware
    used within the FixturCtrl Functional Test Fixture.
    """

    # MTM-USBStem Digital IO
    A_SELECT0 = 0
    A_SELECT1 = 1
    A_SELECT2 = 2
    A_SELECT3 = 3
    POWER_SEL = 4
    EN_12V = 5
    EN_5V = 6
    RP_BOOT = 7
    RP_RUN = 8
    EN_LED1 = 9
    EN_LED2 = 10
    IND_SW_EN = 11

    # MTM-USBStem Analog IO
    MUX = 0
    I_VOUT = 1
    I_VREF = 2

    # Analog MUX IO
    ADC_CONT_TEST = 0
    ADC_DUT_5V = 1
    ADC_DUT_3V3 = 2
    ADC_DUT_1V1 = 3
    ADC_LED1_R = 4
    ADC_LED1_G = 5
    ADC_LED1_B = 6
    ADC_LED2_R = 7
    ADC_LED2_G = 8
    ADC_LED2_B = 9
    ADC_USB_LOAD1 = 10
    ADC_USB_LOAD2 = 11
    ADC_USB_LOAD3 = 12
    ADC_USB_LOAD4 = 13
    ADC_USB_LOAD5 = 14
    ADC_USB_LOAD6 = 15

    # IO Expander Digital IO
    USB1_SERIAL_EN = 0
    USB1_LOAD_EN = 1
    USB2_SERIAL_EN = 2
    USB2_LOAD_EN = 3
    USB3_SERIAL_EN = 4
    USB3_LOAD_EN = 5
    USB4_SERIAL_EN = 6
    USB4_LOAD_EN = 7
    USB5_SERIAL_EN = 10
    USB5_LOAD_EN = 11
    USB6_SERIAL_EN = 12
    USB6_LOAD_EN = 13

    def __init__(self, fixture_config):
        """Initializes the TestInterface.

        Opens connections to all hardware and instruments used in the test
        fixture.

        The configuration for the test fixture is passed in as a
        dictionary and provides the necessary information to establish
        connections to the hardware and instruments.
        """
        self.config = fixture_config
        self.serial_port = None
        self.arduino_cli = ArduinoCLI(port=self.serial_port)

        logger.info("Initializing test fixture")
        logger.info("-> connecting to MTM-USBStem")
        self.usb_stem = brainstem.stem.MTMUSBStem()
        try:
            mtm_exec(self.usb_stem.discoverAndConnect, brainstem.link.Spec.USB)
            self._init_usb_stem()
        except Exception as error:
            logger.error(f"Error connecting to MTM-USBStem: {error}")
            raise error

        logger.info("-> connecting to TCA9555 IO Expander")
        try:
            self.io_expander = TCA9555(self.usb_stem.i2c[1], address=0x42)
            self._init_io_expander()
        except Exception as error:
            logger.error(f"Error connecting to MTM-USBStem: {error}")
            raise error

    def _init_usb_stem(self):
        """Initializes the MTM-USBStem IO."""
        mtm_exec(self.usb_stem.i2c[1].setSpeed, self.usb_stem.i2c[1].I2C_SPEED_100Khz)

        # Configure digital outputs
        for pin in range(12):
            mtm_exec(
                self.usb_stem.digital[pin].setConfiguration,
                self.usb_stem.digital[pin].CONFIGURATION_OUTPUT,
            )
            mtm_exec(self.usb_stem.digital[pin].setState, False)

        mtm_exec(
            self.usb_stem.digital[self.RP_BOOT].setConfiguration,
            self.usb_stem.digital[self.RP_BOOT].CONFIGURATION_HIGHZ,
        )
        mtm_exec(
            self.usb_stem.digital[self.RP_RUN].setConfiguration,
            self.usb_stem.digital[self.RP_RUN].CONFIGURATION_HIGHZ,
        )
        # mtm_exec(self.usb_stem.digital[self.RP_BOOT].setState, True)
        # mtm_exec(self.usb_stem.digital[self.RP_RUN].setState, True)

    def _init_io_expander(self):
        pins = list(range(16))
        self.io_expander.set_direction(self.io_expander.OUTPUT, bits=pins)
        self.io_expander.set_polarity(self.io_expander.DEFAULT, bits=pins)
        self.io_expander.set_level(False, bits=pins)

    def pwr_select(self, state: bool):
        """Set the power select state.

        Connects/disconnects the continuity test and power supply to the DUT.
        Setting state to True connects the DUT to the power supply.
        Setting state to False connects the DUT to the continuity test.

        Parameters:
            state: The state to set the power select to.
        """
        mtm_exec(self.usb_stem.digital[self.POWER_SEL].setState, state)

    def en_12v(self, state: bool):
        """Set the 12V enable state.

        Enables/disables the 12V supply to the DUT.

        Parameters:
            state: The state to set the 12V enable to.
        """
        mtm_exec(self.usb_stem.digital[self.EN_12V].setState, state)

    def en_5v(self, state: bool):
        """Set the 5V enable state.

        Enables/disables the 5V supply to the DUT.

        Parameters:
            state: The state to set the 5V enable to.
        """
        mtm_exec(self.usb_stem.digital[self.EN_5V].setState, state)

    def en_usb_serial(self, state: bool, usb: int):
        """Enables power to USB serial device

        Enables/disables power to the test USB serial device
        for USB Hub enumeration

        Parameters:
            state: True when power on, False when power off
            usb: USB device to switch on/off
        """
        if 1 <= usb <= 6:
            pins = [(usb - 1) * 2]
            self.io_expander.set_level(state, bits=pins)

        else:
            raise ValueError(f"No USB exists at index {usb}")

    def en_usb_load(self, state: bool, usb: int):
        """Enables power to USB load test

        Enables/disables USB load to test the USB serial device
        for USB Hub power draw

        Parameters:
            state: True when power on, False when power off
            usb: USB device to switch on/off
        """

        if 1 <= usb <= 6:
            pins = [(usb - 1) * 2 + 1]
            self.io_expander.set_level(state, bits=pins)

        else:
            raise ValueError(f"No USB exists at index {usb}")

    def bootsel(self):
        mtm_exec(
            self.usb_stem.digital[self.RP_BOOT].setConfiguration,
            self.usb_stem.digital[self.RP_BOOT].CONFIGURATION_OUTPUT,
        )
        mtm_exec(self.usb_stem.digital[self.RP_BOOT].setState, False)
        time.sleep(0.5)
        mtm_exec(
            self.usb_stem.digital[self.RP_RUN].setConfiguration,
            self.usb_stem.digital[self.RP_RUN].CONFIGURATION_OUTPUT,
        )
        mtm_exec(self.usb_stem.digital[self.RP_RUN].setState, False)
        time.sleep(0.5)
        mtm_exec(self.usb_stem.digital[self.RP_RUN].setState, True)
        mtm_exec(
            self.usb_stem.digital[self.RP_RUN].setConfiguration,
            self.usb_stem.digital[self.RP_RUN].CONFIGURATION_HIGHZ,
        )
        time.sleep(0.5)
        mtm_exec(self.usb_stem.digital[self.RP_BOOT].setState, True)
        mtm_exec(
            self.usb_stem.digital[self.RP_BOOT].setConfiguration,
            self.usb_stem.digital[self.RP_BOOT].CONFIGURATION_HIGHZ,
        )

    def inductive_sw(self, state: bool):
        """Set the inductive switch state.

        Parameters:
            state: The state to set the inductive switch to.
        """
        mtm_exec(self.usb_stem.digital[self.IND_SW_EN].setState, state)

    def get_mux_reading(self, channel: int, scalar: int = 1) -> float:
        """Get the MUX reading for the specified channel.

        Parameters:
            channel: The MUX channel to read.
            scalar: (Optional) Voltage scaling multiplier to add

        Returns:
            The MUX reading.
        """
        mtm_exec(self.usb_stem.digital[self.A_SELECT0].setState, channel & 0x01)
        mtm_exec(self.usb_stem.digital[self.A_SELECT1].setState, channel & 0x02)
        mtm_exec(self.usb_stem.digital[self.A_SELECT2].setState, channel & 0x04)
        mtm_exec(self.usb_stem.digital[self.A_SELECT3].setState, channel & 0x08)

        return get_voltage(self.usb_stem.analog[self.MUX], scalar=scalar)

    def get_continuity_reading(self) -> float:
        """Get the continuity test reading.

        Returns:
            The continuity test reading.
        """
        return self.get_mux_reading(self.ADC_CONT_TEST)

    def get_dut_5v0_reading(self) -> float:
        """Get the DUT 5V reading.

        Return the DUT 5V reading from the analog MUX. This voltage is read via
        a voltage divider and is corrected by a scalar value of 2.

        Returns:
            The DUT 5V reading.
        """
        return self.get_mux_reading(self.ADC_DUT_5V, scalar=2)

    def get_dut_3v3_reading(self) -> float:
        """Get the DUT 3.3V reading.

        Measure the DUT 3.3V voltage from the analog MUX. This voltage is read
        via a voltage divider and is corrected by a scalar value of 2.

        Returns:
            The DUT 3.3V reading.
        """
        return self.get_mux_reading(self.ADC_DUT_3V3, scalar=2)

    def get_dut_1v1_reading(self) -> float:
        """Get the DUT 1.1V reading.

        Returns:
            The DUT 1.1V reading.
        """
        return self.get_mux_reading(self.ADC_DUT_1V1)

    def close(self):
        """Closes all connections to the test fixture."""
        logger.info("Closing test fixture connections")
        logger.info("-> disconnecting power from DUT")
        self.en_5v(False)
        self.en_12v(False)
        self.pwr_select(False)

        logger.info("-> reset io expander pins to inputs")
        pins = list(range(16))
        self.io_expander.set_level(False, bits=pins)
        self.io_expander.set_direction(self.io_expander.INPUT, bits=pins)

        logger.info("-> disconnecting from MTM-USBStem")
        self.usb_stem.disconnect()

A_SELECT0 = 0 class-attribute instance-attribute

A_SELECT1 = 1 class-attribute instance-attribute

A_SELECT2 = 2 class-attribute instance-attribute

A_SELECT3 = 3 class-attribute instance-attribute

POWER_SEL = 4 class-attribute instance-attribute

EN_12V = 5 class-attribute instance-attribute

EN_5V = 6 class-attribute instance-attribute

RP_BOOT = 7 class-attribute instance-attribute

RP_RUN = 8 class-attribute instance-attribute

EN_LED1 = 9 class-attribute instance-attribute

EN_LED2 = 10 class-attribute instance-attribute

IND_SW_EN = 11 class-attribute instance-attribute

MUX = 0 class-attribute instance-attribute

I_VOUT = 1 class-attribute instance-attribute

I_VREF = 2 class-attribute instance-attribute

ADC_CONT_TEST = 0 class-attribute instance-attribute

ADC_DUT_5V = 1 class-attribute instance-attribute

ADC_DUT_3V3 = 2 class-attribute instance-attribute

ADC_DUT_1V1 = 3 class-attribute instance-attribute

ADC_LED1_R = 4 class-attribute instance-attribute

ADC_LED1_G = 5 class-attribute instance-attribute

ADC_LED1_B = 6 class-attribute instance-attribute

ADC_LED2_R = 7 class-attribute instance-attribute

ADC_LED2_G = 8 class-attribute instance-attribute

ADC_LED2_B = 9 class-attribute instance-attribute

ADC_USB_LOAD1 = 10 class-attribute instance-attribute

ADC_USB_LOAD2 = 11 class-attribute instance-attribute

ADC_USB_LOAD3 = 12 class-attribute instance-attribute

ADC_USB_LOAD4 = 13 class-attribute instance-attribute

ADC_USB_LOAD5 = 14 class-attribute instance-attribute

ADC_USB_LOAD6 = 15 class-attribute instance-attribute

USB1_SERIAL_EN = 0 class-attribute instance-attribute

USB1_LOAD_EN = 1 class-attribute instance-attribute

USB2_SERIAL_EN = 2 class-attribute instance-attribute

USB2_LOAD_EN = 3 class-attribute instance-attribute

USB3_SERIAL_EN = 4 class-attribute instance-attribute

USB3_LOAD_EN = 5 class-attribute instance-attribute

USB4_SERIAL_EN = 6 class-attribute instance-attribute

USB4_LOAD_EN = 7 class-attribute instance-attribute

USB5_SERIAL_EN = 10 class-attribute instance-attribute

USB5_LOAD_EN = 11 class-attribute instance-attribute

USB6_SERIAL_EN = 12 class-attribute instance-attribute

USB6_LOAD_EN = 13 class-attribute instance-attribute

__init__

Initializes the TestInterface.

Opens connections to all hardware and instruments used in the test fixture.

The configuration for the test fixture is passed in as a dictionary and provides the necessary information to establish connections to the hardware and instruments.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
def __init__(self, fixture_config):
    """Initializes the TestInterface.

    Opens connections to all hardware and instruments used in the test
    fixture.

    The configuration for the test fixture is passed in as a
    dictionary and provides the necessary information to establish
    connections to the hardware and instruments.
    """
    self.config = fixture_config
    self.serial_port = None
    self.arduino_cli = ArduinoCLI(port=self.serial_port)

    logger.info("Initializing test fixture")
    logger.info("-> connecting to MTM-USBStem")
    self.usb_stem = brainstem.stem.MTMUSBStem()
    try:
        mtm_exec(self.usb_stem.discoverAndConnect, brainstem.link.Spec.USB)
        self._init_usb_stem()
    except Exception as error:
        logger.error(f"Error connecting to MTM-USBStem: {error}")
        raise error

    logger.info("-> connecting to TCA9555 IO Expander")
    try:
        self.io_expander = TCA9555(self.usb_stem.i2c[1], address=0x42)
        self._init_io_expander()
    except Exception as error:
        logger.error(f"Error connecting to MTM-USBStem: {error}")
        raise error

config = fixture_config instance-attribute

serial_port = None instance-attribute

arduino_cli = ArduinoCLI(port=self.serial_port) instance-attribute

usb_stem = brainstem.stem.MTMUSBStem() instance-attribute

io_expander = TCA9555(self.usb_stem.i2c[1], address=66) instance-attribute

pwr_select

Set the power select state.

Connects/disconnects the continuity test and power supply to the DUT. Setting state to True connects the DUT to the power supply. Setting state to False connects the DUT to the continuity test.

Parameters: state: The state to set the power select to.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
214
215
216
217
218
219
220
221
222
223
224
def pwr_select(self, state: bool):
    """Set the power select state.

    Connects/disconnects the continuity test and power supply to the DUT.
    Setting state to True connects the DUT to the power supply.
    Setting state to False connects the DUT to the continuity test.

    Parameters:
        state: The state to set the power select to.
    """
    mtm_exec(self.usb_stem.digital[self.POWER_SEL].setState, state)

en_12v

Set the 12V enable state.

Enables/disables the 12V supply to the DUT.

Parameters: state: The state to set the 12V enable to.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
226
227
228
229
230
231
232
233
234
def en_12v(self, state: bool):
    """Set the 12V enable state.

    Enables/disables the 12V supply to the DUT.

    Parameters:
        state: The state to set the 12V enable to.
    """
    mtm_exec(self.usb_stem.digital[self.EN_12V].setState, state)

en_5v

Set the 5V enable state.

Enables/disables the 5V supply to the DUT.

Parameters: state: The state to set the 5V enable to.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
236
237
238
239
240
241
242
243
244
def en_5v(self, state: bool):
    """Set the 5V enable state.

    Enables/disables the 5V supply to the DUT.

    Parameters:
        state: The state to set the 5V enable to.
    """
    mtm_exec(self.usb_stem.digital[self.EN_5V].setState, state)

en_usb_serial

Enables power to USB serial device

Enables/disables power to the test USB serial device for USB Hub enumeration

Parameters: state: True when power on, False when power off usb: USB device to switch on/off

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
def en_usb_serial(self, state: bool, usb: int):
    """Enables power to USB serial device

    Enables/disables power to the test USB serial device
    for USB Hub enumeration

    Parameters:
        state: True when power on, False when power off
        usb: USB device to switch on/off
    """
    if 1 <= usb <= 6:
        pins = [(usb - 1) * 2]
        self.io_expander.set_level(state, bits=pins)

    else:
        raise ValueError(f"No USB exists at index {usb}")

en_usb_load

Enables power to USB load test

Enables/disables USB load to test the USB serial device for USB Hub power draw

Parameters: state: True when power on, False when power off usb: USB device to switch on/off

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
def en_usb_load(self, state: bool, usb: int):
    """Enables power to USB load test

    Enables/disables USB load to test the USB serial device
    for USB Hub power draw

    Parameters:
        state: True when power on, False when power off
        usb: USB device to switch on/off
    """

    if 1 <= usb <= 6:
        pins = [(usb - 1) * 2 + 1]
        self.io_expander.set_level(state, bits=pins)

    else:
        raise ValueError(f"No USB exists at index {usb}")

bootsel

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
def bootsel(self):
    mtm_exec(
        self.usb_stem.digital[self.RP_BOOT].setConfiguration,
        self.usb_stem.digital[self.RP_BOOT].CONFIGURATION_OUTPUT,
    )
    mtm_exec(self.usb_stem.digital[self.RP_BOOT].setState, False)
    time.sleep(0.5)
    mtm_exec(
        self.usb_stem.digital[self.RP_RUN].setConfiguration,
        self.usb_stem.digital[self.RP_RUN].CONFIGURATION_OUTPUT,
    )
    mtm_exec(self.usb_stem.digital[self.RP_RUN].setState, False)
    time.sleep(0.5)
    mtm_exec(self.usb_stem.digital[self.RP_RUN].setState, True)
    mtm_exec(
        self.usb_stem.digital[self.RP_RUN].setConfiguration,
        self.usb_stem.digital[self.RP_RUN].CONFIGURATION_HIGHZ,
    )
    time.sleep(0.5)
    mtm_exec(self.usb_stem.digital[self.RP_BOOT].setState, True)
    mtm_exec(
        self.usb_stem.digital[self.RP_BOOT].setConfiguration,
        self.usb_stem.digital[self.RP_BOOT].CONFIGURATION_HIGHZ,
    )

inductive_sw

Set the inductive switch state.

Parameters: state: The state to set the inductive switch to.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
306
307
308
309
310
311
312
def inductive_sw(self, state: bool):
    """Set the inductive switch state.

    Parameters:
        state: The state to set the inductive switch to.
    """
    mtm_exec(self.usb_stem.digital[self.IND_SW_EN].setState, state)

get_mux_reading

Get the MUX reading for the specified channel.

Parameters: channel: The MUX channel to read. scalar: (Optional) Voltage scaling multiplier to add

Returns: The MUX reading.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
def get_mux_reading(self, channel: int, scalar: int = 1) -> float:
    """Get the MUX reading for the specified channel.

    Parameters:
        channel: The MUX channel to read.
        scalar: (Optional) Voltage scaling multiplier to add

    Returns:
        The MUX reading.
    """
    mtm_exec(self.usb_stem.digital[self.A_SELECT0].setState, channel & 0x01)
    mtm_exec(self.usb_stem.digital[self.A_SELECT1].setState, channel & 0x02)
    mtm_exec(self.usb_stem.digital[self.A_SELECT2].setState, channel & 0x04)
    mtm_exec(self.usb_stem.digital[self.A_SELECT3].setState, channel & 0x08)

    return get_voltage(self.usb_stem.analog[self.MUX], scalar=scalar)

get_continuity_reading

Get the continuity test reading.

Returns: The continuity test reading.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
331
332
333
334
335
336
337
def get_continuity_reading(self) -> float:
    """Get the continuity test reading.

    Returns:
        The continuity test reading.
    """
    return self.get_mux_reading(self.ADC_CONT_TEST)

get_dut_5v0_reading

Get the DUT 5V reading.

Return the DUT 5V reading from the analog MUX. This voltage is read via a voltage divider and is corrected by a scalar value of 2.

Returns: The DUT 5V reading.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
339
340
341
342
343
344
345
346
347
348
def get_dut_5v0_reading(self) -> float:
    """Get the DUT 5V reading.

    Return the DUT 5V reading from the analog MUX. This voltage is read via
    a voltage divider and is corrected by a scalar value of 2.

    Returns:
        The DUT 5V reading.
    """
    return self.get_mux_reading(self.ADC_DUT_5V, scalar=2)

get_dut_3v3_reading

Get the DUT 3.3V reading.

Measure the DUT 3.3V voltage from the analog MUX. This voltage is read via a voltage divider and is corrected by a scalar value of 2.

Returns: The DUT 3.3V reading.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
350
351
352
353
354
355
356
357
358
359
def get_dut_3v3_reading(self) -> float:
    """Get the DUT 3.3V reading.

    Measure the DUT 3.3V voltage from the analog MUX. This voltage is read
    via a voltage divider and is corrected by a scalar value of 2.

    Returns:
        The DUT 3.3V reading.
    """
    return self.get_mux_reading(self.ADC_DUT_3V3, scalar=2)

get_dut_1v1_reading

Get the DUT 1.1V reading.

Returns: The DUT 1.1V reading.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
361
362
363
364
365
366
367
def get_dut_1v1_reading(self) -> float:
    """Get the DUT 1.1V reading.

    Returns:
        The DUT 1.1V reading.
    """
    return self.get_mux_reading(self.ADC_DUT_1V1)

close

Closes all connections to the test fixture.

Source code in test_plans/fixtur-ctrl-func-test/hardware_utils/interface.py
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
def close(self):
    """Closes all connections to the test fixture."""
    logger.info("Closing test fixture connections")
    logger.info("-> disconnecting power from DUT")
    self.en_5v(False)
    self.en_12v(False)
    self.pwr_select(False)

    logger.info("-> reset io expander pins to inputs")
    pins = list(range(16))
    self.io_expander.set_level(False, bits=pins)
    self.io_expander.set_direction(self.io_expander.INPUT, bits=pins)

    logger.info("-> disconnecting from MTM-USBStem")
    self.usb_stem.disconnect()