thorlabs_mc2000b package

Python interface to a ThorLabs MC2000B optical chopper unit.

class thorlabs_mc2000b.Blade(value)[source]

Bases: enum.IntEnum

Mapping of chopping blade model numbers to the indices used by the underlying communications protocol.

As this is an IntEnum, the usual techniques apply. For example:

Blade(6).name               # == "MC1F10HP"
Blade(Blade.MC1F10HP).value # == 6
Blade["MC1F10HP"]           # == Blade.MC1F10HP

Additionally, the valid input and output reference sources for a blade model can be queried using the properties:

Blade["MC1F10HP"].inrefs  # == ("internal-outer", "internal-inner", "external-outer", "external-inner")
Blade["MC1F10HP"].outrefs # == ("target", "outer", "inner")
MC1F10 = 1
MC1F100 = 5
MC1F10A = 9
MC1F10HP = 6
MC1F15 = 2
MC1F2 = 0
MC1F2P10 = 7
MC1F30 = 3
MC1F60 = 4
MC1F6P10 = 8
MC2F330 = 10
MC2F47 = 11
MC2F5360 = 14
MC2F57B = 12
MC2F860 = 13
property inrefs

Get a tuple of valid internal reference source strings for this blade.

property outrefs

Get a tuple of valid output reference source strings for this blade.

class thorlabs_mc2000b.MC2000B(serial_port=None, serial_number='')[source]

Bases: object

Initialise and open serial device for the ThorLabs MC2000B Optical Chopper.

The features of the chopper can be accessed using properties of this class. Valid properties are:

  • freq : internal reference frequency

  • refoutfreq : reference output frequency

  • blade : blade type

  • nharmonic : harmonic multiplier

  • dharmonic : harmonic divider

  • phase : phase adjust

  • enable : enable

  • ref : reference mode

  • output : output reference mode

  • oncycle : on cycle

  • intensity : display intensity

  • input : current external reference frequency

See the chopper’s manual for more detailed descriptions of these features.

Example usage may be something like:

from thorlabs_mc2000b import MC2000B
# Initialise the first detected device
chopper = MC2000B()
# We'll assume the default MC1F10HP is installed
print(chopper.get_blade_string())
# Set up to use external reference source and the inner part of the blade
chopper.set_inref_string("external-inner")
# Apply a 1/2 divider to the input frequency
chopper.nharmonic = 1
chopper.dharmonic = 2
# Start it up!
chopper.enable = True

If the serial_port parameter is None (default), then an attempt to detect a MC2000B will be performed. The first device found will be initialised. If multiple devices are present on the system, then the use of the serial_number parameter will specify a particular device by its serial number. This is a regular expression match, for example serial_number="21" would match devices with serial numbers starting with 21, while serial_number=".*21$" would match devices ending in 21.

Parameters
  • serial_port – Serial port device the chopper is connected to.

  • serial_number – Regular expression matching the serial number of device to search for.

close()[source]

Close the serial connection to the chopper.

get_blade_string()[source]

Return the current blade model as a string.

get_commands()[source]

Returns a string containing the list of possible commands the chopper understands.

get_inref_string()[source]

Return the current input reference source as a string.

get_outref_string()[source]

Return the current output reference source as a string.

set_inref_string(value)[source]

Configure the input reference source using a string. Not all values are valid for every chopper wheel type, and an exception will be raised if an invalid reference type is requested. Valid types can be obtained by looking at the appropriate Blade.inrefs property, for example, Blade(Blade.MC1F10HP).inrefs or Blade["MC1F10HP"].inrefs for the default MC1F10HP model blade.

Parameters

value – String describing the input reference source, one of internal, external, internal-outer, internal-inner, external-outer, external-inner.

Raises

RuntimeError if invalid value requested.

set_outref_string(value)[source]

Configure the output reference source using a string. Not all values are valid for every chopper wheel type — an exception will be raised if an invalid reference type is requested. Valid types can be obtained by looking at the appropriate Blade.outrefs property, for example, Blade(Blade.MC1F10HP).outrefs or Blade["MC1F10HP"].outrefs for the default MC1F10HP model blade.

Parameters

value – String describing the output reference source, one of target, actual, outer, inner, sum, difference.

Raises

RuntimeError if invalid value requested.

thorlabs_mc2000b.find_device(serial_number='')[source]

Search attached serial ports for a Thorlabs MC2000B.

The first device found will be returned. If multiple choppers are attached to the system, the serial_number parameter may be used to select the correct device. This is a regular expression match, for example serial_number="21" would match devices with serial numbers starting with 21, while serial_number=".*21$" would match devices ending in 21.

Parameters

serial_number – Regular expression to match a device serial number.