Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct DC50 enum: 2 -> 50 #191

Merged
merged 2 commits into from
Sep 14, 2023
Merged

Conversation

thennen
Copy link
Contributor

@thennen thennen commented Sep 12, 2023

PS6000a range changed the enum for DC50 coupling from 2 to 50.

@hmaarrfk
Copy link
Collaborator

is this true for all firmware versions? for all library versions? maybe we need to condition on the version of the library itself before making this change.

@thennen
Copy link
Contributor Author

thennen commented Sep 12, 2023

Good question. Hard to know for sure without trying it out on every old dll/firmware. I certainly wouldn't expect them to change the enum between versions. Do you know of any other instances of that happening?

I contacted support and they didn't know either. But they are checking it out.

You can see the information in Pico Technology\SDK\inc\ directory:

in PicoDeviceEnums.h (used by ps6000aApi.h):

typedef enum enPicoCoupling
{
  PICO_AC = 0,
  PICO_DC = 1,

  PICO_DC_50OHM = 50
} PICO_COUPLING;

vs. ps6000Api.h

typedef enum enPS6000Coupling
{
  PS6000_AC,
  PS6000_DC_1M,
  PS6000_DC_50R
} PS6000_COUPLING;

@hmaarrfk
Copy link
Collaborator

maybe this is why i broke my scope like 10 years ago..

@thennen
Copy link
Contributor Author

thennen commented Sep 12, 2023

Well, AndrewA at picoscope support confirmed: "PICO_DC_50OHM enum values were never changed"

So, I think it's safe to merge.

@hmaarrfk
Copy link
Collaborator

so which one is the correct value? 2 or 50?

@thennen
Copy link
Contributor Author

thennen commented Sep 12, 2023

For reference, here is the error I ran into that is fixed by this change.

In [4]: print(ps.getAllUnitInfo())
DriverVersion                 : ps6000a Windows Driver, 1.0.116.3546
USBVersion                    : 3.0
HardwareVersion               : 1.3
VariantInfo                   : 6426E
BatchAndSerial                : JY198/0032
CalDate                       : 07Jun23
KernelVersion                 : 1.0
DigitalHardwareVersion        : 1
AnalogueHardwareVersion       : 3
PicoFirmwareVersion1          : 1.7.16.0
PicoFirmwareVersion2          : 1.1.4.0

In [5]: ps.CHANNEL_COUPLINGS['DC50'] = 2
In [6]: ps.setChannel('A', 'DC50')
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[6], line 1
----> 1 ps.ps.setChannel('A', 'DC50')

File ~\Anaconda3\lib\site-packages\picoscope-0.7.20+3.gce48c63-py3.8.egg\picoscope\picobase.py:296, in _PicoscopeBase.setChannel(self, channel, coupling, VRange, VOffset, enabled, BWLimited, probeAttenuation)
    292     # 20kHz Bandwidth Limiter for PicoScope 4444
    293 else:
    294     BWLimited = 0
--> 296 self._lowLevelSetChannel(chNum, enabled, coupling,
    297                          VRangeAPI["apivalue"],
    298                          VOffset / probeAttenuation, BWLimited)
    300 # if all was successful, save the parameters
    301 self.CHRange[chNum] = VRange

File ~\Anaconda3\lib\site-packages\picoscope-0.7.20+3.gce48c63-py3.8.egg\picoscope\ps6000a.py:461, in PS6000a._lowLevelSetChannel(self, chNum, enabled, coupling, VRange, VOffset, BWLimited)
    458 else:
    459     m = self.lib.ps6000aSetChannelOff(c_int16(self.handle),
    460                                       c_enum(chNum))
--> 461 self.checkResult(m)

File ~\Anaconda3\lib\site-packages\picoscope-0.7.20+3.gce48c63-py3.8.egg\picoscope\picobase.py:1153, in _PicoscopeBase.checkResult(self, errorCode)
   1151 ecName = self.errorNumToName(errorCode)
   1152 ecDesc = self.errorNumToDesc(errorCode)
-> 1153 raise IOError('Error calling %s: %s (%s)' % (
   1154     str(inspect.stack()[1][3]), ecName, ecDesc))

OSError: Error calling _lowLevelSetChannel: PICO_INVALID_COUPLING (An invalid coupling type was specified in psXXXXSetChannel.)

In [7]: ps.CHANNEL_COUPLINGS['DC50'] = 50
In [8]: ps.setChannel('A', 'DC50')
Out[8]: 2.0

@thennen
Copy link
Contributor Author

thennen commented Sep 12, 2023

so which one is the correct value? 2 or 50?

50

@hmaarrfk
Copy link
Collaborator

What is the meaning of the return value of 2.0 in:

In [7]: ps.CHANNEL_COUPLINGS['DC50'] = 50
In [8]: ps.setChannel('A', 'DC50')
Out[8]: 2.0

@thennen
Copy link
Contributor Author

thennen commented Sep 14, 2023

That is the "Actual range of the scope as double" returned by _PicoscopeBase.setChannel.

in this case, 2.0 is the default value.

https://github.com/colinoflynn/pico-python/blob/1747100291d2c3d86eee17e90de0abc633f947e6/picoscope/picobase.py#L306C11-L306C11

@hmaarrfk
Copy link
Collaborator

I see. can you add a release note

@hmaarrfk
Copy link
Collaborator

oh we have no release notes lol

@hmaarrfk hmaarrfk merged commit f0a771a into colinoflynn:master Sep 14, 2023
2 checks passed
@BenediktBurger
Copy link
Contributor

Thanks for that fix. I encountered the error as well, but did not investigate further, as I did not need it.

When I created the ps6000a file, I took the enum from ps4000a (and there the value is 2) as I expected them to have the same enum values...

Finally it is solved, thanks a lot @thennen!

@hmaarrfk
Copy link
Collaborator

amazing. thank you for the confirmation that this works!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants