Skip to content

MFF101/MFF102¤

Communicate with a Motorised Filter Flip mount from Thorlabs.

MFF (Interface) ¤

MFF(equipment: Equipment)

              flowchart LR
              msl.equipment_resources.thorlabs.mff.MFF[MFF]
              msl.equipment.schema.Interface[Interface]

                              msl.equipment.schema.Interface --> msl.equipment_resources.thorlabs.mff.MFF
                


              click msl.equipment_resources.thorlabs.mff.MFF href "" "msl.equipment_resources.thorlabs.mff.MFF"
              click msl.equipment.schema.Interface href "" "msl.equipment.schema.Interface"
            

Communicate with a Motorised Filter Flip mount from Thorlabs.

Regular-expression patterns that are used to select this Resource when connect() is called.

manufacturer=r"Thorlabs"
model=r"MFF"

Parameters:

Name Type Description Default
equipment Equipment

An Equipment instance.

required

A Connection instance supports the properties that are defined in ThorlabsMotion.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(self, equipment: Equipment) -> None:
    """Communicate with a Motorised Filter Flip mount from Thorlabs.

    Regular-expression patterns that are used to select this Resource when
    [connect()][msl.equipment.schema.Equipment.connect] is called.
    ```python
    manufacturer=r"Thorlabs"
    model=r"MFF"
    ```

    Args:
        equipment: An [Equipment][] instance.

    A [Connection][msl.equipment.schema.Connection] instance supports the _properties_
    that are defined in [ThorlabsMotion][msl.equipment_resources.thorlabs.motion.ThorlabsMotion].
    """
    super().__init__(equipment)

    self._motion: ThorlabsMotion = ThorlabsMotion(equipment)

    if self._motion._init_defaults:  # pyright: ignore[reportPrivateUsage]  # noqa: SLF001
        self.set_parameters(
            FlipperParameters(
                transit_time=0.5,
                dig1=FlipperIO(operating_mode=1, signal_mode=1, pulse_width=0.2),
                dig2=FlipperIO(operating_mode=1, signal_mode=1, pulse_width=0.2),
            )
        )

equipment property ¤

equipment: Equipment

The Equipment associated with the interface.

position property writable ¤

position: Literal[-1, 1, 2]

Get/set the position of the Filter Flipper, either 1 or 2 (returns -1 if moving).

Setting the position using this property attribute waits for the move to complete before returning to the calling program. If you do not want to wait, use move_to with wait=False.

timeout property writable ¤

timeout: float | None

The timeout, in seconds, for read and write operations.

A value <0 will set the timeout to be None (blocking mode).

disable ¤

disable() -> None

Disable the motor so the Filter Flipper can be freely moved by hand.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
57
58
59
def disable(self) -> None:
    """Disable the motor so the Filter Flipper can be freely moved by hand."""
    self._motion.disable()

disconnect ¤

disconnect() -> None

Disconnect from the Filter Flipper.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
61
62
63
64
def disconnect(self) -> None:  # pyright: ignore[reportImplicitOverride]
    """Disconnect from the Filter Flipper."""
    if hasattr(self, "_motion"):
        self._motion.disconnect()

enable ¤

enable() -> None

Enable the motor so the Filter Flipper is fixed in position.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
66
67
68
def enable(self) -> None:
    """Enable the motor so the Filter Flipper is fixed in position."""
    self._motion.enable()

get_parameters ¤

get_parameters() -> FlipperParameters

Get the operating parameters.

Returns:

Type Description
FlipperParameters

The transit time, digital I/O parameters for pin 1, digital I/O parameters for pin 2.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
70
71
72
73
74
75
76
77
78
def get_parameters(self) -> FlipperParameters:
    """Get the operating parameters.

    Returns:
        The transit time, digital I/O parameters for pin 1, digital I/O parameters for pin 2.
    """
    params = unpack("<HiiHHiHHiiI", self._motion.query(0x0511, param1=1, dest=0x50))  # MGMSG_MOT_REQ_MFF_OPERPARAMS
    o1, s1, pw1, o2, s2, pw2 = params[3:9]
    return FlipperParameters(params[1] * 1e-3, FlipperIO(o1, s1, pw1 * 1e-3), FlipperIO(o2, s2, pw2 * 1e-3))

hardware_info ¤

hardware_info() -> ThorlabsHardwareInfo

Get the hardware information about the Filter Flipper.

Returns:

Type Description
ThorlabsHardwareInfo

The hardware information.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
80
81
82
83
84
85
86
def hardware_info(self) -> ThorlabsHardwareInfo:
    """Get the hardware information about the Filter Flipper.

    Returns:
        The hardware information.
    """
    return self._motion.hardware_info()

identify ¤

identify() -> None

Instruct the Filter Flipper to identify itself by flashing its LED.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
88
89
90
def identify(self) -> None:
    """Instruct the Filter Flipper to identify itself by flashing its LED."""
    self._motion.identify()

is_enabled ¤

is_enabled() -> bool

Check if the motor is enabled.

If enabled, power is applied to the motor so the Filter Flipper is fixed in position.

Returns:

Type Description
bool

Whether the motor is enabled or disabled.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
 92
 93
 94
 95
 96
 97
 98
 99
100
def is_enabled(self) -> bool:
    """Check if the motor is enabled.

    If enabled, power is applied to the motor so the Filter Flipper is fixed in position.

    Returns:
        Whether the motor is enabled or disabled.
    """
    return self._motion.is_enabled()

is_moving ¤

is_moving() -> bool

Check if the Filter Flipper is moving.

Returns:

Type Description
bool

Whether the Filter Flipper is moving.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
102
103
104
105
106
107
108
def is_moving(self) -> bool:
    """Check if the Filter Flipper is moving.

    Returns:
        Whether the Filter Flipper is moving.
    """
    return bool(self.status() & 0x10)

move_to ¤

move_to(position: Literal[1, 2], *, wait: bool = True) -> None

Move the Filter Flipper to a position.

Parameters:

Name Type Description Default
position Literal[1, 2]

The position to move to (either 1 or 2).

required
wait bool

Whether to wait for the move to complete before returning to the calling program.

True
Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
def move_to(self, position: Literal[1, 2], *, wait: bool = True) -> None:
    """Move the Filter Flipper to a position.

    Args:
        position: The position to move to (either `1` or `2`).
        wait: Whether to wait for the move to complete before returning to the calling program.
    """
    if position not in {1, 2}:
        msg = f"Invalid Filter Flipper position {position}, must be 1 or 2"
        raise ValueError(msg)

    _ = self._motion.write(0x046A, param1=1, param2=position, dest=0x50)  # MGMSG_MOT_MOVE_JOG
    if wait:
        self.wait_until_moved()

set_parameters ¤

set_parameters(parameters: FlipperParameters) -> None

Set the operating parameters.

Parameters:

Name Type Description Default
parameters FlipperParameters

The operating parameters. It is recommended to call get_parameters first and then update the appropriate attributes.

required
Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
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
def set_parameters(self, parameters: FlipperParameters) -> None:
    """Set the operating parameters.

    Args:
        parameters: The operating parameters. It is recommended to call
            [get_parameters][msl.equipment_resources.thorlabs.mff.MFF.get_parameters]
            first and then update the appropriate attributes.
    """
    tt = round(parameters.transit_time * 1e3)
    tt_adc = round(10000000 * (tt**-1.591))
    data = pack(
        "<HiiHHiHHiiI",
        1,  # channel
        tt,
        tt_adc,
        parameters.dig1.operating_mode,
        parameters.dig1.signal_mode,
        round(parameters.dig1.pulse_width * 1e3),
        parameters.dig2.operating_mode,
        parameters.dig2.signal_mode,
        round(parameters.dig2.pulse_width * 1e3),
        0,  # not used
        0,  # not used
    )
    _ = self._motion.write(0x0510, data=data, dest=0x50)  # MGMSG_MOT_SET_MFF_OPERPARAMS

status ¤

status() -> int

Get the status of the Filter Flipper.

Returns:

Type Description
int

The status. A 32-bit value that represents the current status of the Filter Flipper. Each of the 32 bits acts as a flag (0 or 1), simultaneously indicating 32 distinct operating conditions of the Filter Flipper.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
173
174
175
176
177
178
179
180
181
def status(self) -> int:
    """Get the status of the Filter Flipper.

    Returns:
        The status. A 32-bit value that represents the current status of the Filter Flipper.
            Each of the 32 bits acts as a flag (0 or 1), simultaneously indicating 32 distinct
            operating conditions of the Filter Flipper.
    """
    return self._motion.status()

toggle ¤

toggle(*, wait: bool = True) -> None

Toggle the position.

If at position 1 then move to position 2 (and vice versa).

Parameters:

Name Type Description Default
wait bool

Whether to wait for the move to complete before returning to the calling program.

True
Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
196
197
198
199
200
201
202
203
204
205
def toggle(self, *, wait: bool = True) -> None:
    """Toggle the position.

    If at position 1 then move to position 2 (and vice versa).

    Args:
        wait: Whether to wait for the move to complete before returning to the calling program.
    """
    position = 2 if self.position == 1 else 1
    self.move_to(position, wait=wait)

wait_until_moved ¤

wait_until_moved() -> None

Wait until a move is complete.

Source code in packages/resources/src/msl/equipment_resources/thorlabs/mff.py
207
208
209
210
211
def wait_until_moved(self) -> None:
    """Wait until a move is complete."""
    sleep(0.02)  # Doesn't appear to be required, but allow time for the motor to update its status
    while self.is_moving():
        pass

FlipperIO dataclass ¤

FlipperIO(operating_mode: int, signal_mode: int, pulse_width: float)

Filter Flipper Digital I/O parameters.

Attributes:

Name Type Description
operating_mode int

The operating mode:

  • 1 — Toggle position (Input)
  • 2 — Go to position (Input)
  • 3 — At position (Output)
  • 4 — In motion (Output)
signal_mode int

Input/Output signal mode. The value depends on whether operating_mode is an Input or an Output:

If operating_mode is an Input

  • 1 — Button input
  • 2 — Logic edge input
  • 5 — Button input (swap position)
  • 6 — Logic edge input (swap position)

If operating_mode is an Output

  • 16 — Logic level output
  • 32 — Logic pulse output
  • 80 — Logic level output (inverted)
  • 96 — Logic pulse output (inverted)
pulse_width float

The pulse width, in seconds. Valid range is between 0.01 and 65.535 seconds.

FlipperParameters dataclass ¤

FlipperParameters(transit_time: float, dig1: FlipperIO, dig2: FlipperIO)

Filter Flipper parameters.

Attributes:

Name Type Description
transit_time float

The time taken (in seconds) for the flipper to move from position 1 to position 2 and vice versa. The value must be in the range 0.3 to 2.8 seconds.

dig1 FlipperIO

Digital I/O parameters for pin 1.

dig2 FlipperIO

Digital I/O parameters for pin 2.