def test_set_voltage_pv3(power: PowerSupply, multi: Multimeter): voltages = np.arange(0, 3.3, 0.1) measured = np.zeros(len(voltages)) for i, v in enumerate(voltages): power.pv3 = v measured[i] = multi.measure_voltage("VOL") assert measured == pytest.approx(voltages, rel=RELTOL * 2, abs=ABSTOL * 2)
def test_set_current(power: PowerSupply, multi: Multimeter): currents = np.arange(0, 3e-3, 1e-4) measured = np.zeros(len(currents)) for i, c in enumerate(currents): power.pcs = c measured[i] = multi.measure_voltage("CH3") resistor = 100 assert measured == pytest.approx(currents * resistor, rel=RELTOL, abs=ABSTOL)
def __init__(self): super().__init__() self.logic_analyzer = LogicAnalyzer(device=self) self.oscilloscope = Oscilloscope(device=self) self.waveform_generator = WaveformGenerator(device=self) self.pwm_generator = PWMGenerator(device=self) self.multimeter = Multimeter(device=self) self.power_supply = PowerSupply(device=self) self.i2c = I2CMaster(device=self) self.nrf = NRF24L01(device=self) if "V6" in self.version: # Set the built-in WS2812B to green :) self.rgb_led([0, 20, 0])
def __init__( self, port: str = None, baudrate: int = 1000000, timeout: float = 1.0, ): super().__init__(port, baudrate, timeout) self.logic_analyzer = LogicAnalyzer(device=self) self.oscilloscope = Oscilloscope(device=self) self.waveform_generator = WaveformGenerator(device=self) self.pwm_generator = PWMGenerator(device=self) self.multimeter = Multimeter(device=self) self.power_supply = PowerSupply(device=self) self.i2c = I2CMaster(device=self) self.nrf = NRF24L01(device=self) if "V6" in self.version: # Set the built-in WS2812B to green :) self.rgb_led([0, 20, 0])
def multi(handler: SerialHandler) -> Multimeter: handler._logging = True return Multimeter(handler)
def test_measure_rc_capacitance(multi: Multimeter): assert multi._measure_rc_capacitance() == pytest.approx(1e-9, rel=RELTOL)
def test_calibrate_capacitance(multi: Multimeter): multi.calibrate_capacitance() # Need bigger tolerance because measurement will be 1 nF + actual stray # capacitance (ca 50 pF). assert multi._stray_capacitance == pytest.approx(1e-9, rel=3 * RELTOL)
def test_voltmeter_autorange(multi: Multimeter): assert multi._voltmeter_autorange("CH1") <= 3.3
def test_measure_voltage(multi: Multimeter, source): assert multi.measure_voltage("VOL") == pytest.approx(2.2, rel=RELTOL)
def test_measure_resistance(multi: Multimeter): assert multi.measure_resistance() == pytest.approx(1e4, rel=RELTOL)