PwrDetectorController
- class rfblocks.PwrDetectorController(controller_id: str, device: LogDetector)[source]
Higher level control for power detector boards
PwrDetectorControllermaintains the state configuration for a power detector board. This includes the current signal input power and frequency. The controller also holds application specific calibration data associated with the detector and optionally applies corrections to the measured signal power using the calibration data.The following signals are defined:
freq_changed(float)pwr_changed(float)caldata_changed()detector_initialized()correction_state_changed(bool)enable_state_changed(bool)
Documentation for the LTC5582 and LT5537 power detector rfblocks modules can be found here: LTC5582 and LT5537 Power Detectors
- Parameters:
controller_id (str) – The controller name
device (
rfblocks.LogDetector) –rfblocks.LogDetector.
- property apply_correction: bool
Control applying corrections to the measured signal power.
By default, corrections are not applied. Set to True in order to apply corrections. Note that calibration data must be available via the
cal_dataproperty.
- property avg: int
The number of detector measurements to average over.
By default this is 16.
- property cal_data
Return application calibration data.
The format for the calibration data is:
{ frequency_string: power_in_dbm, ... }
For example:
{'100.0': 0.204, '200.0': -0.031, '300.0': 0.063, ... ... '4100.0': 0.262, '4200.0': 0.246}
where the frequency is specified in MHz.
If no calibration data is available this will return None.
See also
- property cal_data_conditions
A dictionary for storing any conditions associated with acquisition of detector calibration data. For example, if the detector has a step attenuator associated with it then the attenuation setting for which the calibration was carried out can be saved here.
- property calibrating: bool
Inform the controller when a calibration is taking place.
During calibration corrections are not applied and any specified
power_offsetis ignored.
- property enabled: bool
Enable/disable operation of the power detector.
By default the power detector operation is enabled.
- property freq: float
The frequency of the detector input signal.
- insertion_loss(f)[source]
Return the insertion loss at the specified signal frequency.
- Parameters:
f (float) – The signal frequency in MHz
- Returns:
The insertion loss in dB.
- Raises:
ValueError If the specified signal frequency is outside the range of the calibration data.
The insertion loss is calculated by cubic spline interpolation on the calibration data as returned from
cal_data.
- property insertion_loss_offset: float
The insertion loss offset.
- Parameters:
loss (float) – The new insertion loss offset value in dB
The insertion loss offset is added to the insertion loss as calculated from the calibration data (see
insertion_loss). The offset is generally used in situations where some known level of attenuation (or amplification) is added between the signal source and the detector after the calibration data has been captured. The correction then becomes an estimate since the additional attenuation/amplification has not been calibrated and may exhibit unquantified variations as a function of frequency (for example).
- is_connected(ser: Serial) bool[source]
Test if there is a connected detector.
- Parameters:
ser (serial.Serial) – serial device to write commands to
- Returns:
True if there is a connected power detector, False otherwise.
- property linear_range
Return the detector’s linear response range.
- Returns:
A tuple containing the minimum and maximum input signal powers for which the detector provides a linear response. If no calibration data is available the
CalibrationDataExceptionis raised.
- load_caldata(input_file)[source]
Load calibration data from a file.
- Parameters:
input_file (str) – Path to file for loading the calibration data.
See also
- property max_frequency: float
The maximum valid detector signal frequency.
- measure(ser: Serial) None[source]
Measure the detector signal power.
- Parameters:
ser (serial.Serial) – Power detector serial connection
- Raises:
If
apply_correctionis True then insertion loss correction will be carried out on the measured signal power. Insertion loss is calculated from the calibration data returned bycal_data. If no calibration is available or if the specified signal frequency is outside the calibration data range, arfblocks.CalibrationRangeErrorexception is raised.If
apply_correctionis False and the detector is not being calibrated thenpower_offset()is subtracted from the measured signal power.The
insertion_loss_offset()value is applied to the measured signal power regardless of whetherapply_correctionis True or False.
- property min_frequency: float
The minimum valid detector signal frequency.
- power_offset(freq: float) float[source]
Calculate the power offset at the specified frequency.
- Parameters:
freq (float) – Frequency (in MHz) to calculate power_offset.
- Returns:
The power loss (or gain) at the specified frequency.
The
power_lossvalue is added to the measured power value in the circumstance whereapply_correctionisFalse. In general,power_losswill be set to the value of any attenuation or gain which is permanently inserted between the power detector and the power meter input.
- property pwr: float
Returns the measured signal power in dBm.
Note
If
apply_correctionis True andcal_dataprovides valid calibration data then the measured signal power will be corrected using this.
- save_caldata(output_file)[source]
Save the prevailing calibration data to a file.
- Parameters:
output_file (str) – Path to file for saving the calibration data.
- set_power_offset_fn(fn: Callable[[float], float] | None) None[source]
Set the power offset function.
- Parameters:
fn (Callable[[float], float]) – A function returning the power loss (or gain) at a specified frequency. The power loss (or gain) value calculated by this function will generally be the (usually frequency dependent) value of an attenuator or amplifier inserted between the power detector and the signal input. This would be used, for example, to condition the input signal to be measured so that it falls into the linear range of the detector.
This function will only be used when
apply_correctionis False and takes the place of the correction that would be applied using the calibration data.