microscope.controllers.lumencor module

Lumencor Spectra Light Engine.

The implementation here is limited to the Lumencor Spectra III but should be trivial to make it work for other Lumencor light engines. We only need access to other such devices.


The engine is expected to be on the standard mode communications (not legacy). This can be changed via the device web interface.

class microscope.controllers.lumencor.SpectraIIILightEngine(port: str, **kwargs)[source]

Bases: microscope.devices.ControllerDevice

Spectra III Light Engine.

Parameters:port (str) – port name (Windows) or path to port (everything else) to connect to. For example, /dev/ttyS1, COM1, or /dev/cuad1.

The names used on the devices dict are the ones provided by the Spectra engine. These are the colour names in capitals such as ‘BLUE’, ‘NIR’, or ‘VIOLET’.

Not all sources may be turned on simultaneously. To prevent exceeding the capacity of the DC power supply, power consumption is tracked by the Spectra onboard computer. If a set limit is exceeded, either by increasing intensity settings for sources that are already on, or by turning on additional sources, commands will be rejected. To clear the error condition, reduce intensities of sources that are on or turn off additional sources.


This relies on having power reference values set for each channel. The Spectra light engines do not provide a method to obtain the maximum power output or to set the power ouput. As such, this relies on the internal power reference value. This should be set manually on the device to obtain reasonable results when setting the power output.


Map of names to the controlled devices.

class microscope.controllers.lumencor._LightChannelConnection(connection: microscope.controllers.lumencor._SpectraIIIConnection, index: int)[source]

Bases: object

Commands for a channel in a Lumencor light engine.

get_light_state() → bool[source]

On (True) or off (False) state

get_max_intensity() → int[source]

Maximum valid intensity that can be applied to a light channel.

get_power_output() → float[source]

Estimated power output for a given channel (in mW).

Power estimation is based on the power output calibration factor, power sensor reading, power sensor exposure, power sensor gain and crosstalk level. Estimation model assumes linear dependency.

get_power_reference() → float[source]

Light power reference (in mW).

This gives an indication of the power output when the channel is set to its maximum intensity. However, its dependent on being manually set and kept adjusted over time.

A value of -1 is returned if the power reference hasn’t been defined yet.

set_intensity(intensity: int) → None[source]

Set light intensity between 0 and maximum intensity.

set_light_state(state: bool) → None[source]

Turn light on (True) or off (False).

class microscope.controllers.lumencor._SpectraIIIConnection(serial: microscope.controllers.lumencor._SyncSerial)[source]

Bases: object

Connection to a Spectra III Light Engine.

This module makes checks for Spectra III light engine and it was only tested for it. But it should work with other lumencor light engines with little work though, if only we got access to them.

command_and_answer(*TX_tokens) → bytes[source]
get_channel_map() → List[Tuple[int, str]][source]
get_command(command: bytes, *args) → bytes[source]
set_command(command: bytes, *args) → None[source]
class microscope.controllers.lumencor._SpectraIIILightChannel(connection: microscope.controllers.lumencor._SpectraIIIConnection, index: int)[source]

Bases: microscope.devices.LaserDevice

A single light channel from a light engine.

A channel is not necessarily a lasers although it subclasses from LaserDevice. Constituent light sources may include LEDs, luminescent light pipes, or lasers.

disable() → None[source]

Disable the device for a short period for inactivity.

enable() → None[source]

Enable the device.

get_is_on() → bool[source]

Return True if the laser is currently able to produce light.

get_max_power_mw() → float[source]

Return the max. power in mW.

get_min_power_mw() → float[source]

Return the min power in mW.

get_power_mw() → float[source]

“” Return the current power in mW.

get_status() → List[str][source]

Query and return the laser status.

initialize() → None[source]

Initialize the device.

class microscope.controllers.lumencor._SyncSerial(serial: serial.serialposix.Serial)[source]

Bases: object

Wraps a Serial instance with a lock for synchronization.

readline() → bytes[source]
write(data: bytes) → int[source]