Spatial light modulators
A spatial light modulator is a subtype of SLM, which is not an AbstractInstrument. [limitation] The interface's display functions (displayimage, displayzernike, displayblaze) do not work on any SLM today; their docstrings say why. The Meadowlark driver, MLSLM, is driven with its own pattern generators and SDK calls, documented below.
SLM interface
MicroscopeControl.HardwareInterfaces.SLMInterface.Pupil — Type
Pupil(x_center, y_center, x_radius, y_radius)The pupil an SLM pattern is meant for: center and radii, all Float64. MLSLM stores one in its pupil field and writes it in export_state; no pattern generator reads it (genzernike! takes its own center and radius).
MicroscopeControl.HardwareInterfaces.SLMInterface.SLM — Type
SLMAbstract type for a spatial light modulator. Unlike the other device classes it is not a subtype of AbstractInstrument. Its one driver is MLSLM (Meadowlark).
MicroscopeControl.HardwareInterfaces.SLMInterface.displayblaze — Method
displayblaze(slm::SLM, angle::Float64, period::Float64; blaze_start=0.0, blaze_end=-1.0)Show a blazed grating at angle with period.
[limitation] Does not work: it calls blaze_to_phase, which is not defined anywhere, and throws an UndefVarError. On an MLSLM use genblazed!.
MicroscopeControl.HardwareInterfaces.SLMInterface.displayimage — Method
displayimage(slm::SLM)
displayimage(slm::SLM, phase::Array{Float64,2})Show a phase pattern on the SLM: the one already in slm.phase, or phase.
[limitation] Neither form works today, for any SLM. The one-argument form does nothing and returns nothing. The two-argument form assigns to the abstract type (SLM.phase) instead of the argument, and throws. No driver defines its own method (MLSLM's file of interface methods is not included in the package). Drive an MLSLM with its pattern generators, such as genblazed! and genzernike!, and the Meadowlark functions its docstring names.
MicroscopeControl.HardwareInterfaces.SLMInterface.displayzernike — Method
displayzernike(slm::SLM, zernike::Vector{Float64})Show the phase described by Zernike coefficients zernike.
[limitation] Does not work: it calls zernike_to_phase, which is not defined in the package (the file that would define it, zernike.jl, is not included and its function has no body), and throws an UndefVarError. On an MLSLM use genzernike!.
Meadowlark SLM
MicroscopeControl.HardwareImplementations.Meadowlark — Module
The driver for Meadowlark spatial light modulators: MLSLM, its pattern generators, and bindings to the Blink SDK.
MicroscopeControl.HardwareImplementations.Meadowlark.MLSLM — Type
MLSLM(; width=1024, height=1024, pixelsize=1, wavelength=1, phase, offset, pupil=Pupil(0, 0, 1, 1),
sequence=Sequence(), bit_depth=Cuint(12), ...) -> MLSLMMeadowlark Optics spatial light modulator driven through the Blink OverDrive Plus SDK. The keyword constructor only fills the struct: it does not load the SDK DLL or contact a board. MLSLM has no initialize, shutdown or gui method. The functions that drive it are unexported: initializesdk opens the SDK, loadlut loads a fixed LUT file, writesingleimage(slm) writes slm.phase to board 1 and closesdk closes the SDK. genblazed! and genzernike! fill slm.phase in memory. [limitation] The SLM interface's displayimage, displayzernike and displayblaze do not drive an MLSLM: the module defines no methods of its own for them (its interface_functions.jl is not loaded), so a call reaches the generic interface methods, which send nothing to the board or fail. [limitation] The SDK functions above name C:\Program Files\Meadowlark Optics\Blink OverDrive Plus\SDK\Blink_C_wrapper.dll, so the device path works only on Windows with that SDK installed.
Keywords and fields: width and height (pixels), pixelsize and wavelength (stored and exported by export_state only; the code gives no unit), phase and offset (Float64 arrays of size (width, height), default zeros; phase holds fractions of a wave in 0 to 1, which writesingleimage scales to 0 to 255), pupil (a Pupil), sequence (a Sequence). The SDK fields bit_depth, n_boards_found, constructed_ok, is_nematic_type, ram_write_enable, use_gpu and max_transient_frames (all Cuint, defaults 12, 0, 1, 1, 1, 1, 10) are cached values only; initializesdk takes its own keywords and does not read them.
MicroscopeControl.HardwareImplementations.Meadowlark.Sequence — Type
Sequence(; phase=zeros(Float64, 1024, 1024, 10), offset=zeros(Float64, 1024, 1024, 10)) -> SequenceA stack of phase patterns for a Meadowlark SLM, held in the sequence field of MLSLM. phase and offset are three-dimensional Float64 arrays with frames along the third dimension; num_frames is size(phase, 3). If it exceeds 754, the Meadowlark limit named in the source, an error is logged but the object is still returned. offset is not checked against phase. [limitation] Nothing in this package writes a sequence to the board (writesequence and selectsequenceimage log "Not implemented").
MicroscopeControl.HardwareImplementations.Meadowlark.genblazed! — Function
genblazed!(slm::MLSLM, is_vert::Bool=true, period::Int=32; blaze_start::Int=1, blaze_end::Int=-1)Fill slm.phase with a blazed grating and return it; nothing is sent to the board. Along the chosen axis the phase ramps from 1 down to 0 over period pixels and repeats; with is_vert true it depends only on the second index of the (width, height) array, otherwise only on the first. Pixels outside blaze_start:blaze_end (1-based indices along that axis) stay 0. period == 1 gives 0 everywhere. [limitation] blaze_end must lie in 1:height (is_vert true) or 1:width (is_vert false). The default -1, or any value past that axis length, leaves pattern_end unset, so the call throws UndefVarError; a call with no blaze_end keyword always fails this way.
MicroscopeControl.HardwareImplementations.Meadowlark.genzernike! — Method
genzernike!(slm::MLSLM, radial_order::Int, coefficients::Vector{Float64}, radius::Int, x_center::Int,
y_center::Int)Fill slm.phase with a sum of Zernike polynomials over a disk and return it; nothing is sent to the board. The disk has radius radius pixels and is centered at index (x_center, y_center) of the (width, height) array; everything outside it is 0. coefficients weights the polynomials (each scaled by sqrt(n+1) or sqrt(2(n+1))) up to radial_order in the order of the recurrence in gen_patterns.jl (OSA, per its comment), so it must have (radial_order+1)*(radial_order+2)/2 elements and radial_order must be at least 1. Coefficients are in radians; the sum is wrapped into 0 to 2 pi and stored divided by 2 pi, so slm.phase holds fractions of a wave in 0 to 1. If the disk extends past the array edge, only the part on the array is kept and four index ranges are printed.
MicroscopeControl.export_state — Method
export_state(slm::MLSLM)Export cached configuration attributes without accessing the SDK or including image arrays. The SDK fields are cached construction values, not evidence of a connected board.
SLM internals
MicroscopeControl.HardwareImplementations.Meadowlark.initializesdk — Method
initializesdk(; bit_depth = 12, is_nematic_type = 1, ram_write_enable = 1, use_gpu = 1,
max_transient_frames = 10, regional_lut = nothing) -> (; n_boards_found, constructed_ok)Open the Blink SDK (Create_SDK). regional_lut is the path of a static regional LUT file, or nothing for none (a NULL pointer). Prints the board count and the constructor's flag, as before, and returns them.
Call it once per process: a second Create_SDK without closesdk() in between crashes the process, and so does a Create_SDK on a board another process (or a crashed session) still holds, which needs a power cycle of the SLM controller.