|
Wasatch.PY
Python application driver for Wasatch Photonics spectrometers
|
Protected Member Functions | |
| _apply_2x2_binning (self, list[float] spectrum) | |
| _check_for_random_error (self) | |
| _correct_bad_pixels (self, list[float] spectrum) | |
| _correct_ingaas_gain_and_offset (self, list[float] spectrum) | |
| Until support for even/odd InGaAs gain and offset have been added to the firmware, apply the correction in software. | |
| SpectrometerResponse | _get_code (self, int bRequest, int wValue=0, int wIndex=0, int wLength=64, str label="", int msb_len=None, int lsb_len=None) |
| _init_process_funcs (self) | |
| _post_connect (self) | |
| _read_eeprom (self) | |
| _read_fpga_compilation_options (self) | |
| _schedule_disconnect (self, exc) | |
| SpectrometerResponse | _send_code (self, int bRequest, int wValue=0, int wIndex=0, int data_or_wLength=None, str label="", bool dry_run=False, bool retry_on_error=False, int success_result=0x00) |
| _set_laser_enable_immediate (self, bool flag) | |
| _to40bit (self, val) | |
| _wait_for_usb_available (self) | |
This is the basic implementation of our FeatureIdentificationDevice (FID)
spectrometer USB API as defined in ENG-0001.
This class is roughly comparable to Wasatch.NET's Spectrometer.cs.
This class is normally not accessed directly, but through the higher-level
abstraction WasatchDevice.
@see ENG-0001
##########################################################################
This class adopts the external device interface structure
This invlovles receiving a request through the handle_request function
A request is processed based on the key in the request
The processing function passes the commands to the requested device
Once it recevies a response from the connected device it then passes that
back up the chain
@verbatim
Enlighten Request
|
handle_requests
|
------------
/ / | \ \
{ get_laser status, acquire, set_laser_watchdog, etc....}
\ \ | / /
------------
|
_send_code
@endverbatim
############################################################################
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.__init__ | ( | self, | |
| str | device_id, | ||
| list | message_queue = None ) |
Instantiate a FeatureIdentificationDevice with from the given device_id.
@param device_id [in] device ID ("USB:0x24aa:0x1000:1:24")
@param message_queue [out] if provided, provides an outbound (from FID)
queue for writing StatusMessage objects upstream
Reimplemented from wasatch.InterfaceDevice.InterfaceDevice.
|
protected |
|
protected |
This function is provided to simulate random USB communication errors during regression testing, and is normally a no-op.
|
protected |
If a spectrometer has bad_pixels configured in the EEPROM, then average over them in the driver. Note this function modifies the passed array in-place, rather than returning a modified copy. @note assumes bad_pixels is previously sorted
|
protected |
Until support for even/odd InGaAs gain and offset have been added to the firmware, apply the correction in software.
|
protected |
|
protected |
Is it the expectation that all of these functions will return SpectrometerResponse? If so, that should be made explicit.
|
protected |
Perform additional setup after instantiating FID device. Split-out from physical / bus connect() to simplify MockSpectrometer.
|
protected |
|
protected |
|
protected |
Something in the driver has caused it to request the controlling application to close the peripheral. The next time WasatchDevice.acquire_data is called, it will pass a "poison pill" back up the response queue. Alternately, non-ENLIGHTEN callers can set "raise_exceptions" -> True for in-process exception-handling.
|
protected |
|
protected |
The user has requested to update the laser firing state (on or off), so apply the new laser state to the spectrometer immediately. Because the ability to immediately disable a laser is a safety-related feature (noting that truly safety-critical capabilities should be implemented in hardware, and generally can't be robustly achieved through Python scripts), this function takes the unusual step of looping over multiple attempts to set the laser state until either the command succeeds, or 3 consecutive failures have occured. This behavior was added after a developmental, unreleased prototype was found to occasionally drop USB packets, and was therefore susceptible to inadvertently failing to disable the laser upon command. @private (as callers are recommended to use set_laser_enable) @param flag (Input) whether the laser should be on (true) or off (false) @returns true if new state was successfully applied
|
protected |
Laser modulation and continuous-strobe commands take arguments in micro- seconds as 40-bit values, where the least-significant 16 bits are passed as wValue, the next-significant 16 as wIndex, and the most-significant as a single byte of payload. This function takes an unsigned integral value (presumably microseconds) and returns a tuple of wValue, wIndex and a buffer to pass as payload.
|
protected |
Wait until any enforced USB packet intervals have elapsed. This does nothing in most cases - the function is normally a no-op. However, if the application has defined min/max_usb_interval_ms (say (20, 50ms), then pick a random delay in the defined window (e.g. 37ms) and sleep until it has been at least that long since the last USB exchange. The purpose of this function was to wring-out some early ARM micro- controllers with apparent timing issues under high-speed USB 2.0, to see if communications issues disappeared if we enforced a communication latency from the software side.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.apply_edc | ( | self, | |
| spectrum ) |
Use the "pixel side ignored area" for electrical dark correction (EDC).
@par IMX385LQR-C datasheet (p8)
@verbatim
Pixels Count Description
0-3 4 OB side ignored area
4-8 4 Effective pixel side ignored area <-- "shelf" complicates
9-16 8 Effective margin for color processing
17-1936 1920 Recording pixel area
1937-1945 9 Effective margin for color processing
1946-1949 4 Effective pixel side ignored area <-- using these
1950-1952 3 Dummy
@endverbatim
@todo we might want to make buffer length configurable, either in spectra
or by time (consider 10ms vs 1sec integration time)
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.can_laser_fire | ( | self | ) |
@note only works on FX2-based spectrometers with FW >= 10.0.0.11 @returns True if there is a laser and either the interlock is closed (in firing position), or there is no readable interlock
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.clear_regions | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.connect | ( | self, | |
| retries = 0 ) |
Connect to the device and initialize basic settings. @warning this causes a problem in non-blocking mode (WasatchDeviceWrapper) on MacOS
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.disconnect | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_actual_frames | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_actual_integration_time_us | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_ambient_temperature_degC | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_ambient_temperature_degC_arm | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_ambient_temperature_degC_gen15 | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_analog_input_value | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_analog_output_state | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_battery_charging | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_battery_percentage | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_battery_register | ( | self, | |
| int | reg ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_battery_state_raw | ( | self | ) |
Retrieves the raw battery reading and then caches it for 1 sec
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_ccd_sensing_threshold | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_ccd_threshold_sensing_mode | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_dac | ( | self, | |
| int | dacIndex = 0 ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_gain | ( | self, | |
| bool | update_session_eeprom = False ) |
Read the device stored gain. Convert from binary "half-precision" float. - 1st byte (LSB) is binary encoded: bit 0 = 1/2, bit 1 = 1/4, bit 2 = 1/8 etc. - 2nd byte (MSB) is the integral part to the left of the decimal E.g., 231 dec == 0x01e7 == 1.90234375
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_gain_odd | ( | self, | |
| bool | update_session_eeprom = False ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_offset | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_offset_odd | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_tec_setpoint_degC | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_tec_setpoint_raw | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_temperature_degC | ( | self, | |
| float | raw = None ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_detector_temperature_raw | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_discretes_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_external_trigger_output | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_fan_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_fpga_configuration_register | ( | self, | |
| str | label = "" ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_fpga_firmware_version | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_high_gain_mode_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_integration_time_ms | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_lamp_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_interlock | ( | self | ) |
laser interlock
Legacy wrapper over can_laser_fire.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_power_attenuator | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_tec_mode | ( | self | ) |
The current opcode (0x85) seems to be actually returning GET_LASER_TEC_ENABLED, not GET_LASER_TEC_MODE.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_temperature_degC | ( | self, | |
| raw = None ) |
Laser temperature conversion doesn't use EEPROM coeffs at all.
Wasatch SML products use an IPS Wavelength-Stabilized TO-56 laser, which internally uses a Betatherm 10K3CG3 thermistor.
The official conversion from thermistor resistance (in ohms) to degC is:
1 / ( C1
+ C2 * ln(ohms)
+ C3 * pow(ln(ohms), 3)
)
- 273.15
Where: C1 = 0.00113
C2 = 0.000234
C3 = 8.78e-8That said, on XS the IPS thermistor then goes through a MAX1978ETM-T TEC IC which buffers the thermistor voltage. This requires the additional empirically-determined static conversion captured below.
Regrettably, the laser thermistor voltage on X series spectrometers overflows the ADC range, so we don't currently have valid laser temperature read-out on X.
Also, on MML units using the Ondax OEM Module, the cable to the 220060 does not seem to pass-through the thermistor pin, so we don't have laser temperature read-out on those, either. (Nor photodiode...)
| raw | the value read from the thermistor's 12-bit ADC (can be uint12 or SpectrometerResponse) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_temperature_raw | ( | self | ) |
@note little-endian, reverse of get_detector_temperature_raw
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_temperature_setpoint_raw | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_warning_delay_sec | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_laser_watchdog_sec | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_line | ( | self, | |
| bool | trigger = True ) |
Send "acquire", then immediately read the bulk endpoint(s).
Probably the most important method in this class, more commonly called
"getSpectrum" in most drivers.
@param trigger (Input) send an initial ACQUIRE
@returns tuple of (spectrum[], area_scan_row_count) for success
@returns None when it times-out while waiting for an external trigger
(interpret as, "didn't find any fish this time, try again in a bit")
@returns False (bool) when it times-out or encounters an exception
when NOT in external-triggered mode
@throws exception on timeout (unless external triggering enabled)
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_microcontroller_firmware_version | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_microcontroller_serial_number | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_mod_delay_us | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_mod_duration_us | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_mod_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_mod_linked_to_integration | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_mod_period_us | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_mod_width_us | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_actual_integration_time | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_area_scan | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_cf_select | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_data_header_tab | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_has_laser | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_horizontal_binning | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_integration_time_resolution | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_opt_laser_control | ( | self | ) |
Laser commands.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_poll_status | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_raman_delay_ms | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_raman_mode_enabled_NOT_USED | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_secondary_adc_calibrated | ( | self, | |
| float | raw = None ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_secondary_adc_raw | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_selected_adc | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_selected_laser | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_sensor_line_length | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_shutter_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_strobe_enabled | ( | self | ) |
a literal pass-through to get_laser_enabled()
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_tec_enabled | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_trigger_delay | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_trigger_source | ( | self | ) |
Read the trigger source setting from the device.
Use caution when interpreting the larger behavior of the device as ARM and FX2 implementations differ as of 2017-08-02
| SpectrometerResponse wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_upper_code | ( | self, | |
| int | wValue, | ||
| int | wIndex = 0, | ||
| int | wLength = 64, | ||
| str | label = "", | ||
| int | msb_len = None, | ||
| int | lsb_len = None ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_vr_continuous_ccd | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.get_vr_num_frames | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.handle_requests | ( | self, | |
| list[SpectrometerRequest] | requests ) |
@todo consider making 'requests' an object, and dynamically checking to
see if it is a single SpectrometerRequest or a list[SpectrometerRequest];
if the former, only return a single SpectrometerResponse.
Reimplemented from wasatch.InterfaceDevice.InterfaceDevice.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.has_linearity_coeffs | ( | self | ) |
At least one linearity coeff is other than 0 or -1 (and no NaN). Public because used by wasatch-shell.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.is_laser_firing | ( | self | ) |
Check if the laser actually IS firing, independent of laser_enable or can_laser_fire. @returns SpectrometerResponse
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.is_sensor_stable | ( | self | ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.queue_message | ( | self, | |
| setting, | |||
| value ) |
If an upstream queue is defined, send the name-value pair. Does nothing if the caller hasn't provided a queue. "setting" is application (caller) dependent, but ENLIGHTEN currently uses "marquee_info" and "marquee_error".
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.replace_session_eeprom | ( | self, | |
| tuple[str, EEPROM] | pair ) |
Given a (serial_number, EEPROM) pair, replace this process's "session" EEPROM with the passed EEPROM.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.require_throwaway | ( | self, | |
| flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.reset | ( | self, | |
| * | args ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.reset_fpga | ( | self | ) |
(end of laser commands)
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.select_adc | ( | self, | |
| int | n ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_accessory_enable | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_analog_output_mode | ( | self, | |
| tuple[bool, int] | value ) |
| value | (Input) tuple of (bool enable, int mode) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_analog_output_value | ( | self, | |
| int | value ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_area_scan_enable | ( | self, | |
| bool | flag ) |
Historically, this opcode moved around a bit.
At one point it was 0xeb (and is now again), which conflicts with CF_SELECT). At other times it was 0xe9, which conflicted with LASER_RAMP_ENABLE. This seems to be what we're standardizing on henceforth.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_detector_gain | ( | self, | |
| float | gain ) |
Note that this is used for detector types, including:
It is important to understand that the UNIT of this value changes between Hamamatsu and IMX detectors, but the DATATYPE does not.
Reasonable gain levels for Hamamatsu are a floating-point scalar, literally used to scale (gain) the signal, and are usually in the range (0.8 .. 1.2) or thereabouts.
Reasonable levels for IMX sensors are in dB and vary by detector, but are usually in the range (0.0 .. 31.0), with exactly 0.1dB precision. The spectrometer's FW will round to the nearest setting (1.23 will be rounded to 1.2). IMX sensors switch from "analog gain" to "digital gain" above a given threshold...on the IMX123, analog gain is 0.0 - 31.0, and digital is 31.1 - 72.0 (I think).
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_detector_gain_odd | ( | self, | |
| float | gain ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_detector_offset | ( | self, | |
| int | value ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_detector_offset_odd | ( | self, | |
| int | value ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_detector_roi | ( | self, | |
| list[float] | args, | ||
| bool | store = True ) |
Note this only sends the ROI downstream to the spectrometer (and stores it in DetectorRegions). If you want to update the wavecal and store the "selected" region index, use set_region() instead (which calls this). You should use set_region() if you are selecting one of the standard regions already configured on the EEPROM. You should use set_detector_roi() if you're making ad-hoc ROIs which aren't configured on the EEPROM. @param args: either a DetectorROI or a tuple of (region, y0, y1, x0, x1)
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_detector_tec_setpoint_degC | ( | self, | |
| float | degC ) |
Attempt to set the CCD cooler setpoint. Verify that it is within an acceptable range. Ideally this is to prevent condensation and other issues. This value is a default and is hugely dependent on the environmental conditions.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_dfu_enable | ( | self | ) |
Puts ARM-based spectrometers into Device Firmware Update (DFU) mode. @warning reflashing spectrometer firmware without specific instruction and support from Wasatch Photonics will void your warranty
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_fan_enable | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_high_gain_mode_enable | ( | self, | |
| bool | flag ) |
CF_SELECT is configured using bit 2 of the FPGA configuration register 0x12.
This bit can be set using vendor commands 0xeb to SET and 0xec to GET. Note that the set command is expecting a 5-byte unsigned value, the highest byte of which we pass as part of an 8-byte buffer. Not sure why.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_integration_time_ms | ( | self, | |
| float | ms ) |
Send the updated integration time in a control message to the device
@warning disabled EEPROM range-checking by customer
request; range limits in EEPROM are defined as 16-bit
values, while integration time is actually a 24-bit value,
such that the EEPROM is artificially limiting our range.
@todo SiG needs to wait 20ms + 8 frames for stabilization.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_lamp_enable | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_enable | ( | self, | |
| bool | flag ) |
Turn the laser on or off. If laser power hasn't yet been externally configured, applies the default of full-power. The new state will be applied immediately. @param flag (Input) bool (True turns laser on, False turns laser off) @returns whether the new state was applied
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_power_attenuator | ( | self, | |
| value ) |
digital pot on 220250 Rev4A+
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_power_high_resolution | ( | self, | |
| bool | flag ) |
Sets whether the PWM pulse period is 1000µs (high-resolution, default) or 100µs (low-resolution, legacy).
| flag | (Input) True for 1000µs PWM period (high-resolution, default), False for 100µs (low-resolution) |
Laser power is controlled via PWM (Pulse Width Modulation), essentially a square wave whose "duty cycle" (high vs low), expressed as a percentage, represents the amount of time the laser is actually firing. If the duty cycle is 33%, the laser will be firing 1/3 of the time, representing approximately one-third of "full power".
(It's not "exactly" one-third because the laser needs a moment to stablize when energized, and that "start-up" instability is increased when you're constantly pulsing the laser on-and-off.)
This function is used to determine the LENGTH (period) of that PWM square wave. Because the laser's PWM parameters are all specified in microseconds (µs), a longer period allows greater precision (resolution) in specifying the duty cycle.
Historically, Wasatch spectrometers used a PWM period of 100µs, meaning the pulse width (time each wave was high) could only be set from 1-99µs, giving an essential laser power resolution of 1%. That behavior can be restored by setting this value False.
More recently, we've increased the default PWM pulse period to 1000µs (1ms). Since the pulse width is still set in µs, that allows an effective laser power resolution of 0.1%. This is the new default, and can be explicitly requested by setting this value to True.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_power_mW | ( | self, | |
| int | mW_in ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_power_perc | ( | self, | |
| float | value_in, | ||
| bool | set_in_perc = True ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_power_perc_immediate | ( | self, | |
| float | value ) |
Sets laser power (modulated pulse width) which will be used next time the laser is turned on (or changed immediately, if the laser is already enabled).
Laser power is determined by a combination of the pulse width, period and modulation being enabled. There are many combinations of these values that will produce a given percentage of the total laser power through pulse width modulation. There is no 'get laser power' control message on the device.
Some of the goals of Enlighten are for it to be stable, and a reason we have sales. During spectrometer builds, it was discovered that the laser power settings were not implemented. During the implementation process, it was discovered that the laser modulation, pulse period and pulse width commands do not conform to specification. Where you can set integration time 100 ms with the command:
device.ctrl_transfer(bmRequestType=device_to_host, bRequest=0xDB, wValue=100, wIndex=0, data_or_wLength=0)
The laser pulse period must be set where the wValue and data_or_wLength parameters are equal. So if you wanted a pulse period of 100, you must specify the value in both places:
... wValue=100, data_or_wLength=100) ...
This in turn implies that the legacy firmware has a long masked issue when reading the value to update from the data_or_wLength parameter instead of the wValue field. This is only accurate for the laser modulation related functions.
This is backed up by the Dash v3 StrokerControl DLL implementation. It was discovered that the StrokerControl DLL sets the wValue and data or wLength parameters to the same value at every control message write.
The exciting takeaway here is that Enlighten is stable enough. Turning the laser on with the data or wLength parameter not set correctly will cause a hardware failure and complete device lockup requiring a power cycle.
fid: CRITICAL Hardware Failure FID Send Code Problem with ctrl transfer: [Errno None] 11
Unlike Dash which may lockup and require killing the application, Enlighten does not lock up. The Enlighten code base has now been used to unmask an issue that has been lurking with our legacy firmware for close to 6 years. We've detected this out of specification area of the code before it can adversely impact a customer. """
As long as laser power is modulated using a period of 100us, with a necessarily-integral pulse width of 1-99us, then it's not physically possible to support fractional power levels.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_power_require_modulation | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_tec_mode | ( | self, | |
| mode ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_temperature_setpoint_raw | ( | self, | |
| int | value ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_warning_delay_sec | ( | self, | |
| value ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_laser_watchdog_sec | ( | self, | |
| sec ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_log_level | ( | self, | |
| str | s ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_mod_delay_us | ( | self, | |
| float | us ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_mod_duration_us_NOT_USED | ( | self, | |
| float | us ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_mod_enable | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_mod_linked_to_integration | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_mod_period_us | ( | self, | |
| float | us ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_mod_width_us | ( | self, | |
| float | us ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_pixel_mode | ( | self, | |
| float | mode ) |
| mode | integral value 0-3 |
mode ADC (AD) Pixel Width (OD) b00 10-bit 10-bit b01 10-bit 12-bit b10 12-bit 10-bit b11 12-bit 12-bit
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_raman_delay_ms | ( | self, | |
| int | ms ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_raman_mode_enable_NOT_USED | ( | self, | |
| bool | flag ) |
Enable "Raman mode" (automatic laser) in the spectrometer firmware.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_selected_laser | ( | self, | |
| int | value ) |
On spectrometers supporting two lasers, select the primary (0) or secondary (1). Laser Enable, laser power etc should all then affect the currently-selected laser. @warning conflicts with GET_RAMAN_MODE_ENABLE
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_shutter_enable | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_single_region | ( | self, | |
| int | n ) |
This function uses the the multi-region feature to select just a single
pre-configured region at a time. Whichever region is selected, that
region's parameters are written to "region 0" of the spectrometer, and
the global wavecal is updated to use that region's calibration.
@todo consider clear_region() function to restore physical ROI to
(0, active_vertical_pixels, 0, active_horizontal_pixels)
(leave wavecal alone?)
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_strobe_enable | ( | self, | |
| bool | flag ) |
this is a synonym for _set_laser_enable_immediate(), but without side-effects
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_tec_enable | ( | self, | |
| bool | flag ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_trigger_delay | ( | self, | |
| float | half_us ) |
A confenurable delay from when an inbound trigger signal is received by the spectrometer, until the triggered acquisition actually starts. Default value is 0us. Unit is in 0.5 microseconds (500ns), so value of 25 would represent 12.5us. Value is 24bit, so max value is 16777216 (8.388608 sec). Like triggering, only currently supported on ARM.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_trigger_source | ( | self, | |
| bool | value ) |
Set the source for incoming acquisition triggers. @param value either 0 for "internal" or 1 for "external" With internal triggering (the default), the spectrometer expects the USB host to explicitly send a START_ACQUISITION (ACQUIRE) opcode to begin each integration. In external triggering, the spectrometer waits for the rising edge on a signal connected to a pin on the OEM accessory connector. Technically on ARM, the microcontroller is continuously monitoring both the external pin and listening for internal software opcodes. On the FX2 you need to explicitly place the microcontroller into external triggering mode to avail the feature.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.set_vertical_binning | ( | self, | |
| tuple[int, int] | lines ) |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.update_laser_watchdog | ( | self | ) |
Automatically set the laser watchdog long enough to handle the current integration time, assuming we have to perform 6 throwaways on the sensor in case it went to sleep. @note we are not currently using this function
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.update_session_eeprom | ( | self, | |
| tuple[str, EEPROM] | pair ) |
Given a (serial_number, EEPROM) pair, update this process's "session" EEPROM with just the EDITABLE fields of the passed EEPROM.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.write_eeprom | ( | self | ) |
Actually store the current session EEPROM fields to the spectrometer.
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.allow_default_gain_reset |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.ccd_temperature_invalid |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.connected |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.connecting |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.detector_tec_setpoint_degC |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.detector_tec_setpoint_has_been_set |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.device |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.device_id |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.device_type |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.eeprom_backup |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.inject_random_errors |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.laser_temperature_invalid |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.last_applied_laser_power |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.last_spectrum |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.last_usb_timestamp |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.message_queue |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.next_applied_laser_power |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.prev_pixels |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.process_f |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.raise_exceptions |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.random_error_perc |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.remaining_throwaways |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.retry_enabled |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.retry_max |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.retry_ms |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.settings |
| wasatch.FeatureIdentificationDevice.FeatureIdentificationDevice.shutdown_requested |