From 0095961c63537127b4cd83e69bd1d092c52b8d39 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Fri, 18 Apr 2025 18:01:12 -0400 Subject: [PATCH] Fixed SAR weighting configuration --- adc_eval/adcs/sar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adc_eval/adcs/sar.py b/adc_eval/adcs/sar.py index 3d13567..f4b59d7 100644 --- a/adc_eval/adcs/sar.py +++ b/adc_eval/adcs/sar.py @@ -62,7 +62,8 @@ def __init__(self, nbits=8, fs=1, vref=1, seed=1, **kwargs): self._comp_noise = 0 # Get keyword arguments - self._weights = kwargs.get("weights", None) + self._weights = None + self.weights = kwargs.get("weights", self.weights) @property def weights(self): @@ -75,6 +76,7 @@ def weights(self): def weights(self, values): """Sets the capacitor unit weights.""" self._weights = np.array(values) + self.dbits = np.zeros(len(values)) if self._weights.size < self.nbits: print( f"WARNING: Capacitor weight array size is {self._weights.size} for {self.nbits}-bit ADC."