diff --git a/pslab/instrument/analog.py b/pslab/instrument/analog.py index bc3ccca..14ee2ee 100644 --- a/pslab/instrument/analog.py +++ b/pslab/instrument/analog.py @@ -144,6 +144,13 @@ def resolution(self, value: int): self._calibrate() def _calibrate(self): + """ + Calculates the scaling coefficients based on current gain and resolution. + + This updates the internal _scale and _unscale callables as a side effect, + preparing them 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 @@ -243,4 +250,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() \ No newline at end of file diff --git a/tests/test_spi.py b/tests/test_spi.py index ecd73d9..9672018 100644 --- a/tests/test_spi.py +++ b/tests/test_spi.py @@ -30,7 +30,7 @@ CS = "LA3" SPIMaster._primary_prescaler = PPRE = 0 SPIMaster._secondary_prescaler = SPRE = 0 -PWM_FERQUENCY = SPIMaster._frequency * 2 / 3 +PWM_FERQUENCY = 166666.67 MICROSECONDS = 1e-6 RELTOL = 0.05 # Number of expected logic level changes.