Skip to content

Commit 6768e73

Browse files
committed
Add support for PSLab v6
- Added new USB VID and PID to packet_handler.py and 99-pslab.rules. - Increased the voltage threshold where a capacitor is considered to be discharged from 33 mV to 165 mV. When CAP is pulled low, then left to float, the voltage seems to increase from zero faster than it did in v5.
1 parent 01c77f8 commit 6768e73

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

99-pslab.rules

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#Rules for TestBench
1+
ACTION!="add", SUBSYSTEM!="tty", GOTO="pslab_rules_end"
22

3-
SUBSYSTEM=="tty",ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="00df", MODE="666",SYMLINK+="TestBench"
4-
ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="00df", ENV{ID_MM_DEVICE_IGNORE}="1"
3+
ATTR{idVendor}=="04d8", ATTRS{idProduct}=="00df", ENV{ID_MM_DEVICE_IGNORE}="1"
4+
ATTR{idVendor}=="04d8", ATTRS{idProduct}=="00df", MODE="666"
5+
6+
ATTR{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ENV{ID_MM_DEVICE_IGNORE}="1"
7+
ATTR{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="666"
8+
9+
LABEL="pslab_rules_end"

PSL/multimeter.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Multimeter(Oscilloscope):
2727
CURRENTS_RANGES = [1, 2, 3, 0] # Smallest first,
2828
RC_RESISTANCE = 1e4
2929
CAPACITOR_CHARGED_VOLTAGE = 0.9 * max(INPUT_RANGES["CAP"])
30-
CAPACITOR_DISCHARGED_VOLTAGE = 0.01 * max(INPUT_RANGES["CAP"])
30+
CAPACITOR_DISCHARGED_VOLTAGE = 0.05 * max(INPUT_RANGES["CAP"])
3131

3232
def __init__(self, device: Handler = None):
3333
self._stray_capacitance = 5e-11
@@ -110,8 +110,9 @@ def calibrate_capacitance(self):
110110
to the CAP pin.
111111
"""
112112
for charge_time in np.unique(np.int16(np.logspace(2, 3))):
113+
self._discharge_capacitor()
113114
voltage, capacitance = self._measure_capacitance(1, 0, charge_time)
114-
if voltage >= 3:
115+
if voltage >= self.CAPACITOR_CHARGED_VOLTAGE:
115116
break
116117
self._stray_capacitance += capacitance
117118

@@ -126,8 +127,10 @@ def measure_capacitance(self) -> float:
126127
previous_capacitance = 0
127128

128129
for current_range in self.CURRENTS_RANGES:
129-
for i in (100, 200, 400, 800):
130-
voltage, capacitance = self._measure_capacitance(current_range, 0, i)
130+
for charge_time in (100, 200, 400, 800):
131+
voltage, capacitance = self._measure_capacitance(
132+
current_range, 0, charge_time
133+
)
131134

132135
if voltage >= self.CAPACITOR_CHARGED_VOLTAGE:
133136
return previous_capacitance
@@ -216,10 +219,12 @@ def _measure_rc_capacitance(self) -> float:
216219
y = y[cap_low:]
217220

218221
# Discard data after the voltage reaches zero (improves fit).
219-
if 0 in y:
222+
try:
220223
v_zero = np.where(y == 0)[0][0]
221224
x = x[:v_zero]
222225
y = y[:v_zero]
226+
except IndexError:
227+
pass
223228

224229
# Remove time offset.
225230
x -= x[0]

PSL/packet_handler.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222

2323
logger = logging.getLogger(__name__)
2424

25-
USB_VID = 0x04D8
26-
USB_PID = 0x00DF
27-
2825

2926
class Handler:
3027
"""Provides methods for communicating with the PSLab hardware.
@@ -37,6 +34,10 @@ class Handler:
3734
See :meth:`connect. <PSL.packet_handler.Handler.connect>`.
3835
"""
3936

37+
# V5 V6
38+
_USB_VID = [0x04D8, 0x10C4]
39+
_USB_PID = [0x00DF, 0xEA60]
40+
4041
def __init__(
4142
self,
4243
port: str = None,
@@ -140,7 +141,12 @@ def connect(
140141
# User specified a port.
141142
version = self.get_version()
142143
else:
143-
port_info_generator = list_ports.grep(f"{USB_VID:04x}:{USB_PID:04x}")
144+
regex = []
145+
for vid, pid in zip(self._USB_VID, self._USB_PID):
146+
regex.append(f"{vid:04x}:{pid:04x}")
147+
148+
regex = "(" + "|".join(regex) + ")"
149+
port_info_generator = list_ports.grep(regex)
144150

145151
for port_info in port_info_generator:
146152
self.interface.port = port_info.device

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy