fossasia / pslab-python

Python Library for PSLab Desktop: https://pslab.io
GNU General Public License v3.0
1.62k stars 226 forks source link

Bug: CH1 and CH2 autorange set incorrectly #159

Closed cynthi8 closed 3 years ago

cynthi8 commented 3 years ago
  1. Reading a measurement from CH1 or CH2
  2. Removing the measurement probes
  3. Re-inserting them

yields incorrect results.

When _voltmeter_autorangeis bypassed by calling _measure_voltage directly, this issue does not occur.

Setup I connected CH1 measurement pins to I2C VDD (3.3 V) and GND and ran this code

import time
import sys
from PSL import sciencelab
I = sciencelab.connect()

channel = sys.argv[1]

while True:
    voltage = I.multimeter.measure_voltage(channel)
    print(channel, "=", voltage)
    time.sleep(1)

Results PSL_CH1_wrong_voltage

With _measure_voltage instead of measure_voltage, PSL_CH1_auto_range_bypassed

bessman commented 3 years ago

Fixed in cc9ad27.

cynthi8 commented 3 years ago

Ah ok, sorry, I didn't check. Thanks!

bessman commented 3 years ago

No worries. Good job on finding the bug either way. I'll draft a new release and push it to pypi shortly.