Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pslab/instrument/analog.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def resolution(self, value: int):
self._calibrate()

def _calibrate(self):
"""
Calculates the scaling coefficients based on current gain and resolution.

This prepares the linear functions (_scale and _unscale) used to convert
between raw integer ADC values and floating point voltages.
"""
A = INPUT_RANGES[self._name][0] / self._gain
B = INPUT_RANGES[self._name][1] / self._gain
slope = B - A
Expand Down Expand Up @@ -243,4 +249,4 @@ def lowres_waveform_table(self) -> np.ndarray:
def _range_normalize(self, x: np.ndarray, norm: int = 1) -> np.ndarray:
"""Normalize waveform table to the digital output range."""
x = (x - self.RANGE[0]) / (self.RANGE[1] - self.RANGE[0]) * norm
return np.int16(np.round(x)).tolist()
return np.int16(np.round(x)).tolist()