From caa2656f42e622b2276d2f218efb712310be67e2 Mon Sep 17 00:00:00 2001 From: Kieren Rasmussen Date: Wed, 2 Oct 2019 16:45:54 +1000 Subject: [PATCH 1/2] Ported fix for USB power from ps5000a to ps4000a. Enabled Bandwidth Filtering for PicoScope 4444 --- picoscope/picobase.py | 8 +++++--- picoscope/ps4000a.py | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/picoscope/picobase.py b/picoscope/picobase.py index 2f47d92..7e8547a 100644 --- a/picoscope/picobase.py +++ b/picoscope/picobase.py @@ -247,10 +247,12 @@ def setChannel(self, channel='A', coupling="AC", VRange=2.0, if not isinstance(BWLimited, int): BWLimited = self.BW_LIMITS[BWLimited] - if BWLimited == 2: - BWLimited = 2 # Bandwidth Limiter for PicoScope 6404 + if BWLimited == 3: + BWLimited = 3 # 1MHz Bandwidth Limiter for PicoScope 4444 + elif BWLimited == 2: + BWLimited = 2 # Bandwidth Limiter for PicoScope 6404, 100kHz Bandwidth Limiter for PicoScope 4444 elif BWLimited == 1: - BWLimited = 1 # Bandwidth Limiter for PicoScope 6402/6403 + BWLimited = 1 # Bandwidth Limiter for PicoScope 6402/6403, 20kHz Bandwidth Limiter for PicoScope 4444 else: BWLimited = 0 diff --git a/picoscope/ps4000a.py b/picoscope/ps4000a.py index e7bbcfc..af1df84 100644 --- a/picoscope/ps4000a.py +++ b/picoscope/ps4000a.py @@ -145,9 +145,19 @@ def _lowLevelOpenUnit(self, sn): serialNullTermStr = None # Passing None is the same as passing NULL m = self.lib.ps4000aOpenUnit(byref(c_handle), serialNullTermStr) - self.checkResult(m) self.handle = c_handle.value + # This will check if the power supply is not connected + # and change the power supply accordingly + # Personally (me = Mark), I don't like this + # since the user should address this immediately, and we + # shouldn't let this go as a soft error + # but I think this should do for now + if m == 0x11A: + self.changePowerSource(m) + else: + self.checkResult(m) + self.model = self.getUnitInfo('VariantInfo') def _lowLevelOpenUnitAsync(self, sn): @@ -216,6 +226,9 @@ def _lowLevelSetChannel(self, chNum, enabled, coupling, VRange, VOffset, c_enum(VRange), c_float(VOffset)) self.checkResult(m) + m = self.lib.ps4000aSetBandwidthFilter(c_int16(self.handle), c_enum(chNum), c_enum(BWLimited)) + self.checkResult(m) + def _lowLevelStop(self): m = self.lib.ps4000aStop(c_int16(self.handle)) self.checkResult(m) @@ -406,6 +419,12 @@ def _lowLevelSetDeviceResolution(self, resolution): c_enum(resolution)) self.checkResult(m) + def _lowLevelChangePowerSource(self, powerstate): + m = self.lib.ps4000aChangePowerSource( + c_int16(self.handle), + c_enum(powerstate)) + self.checkResult(m) + def _lowLevelGetValuesBulk(self, numSamples, fromSegment, toSegment, downSampleRatio, downSampleMode, overflow): """Copy data from several memory segments at once.""" From 933d1a649dfca2454f6a160ddacc32881c38d5e1 Mon Sep 17 00:00:00 2001 From: Kieren Rasmussen Date: Wed, 2 Oct 2019 23:28:41 +1000 Subject: [PATCH 2/2] Corrected PEP8 violations --- picoscope/picobase.py | 6 ++++-- picoscope/ps4000a.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/picoscope/picobase.py b/picoscope/picobase.py index 7e8547a..0affd25 100644 --- a/picoscope/picobase.py +++ b/picoscope/picobase.py @@ -250,9 +250,11 @@ def setChannel(self, channel='A', coupling="AC", VRange=2.0, if BWLimited == 3: BWLimited = 3 # 1MHz Bandwidth Limiter for PicoScope 4444 elif BWLimited == 2: - BWLimited = 2 # Bandwidth Limiter for PicoScope 6404, 100kHz Bandwidth Limiter for PicoScope 4444 + BWLimited = 2 # Bandwidth Limiter for PicoScope 6404, + # 100kHz Bandwidth Limiter for PicoScope 4444 elif BWLimited == 1: - BWLimited = 1 # Bandwidth Limiter for PicoScope 6402/6403, 20kHz Bandwidth Limiter for PicoScope 4444 + BWLimited = 1 # Bandwidth Limiter for PicoScope 6402/6403, + # 20kHz Bandwidth Limiter for PicoScope 4444 else: BWLimited = 0 diff --git a/picoscope/ps4000a.py b/picoscope/ps4000a.py index af1df84..2d55da9 100644 --- a/picoscope/ps4000a.py +++ b/picoscope/ps4000a.py @@ -226,7 +226,9 @@ def _lowLevelSetChannel(self, chNum, enabled, coupling, VRange, VOffset, c_enum(VRange), c_float(VOffset)) self.checkResult(m) - m = self.lib.ps4000aSetBandwidthFilter(c_int16(self.handle), c_enum(chNum), c_enum(BWLimited)) + m = self.lib.ps4000aSetBandwidthFilter(c_int16(self.handle), + c_enum(chNum), + c_enum(BWLimited)) self.checkResult(m) def _lowLevelStop(self):