Skip to main content

Theia Technologies motor control board interface

Theia Technologies offers a MCR IQ 400 motor control board for controlling Theia's motorized lenses. This board controls focus, zoom, iris, and IRC filter motors. It can be connected to a host comptuer by USB, UART, or I2C connection.

Also available: C++ version of TheiaMCR — includes native C++ implementation and pybind11 bindings for Python integration.

Features

python The MCR IQ 400 board (and MCR IQ 600, MCR IQ 500 and others in the MCR series) has a proprietary command protocol to control and get information from the control program. The protocol is a customized string of up to 12 bytes which can be deciphered in the MCR IQ 400 documentation. For ease of use, Theia has developed this Python module to format the custom byte strings and send them to the board. For example, the user can request the focus motor to move 1000 steps. The focusRel() function will convert this request to the appropriate byte string and send it over USB connection to the MCR control board. This will cause the lens motor to move 1000 steps.

Quick start

This module can be loaded into a Python program using pip.
pip install TheiaMCR
Theia's motorized lens should be connected to the MCR IQ 400 board (or similar) and the board should be connected to the host computer via USB connection thorugh a virtual com port. The class must be initialized first using the __init__() function.

# create the motor control board instance
import TheiaMCR
MCR = TheiaMCR.MCRControl(comport)

Note: MCRControl uses a singleton pattern — calling it a second time with the same port name returns the existing instance rather than creating a new one. A second board can be controlled through a different port.

After a succesful board initialization, the motors must all be initialized with their steps and limit positions.

# initialize the motors (Theia TL1250P N6 lens parameters shown in this case)
MCR.focusInit(8390, 7959)
MCR.zoomInit(3227, 3119)
MCR.irisInit(75)
MCR.IRCInit()

The initialization commands will create instances of the motor class for each motor which can be accessed by focus, zoom, and iris named instances. If the MCRControl class was not successful (possibly due to hardware connection issue) any subsequent functions will return an error value. There are some board query commands that use the MCRBoard subclass. This subclass was automatically initilized.

Motor initialization requires the number of steps and PI home position (if applicable). These values are available in the lens spec sheet:

  • steps: total number of steps
  • pi: photo interrupter (PI) home position step number (available for focus and zoom)

Focus, zoom, and iris motor init functions accept optional parameters:

  • move (default True): move motor to home position on initialization
  • homingSpeed (default: motor default speed): speed used when seeking the PI home position
  • accel (focus/zoom only, default 0): motor acceleration steps — reserved for future hardware support, not currently implemented

Now the motors can be controlled individually. For example, the focus motor can be moved to an absolute step number.

# move the focus motor
MCR.focus.moveAbs(6000)
log.info(f'Focus step {MCR.focus.currentStep}')

If the lens has an internal IRC switchable filter, the state can be 1 or 2 to match the specification sheet.

When ending the program, call MCR.close() to close the serial port and release any resources being used unless they are automatically closed per OS.

Motor limits

The parameters for focusInit(), zoomInit(), and irisInit() can be found in the lens specification. These are the parameters for some of Theia's lenses.

  • TL1250 (-N) lens:
    • focusInit(8390, 7959)
    • zoomInit(3227, 3119)
    • irisInit(75)
  • TL410 (-R) lens:
    • focusInit(9353, 8652)
    • zoomInit(4073, 154)
    • irisInit(75) (updated v.3.5.0)

The PI position is based on the motor move direction (positive/negative) so may not be at position 0. It is set as a known starting step number. For example when homing the focus motor of TL1250 lens, the home position is defined as motor step 7959. From there the lens can move to position 0 (hard stop) and, if regardLimits is off, it can move to at least position 8390. The positive hard stop is just past the maximum step position. Hitting either hard stop will create a mismatch in step counting and the lens must be re-homed.

Motor functions

Each motor (focus, zoom, iris) supports these functions:

  • motor.home(): move motor to the PI limit switch home position
  • motor.moveAbs(step): move to an absolute step number
  • motor.moveRel(steps, correctForBL=True): move by a relative number of steps with optional backlash correction
  • motor.setMotorSpeed(speed): set the motor speed in pps (focus/zoom: 100–1500; iris: 10–200)
  • motor.setHomingSpeed(speed): set the speed in pps used when homing
  • motor.setRespectLimits(state): enable (True) or disable (False) enforcement of the PI limit position
  • motor.readMotorSetup(): read motor configuration from board EEPROM
  • motor.writeMotorSetup(...): write motor configuration to board EEPROM

The IRC filter motor uses MCR.IRC.state(1) or MCR.IRC.state(2) to switch filter positions.

MCRBoard functions

The MCRBoard subclass (initialized automatically) provides board-level queries:

  • MCR.MCRBoard.readFWRevision(): returns the firmware version string (e.g. '5.3.1.0.0')
  • MCR.MCRBoard.readBoardSN(): returns the board serial number string
  • MCR.MCRBoard.setCommunicationPath(path): switch the active connection to 'USB', 'UART', or 'I2C' — the board reboots after this command, wait >700 ms before sending further commands

To verify the serial connection is still active at any time, call MCR.checkBoardCommunication() which returns True if communication is successful.

Important variables

Each motor has these variables available:

  • motor.currentStep: current motor step number
  • motor.currentSpeed: current motor speed in pulses per second (pps)
  • motor.homingSpeed: speed in pps used when homing to the PI position
  • motor.maxSteps: maximum number of steps for the full range of movement
  • motor.PIStep: photointerrupter limit switch step position (within the full range of movement). After sending the motor to home, the current step will be set to this PIStep number.
  • motor.PISide: indicates whether the PI limit switch is on the high (1) or low (-1) step side
  • motor.respectLimits: when True, moves are prevented from exceeding the PI limit position

More information about the available functions can be found in the wiki pages.

Logging

There are logging commands in the module using Python's logging libray. These are set by default to log WARNING and higher levels. To see other log prints in the console, initialize the class with MCR = TheiaMCR.MCRControl("com4", moduleDebugLevel=True) or manually set the logging level with TheiaMCR.log.setLevel(logging.INFO).
The module creates 2 rotating log files in the background by default based on Python's logging module. If the logging module isn't used, the log files can be disabled by calling MCR = TheiaMCR.MCRControl("com4", logFiles=False).

Unhandled exceptions are logged to the log file using the sys.excepthook variable. This is a global variable so check the operation within your application if you set this variable elsewhere.

License

Theia Technologies BSD-3-Clause license
Copyright 2023-2026 Theia Technologies

Contact information

For more information contact: Mark Peterson at Theia Technologies mpeterson@theiatech.com

Revision

v.3.5

Metadata

Release files for TheiaMCR 3.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TheiaMCR 3.5.1
File Size Uploaded
theiamcr-3.5.1.tar.gz 33.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TheiaMCR 3.5.1
File Interpreter ABI Platform
theiamcr-3.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 60.0 kB

Release files / theiamcr-3.5.1.tar.gz

Download URL theiamcr-3.5.1.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c64ac367583406e7c92a1aaea2d439845a43b1fa9a383f2b73d302d22d06abfb
BLAKE2b-256 checksum
How to use checksums
90d548bc8b91afdcc6dad64ffdf342ab2d4e00c8f335fb0c8857ef02b1f09137
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / theiamcr-3.5.1-py3-none-any.whl

Download URL theiamcr-3.5.1-py3-none-any.whl
Size 26.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5dd90ba68168a0bb3f123ab6c4859da81a42cd58edd08752053189f42b31e6d8
BLAKE2b-256 checksum
How to use checksums
1690dc9bd76a4ea861e7ce36f55efbd1392d416614e09bfd446de34197453a9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

3.5.1 This release

2 release files

3.5.0

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.10

2 release files

3.3.4

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.5.0

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.5

2 release files

2.3.4

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.7

2 release files

2.1.6

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.8

2 release files

1.0.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page