autoemx.core.em_runtime.microscope_controller module
Microscope hardware control module for automated electron microscopy operations.
This module provides low-level control of microscope hardware including beam settings, focus adjustment, brightness/contrast, and stage movement.
Classes
- MicroscopeController
Handles microscope hardware initialization and adjustment.
Created on 2026 @author: Andrea
- class autoemx.core.em_runtime.microscope_controller.MicroscopeController(EM_driver_obj, microscope_cfg, measurement_cfg, init_wd, im_width, im_height, verbose=True)[source]
Bases:
objectLow-level microscope hardware controller.
Handles initialization of SEM, beam settings, focus, brightness/contrast adjustment, and stage movement.
- Parameters:
EM_driver_obj (module) – The EM_driver module for hardware communication.
microscope_cfg (MicroscopeConfig) – Microscope configuration.
measurement_cfg (MeasurementConfig) – Measurement/acquisition configuration.
init_wd (float) – Initial working distance in mm.
im_width (int) – Image width in pixels.
im_height (int) – Image height in pixels.
verbose (bool) – If True, print progress information.
- initialise_SEM(center_pos: tuple | None = None) None[source]
Activate and configure the Scanning Electron Microscope (SEM).
- This method performs the following steps:
Wakes up the SEM if necessary.
Switches to SEM mode.
Sets the electron detector mode to backscattered electrons (BSD).
Sets the beam voltage and current according to measurement configuration.
Moves the stage to the sample center, if provided.
Sets working distance.
Adjusts focus, brightness, and contrast.
- Parameters:
center_pos (tuple of float, optional) – (x, y) stage position of the sample center, in mm. Focus, brightness and contrast are adjusted there. If None, the stage is not moved.
- Raises:
EMError – If an error occurs during SEM activation or configuration.
- adjust_BCF() float[source]
Adjust brightness, contrast, and focus (BCF).
If automatic brightness and contrast adjustment is enabled, calls the automatic adjustment method. Otherwise, sets brightness and contrast to fixed values then performs autofocus.
- Returns:
Timestamp of adjustment completion.
- Return type:
float
- Raises:
EMError – If an error occurs during adjustment.
- set_frame_width(frame_width: float) None[source]
Set the frame width at the microscope.
- Parameters:
frame_width (float) – The desired frame width in millimeters.
- Raises:
EMError – If an error occurs during frame width setting.