Skip to content

Acroname MTM

Acroname Manufacturing Test Modules is a series of instrumentation modules that can be mixed and matched to create a complete test system without requiring a large rack or expensive PXI or LXI test equipment.

Acroname supplies various modules, some of our favorites are:

  • MTM-USBStem: General Digital and Analog I/O
  • MTM-DAQ-2: High Resolution Analog IO
  • MTM-PM-1: Programmable Power Supply
  • MTM-IO-SERIAL: Programmable USB Hub and Serial Interface

You can read all about MTM here.

Brainstem Documentation

The Acroname Brainstem python module is used to interface with all of these devices. In addition to their supplied library, we have developed some utility functions that we use to simplify common operations and error handling.

You can find Acroname's Brainstem documentation here.

Module Documentation

Acroname MTM Utilities.

This module provides utilities for working with Acroname Manufacturing Test Modules using the Brainstem python library.

byte_list_to_int(byte_list, big_endian=False)

Convert a list of bytes to an integer.

:param byte_list: List of bytes to convert to a int :type byte_list: list :param big_endian: Big/little endian flag :type big_endian: bool :return: Integer value from list :rtype: int

Source code in f3ts_hardware_utils/mtm_utils.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
def byte_list_to_int(byte_list, big_endian=False):
    """
    Convert a list of bytes to an integer.

    :param byte_list: List of bytes to convert to a int
    :type byte_list: list
    :param big_endian: Big/little endian flag
    :type big_endian: bool
    :return: Integer value from list
    :rtype: int
    """
    value = 0
    for i, v in enumerate(byte_list):
        if big_endian:
            value = (value << 8) + v
        else:
            value += v << i * 8

    return value

get_current(channel, num_samples=10)

Get a current reading from a power channel.

Reads from the specified channel for the given number of samples. A dictionary is then returned containing the min, max, and mean readings.

Source code in f3ts_hardware_utils/mtm_utils.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def get_current(channel, num_samples=10):
    """
    Get a current reading from a power channel.

    Reads from the specified channel for the given number of samples. A
    dictionary is then returned containing the min, max, and mean readings.
    """
    samples = [mtm_exec(channel.getCurrent) / 1000000.0 for _ in range(num_samples)]
    return {
        "min": min(samples),
        "max": max(samples),
        "mean": mean(samples),
        "median": median(samples),
        "samples": samples,
    }

get_voltage(channel, num_samples=10, scalar=1)

Get a voltage reading from the specified channel.

Reads from the specified channel for the given number of samples. A dictionary is then returned containing the min, max, and mean readings.

:param channel: MTM-DAQ2 channel to read :type channel: Analog :param num_samples: Number of readings to take of the specified channel :type num_samples: int :param scalar: Scalar to apply to voltage reading, i.e Voltage Divider :type scalar: float :return: Voltage reading dictionary7 :rtype: dict

Source code in f3ts_hardware_utils/mtm_utils.py
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
def get_voltage(channel, num_samples=10, scalar=1):
    """
    Get a voltage reading from the specified channel.

    Reads from the specified channel for the given number of samples. A
    dictionary is then returned containing the min, max, and mean readings.

    :param channel: MTM-DAQ2 channel to read
    :type channel: Analog
    :param num_samples: Number of readings to take of the specified channel
    :type num_samples: int
    :param scalar: Scalar to apply to voltage reading, i.e Voltage Divider
    :type scalar: float
    :return: Voltage reading dictionary7
    :rtype: dict
    """
    start_time = time.time()
    samples = [
        mtm_exec(channel.getVoltage) / 1000000.0 * scalar for _ in range(num_samples)
    ]
    end_time = time.time()
    return {
        "min": min(samples),
        "max": max(samples),
        "mean": mean(samples),
        "median": median(samples),
        "samples": samples,
        "duration": end_time - start_time,
    }

mtm_exec(func, *args, **kwargs)

Execute brainstem function call.

:param func: Function to execute :param args: Function args :param kwargs: Function kwargs :return: Function results

Source code in f3ts_hardware_utils/mtm_utils.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def mtm_exec(func, *args, **kwargs):
    """
    Execute brainstem function call.

    :param func: Function to execute
    :param args: Function args
    :param kwargs: Function kwargs
    :return: Function results
    """
    retries = 3
    value = None

    while retries > 0:
        result = func(*args, **kwargs)
        error = value = copy.deepcopy(result)

        if isinstance(result, Result):
            error = result.error
            value = result.value

        if error == 0:
            break
        else:
            retries -= 1
            if retries == 0:
                raise Exception(f"Brainstem Error {func.__name__}: {repr(result)}")

    return value